Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- //using AssemblyCSharp;
- public class Game : MonoBehaviour {
- public enum GAME_PROPERTIES
- {
- rowLength = 6
- ,columnLength = 6
- };
- //de (int)PIECE_TYPE.java
- public enum PIECE_TYPE
- {
- OUT_OF_BOUNDS = -1
- ,NOT_USED = 0
- ,ROAD
- ,BUSH
- ,TREE
- ,RUCA
- ,HOME
- ,CASTLE
- ,BUILDING
- ,FUTURE_HOME
- ,FUTURE_HOME_HOVERING
- ,FUTURE_CITY
- ,ALIEN_BASIC
- ,ALIEN_TELEPORTER
- ,MOAI
- ,MOAIS
- ,STONEHENGE
- ,ROCK// = 18
- ,CAVE
- ,DIAMOND
- ,RUBY
- ,MAGIC_CRISTAL_PURPLE// = 22
- ,MAGIC_CRISTAL_GREEN
- ,BLACK_HOLE
- };
- //fin (int)PIECE_TYPE.java
- public enum BG_TYPE {
- NOT_USED
- ,ROAD
- ,LEFT_DOWN_RIGHT
- ,TOP_DOWN_RIGHT
- ,TOP_LEFT_RIGHT
- ,TOP_LEFT_DOWN
- ,TOP_LEFT
- ,LEFT_DOWN
- ,DOWN_RIGHT
- ,TOP_RIGHT
- ,TOP_LEFT_CORNER_4
- ,LEFT_DOWN_CORNER_1
- ,DOWN_RIGHT_CORNER_2
- ,TOP_RIGHT_CORNER_3
- ,TOP
- ,TOP_CORNER_3
- ,TOP_CORNER_4
- ,TOP_CORNER_3_4
- ,LEFT
- ,LEFT_CORNER_1
- ,LEFT_CORNER_4
- ,LEFT_CORNER_1_4
- ,DOWN
- ,DOWN_CORNER_1
- ,DOWN_CORNER_2
- ,DOWN_CORNER_1_2
- ,RIGHT
- ,RIGHT_CORNER_2
- ,RIGHT_CORNER_3
- ,RIGHT_CORNER_2_3
- ,CORNER_1
- ,CORNER_2
- ,CORNER_3
- ,CORNER_4
- ,CORNER_1_2
- ,CORNER_1_3
- ,CORNER_1_4
- ,CORNER_2_3
- ,CORNER_2_4
- ,CORNER_3_4
- ,CORNER_1_2_3
- ,CORNER_2_3_4
- ,CORNER_1_3_4
- ,CORNER_1_2_4
- ,CORNER_1_2_3_4
- ,HORIZONTAL_GRASS = (49 - 4)
- ,VERTICAL_GRASS = (49 - 3)
- ,GRASS = (49-2)
- ,ISLE = (49-1)
- //original
- // ,HORIZONTAL_GRASS = vbackgroundGraphic.Length-4
- // ,VERTICAL_GRASS = backgroundGraphic.Length-3
- // ,GRASS = backgroundGraphic.Length-2
- // ,ISLE = backgroundGraphic.Length-1
- }
- public List<PIECE_TYPE> pieceChance;
- public enum Estados {
- // DEAD = -99
- // ,RETRY = -1
- INITIALIZE = 0
- ,WAITING_FOR_CLICK
- ,COLLAPSING
- ,WAIT_END_ANIMATION
- ,BUYING
- ,PAUSE
- ,GAME_OVER
- // ,START_NEW_GAME = 97
- // ,EXIT_GAME
- };
- public delegate void OnUpdateStateDelegate();
- OnUpdateStateDelegate[] onUpdateDelegate = null;
- public Estados STATE;
- // private Estados PreviousState;
- //bg_type.java
- public static string[] backgroundGraphic =
- {
- "Road"
- ,"Road"
- ,"LeftDownRight"
- ,"TopDownRight"
- ,"TopLeftRight"
- ,"TopLeftDown"
- ,"TopLeft"
- ,"LeftDown"
- ,"DownRight"
- ,"TopRight"
- ,"TopLeftCorner4"
- ,"LeftDownCorner1"
- ,"DownRightCorner2"
- ,"TopRightCorner3"
- ,"Top"
- ,"TopCorner3"
- ,"TopCorner4"
- ,"TopCorner3_4"
- ,"Left"
- ,"LeftCorner1"
- ,"LeftCorner4"
- ,"LeftCorner1_4"
- ,"Down"
- ,"DownCorner1"
- ,"DownCorner2"
- ,"DownCorner1_2"
- ,"Right"
- ,"RightCorner2"
- ,"RightCorner3"
- ,"RightCorner2_3"
- ,"Corner1"
- ,"Corner2"
- ,"Corner3"
- ,"Corner4"
- ,"Corner1_2"
- ,"Corner1_3"
- ,"Corner1_4"
- ,"Corner2_3"
- ,"Corner2_4"
- ,"Corner3_4"
- ,"Corner1_2_3"
- ,"Corner2_3_4"
- ,"Corner1_3_4"
- ,"Corner1_2_4"
- ,"Corner1_2_3_4"
- ,"HorizontalGrass"
- ,"VerticalGrass"
- ,"Grass"
- ,"Isle"
- };
- [HideInInspector]
- public int[] connections = new int[300];
- //fin BG_TYPE ^
- public Hashtable tablaAllAnimations;
- public int[] buyValue =
- {
- 0
- ,10
- ,30
- ,45
- ,70
- ,100
- ,150
- ,225
- ,350
- ,530
- ,800
- ,12
- ,18
- ,2700
- ,4000
- ,6000
- ,9000
- ,15000
- ,4000
- ,6000
- ,9000
- ,15000
- ,2000
- ,1100
- ,2500
- };
- public Hashtable tablaBuyForCoinsValue;
- public Hashtable tablaSellForCoinsValue;
- // public static bool soundEnabled = false;
- // public static int initGold;
- // public static int initCurrentScore;
- // public static int initRecordScore;
- public tk2dSprite guiCoin;
- private float angleRadians;
- // public tk2dSpriteAnimation animCollectionUpgrade;
- // public tk2dSpriteAnimation animCollectionBasic;
- private string scoreString;
- private string highScoreString;
- private string coinsString;
- // private string debugTextGridClick;
- //coordenadas que hacen referencia al gameGrid[,]
- public int touchX;
- public int touchY;
- private List<int> indexesToCollapseList = new List<int>();
- public int lastAlienToMoaiX;
- public int lastAlienToMoaiY;
- public GameObject selector;
- private tk2dAnimatedSprite selectorAnimation;
- public tk2dAnimatedSprite selectorNextPiece;
- public readonly Color32 SELECTOR_COLOR_RED = new Color32(255, 0, 0, 255);//168
- public readonly Color32 SELECTOR_COLOR_NORMAL = new Color32(255, 255, 255, 255);//200
- public tk2dAnimatedSprite ufoNextPiece;
- private Vector3 ufoNextPieceOriginPos;
- public tk2dAnimatedSprite wildCardStoragePiece;
- public tk2dTextMesh txtCoins;
- public tk2dTextMesh txtScore;
- public tk2dTextMesh txtHiScore;
- public tk2dTextMesh txtGameOver;
- public int bonusMultiplier = 0;
- public tk2dSprite[] gameGridSprites;// fondo
- public tk2dAnimatedSprite[] gamePiecesAnimations; //animaciones de foreground
- public GameObject[] lightCells; //grilla highlight
- public tk2dSprite btnBuy;
- public tk2dSprite btnHelp;
- public tk2dSprite btnPause;
- public tk2dSprite btnMute;
- private SoundController btnMuteSoundScript;
- // public GameObject btnSoundPrefab;
- public GameObject comboStarAnimationPrefab;
- // private GameObject btnSound = null;
- public GameObject txtAddScorePrefab;
- public int[,] gameGrid;
- // public int[,] compareGrid;
- // public bool[,] usedGrid;
- // public bool[,] usedGridCopy;
- public bool initializing = false;
- public bool firstClick = false;
- public bool animateNeigbors = false;
- public bool collapsing = true;
- public bool upgradedGraphic = false;
- // public bool enabledSound = true;
- // public bool magicCrystalToRock = false;
- public bool alreadyMovedAliens = false;
- public bool gameOver = false;
- public int nextPiece;
- // public PIECE_TYPE lastPieceUsed;
- // public int pieceBought = -1;
- // public bool boughtPiece = false;
- public int neighborToFind;
- public int transitionPiece;
- public int wildCard = -1;
- public enum TipoJuego {NEW_GAME, CONTINUE_GAME, DEMO};
- public static TipoJuego LOAD_GAME_TYPE = TipoJuego.NEW_GAME;
- //public final int NEW_GAME = 0;
- //public final int CONTINUE_GAME = 1;
- // public bool[,] movingPiece = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public bool[,] toMoai = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public bool[,] pieceChecked = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public bool[,] destAvailable = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public bool[,] roadSearched = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public bool[,] alienTranformedAt = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] originalX = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] originalY = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] destPieceX = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] destPieceY = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] destPieceMidpointX = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // public float[,] destPieceMidpointY = new float[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- public int prevClickX = -1;
- public int prevClickY = -1;
- public int currentGold = 0;
- public int currentScore = 0;
- public int highScore = 0;
- public static float anchoEnTransformUnitsSquareSprite;
- public static float altoEnTransformUnitsSquareSprite;
- public Hashtable tablaScorePerPiece;
- public float currentTime = 0;
- public float maxTime = 0;
- delegate void onPieceClick(int clickCount);
- Dictionary<PIECE_TYPE,onPieceClick> piecesClick = null;
- GameObject buyScreen = null;
- GameObject helpScreen = null;
- GameObject pauseScreen = null;
- // GameObject gameChangeScreen = null;
- GameObject popUpConfirmWindow = null;
- GameObject popUpSaveGameWindow = null;
- GameObject popUpPurchaseFeedbackWindow = null;
- GameObject popUpFreeCoinsWindow = null;
- public GameObject popUpSaveGameWindowPrefab = null;
- public GameObject buyScreenPrefab = null;
- public GameObject helpScreenPrefab = null;
- public GameObject pauseScreenPrefab = null;
- public GameObject gameChangeScreenPrefab = null;
- public GameObject popUpConfirmWindowPrefab = null;
- public GameObject popUpPurchaseFeedbackPrefab = null;
- public GameObject popUpFreeCoinsPrefab = null;
- private GameObject sound;
- public GameObject sndPutPiecePrefab = null;
- public GameObject sndCombinePiecePrefab = null;
- public GameObject sndCavernicolaMPrefab = null;
- public GameObject sndCavernicolaFPrefab = null;
- public GameObject sndVillagerPrefab = null;
- public GameObject sndAlienTeleportPrefab = null;
- public GameObject sndCashSound1Prefab = null;
- public GameObject sndCashSound2Prefab = null;
- // public tk2dSprite spriteBtnSound;
- private List<AudioSource> listCashSounds = new List<AudioSource>();
- //public List<GameObject> cashSoundsListPrefab = new List<GameObject>();
- // GameObject copperCoin = null;
- // GameObject silverCoin = null;
- // GameObject goldCoin = null;
- public GameObject copperCoinPrefab = null;
- public GameObject silverCoinPrefab = null;
- public GameObject goldCoinPrefab = null;
- public GameObject villagerPrefab;
- private tk2dTextMesh txtPopUpQuestion;
- private string popUpQuestionString;
- // Use this for initialization
- public int numberOfPlays;
- public System.DateTime lastDateFreeCoins;
- private struct DemoMoves {
- public PIECE_TYPE demoNextPiece;
- public int toqueGridX;
- public int toqueGridY;
- }
- void Start ()
- {
- onUpdateDelegate = new OnUpdateStateDelegate[]
- {
- onUpdateInitialize
- ,onWaitForClick
- ,onCollapsingCells
- ,onWaitEndOfAnimation
- ,onBuyScreen
- ,onPause
- ,onGameOver
- };
- piecesClick = new Dictionary<PIECE_TYPE, onPieceClick>()
- {
- {PIECE_TYPE.BLACK_HOLE,onBlackHoleClick}
- ,{PIECE_TYPE.MAGIC_CRISTAL_GREEN,onMagicCrystalGreenClick}
- ,{PIECE_TYPE.MAGIC_CRISTAL_PURPLE, onMagicCrystalPurpleClick}
- };
- touchX = -1;
- touchY = -1;
- lastAlienToMoaiX = -1;
- lastAlienToMoaiY = -1;
- btnMuteSoundScript = btnMute.GetComponent<SoundController>();
- //
- // BoxCollider newCollider = btnMute.gameObject.AddComponent<BoxCollider>();
- // Vector3 colliderExtents = newCollider.extents;
- // colliderExtents.z = 0.2f;
- // newCollider.extents = colliderExtents;
- // btnMute.boxCollider = new BoxCollider();
- initializeArrayConnections();
- initializeTablaAllAnimations();
- initializeArrayPieceChance();
- initializeTablaScorePerPiece();
- initializeTablaBuyForCoinsValue();
- initializeTablaSellForCoinsValue();
- // compareGrid = new int[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // usedGrid = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- // usedGridCopy = new bool[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- initializeMouseColliderHelper();
- // Instantiate(btnSoundPrefab);// as GameObject;
- currentGold = MainMenu.gold;
- highScore = MainMenu.highScore;
- ufoNextPieceOriginPos = ufoNextPiece.transform.position;
- selectorAnimation = selector.GetComponent<tk2dAnimatedSprite>();
- numberOfPlays = 0;
- #if UNITY_EDITOR
- lastDateFreeCoins = System.DateTime.Today.AddDays(-1);
- #else
- DataGame.loadOnlyFreeCoinsDate();
- #endif
- STATE = Estados.INITIALIZE;
- }
- // static bool show = false;
- public bool printDebugGameGrid = false;
- void Update()
- {
- int state = (int)STATE;
- // if (STATE != PreviousState) {
- // if (STATE == Estados.WAITING_FOR_CLICK || STATE == Estados.COLLAPSING || STATE == Estados.WAIT_END_ANIMATION) {
- // iTween.Resume();
- // } else {
- // iTween.Pause();
- // }
- // }
- if (STATE != Estados.WAITING_FOR_CLICK) {
- if (btnBuy.enabled) {
- btnBuy.enabled = false;
- }
- if (btnMuteSoundScript.isSpriteClickeable) {
- btnMuteSoundScript.isSpriteClickeable = false;
- }
- if (btnHelp.enabled) {
- btnHelp.enabled = false;
- }
- if (btnPause.enabled) {
- btnPause.enabled = false;
- }
- } else {
- if (!btnBuy.enabled) {
- btnBuy.enabled = true;
- }
- if (!btnMuteSoundScript.isSpriteClickeable) {
- btnMuteSoundScript.isSpriteClickeable = true;
- }
- if (!btnHelp.enabled) {
- btnHelp.enabled = true;
- }
- if (!btnPause.enabled) {
- btnPause.enabled = true;
- }
- }
- if(state >=0 && state< onUpdateDelegate.Length && onUpdateDelegate[state]!=null)
- {
- onUpdateDelegate[state]();
- }
- if (currentScore < 0) {
- currentScore = 0;
- }
- updateHud();
- if (printDebugGameGrid) {
- printGameGrid();
- printDebugGameGrid = false;
- }
- if (Input.GetKeyDown(KeyCode.Escape)) {
- switch(STATE) {
- case Estados.WAITING_FOR_CLICK:
- openPauseScreen();
- break;
- case Estados.PAUSE:
- if (pauseScreen != null && !gameOver) {
- closePauseScreen();
- }
- break;
- }
- }
- // PreviousState = STATE;
- }
- public PIECE_TYPE nextPieceReadable;
- public void updateHud()
- {
- scoreString = "Score "+currentScore.ToString();
- highScoreString = "Top "+highScore.ToString();
- coinsString = currentGold.ToString();
- nextPieceReadable = (PIECE_TYPE)nextPiece;
- if (txtScore.text != scoreString) {
- txtScore.text = scoreString;
- txtScore.maxChars = txtScore.text.Length+1;
- txtScore.Commit();
- }
- if (currentScore > highScore) {
- highScore = currentScore;
- highScoreString = "Top "+highScore.ToString();
- }
- if (highScoreString != txtHiScore.text) {
- txtHiScore.text = highScoreString;
- txtHiScore.maxChars = txtHiScore.text.Length+1;
- txtHiScore.Commit();
- }
- if (txtCoins.text != coinsString) {
- txtCoins.text = coinsString;
- txtCoins.maxChars = txtCoins.text.Length+1;
- txtCoins.Commit();
- }
- }
- public void rebuildForeground ()
- {
- for(int i=0; i < (int)GAME_PROPERTIES.rowLength; i++)
- {
- for(int j=0; j < (int)GAME_PROPERTIES.columnLength; j++)
- {
- replaceGraphicGridAt(i, j);
- if (gameGrid[i,j] == (int)PIECE_TYPE.RUCA || gameGrid[i,j] == (int)PIECE_TYPE.CAVE) {
- addVillager(Villager.TIPOS_VILLAGER.CAVERNICOLA, gameGridSprites[j*6+i].transform.position);
- }
- if (gameGrid[i,j] == (int)PIECE_TYPE.HOME || gameGrid[i,j] == (int)PIECE_TYPE.CASTLE) {
- addVillager(Villager.TIPOS_VILLAGER.CIUDADANO, gameGridSprites[j*6+i].transform.position);
- }
- }
- }
- }
- public void rebuildBackground ()
- {
- replaceNotUsed();
- for(int i=0; i < (int)GAME_PROPERTIES.rowLength; i++)
- {
- for(int j=0; j < (int)GAME_PROPERTIES.columnLength; j++)
- {
- updateBackgroundGridAt(i, j);
- updateBackgroundGridAroundAt(i, j);
- }
- }
- }
- private DemoMoves[] demoMoves = new DemoMoves[10];
- public void onUpdateInitialize ()
- {
- initializing = true;
- gameGrid = new int[(int)GAME_PROPERTIES.rowLength,(int)GAME_PROPERTIES.columnLength];
- gameGrid[0,(int)GAME_PROPERTIES.columnLength-1] = -1;
- wildCard = -1;
- wildCardStoragePiece.Play("RoadT");
- gameOver = false;
- //currentGold = 0;
- currentScore = 0;
- switch(LOAD_GAME_TYPE)
- {
- case TipoJuego.NEW_GAME:
- {
- if (listAldeanos.Count > 0) {
- for (int i = 0; i < listAldeanos.Count; i++) {
- Destroy(listAldeanos[i]);
- }
- listAldeanos.Clear();
- }
- getNextPiece();
- // nextPiece = (int)PIECE_TYPE.BLACK_HOLE;
- // nextPiece = (int)PIECE_TYPE.ALIEN_BASIC;
- // showNextPieceInSelectorAndGui(nextPiece);
- populate(Random.Range(5, 10 + 1), (int)PIECE_TYPE.BUSH , (int)PIECE_TYPE.NOT_USED);
- populate(Random.Range(1, 2 + 1), (int)PIECE_TYPE.TREE , (int)PIECE_TYPE.NOT_USED);
- populate(Random.Range(0, 1 + 1), (int)PIECE_TYPE.RUCA , (int)PIECE_TYPE.NOT_USED);
- populate(Random.Range(1, 3 + 1), (int)PIECE_TYPE.ROCK , (int)PIECE_TYPE.NOT_USED);
- populate(Random.Range(0, 2 + 1), (int)PIECE_TYPE.ALIEN_BASIC , (int)PIECE_TYPE.NOT_USED);
- // populate(Random.Range(0, 2 + 1), (int)PIECE_TYPE.ALIEN_TELEPORTER , (int)PIECE_TYPE.NOT_USED);
- populate(Random.Range(1, 2 + 1), (int)PIECE_TYPE.MOAI , (int)PIECE_TYPE.NOT_USED);
- //caso full of moais
- // for (int i = 0; i < 6; i++) {
- // for (int j = 0; j < 6; j++) {
- // if ((i == 0 && j == 5) || (i== 2 && j == 2) || (i == 3 && j == 2) ) {
- // continue;
- // } else {
- // gameGrid[i,j] = (int)PIECE_TYPE.MOAI;
- // }
- // }
- // }
- // gameGrid[2,2] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- // gameGrid[3,2] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- //caso full of aliens
- // for (int i = 0; i < 6; i++) {
- // for (int j = 0; j < 6; j++) {
- // if ((i == 0 && j == 5) || (i== 2 && j == 2) || (i == 3 && j == 2) ) {
- // continue;
- // } else {
- // gameGrid[i,j] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- // }
- // }
- // }
- // gameGrid[2,2] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- // gameGrid[3,2] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- // caso 2 cadenas diferentes
- // gameGrid[5,5] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[4,5] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- // gameGrid[2,2] = (int)PIECE_TYPE.BUSH;
- // gameGrid[2,3] = (int)PIECE_TYPE.BUSH;
- // gameGrid[0,1] = (int)PIECE_TYPE.RUCA;
- // gameGrid[1,1] = (int)PIECE_TYPE.RUCA;
- // gameGrid[3,1] = (int)PIECE_TYPE.RUCA;
- // gameGrid[4,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[5,2] = (int)PIECE_TYPE.BUSH;
- // gameGrid[5,1] = (int)PIECE_TYPE.MOAI;
- // gameGrid[0,0] = (int)PIECE_TYPE.MOAIS;
- // gameGrid[1,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[2,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[3,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[4,0] = (int)PIECE_TYPE.MOAIS;
- // gameGrid[5,0] = (int)PIECE_TYPE.MOAIS;
- // caso 2 grupos de aliens
- // nextPiece = (int)PIECE_TYPE.ROCK;
- // gameGrid[5,5] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[0,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[1,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[2,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[3,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[4,1] = (int)PIECE_TYPE.BUSH;
- // gameGrid[5,2] = (int)PIECE_TYPE.BUSH;
- // gameGrid[5,1] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[0,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[1,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[2,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- //// gameGrid[3,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[4,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- // gameGrid[5,0] = (int)PIECE_TYPE.ALIEN_BASIC;
- initializeMoaiIndexes();
- rebuildBackground();
- rebuildForeground();
- anchoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.x - gameGridSprites[1].transform.position.x);
- altoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.y - gameGridSprites[0+6].transform.position.y);
- //gamePiecesAnimations[0].CurrentClip.fps = 99f;
- STATE = Estados.WAITING_FOR_CLICK;
- }
- break;
- case TipoJuego.CONTINUE_GAME:
- {
- DataGame.loadSaveGame();
- initializeMoaiIndexes();
- rebuildBackground();
- rebuildForeground();
- checkForChancesOnLoadSavedGame();
- anchoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.x - gameGridSprites[1].transform.position.x);
- altoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.y - gameGridSprites[0+6].transform.position.y);
- showNextPieceInSelectorAndGui(nextPiece);
- if (wildCard != (int)PIECE_TYPE.OUT_OF_BOUNDS) {
- wildCardStoragePiece.Play((string)tablaAllAnimations[wildCard]);
- }
- LOAD_GAME_TYPE = TipoJuego.NEW_GAME;
- STATE = Estados.WAITING_FOR_CLICK;
- }
- break;
- case TipoJuego.DEMO:
- //inicializar gamegrid para demo
- if (listAldeanos.Count > 0) {
- for (int i = 0; i < listAldeanos.Count; i++) {
- Destroy(listAldeanos[i]);
- }
- listAldeanos.Clear();
- }
- gameGrid = new int[(int)GAME_PROPERTIES.rowLength, (int)GAME_PROPERTIES.columnLength];
- rebuildBackground();
- rebuildForeground();
- demoMoves[0].demoNextPiece = PIECE_TYPE.BUSH;
- demoMoves[0].toqueGridX = -1;
- demoMoves[0].toqueGridY = -1;
- demoMoves[1].demoNextPiece = PIECE_TYPE.BUSH;
- demoMoves[1].toqueGridX = 2;
- demoMoves[1].toqueGridY = 2;
- anchoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.x - gameGridSprites[1].transform.position.x);
- altoEnTransformUnitsSquareSprite = Mathf.Abs(gameGridSprites[0].transform.position.y - gameGridSprites[0+6].transform.position.y);
- break;
- default:
- break;
- }
- }
- private List<int> neighborsList = new List<int>();
- void onBlackHoleClick(int clickCount)
- {
- if (touchX < 0 && touchY < 0) {
- return;
- }
- if (gameGrid[touchX, touchY] == (int)PIECE_TYPE.ROAD) {
- // changeSelectorAnimationColor(SELECTOR_COLOR_RED);
- changeSelectorAnimation(false);
- return;
- } else {
- // changeSelectorAnimationColor(SELECTOR_COLOR_NORMAL);
- changeSelectorAnimation(true);
- }
- if (clickCount == 1) {
- if (gameGrid[touchX,touchY] == (int)PIECE_TYPE.ALIEN_BASIC || gameGrid[touchX,touchY] == (int)PIECE_TYPE.ALIEN_TELEPORTER) {
- startNeighborsSearch(PIECE_TYPE.MOAI, touchX, touchY);
- animateNeigbors = (this.neighborsList.Count >= 2);
- turnOnOffHighLightGrid(animateNeigbors);
- }
- } else {
- createBlackHole((PIECE_TYPE) gameGrid[touchX, touchY]);
- // lastPieceUsed = PIECE_TYPE.BLACK_HOLE;
- }
- }
- void onMagicCrystalGreenClick(int clickCount)
- {
- if (touchX < 0 && touchY < 0) {
- return;
- }
- PIECE_TYPE pieceToSell = (PIECE_TYPE)gameGrid[touchX, touchY];
- if (pieceToSell == PIECE_TYPE.ALIEN_BASIC || pieceToSell == PIECE_TYPE.ALIEN_TELEPORTER) {
- // changeSelectorAnimationColor(SELECTOR_COLOR_RED);
- changeSelectorAnimation(false);
- return;
- } else {
- // changeSelectorAnimationColor(SELECTOR_COLOR_NORMAL);
- changeSelectorAnimation(true);
- }
- if (clickCount == 2) {
- // lastPieceUsed = PIECE_TYPE.MAGIC_CRISTAL_GREEN;
- if (pieceToSell == PIECE_TYPE.ROAD) {
- addCoins(1, touchX, touchY);
- } else {
- addCoins((int)tablaSellForCoinsValue[pieceToSell], touchX, touchY);
- int scoreAmountToAdd = -((int)tablaScorePerPiece[pieceToSell]);
- currentScore += scoreAmountToAdd;
- createScoreText(scoreAmountToAdd, touchX, touchY, bonusMultiplier, false);
- gameGrid[touchX, touchY] = (int)PIECE_TYPE.ROAD;
- gamePiecesAnimations[touchY*6 + touchX].Play((string)tablaAllAnimations[(int)PIECE_TYPE.ROAD]);
- updateBackgroundGridAt(touchX, touchY);
- updateBackgroundGridAroundAt(touchX, touchY);
- }
- getNextPiece();
- moveAliens();
- hideSelector();
- // selector.transform.position
- // if(piecesClick.ContainsKey((PIECE_TYPE)nextPiece))
- // {
- // piecesClick[(PIECE_TYPE)nextPiece](1);
- // }
- // else
- // {
- // onPieceClickDefault(1);
- // }
- }
- }
- public PIECE_TYPE jokerPiece;
- void onMagicCrystalPurpleClick(int clickCount)
- {
- if (touchX < 0 && touchY < 0) {
- return;
- }
- if(clickCount==1)
- {
- if (gameGrid[touchX,touchY] == (int)PIECE_TYPE.ROAD)
- {
- //inicia busqueda y animacion
- // changeSelectorAnimationColor(SELECTOR_COLOR_NORMAL);
- changeSelectorAnimation(true);
- jokerPiece = jokerSearch(PIECE_TYPE.ROCK);//siempre se busca rock primero
- animateNeigbors = (this.neighborsList.Count >= 2);
- turnOnOffHighLightGrid(animateNeigbors);
- } else {
- // changeSelectorAnimationColor(SELECTOR_COLOR_RED);
- changeSelectorAnimation(false);
- }
- }
- else
- {
- if (gameGrid[touchX,touchY] == (int)PIECE_TYPE.ROAD)
- {
- //poner piezas o colapsarlas
- putOrCollapsePieces(jokerPiece);
- }
- }
- }
- void onPieceClickDefault(int clickCount)
- {
- if (touchX < 0 && touchY < 0) {
- return;
- }
- if(clickCount==1)
- {
- if (gameGrid[touchX,touchY] == (int)PIECE_TYPE.ROAD)
- {
- //inicia busqueda y animacion
- // changeSelectorAnimationColor(SELECTOR_COLOR_NORMAL);
- changeSelectorAnimation(true);
- if (nextPiece == (int)PIECE_TYPE.ALIEN_BASIC || nextPiece == (int)PIECE_TYPE.ALIEN_TELEPORTER) {
- neighborsList.Clear();
- return;
- }
- startNeighborsSearch((PIECE_TYPE)nextPiece, touchX, touchY);
- animateNeigbors = (this.neighborsList.Count >= 2);
- turnOnOffHighLightGrid(animateNeigbors);
- } else {
- // changeSelectorAnimationColor(SELECTOR_COLOR_RED);
- changeSelectorAnimation(false);
- }
- }
- else
- {
- if (gameGrid[touchX,touchY] == (int)PIECE_TYPE.ROAD)
- {
- //poner piezas o colapsarlas
- putOrCollapsePieces((PIECE_TYPE)nextPiece);
- }
- }
- }
- /// <summary>
- /// Starts the neighbors search.
- /// </summary>
- public void startNeighborsSearch(PIECE_TYPE pieceToFind, int x, int y)
- {
- neighborsList.Clear();
- getNeighBorsListAt(ref neighborsList,x,y,x,y, pieceToFind);
- }
- public PIECE_TYPE jokerSearch (PIECE_TYPE pieceToSearch)
- {
- if ( (getPieceTypeAt(touchX, touchY + 1) == PIECE_TYPE.ROAD || getPieceTypeAt(touchX, touchY + 1) == PIECE_TYPE.OUT_OF_BOUNDS)
- && (getPieceTypeAt(touchX + 1, touchY) == PIECE_TYPE.ROAD || getPieceTypeAt(touchX + 1, touchY) == PIECE_TYPE.OUT_OF_BOUNDS)
- && (getPieceTypeAt(touchX, touchY - 1) == PIECE_TYPE.ROAD || getPieceTypeAt(touchX, touchY - 1) == PIECE_TYPE.OUT_OF_BOUNDS)
- && (getPieceTypeAt(touchX - 1, touchY) == PIECE_TYPE.ROAD || getPieceTypeAt(touchX - 1, touchY) == PIECE_TYPE.OUT_OF_BOUNDS)) {
- if (neighborsList.Count > 0) {
- neighborsList.Clear();
- }
- return PIECE_TYPE.ROCK;
- }
- PIECE_TYPE pieceToReturn;
- startNeighborsSearch(pieceToSearch, touchX, touchY);
- switch(pieceToSearch) {
- case PIECE_TYPE.ROCK:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.ROCK;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.CAVE);
- }
- break;
- case PIECE_TYPE.CAVE:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.CAVE;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.DIAMOND);
- }
- break;
- case PIECE_TYPE.DIAMOND:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.DIAMOND;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.MOAI);
- }
- break;
- case PIECE_TYPE.MOAI:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.MOAI;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.MOAIS);
- }
- break;
- case PIECE_TYPE.MOAIS:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.MOAIS;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.STONEHENGE);
- }
- break;
- case PIECE_TYPE.STONEHENGE:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.STONEHENGE;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.BUSH);
- }
- break;
- case PIECE_TYPE.BUSH:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.BUSH;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.TREE);
- }
- break;
- case PIECE_TYPE.TREE:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.TREE;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.RUCA);
- }
- break;
- case PIECE_TYPE.RUCA:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.RUCA;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.HOME);
- }
- break;
- case PIECE_TYPE.HOME:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.HOME;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.CASTLE);
- }
- break;
- case PIECE_TYPE.CASTLE:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.CASTLE;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.BUILDING);
- }
- break;
- case PIECE_TYPE.BUILDING:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.BUILDING;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.FUTURE_HOME);
- }
- break;
- case PIECE_TYPE.FUTURE_HOME:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.FUTURE_HOME;
- } else {
- pieceToReturn = jokerSearch(PIECE_TYPE.FUTURE_HOME_HOVERING);
- }
- break;
- case PIECE_TYPE.FUTURE_HOME_HOVERING:
- if (neighborsList.Count >= 2) {
- return PIECE_TYPE.FUTURE_HOME_HOVERING;
- } else {
- return PIECE_TYPE.ROCK;
- }
- // break;
- default:
- return PIECE_TYPE.ROCK;
- // break;
- }
- return pieceToReturn;
- }
- /// <summary>
- /// Puts the or collapse pieces.
- /// </summary>
- bool collapsingHasStarted = false;
- bool collapsingPieces = false;
- bool collapsingHasEnded = false;
- public void onCollapsingCells() {
- int indexesToCollapseOriginalCount = indexesToCollapseList.Count;
- enableOrDisableUFOGuiButtons(false);
- for(int i = 0; i < indexesToCollapseList.Count; i++) {
- //just in case
- int targetX = indexesToCollapseList[i]%6;
- int targetY = indexesToCollapseList[i]/6;
- if(!collapsingHasStarted)
- {
- turnOnOffHighLightGrid(false);
- collapsingHasStarted = true;
- // if (i == 0) {
- // selector.transform.Translate(Vector3.forward*-10f);//ocultar selector
- // }
- }
- if(!collapsingPieces)
- {
- collapseNeighBors(targetX,targetY);
- }
- if(collapsingHasEnded)
- {
- collapsingHasStarted = false;
- collapsingPieces = false;
- collapsingHasEnded = false;
- resetPositionsOfAnimatedNeighbors();
- if (i == indexesToCollapseList.Count - 1) {//el final
- moveAliens();
- animateNeigbors = false;
- neighborsList.Clear();
- if (indexesToCollapseOriginalCount < indexesToCollapseList.Count) {
- continue;
- }
- bonusMultiplier = 0;
- STATE = Estados.WAITING_FOR_CLICK;
- //selector.transform.Translate(Vector3.forward*10f);//mostrar selector nuevamente
- resetTouch();
- indexesToCollapseList.Clear();
- enableOrDisableUFOGuiButtons(true);
- }
- }
- }
- }
- public void resetTouch() {
- touchX = -1;
- touchY = -1;
- prevClickX = -1;
- prevClickY = -1;
- }
- // public void purpleAliensOldRaiseFPSspeed() {
- // foreach(int alienIndex in listAlienPurpleOldIndexes)
- // {
- // gamePiecesAnimations[alienIndex].CurrentClip.fps = 20f;
- // }
- // }
- public void purpleAliensTeleportFase1ColorUpdate(Color value)
- {
- foreach(int alienIndex in listAlienPurpleOldIndexes)
- {
- gamePiecesAnimations[alienIndex].color = value;
- }
- }
- public void purpleAliensTeleportFase1ColorComplete()
- {
- foreach(int alienIndex in listAlienPurpleOldIndexes)
- {
- gamePiecesAnimations[alienIndex].color = Color.white;
- if (gameGrid[alienIndex%6, alienIndex/6] == (int)PIECE_TYPE.ROAD) {
- gamePiecesAnimations[alienIndex].CurrentClip.fps = 8f;
- gamePiecesAnimations[alienIndex].Play("RoadT");
- }
- }
- }
- // public void purpleAliensNewRaiseFPSspeed() {
- // foreach(int alienIndex in listAlienPurpleNewIndexes)
- // {
- // gamePiecesAnimations[alienIndex].CurrentClip.fps = 20f;
- // }
- // }
- public void purpleAliensTeleportFase2ColorUpdate(Color value)
- {
- foreach(int alienIndex in listAlienPurpleNewIndexes)
- {
- gamePiecesAnimations[alienIndex].color = value;
- }
- }
- public void purpleAliensTeleportFase2ColorComplete()
- {
- foreach(int alienIndex in listAlienPurpleNewIndexes)
- {
- gamePiecesAnimations[alienIndex].CurrentClip.fps = 8f;
- }
- }
- public List<int> listAlienPurpleOldIndexes = new List<int>();
- public List<int> listAlienPurpleNewIndexes = new List<int>();
- public readonly float teleportTime = 0.65f;
- public void movePurpleAliens() {
- listAlienPurpleOldIndexes.Clear();
- listAlienPurpleNewIndexes.Clear();
- fillListAlienPurple();
- List<int> validMoves = this.getValidPlacesToTeleport();
- if(listAlienPurpleOldIndexes.Count == 0)
- return;
- foreach(int alienIndex in listAlienPurpleOldIndexes)
- {
- if (validMoves.Count > 0) {
- int alienCurrentX = alienIndex%6;
- int alienCurrentY = alienIndex/6;
- gameGrid[alienCurrentX,alienCurrentY] = (int)PIECE_TYPE.ROAD;
- int indexDestino = validMoves[Random.Range(0, validMoves.Count)];
- int alienDestX = indexDestino%6;
- int alienDestY = indexDestino/6;
- gameGrid[alienDestX, alienDestY] = (int)PIECE_TYPE.ALIEN_TELEPORTER;
- validMoves.Remove(indexDestino);
- validMoves.Add(alienIndex);
- listAlienPurpleNewIndexes.Add(indexDestino);
- gamePiecesAnimations[alienIndex].CurrentClip.fps = 20f;
- }
- }
- if (validMoves.Count == 0) {
- return;
- // fillListAlienBasics();
- // if (listGreenAliensIndexes.Count > 0) {
- // return;
- // } else {
- // if (isGameOver()) {
- // STATE = Estados.GAME_OVER;
- // }
- // }
- } else {
- iTween.ValueTo(this.gameObject,
- iTween.Hash(
- "from",Color.white,
- "to",new Color(1.0f,1.0f,1.0f,0.0f),
- "time",teleportTime,
- // "onstart", "purpleAliensOldRaiseFPSspeed",
- "onupdate","purpleAliensTeleportFase1ColorUpdate",
- "oncomplete","purpleAliensTeleportFase1ColorComplete"
- ));
- foreach(int indexDestino in listAlienPurpleNewIndexes)
- {
- gamePiecesAnimations[indexDestino].Play("Alien_2");
- gamePiecesAnimations[indexDestino].CurrentClip.fps = 20f;
- gamePiecesAnimations[indexDestino].color = new Color(1.0f,1.0f,1.0f,0.0f);
- }
- iTween.ValueTo(this.gameObject,
- iTween.Hash(
- "from", new Color(1.0f,1.0f,1.0f,0.0f),
- "to",Color.white,
- "time",teleportTime,
- "delay",teleportTime,
- // "onstart", "purpleAliensNewRaiseFPSspeed",
- "onupdate","purpleAliensTeleportFase2ColorUpdate",
- "oncomplete","purpleAliensTeleportFase2ColorComplete"
- ));
- }
- }
- private List<List<int>> moaiGroupsList = new List<List<int>>();
- public void moveAliens() {
- //bool purple = false;
- // Estados prevState = STATE;
- // STATE = Estados.WAIT_END_ANIMATION;
- if (!alreadyMovedAliens) {
- movePurpleAliens();
- moveGreenAliens();
- alreadyMovedAliens = true;
- }
- if (isGameOver()) {
- STATE = Estados.GAME_OVER;
- }
- }
- public List<int> listGreenAliensIndexes = new List<int>();
- public List<int> listGreenAliensMoved = new List<int>();
- public List<int> listGreenAliensStuck = new List<int>();
- public void moveGreenAliens()//float timeToWaitBeforeMove)
- {
- listGreenAliensStuck.Clear();
- listGreenAliensMoved.Clear();
- listGreenAliensIndexes.Clear();
- moaiGroupsList.Clear();
- fillListAlienBasics();
- if (listGreenAliensIndexes.Count == 0) {
- return;
- }
- for(int i = 0; i < listGreenAliensIndexes.Count; i++)// in listGreenAliensIndexes)
- {
- int alienIndex = listGreenAliensIndexes[i];
- // int alienCurrentX = alienIndex%6;
- // int alienCurrentY = alienIndex/6;
- // List<int> validMoves = getValidAlienNeighborsMoves(alienIndex);
- if (tryToMoveGreenAlien(alienIndex)) {
- if (!listGreenAliensMoved.Contains(alienIndex)) {
- listGreenAliensMoved.Add(alienIndex);
- }
- } else {
- if (!listGreenAliensStuck.Contains(alienIndex)) {
- listGreenAliensStuck.Add(alienIndex);
- }
- }
- }
- int prevoiusAmountOfAliensStuck = listGreenAliensStuck.Count;
- do {
- prevoiusAmountOfAliensStuck = listGreenAliensStuck.Count;
- for(int i = 0; i < listGreenAliensStuck.Count; i++) {
- int alienStuckIndex = listGreenAliensStuck[i];
- if (!listGreenAliensMoved.Contains(alienStuckIndex) && tryToMoveGreenAlien(alienStuckIndex)) {//antes estaba pegado y logró moverse...
- listGreenAliensStuck.Remove(alienStuckIndex);//lo quitamos de la lista de aliens pegados
- i--;//se retrocede 1 loop en la iteración, ya que ahora hay un alien pegado menos
- listGreenAliensMoved.Add(alienStuckIndex);//añadimos al alien q se movió a la lista de los que ya se han movido
- }
- }
- } while(listGreenAliensStuck.Count != prevoiusAmountOfAliensStuck);//mientras la cantidad de fe aliens pegados no sea constante
- checkStuckAliens();
- resetTouch();
- //yield return null;
- }
- public enum PUNTOS_CARDINALES {
- NORTE
- ,SUR
- ,ESTE
- ,OESTE
- }
- public void initAnimGreenAlien(MoveAlienParams alienParams) {
- if (alienParams.direccionDeMovimiento == PUNTOS_CARDINALES.NORTE || alienParams.direccionDeMovimiento == PUNTOS_CARDINALES.SUR) {
- gamePiecesAnimations[alienParams.index].Play("Alien_1_move_v");
- } else {
- if (alienParams.direccionDeMovimiento == PUNTOS_CARDINALES.ESTE) {
- gamePiecesAnimations[alienParams.index].Play("Alien_1_move_hder");
- } else {
- gamePiecesAnimations[alienParams.index].Play("Alien_1_move_h");
- }
- }
- }
- public void endAnimGreenAlien(MoveAlienParams alienParams) {
- if (gameGrid[alienParams.index%6, alienParams.index/6] == (int)PIECE_TYPE.ALIEN_BASIC) {
- gamePiecesAnimations[alienParams.index].Play("Alien_1");
- }
- }
- public void keepGreenAlienColor(int indexAlien) {
- if (gamePiecesAnimations[indexAlien].color != Color.white) {
- gamePiecesAnimations[indexAlien].color = Color.white;
- }
- }
- public struct MoveAlienParams {
- public int index;
- public PUNTOS_CARDINALES direccionDeMovimiento;
- public float delay;
- }
- public bool tryToMoveGreenAlien(int indexIni) {
- //int indexInicio = currentY*6 + currentX;
- int currentX = indexIni%6;
- int currentY = indexIni/6;
- List<int> validMoves = getValidAlienNeighborsMoves(indexIni);
- if(validMoves.Count > 0)
- {
- int indexDestino = validMoves[Random.Range(0, validMoves.Count)];
- int destinyX = indexDestino%6;
- int destinyY = indexDestino/6;
- // moveGreenAlienFromTo(alienCurrentX, alienCurrentY, alienDestX, alienDestY);
- gameGrid[currentX,currentY] = (int)PIECE_TYPE.ROAD;
- gameGrid[destinyX, destinyY] = (int)PIECE_TYPE.ALIEN_BASIC;
- MoveAlienParams alienInfo = new MoveAlienParams();
- alienInfo.index = indexDestino;
- if (destinyX - currentX < 0) {//izq
- alienInfo.direccionDeMovimiento = PUNTOS_CARDINALES.OESTE;
- } else {
- if (destinyX - currentX > 0) {//derecha
- alienInfo.direccionDeMovimiento = PUNTOS_CARDINALES.ESTE;
- } else {//en la misma x
- if (destinyY - currentY < 0) {
- alienInfo.direccionDeMovimiento = PUNTOS_CARDINALES.SUR;
- } else {
- alienInfo.direccionDeMovimiento = PUNTOS_CARDINALES.NORTE;
- }
- }
- }
- // if(!gamePiecesAnimations[indexIni].Playing) {
- gamePiecesAnimations[indexIni].Play("RoadT");
- // }
- gamePiecesAnimations[indexDestino].Play("Alien_1");
- Vector3 DestinyPos = gamePiecesAnimations[indexDestino].transform.position;
- gamePiecesAnimations[indexDestino].transform.position = gamePiecesAnimations[indexIni].transform.position;
- alienInfo.delay = 0;
- if (listAlienPurpleOldIndexes.Count > 0) {
- alienInfo.delay = teleportTime;
- }
- iTween.MoveTo(gamePiecesAnimations[indexDestino].gameObject, iTween.Hash(
- "position", DestinyPos,
- "onstart", "initAnimGreenAlien",
- "onstarttarget", this.gameObject,
- "onstartparams", alienInfo,
- "onupdate", "keepGreenAlienColor",
- "onupdatetarget", this.gameObject,
- "onupdateparams", indexDestino,
- "oncomplete", "endAnimGreenAlien",
- "oncompletetarget", this.gameObject,
- "oncompleteparams", alienInfo,
- "delay", alienInfo.delay,
- "easetype", iTween.EaseType.spring,
- "time", 1.0f));
- return true;
- } else {
- return false;
- }
- }
- public void checkStuckAliens() {
- int alienX;
- int alienY;
- bool checkForMoai = false;
- PIECE_TYPE pieceNorth;
- PIECE_TYPE pieceEast;
- PIECE_TYPE pieceSouth;
- PIECE_TYPE pieceWest;
- List<int> listAliensStuckNextToAliens = new List<int>();
- // int lastAloneAlienToMoaiIndex = -1;
- foreach (int alienStuckIndex in listGreenAliensStuck) {
- alienX = alienStuckIndex%6;
- alienY = alienStuckIndex/6;
- //N
- pieceNorth = getPieceTypeAt(alienX, alienY + 1);
- //E
- pieceEast = getPieceTypeAt(alienX + 1, alienY);
- //S
- pieceSouth = getPieceTypeAt(alienX, alienY - 1);
- //O
- pieceWest = getPieceTypeAt(alienX - 1, alienY);
- if ( !(pieceNorth == PIECE_TYPE.ALIEN_BASIC || pieceNorth == PIECE_TYPE.ALIEN_TELEPORTER || pieceNorth == PIECE_TYPE.ROAD) &&
- !(pieceEast == PIECE_TYPE.ALIEN_BASIC || pieceEast == PIECE_TYPE.ALIEN_TELEPORTER || pieceEast == PIECE_TYPE.ROAD) &&
- !(pieceSouth == PIECE_TYPE.ALIEN_BASIC || pieceSouth == PIECE_TYPE.ALIEN_TELEPORTER || pieceSouth == PIECE_TYPE.ROAD) &&
- !(pieceWest == PIECE_TYPE.ALIEN_BASIC || pieceWest == PIECE_TYPE.ALIEN_TELEPORTER || pieceWest == PIECE_TYPE.ROAD)) {
- alienToMoaiAt(alienStuckIndex);
- checkForMoai = true;
- } else {
- listAliensStuckNextToAliens.Add(alienStuckIndex);
- }
- for(int i = 0; i < listAliensStuckNextToAliens.Count; i++) {
- int stuckAlienIndex = listAliensStuckNextToAliens[i];
- List<int> currentAlienValidMoves = getValidAlienNeighborsMoves(stuckAlienIndex, true);
- startNeighborsSearch(PIECE_TYPE.ALIEN_BASIC, alienX, alienY);
- // neighborsList.Clear();
- // getNeighBorsListAt(ref neighborsList,alienX,alienY,alienX,alienY, PIECE_TYPE.ALIEN_BASIC);
- int countStuck = 0;
- for (int n = 0; n < neighborsList.Count; n++) {
- int stuckAlienNeighborIndex = neighborsList[n];
- List<int> validMoves = getValidAlienNeighborsMoves(stuckAlienNeighborIndex, true);
- if (validMoves.Count + currentAlienValidMoves.Count > 0) { //no convertir, quitarlos de la lista
- listAliensStuckNextToAliens.Remove(stuckAlienIndex);
- for (int m = 0; m < neighborsList.Count; m++) {
- listAliensStuckNextToAliens.Remove(neighborsList[m]);
- }
- i = -1;
- break;
- } else {
- countStuck++;//contando los pegados
- if (countStuck == neighborsList.Count) {//si todos estan pegados, los convierte a moai
- for (int k = 0; k < neighborsList.Count; k++) {
- int indexNeighbor = neighborsList[k];
- alienToMoaiAt(indexNeighbor);
- listAliensStuckNextToAliens.Remove(neighborsList[k]);
- }
- i = -1;
- alienToMoaiAt(stuckAlienIndex);
- checkForMoai = true;
- break;
- }
- }
- }
- }
- }
- if (checkForMoai) {
- checkForMoaiGroups();
- }
- // } else {
- // if (isGameOver()) {
- // STATE = Estados.GAME_OVER;
- // }
- // }
- }
- void checkForMoaiGroups() {
- // initializeMoaiIndexes();
- int groupCount = 0;
- moaiGroupsList.Clear();
- for (int i = 0; i < listMoaiIndexes.Count; i++) {
- int moaiIndex = listMoaiIndexes[i];
- int moaiX = moaiIndex%6;
- int moaiY = moaiIndex/6;
- List<int> tempList = new List<int>();
- // neighborsList.Clear();
- // getNeighBorsListAt(ref neighborsList, moaiX, moaiY, moaiX, moaiY, PIECE_TYPE.MOAI);//verificando los vecinos moai
- startNeighborsSearch(PIECE_TYPE.MOAI, moaiX, moaiY);
- if (neighborsList.Count >= 2) {//si hay un grupo de 3 o más
- moaiGroupsList.Add(new List<int>());//se crea un grupo
- tempList.Add (moaiIndex);
- tempList.AddRange(neighborsList);
- moaiGroupsList[groupCount].AddRange(tempList);
- for (int n = 0; n < tempList.Count; n++) {
- int moaiInGroupIndex = tempList[n];
- listMoaiIndexes.Remove(moaiInGroupIndex);//se quitan todos los moai del grupo de la lista de moais
- }
- i--; //como se quitó el moai actual, se retrocede en 1 el loop
- groupCount++;
- }
- }
- //debug
- // Debug.Log("Grupos: " + moaiGroupsList.Count);
- if (moaiGroupsList.Count > 0) {
- for (int i = 0; i < moaiGroupsList.Count; i++ ) {//List<int> lista in moaiGroupsList) {
- List<int> lista = moaiGroupsList[i];
- // Debug.Log("Grupo #" + i + " Tiene " + lista.Count + " moais");
- // Debug.Log("-----");
- if (lista.Contains(touchY*6 + touchX)) {
- indexesToCollapseList.Add(touchY*6 + touchX);
- // Debug.Log("Grupo #" + i + " Index a colapsar: " + (touchY*6 + touchX));
- continue;//nos saltamos al siguiente grupo de moais
- } else {
- List<int> candidateToBeCollapseTarget = new List<int>();
- for(int m = 0; m < lista.Count; m++) {
- int moaiIndex = lista[m];
- int currentMoaiX = moaiIndex%6;
- int currentMoaiY = moaiIndex/6;
- float distX = Mathf.Abs(touchX - currentMoaiX);
- float distY = Mathf.Abs(touchY - currentMoaiY);
- if (distX <= 1f && distY <= 1f) {
- candidateToBeCollapseTarget.Add(moaiIndex);
- //indexesToCollapseList.Add(moaiIndex);
- //Debug.Log("Grupo #" + i + " Index a colapsar: " + moaiIndex);
- //break;
- }
- }
- int indexNorth = (touchY + 1)*6 + (touchX);
- int indexSouth = (touchY - 1)*6 + (touchX);
- int indexEast = (touchY)*6 + (touchX + 1);
- int indexWest = (touchY)*6 + (touchX - 1);
- if (candidateToBeCollapseTarget.Contains(indexNorth)) {
- indexesToCollapseList.Add(indexNorth);
- continue;
- } else {
- if (candidateToBeCollapseTarget.Contains(indexSouth)) {
- indexesToCollapseList.Add(indexSouth);
- continue;
- } else {
- if (candidateToBeCollapseTarget.Contains(indexEast)) {
- indexesToCollapseList.Add(indexEast);
- continue;
- } else {
- if (candidateToBeCollapseTarget.Contains(indexWest)) {
- indexesToCollapseList.Add(indexWest);
- continue;
- } else {
- indexesToCollapseList.Add(lista[0]);
- continue;
- }
- }
- }
- }
- }
- }
- neighborsList.Clear();
- STATE = Estados.COLLAPSING;
- }
- // else {
- // if (isGameOver()) {
- // STATE = Estados.GAME_OVER;
- // }
- // }
- //reconstuir la lista
- initializeMoaiIndexes();
- }
- private List<int> listMoaiIndexes = new List<int>();
- public void alienToMoaiAt(int index) {
- alienToMoaiAt(index, true);
- }
- public void alienToMoaiAt(int index, bool playAnimation) {
- int alienX = index%6;
- int alienY = index/6;
- gameGrid[alienX, alienY] = (int)PIECE_TYPE.MOAI;
- if (playAnimation) {
- gamePiecesAnimations[index].Play((string)tablaAllAnimations[(int)PIECE_TYPE.MOAI]);//"Moai_Single" ?
- }
- updateBackgroundGridAt(alienX, alienY);
- updateBackgroundGridAroundAt(alienX, alienY);
- if (!listMoaiIndexes.Contains(index)) {
- listMoaiIndexes.Add(index);
- }
- //updateBackgroundGraphics();
- }
- public void fillListAlienBasics() {
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.ALIEN_BASIC) {
- listGreenAliensIndexes.Add(j*6+i);
- }
- }
- }
- }
- public void fillListAlienPurple() {
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.ALIEN_TELEPORTER) {
- listAlienPurpleOldIndexes.Add(j*6+i);
- }
- }
- }
- }
- public List<int> getValidAlienNeighborsMoves(int alienIndex) {
- return getValidAlienNeighborsMoves(alienIndex, false);
- }
- public List<int> getValidAlienNeighborsMoves(int alienIndex, bool countPurpleAlienNeighborAsValidMove) {
- List<int> listaIndexesValidos = new List<int>();
- int alienX = alienIndex%6;
- int alienY = alienIndex/6;
- if (countPurpleAlienNeighborAsValidMove) {
- //N
- if (getPieceTypeAt(alienX, alienY + 1) == PIECE_TYPE.ROAD || getPieceTypeAt(alienX, alienY + 1) == PIECE_TYPE.ALIEN_TELEPORTER) {
- listaIndexesValidos.Add(alienIndex + 6);
- }
- //E
- if (getPieceTypeAt(alienX + 1, alienY) == PIECE_TYPE.ROAD || getPieceTypeAt(alienX + 1, alienY) == PIECE_TYPE.ALIEN_TELEPORTER) {
- listaIndexesValidos.Add(alienIndex + 1);
- }
- //S
- if (getPieceTypeAt(alienX, alienY - 1) == PIECE_TYPE.ROAD || getPieceTypeAt(alienX, alienY - 1) == PIECE_TYPE.ALIEN_TELEPORTER) {
- listaIndexesValidos.Add(alienIndex - 6);
- //O
- }
- if (getPieceTypeAt(alienX - 1, alienY) == PIECE_TYPE.ROAD || getPieceTypeAt(alienX - 1, alienY) == PIECE_TYPE.ALIEN_TELEPORTER) {
- listaIndexesValidos.Add(alienIndex - 1);
- }
- } else {
- //N
- if (getPieceTypeAt(alienX, alienY + 1) == PIECE_TYPE.ROAD) {
- listaIndexesValidos.Add(alienIndex + 6);
- }
- //E
- if (getPieceTypeAt(alienX + 1, alienY) == PIECE_TYPE.ROAD) {
- listaIndexesValidos.Add(alienIndex + 1);
- }
- //S
- if (getPieceTypeAt(alienX, alienY - 1) == PIECE_TYPE.ROAD) {
- listaIndexesValidos.Add(alienIndex - 6);
- //O
- }
- if (getPieceTypeAt(alienX - 1, alienY) == PIECE_TYPE.ROAD) {
- listaIndexesValidos.Add(alienIndex - 1);
- }
- }
- return listaIndexesValidos;
- }
- public List<int> getValidPlacesToTeleport() {
- List<int> listaIndexesValidos = new List<int>();
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.ROAD) {
- listaIndexesValidos.Add(j*6+i);
- }
- }
- }
- return listaIndexesValidos;
- }
- private PIECE_TYPE getPieceTypeAt(int x, int y)
- {
- if((x>=0) && (x<=(int)GAME_PROPERTIES.rowLength-1))
- {
- if((y>=0) && (y<=(int)GAME_PROPERTIES.columnLength-1))
- {
- if((x!=0) || (y!= (int)GAME_PROPERTIES.columnLength-1))
- {
- return (PIECE_TYPE)gameGrid[x,y];
- }
- }
- }
- return PIECE_TYPE.OUT_OF_BOUNDS;
- }
- public void createBlackHole(PIECE_TYPE pieceTarget) {
- int indexPieceAnimation = touchY*6 + touchX;
- Estados oldState = STATE;
- STATE = Estados.WAIT_END_ANIMATION;
- // if (pieceTarget == PIECE_TYPE.ROAD) {
- // STATE = Estados.WAITING_FOR_CLICK;
- // return;
- // }
- if(neighborsList.Count < 2)
- {
- //poner piezas
- if (pieceTarget == PIECE_TYPE.ALIEN_BASIC || pieceTarget == PIECE_TYPE.ALIEN_TELEPORTER) {
- //gameGrid[touchX, touchY] = (int)PIECE_TYPE.MOAI;
- alienToMoaiAt(touchY*6 + touchX, false);
- } else {
- if (gameGrid[touchX, touchY] == (int)PIECE_TYPE.MOAI) {
- listMoaiIndexes.Remove(touchY * 6 + touchX);
- }
- gameGrid[touchX, touchY] = (int)PIECE_TYPE.ROAD;
- }
- gamePiecesAnimations[indexPieceAnimation].Play("Black_Hole_Full_Animation");
- float clipTotalTime = gamePiecesAnimations[indexPieceAnimation].CurrentClipTotalAnimationTime;
- StartCoroutine(changeAnimationBlackHoleToPiece(indexPieceAnimation, (PIECE_TYPE)gameGrid[touchX, touchY], clipTotalTime, oldState, true));//);
- // //waitAWhile((float)gamePiecesAnimations[indexPieceAnimation].CurrentClip.frames.Length/gamePiecesAnimations[indexPieceAnimation].CurrentClip.fps);
- //
- int scoreAmountToAdd = (int)tablaScorePerPiece[(PIECE_TYPE)gameGrid[touchX, touchY]];
- currentScore += scoreAmountToAdd;
- createScoreText(scoreAmountToAdd, touchX, touchY, bonusMultiplier, false);
- this.updateBackgroundGridAt(touchX, touchY);
- this.updateBackgroundGridAroundAt(touchX,touchY);
- getNextPiece();
- //updateBackgroundGraphics();
- neighborsList.Clear();
- }
- else //varios moais
- {
- gameGrid[touchX, touchY] = (int)PIECE_TYPE.MOAI;
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.MOAI];
- gamePiecesAnimations[indexPieceAnimation].Play("Black_Hole_Full_Animation");
- float clipTotalTime = gamePiecesAnimations[indexPieceAnimation].CurrentClipTotalAnimationTime;
- StartCoroutine(changeAnimationBlackHoleToPiece(indexPieceAnimation, PIECE_TYPE.MOAI, clipTotalTime, Estados.COLLAPSING, false));
- indexesToCollapseList.Add(touchY*6 + touchX);
- }
- }
- IEnumerator changeAnimationBlackHoleToPiece(int indexSpriteAnimado, PIECE_TYPE nuevaPieza, float timeToWait, Estados newState, bool isSingleNeighbor) {
- hideSelector();
- yield return new WaitForSeconds(timeToWait);
- gamePiecesAnimations[indexSpriteAnimado].Play((string)tablaAllAnimations[(int)nuevaPieza]);
- //selector.transform.Translate(Vector3.forward*10f);
- STATE = newState;
- if (isSingleNeighbor) {
- moveAliens();
- }
- }
- public void putOrCollapsePieces (PIECE_TYPE pieceToPut)
- {
- gameGrid[touchX,touchY] = (int)pieceToPut;
- gamePiecesAnimations[touchY*6+touchX].Play((string)tablaAllAnimations[(int)pieceToPut]);
- hideSelector();//selector.transform.Translate(Vector3.forward*-10f);
- // lastPieceUsed = pieceToPut;
- if (pieceToPut == PIECE_TYPE.ALIEN_BASIC || pieceToPut == PIECE_TYPE.ALIEN_TELEPORTER) {
- playFX((Instantiate(this.sndAlienTeleportPrefab) as GameObject).GetComponent<AudioSource>());
- } else {
- if (neighborsList.Count < 3) {
- playFX((Instantiate(this.sndPutPiecePrefab) as GameObject).GetComponent<AudioSource>());
- } else {
- playFX((Instantiate(this.sndCombinePiecePrefab) as GameObject).GetComponent<AudioSource>());
- }
- }
- // switch(pieceToPut) {
- // case PIECE_TYPE.ALIEN_BASIC:
- // case PIECE_TYPE.ALIEN_TELEPORTER:
- // break;
- // default:
- // playFX((Instantiate(this.sndPutPiecePrefab) as GameObject).GetComponent<AudioSource>());
- // break;
- //
- // }
- updateBackgroundGridAt(touchX, touchY);
- updateBackgroundGridAroundAt(touchX,touchY);
- if(neighborsList.Count < 2)
- {
- //poner piezas
- if (pieceToPut == PIECE_TYPE.RUCA) {
- addVillager(Villager.TIPOS_VILLAGER.CAVERNICOLA, gameGridSprites[touchY*6+ touchX].transform.position);
- }
- int scoreAmountToAdd = (int)tablaScorePerPiece[pieceToPut];
- currentScore += scoreAmountToAdd;
- createScoreText(scoreAmountToAdd, touchX, touchY, bonusMultiplier, false);
- getNextPiece();
- //updateBackgroundGraphics();
- moveAliens();
- }
- else
- {
- //currentScore += (int)tablaScorePerPiece[(PIECE_TYPE)nextPiece];
- indexesToCollapseList.Add(touchY*6+touchX);
- STATE = Estados.COLLAPSING;
- getNextPiece();
- }
- }
- struct CollapseParams
- {
- public Vector3 origin;
- public GameObject go;
- public int origin_index;
- public int destiny_index;
- };
- private int collapsingCount = 0;
- private readonly float DELAY_TO_COLLAPSE = 0.2f;
- void collapseNeighBors (int x, int y)
- {
- int index = y*6 + x;
- startNeighborsSearch((PIECE_TYPE)gameGrid[x,y], x, y);
- if (neighborsList.Count >= 2) {
- Vector3 pos = gamePiecesAnimations[index].transform.position;
- collapsingPieces = true;
- bonusMultiplier++;
- foreach(int i in neighborsList)
- {
- //currentScore += (int)tablaScorePerPiece[(PIECE_TYPE)gameGrid[x,y]]*bonusMultiplier;
- CollapseParams onCollapseParams = new CollapseParams();
- onCollapseParams.origin = gamePiecesAnimations[i].transform.position;
- onCollapseParams.go = gamePiecesAnimations[i].gameObject;
- onCollapseParams.origin_index = i;
- onCollapseParams.destiny_index = index;
- iTween.MoveTo(gamePiecesAnimations[i].gameObject,iTween.Hash
- (
- "position",pos
- ,"time", 0.7f
- ,"delay", DELAY_TO_COLLAPSE
- ,"easetype", iTween.EaseType.easeOutBounce
- ,"oncomplete","neighborHasReachTarget"
- ,"oncompletetarget",this.gameObject
- ,"oncompleteparams",onCollapseParams
- ));
- }
- } else {
- collapsingPieces = false;
- neighborsList.Clear();
- collapsingHasEnded = true;
- }
- }
- void neighborHasReachTarget(CollapseParams onCollapseParams)
- {
- collapsingCount++;
- int x = onCollapseParams.origin_index%6;
- int y = onCollapseParams.origin_index/6;
- onCollapseParams.go.transform.position = onCollapseParams.origin;
- if (gameGrid[x,y] == (int)PIECE_TYPE.MOAI && !listMoaiIndexes.Contains(onCollapseParams.origin_index)) {
- listMoaiIndexes.Remove(onCollapseParams.origin_index);
- }
- gameGrid[x,y] = (int)PIECE_TYPE.ROAD;
- gamePiecesAnimations[onCollapseParams.origin_index].Play("RoadT");
- if(collapsingCount==neighborsList.Count)
- {
- int dx = onCollapseParams.destiny_index%6;
- int dy = onCollapseParams.destiny_index/6;
- onUpgradeGrid(dx,dy,collapsingCount);
- collapsingCount = 0;
- collapsingPieces = false;
- startNeighborsSearch((PIECE_TYPE)gameGrid[dx,dy], dx, dy);
- if(neighborsList.Count>=2)
- {
- collapsingPieces = false;
- }
- else
- {
- neighborsList.Clear();
- collapsingHasEnded = true;
- // getNextPiece();
- }
- rebuildBackground ();
- }
- }
- void onUpgradeGrid (int x, int y, int count)
- {
- int index = y*6 + x;
- updateGameGrid(ref gameGrid[x,y],ref gamePiecesAnimations[index],count, x, y);
- }
- void updateGameGrid (ref int pieceValue, ref tk2dAnimatedSprite sprite, int count, int x, int y)
- {
- PIECE_TYPE type = (PIECE_TYPE)pieceValue;
- int montoMonedas;
- int scoreAmountToAdd = (int)tablaScorePerPiece[type]*(count+1)*bonusMultiplier;
- //ptje x cada pieza juntada, +1 incluyendo la que se puso para hacer la cadena
- if (count > 2) {
- scoreAmountToAdd += (int)tablaScorePerPiece[type]*(count-2)*bonusMultiplier;//ptje extra x cada pieza sobre 2
- montoMonedas = ((int)tablaScorePerPiece[type]*(count+1)*bonusMultiplier)/5;//count-2
- addCoins(montoMonedas, x, y);
- }
- currentScore += scoreAmountToAdd;
- createScoreText(scoreAmountToAdd, x, y, bonusMultiplier, false);
- scoreAmountToAdd = 0;
- Vector3 starPosIni = sprite.transform.position;// + Vector3.up*-altoEnTransformUnitsSquareSprite/2f + Vector3.right*anchoEnTransformUnitsSquareSprite/2f;
- starPosIni.Set(starPosIni.x + anchoEnTransformUnitsSquareSprite/2f, starPosIni.y - altoEnTransformUnitsSquareSprite/2f + 4f*(bonusMultiplier), 1.45f);
- GameObject stars = Instantiate(this.comboStarAnimationPrefab, starPosIni, new Quaternion(0f, 0f, Random.Range(0f, 360f + 1f), 0f)) as GameObject;
- stars.transform.localScale += new Vector3(0.5f*(float)(bonusMultiplier-1), 0.5f*(float)(bonusMultiplier-1), 0.5f*(float)(bonusMultiplier-1));
- switch(type)
- {
- case PIECE_TYPE.BUSH:
- pieceValue = (int)PIECE_TYPE.TREE;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.TREE]*bonusMultiplier;
- //currentScore +=
- //int scoreAmountToAdd = (int)tablaScorePerPiece[type]*(count+1)*bonusMultiplier;
- if (count>2) {
- sprite.Play("Tree_Upgraded");
- } else {
- sprite.Play("Tree");
- }
- break;
- case PIECE_TYPE.TREE:
- pieceValue = (int)PIECE_TYPE.RUCA;
- //currentScore +=
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.RUCA]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Ruca_2");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.TREE]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.TREE]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Ruca_1");
- }
- addVillager(Villager.TIPOS_VILLAGER.CAVERNICOLA, sprite.transform.position);
- break;
- case PIECE_TYPE.RUCA:
- pieceValue = (int)PIECE_TYPE.HOME;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.HOME]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Home_Upgraded");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.RUCA]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.RUCA]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Home");
- }
- addVillager(Villager.TIPOS_VILLAGER.CIUDADANO, sprite.transform.position);
- break;
- case PIECE_TYPE.HOME:
- pieceValue = (int)PIECE_TYPE.CASTLE;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.CASTLE]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Castle_Upgraded");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.HOME]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.HOME]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Castle");
- }
- // sprite.Play(count>2? "Castle_Upgraded" : "Castle");
- addVillager(Villager.TIPOS_VILLAGER.CIUDADANO, sprite.transform.position);
- break;
- case PIECE_TYPE.CASTLE:
- pieceValue = (int)PIECE_TYPE.BUILDING;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.BUILDING]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Building_Upgraded");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.CASTLE]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.CASTLE]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Building");
- }
- break;
- case PIECE_TYPE.BUILDING:
- pieceValue = (int)PIECE_TYPE.FUTURE_HOME;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Future_Home_1_Upgraded");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.BUILDING]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.BUILDING]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Future_Home_1");
- }
- break;
- case PIECE_TYPE.FUTURE_HOME:
- pieceValue = (int)PIECE_TYPE.FUTURE_HOME_HOVERING;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME_HOVERING]*bonusMultiplier;
- if (count>2) {
- sprite.Play("Future_Home_2_Upgraded");
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- } else {
- sprite.Play("Future_Home_2");
- }
- break;
- case PIECE_TYPE.FUTURE_HOME_HOVERING:
- pieceValue = (int)PIECE_TYPE.FUTURE_CITY;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.FUTURE_CITY]*bonusMultiplier;
- if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME_HOVERING]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.FUTURE_HOME_HOVERING]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- }
- sprite.Play("Future_City");
- break;
- //aliens y moai
- case PIECE_TYPE.MOAI://moai single
- pieceValue = (int)PIECE_TYPE.MOAIS;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.MOAIS]*bonusMultiplier;
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.MOAI]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.MOAI]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- sprite.Play("Moais_Triple");
- break;
- case PIECE_TYPE.MOAIS:
- pieceValue = (int)PIECE_TYPE.STONEHENGE;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.STONEHENGE]*bonusMultiplier;
- sprite.Play("Stonehenge");
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.MOAIS]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.MOAIS]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- break;
- case PIECE_TYPE.STONEHENGE:
- pieceValue = (int)PIECE_TYPE.DIAMOND;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.DIAMOND]*bonusMultiplier;
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.STONEHENGE]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.STONEHENGE]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- sprite.Play("Diamond");
- break;
- case PIECE_TYPE.ROCK:
- pieceValue = (int)PIECE_TYPE.CAVE;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.CAVE]*bonusMultiplier;
- sprite.Play("Cave");
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.ROCK]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.ROCK]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- addVillager(Villager.TIPOS_VILLAGER.CAVERNICOLA, sprite.transform.position);
- break;
- case PIECE_TYPE.CAVE:
- pieceValue = (int)PIECE_TYPE.DIAMOND;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.DIAMOND]*bonusMultiplier;
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.CAVE]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.CAVE]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- sprite.Play("Diamond");
- break;
- case PIECE_TYPE.DIAMOND:
- pieceValue = (int)PIECE_TYPE.RUBY;
- scoreAmountToAdd += (int)tablaScorePerPiece[PIECE_TYPE.RUBY]*bonusMultiplier;
- // if (count>2) {
- // currentScore += (int)tablaScorePerPiece[PIECE_TYPE.DIAMOND]*count;
- // montoMonedas = ((int)tablaScorePerPiece[PIECE_TYPE.DIAMOND]*(count-2)*bonusMultiplier)/5;
- // addCoins(montoMonedas, x, y);
- // }
- sprite.Play("Ruby");
- break;
- default:
- break;
- }
- StartCoroutine(delayToShowScoreAddText(scoreAmountToAdd, x, y, bonusMultiplier));
- // currentScore += scoreAmountToAdd;
- // createScoreText(scoreAmountToAdd, x, y, bonusMultiplier);
- }
- IEnumerator delayToShowScoreAddText(int scoreAmount, int x, int y, float currentBonusMultiplier) {
- yield return new WaitForSeconds(0.5f + currentBonusMultiplier*0.05f);
- currentScore += scoreAmount;
- createScoreText(scoreAmount, x, y, currentBonusMultiplier, true);
- }
- // struct TxtObject {
- // public GameObject txtGameObject;
- // }
- // private List<GameObject> listScoreAddedText = new List<GameObject>();
- public void createScoreText(int amountScore, int x, int y, float chainNumber, bool fromMultiCollapse) {
- if (amountScore == 0) {
- return;
- }
- Vector3 posIni = gameGridSprites[y*6+x].transform.position;// + Vector3.up*-altoEnTransformUnitsSquareSprite/2f
- //+ Vector3.right*anchoEnTransformUnitsSquareSprite/2f + Vector3.forward*-10f;
- posIni.Set(posIni.x + anchoEnTransformUnitsSquareSprite/2f, posIni.y - altoEnTransformUnitsSquareSprite/2f, 1f);
- // TxtObject paramsObject = new TxtObject();
- GameObject txtObject = Instantiate(this.txtAddScorePrefab, posIni, Quaternion.identity) as GameObject;
- float extraScale = 0f;
- if (fromMultiCollapse) {
- extraScale = 0.1f;
- }
- txtObject.transform.localScale = new Vector3(0.4f + 0.07f*chainNumber + extraScale, 0.4f + 0.07f*chainNumber + extraScale, 1f);
- tk2dTextMesh texto = txtObject.GetComponent<tk2dTextMesh>();
- if (amountScore < 0) {
- texto.color = Color.red;
- texto.color2 = new Color(1f, 0.2f, 0.2f, 1f);
- } else {
- texto.text = "+";
- }
- texto.text += amountScore;
- texto.Commit();
- DestroyTextAfterTime scriptDestruyeTexto = txtObject.GetComponent<DestroyTextAfterTime>();
- iTween.MoveTo(txtObject,
- iTween.Hash(
- "position", posIni+Vector3.up*(15f+chainNumber*3),
- "delay", DELAY_TO_COLLAPSE*chainNumber/1.5f,
- "time", scriptDestruyeTexto.timeToLive,
- "easetype", iTween.EaseType.spring
- ));
- }
- public void createBanishText(string textToShow, Vector3 posIni, float zeta, float extraScale, float timeShowing) {
- posIni.z = zeta;
- GameObject txtObject = Instantiate(this.txtAddScorePrefab, posIni, Quaternion.identity) as GameObject;
- txtObject.transform.localScale = new Vector3(0.4f + extraScale, 0.4f + extraScale, 1f);
- tk2dTextMesh texto = txtObject.GetComponent<tk2dTextMesh>();
- texto.maxChars = textToShow.Length;
- texto.text = textToShow;
- texto.Commit();
- DestroyTextAfterTime scriptDestruyeTexto = txtObject.GetComponent<DestroyTextAfterTime>();
- scriptDestruyeTexto.timeToLive = timeShowing;
- scriptDestruyeTexto.banishTotalTime = 0.5f;
- iTween.MoveTo(txtObject,
- iTween.Hash(
- "position", posIni+Vector3.up*(5f),
- "delay", 0f,
- "time", scriptDestruyeTexto.timeToLive,
- "easetype", iTween.EaseType.spring
- ));
- }
- public void onWaitForClick()
- {
- alreadyMovedAliens = false;
- if (Input.GetMouseButtonDown(0))
- {
- if (clickOnGrid())
- {
- updateSelectorPosition(touchX, touchY);
- if (touchX == 0 && touchY == (int)GAME_PROPERTIES.rowLength - 1) { //click en wildcard
- swapWildCardAndNextPiece();
- } else {
- if(piecesClick.ContainsKey((PIECE_TYPE)nextPiece))
- {
- piecesClick[(PIECE_TYPE)nextPiece](firstClick?1:2);
- }
- else
- {
- onPieceClickDefault(firstClick?1:2);
- }
- }
- }
- }
- if (animateNeigbors) {
- this.animateNeighbors();
- }
- }
- public void onWaitEndOfAnimation(){
- //just wait
- if (animateNeigbors) {
- this.animateNeighbors();
- }
- }
- public void onBuyScreen() {//hecho solo por si hay que agregar algo mientras se compra
- }
- public void onPause() {
- }
- private int gameOverCounter = 0;
- private float countTime = 0f;
- private readonly float DELAY_BETWEEN_COINS_IN_GAMEOVER = 0.5f;
- public void onGameOver() {
- enableOrDisableUFOGuiButtons(false);
- countTime += Time.deltaTime;
- if (countTime >= DELAY_BETWEEN_COINS_IN_GAMEOVER) {
- countTime = 0f;
- if (gameOverCounter < 6*6) {
- int currentCheckingX = gameOverCounter%6;
- int currentCheckingY = gameOverCounter/6;
- if (currentCheckingX == 0 && currentCheckingY == (int)GAME_PROPERTIES.rowLength - 1) {
- gameOverCounter++;
- countTime = DELAY_BETWEEN_COINS_IN_GAMEOVER;
- return;
- } else {
- int amountToAdd = ((int)tablaScorePerPiece[(PIECE_TYPE)gameGrid[currentCheckingX,currentCheckingY]])/5;
- if (amountToAdd > 0) {
- addCoins(amountToAdd, currentCheckingX, currentCheckingY);
- } else {
- gameOverCounter++;
- countTime = DELAY_BETWEEN_COINS_IN_GAMEOVER;
- return;
- }
- }
- gameOverCounter++;
- }
- if (gameOverCounter >= 6*6 && !gameOver) {
- gameOver = true;
- gameOverCounter = 0;
- countTime = 0;
- openPauseScreen();
- }
- }
- // if (!doingGameOver) {
- // doingGameOver = true;
- //
- // for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- // for (int j = 0; j < (int)GAME_PROPERTIES.rowLength; j++) {
- // if (i == 0 && j == (int)GAME_PROPERTIES.rowLength - 1) {
- // continue;
- // }
- // addCoins(((int)tablaScorePerPiece[(PIECE_TYPE)gameGrid[i,j]])/5, i, j);
- // }
- // }
- // }
- }
- public void populate(int max, int pieceToFill, int pieceToReplace)
- {
- int index = 0;
- int counter = 0;
- int rowL = (int)GAME_PROPERTIES.rowLength;
- int columnL = (int)GAME_PROPERTIES.columnLength;
- while(counter<max)
- {
- for(index = 0 ; index < (rowL*columnL) ; index++)
- {
- if(counter >= max)
- break;
- int x = index%6;
- int y = index/6;
- if(x>rowL-1)
- {
- x=rowL-1;
- }
- if(y>columnL-1)
- {
- y=columnL-1;
- }
- if(gameGrid[y,x] == pieceToReplace)
- {
- int res = Random.Range(0,6+1);
- if(res == 0)
- {
- gameGrid[y,x] = pieceToFill;
- counter++;
- }
- }
- }
- }
- }
- //Replace no used values with road values
- public void replaceNotUsed()
- {
- for(int i = 0;i < (int)GAME_PROPERTIES.rowLength; i++)
- {
- for(int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++)
- {
- if(gameGrid[i,j] == (int)PIECE_TYPE.NOT_USED)
- {
- gameGrid[i,j] = (int)PIECE_TYPE.ROAD;
- }
- }
- }
- }
- //Swap the "next piece" with the one saved at the support, graphicGrid[0,5]
- public void swapWildCardAndNextPiece()
- {
- int Temp = (int)PIECE_TYPE.NOT_USED;
- // changeSelectorAnimationColor(SELECTOR_COLOR_NORMAL);
- changeSelectorAnimation(true);
- // STATE = Estados.WAITING_FOR_CLICK;
- if(wildCard != nextPiece)
- {
- if((wildCard != -1) && (wildCard != (int)PIECE_TYPE.ROAD))
- {
- Temp = wildCard;
- wildCard = nextPiece;
- nextPiece = Temp;
- selectorNextPiece.Play((string)tablaAllAnimations[nextPiece]);
- if (nextPiece == (int)PIECE_TYPE.BUSH || nextPiece == (int)PIECE_TYPE.ROCK) {
- ufoNextPiece.transform.position = ufoNextPieceOriginPos + Vector3.up*5f;
- } else {
- ufoNextPiece.transform.position = ufoNextPieceOriginPos;
- }
- }else
- {
- wildCard = nextPiece;
- getNextPiece();
- if (isGameOver()) {
- STATE = Estados.GAME_OVER;
- }
- }
- animateNeigbors = false;
- resetPositionsOfAnimatedNeighbors();
- //
- wildCardStoragePiece.Play((string)tablaAllAnimations[wildCard]);
- ufoNextPiece.Play(ufoNextPiece.GetClipIdByName((string)tablaAllAnimations[nextPiece]));//.spriteId = ufoNextPiece.collection.GetSpriteIdByName((string)tablaAllAnimations[nextPiece]);
- }
- }
- //Randomize the int value of the nextPiece and loads the respective graphic
- public static readonly int PLAYS_TO_ADD_GREENALIENS = 15;
- public static readonly int MAX_TIMES_ADDING_GREENALIENS = 7;
- public static readonly int PLAYS_TO_ADD_PURPLEALIENS = 30;
- public static readonly int MAX_TIMES_ADDING_PURPLEALIENS = 5;
- public static readonly int PLAYS_TO_ADD_RUCAS = 45;
- public static readonly int MAX_TIMES_ADD_RUCAS = 4;
- public static readonly int PLAYS_TO_ADD_PURPLE_CRISTAL = 40;
- public static readonly int MAX_TIMES_ADD_PURPLE_CRISTAL = 2;
- public static readonly int PLAYS_TO_ADD_GREEN_CRISTAL = 50;
- public static readonly int MAX_TIMES_ADD_GREEN_CRISTAL = 3;
- public void getNextPiece()
- {
- //TUtils.trace("### Changing Next piece ###");
- // if(!boughtPiece) {
- //nextPiece = (int)PIECE_TYPE.BUSH;
- // nextPiece = (int)PIECE_TYPE.RUCA;
- numberOfPlays++;
- if (numberOfPlays%PLAYS_TO_ADD_GREENALIENS == 0 && numberOfPlays <= PLAYS_TO_ADD_GREENALIENS*MAX_TIMES_ADDING_GREENALIENS) {
- addPiecesToChanceList(1, PIECE_TYPE.ALIEN_BASIC);
- Debug.Log("Added 1 alien verdes");
- }
- if (numberOfPlays%PLAYS_TO_ADD_PURPLEALIENS == 0 && numberOfPlays <= PLAYS_TO_ADD_PURPLEALIENS*MAX_TIMES_ADDING_PURPLEALIENS) {
- addPiecesToChanceList(2, PIECE_TYPE.ALIEN_TELEPORTER);
- addPiecesToChanceList(1, PIECE_TYPE.BLACK_HOLE);
- addPiecesToChanceList(1, PIECE_TYPE.MAGIC_CRISTAL_GREEN);
- Debug.Log("Added 2 aliens purple");
- Debug.Log("Added 1 blackhole");
- Debug.Log("Added 1 green crystal");
- }
- if (numberOfPlays%PLAYS_TO_ADD_RUCAS == 0 && numberOfPlays <= PLAYS_TO_ADD_RUCAS*MAX_TIMES_ADD_RUCAS) {
- addPiecesToChanceList(1, PIECE_TYPE.RUCA);
- Debug.Log("Added 1 ruca");
- Debug.Log("Added 1 cristal purple");
- }
- if (numberOfPlays%PLAYS_TO_ADD_PURPLE_CRISTAL == 0 && numberOfPlays <= PLAYS_TO_ADD_PURPLE_CRISTAL*MAX_TIMES_ADD_PURPLE_CRISTAL) {
- addPiecesToChanceList(1, PIECE_TYPE.MAGIC_CRISTAL_PURPLE);
- Debug.Log("Added 1 cristal purple");
- }
- if (numberOfPlays%PLAYS_TO_ADD_GREEN_CRISTAL == 0 && numberOfPlays <= PLAYS_TO_ADD_GREEN_CRISTAL*MAX_TIMES_ADD_GREEN_CRISTAL) {
- addPiecesToChanceList(1, PIECE_TYPE.MAGIC_CRISTAL_GREEN);
- Debug.Log("Added 1 cristal green");
- }
- nextPiece = (int)this.pieceChance[Random.Range(0, pieceChance.Count)];
- // } else {
- // boughtPiece = false;
- // nextPiece = pieceBought;
- // pieceBought = -1;
- //// }
- showNextPieceInSelectorAndGui(nextPiece);
- }
- public void checkForChancesOnLoadSavedGame() {
- if (numberOfPlays >= PLAYS_TO_ADD_GREENALIENS && numberOfPlays <= PLAYS_TO_ADD_GREENALIENS*MAX_TIMES_ADDING_GREENALIENS) {
- addPiecesToChanceList(numberOfPlays/PLAYS_TO_ADD_GREENALIENS, PIECE_TYPE.ALIEN_BASIC);
- Debug.Log("Added " + numberOfPlays/PLAYS_TO_ADD_GREENALIENS + " aliens verdes");
- }
- if (numberOfPlays >= PLAYS_TO_ADD_PURPLEALIENS && numberOfPlays <= PLAYS_TO_ADD_PURPLEALIENS*MAX_TIMES_ADDING_PURPLEALIENS) {
- addPiecesToChanceList(2*(numberOfPlays/PLAYS_TO_ADD_PURPLEALIENS), PIECE_TYPE.ALIEN_TELEPORTER);
- addPiecesToChanceList(numberOfPlays/PLAYS_TO_ADD_PURPLEALIENS, PIECE_TYPE.BLACK_HOLE);
- Debug.Log("Added " + 2*(numberOfPlays/PLAYS_TO_ADD_PURPLEALIENS) + " aliens purpuras");
- Debug.Log("Added " + numberOfPlays/PLAYS_TO_ADD_PURPLEALIENS + " blackholes");
- }
- if (numberOfPlays >= PLAYS_TO_ADD_RUCAS && numberOfPlays <= PLAYS_TO_ADD_RUCAS*MAX_TIMES_ADD_RUCAS) {
- addPiecesToChanceList(numberOfPlays/PLAYS_TO_ADD_RUCAS, PIECE_TYPE.RUCA);
- Debug.Log("Added " + numberOfPlays/PLAYS_TO_ADD_RUCAS + " rucas");
- }
- if (numberOfPlays >= PLAYS_TO_ADD_PURPLE_CRISTAL && numberOfPlays <= PLAYS_TO_ADD_PURPLE_CRISTAL*MAX_TIMES_ADD_PURPLE_CRISTAL) {
- addPiecesToChanceList(numberOfPlays/PLAYS_TO_ADD_PURPLE_CRISTAL, PIECE_TYPE.MAGIC_CRISTAL_PURPLE);
- Debug.Log("Added " + numberOfPlays/PLAYS_TO_ADD_PURPLE_CRISTAL + " cristal purple");
- }
- if (numberOfPlays >= PLAYS_TO_ADD_GREEN_CRISTAL && numberOfPlays <= PLAYS_TO_ADD_GREEN_CRISTAL*MAX_TIMES_ADD_GREEN_CRISTAL) {
- addPiecesToChanceList(numberOfPlays/PLAYS_TO_ADD_GREEN_CRISTAL, PIECE_TYPE.MAGIC_CRISTAL_GREEN);
- Debug.Log("Added " + numberOfPlays/PLAYS_TO_ADD_GREEN_CRISTAL + " cristal green");
- }
- }
- // public void nextPieceCheat()
- // {
- // if(pieceBought != -1)
- // {
- // boughtPiece = true;
- // }
- //
- // if(!boughtPiece)
- // {
- // nextPiece = cheatChance[Random.Range(0, cheatChance.Length)];
- // }else
- // {
- // boughtPiece = false;
- // nextPiece = pieceBought;
- // pieceBought = -1;
- // }
- //
- //// if(discMenu != null)
- //// {
- //// discMenu.updateCurrentPiece(nextPiece);
- //// }else
- //// {
- //// createDiscMenu();
- //// }
- // selectorNextPiece.Play((string)tablaAllAnimations[nextPiece]);
- //
- // }
- private void cleanVarsFromShop() {
- firstClick = true;
- turnOnOffHighLightGrid(false);
- neighborsList.Clear();
- }
- public void buyBush() {
- nextPiece = (int)PIECE_TYPE.BUSH;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.BUSH];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- onPieceClickDefault(1);
- }
- public void buyTree() {
- nextPiece = (int)PIECE_TYPE.TREE;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.TREE];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- onPieceClickDefault(1);
- }
- public void buyRuca() {
- nextPiece = (int)PIECE_TYPE.RUCA;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.RUCA];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- onPieceClickDefault(1);
- }
- public void buyGreenGem() {
- nextPiece = (int)PIECE_TYPE.MAGIC_CRISTAL_GREEN;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.MAGIC_CRISTAL_GREEN];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- onMagicCrystalGreenClick(1);
- }
- public void buyPurpleGem() {
- nextPiece = (int)PIECE_TYPE.MAGIC_CRISTAL_PURPLE;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.MAGIC_CRISTAL_PURPLE];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- onMagicCrystalPurpleClick(1);
- }
- public void buyBlackHole() {
- nextPiece = (int)PIECE_TYPE.BLACK_HOLE;
- currentGold -= (int)tablaBuyForCoinsValue[PIECE_TYPE.BLACK_HOLE];
- showNextPieceInSelectorAndGui(nextPiece);
- closeShopWindow();
- cleanVarsFromShop();
- this.onBlackHoleClick(1);
- }
- //Replace the graphic at graphicGrid[x,y], Temp function, probably
- public void replaceGraphicGridAt(int x, int y)
- {
- int index = y*6+x;
- string piece = "";
- if (!upgradedGraphic) {
- piece = (string)tablaAllAnimations[gameGrid[x,y]];
- gamePiecesAnimations[index].Play(piece);
- }
- // if(score != 0)
- // {
- // //showScoreText(x, y, score);
- // if((!initializing) && (score>0))
- // {
- // if(!upgradedGraphic)
- // {
- // //playFX(PLACE_PIECE, 1);
- // }else
- // {
- // //playFX(MATCH, 1);
- // }
- // }
- // }
- // if((gameGrid[x,y] == (int)PIECE_TYPE.RUCA) || (gameGrid[x,y] == (int)PIECE_TYPE.HOME) || (gameGrid[x,y] == (int)PIECE_TYPE.CASTLE) || (gameGrid[x,y] == (int)PIECE_TYPE.BUILDING)
- // || (gameGrid[x,y] == (int)PIECE_TYPE.FUTURE_HOME) || (gameGrid[x,y] == (int)PIECE_TYPE.FUTURE_HOME_HOVERING) || (gameGrid[x,y] == (int)PIECE_TYPE.CAVE))
- // {
- // addVillager(x, y, gameGrid[x,y]);
- // }
- }
- //What the fucking name of the fucking function says, and fuck you spell check, "fucking" is perfectly spelled.
- public void updateBackgroundGraphics()
- {
- for(int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++)
- {
- for(int j = (int)GAME_PROPERTIES.columnLength-1; j > -1; j--)
- {
- //Debug.Log("x: " + i + " y: " + j + " valor: " + gameGrid[i,j]);
- if((gameGrid[i,j] == (int)PIECE_TYPE.ROAD) || (gameGrid[i,j] == (int)PIECE_TYPE.ALIEN_BASIC) || (gameGrid[i,j] == (int)PIECE_TYPE.ALIEN_TELEPORTER))
- {
- updateBackgroundGridAt(i, j);
- }else
- {
- replaceBackgroundGraphicGridAt(i, j, (int)BG_TYPE.GRASS);
- }
- }
- }
- }
- public int checkRoadAt(int x, int y)
- {
- if((x>=0)&&(x<=(int)GAME_PROPERTIES.rowLength-1))
- {
- if((y>=0)&&(y<=(int)GAME_PROPERTIES.columnLength-1))
- {
- if((x==0)&&(y==(int)GAME_PROPERTIES.columnLength-1))
- {
- return 1;
- }else
- {
- if((gameGrid[x,y] == (int)PIECE_TYPE.ROAD) || (gameGrid[x,y] == (int)PIECE_TYPE.ALIEN_BASIC) || (gameGrid[x,y] == (int)PIECE_TYPE.ALIEN_TELEPORTER))
- {
- return 0;
- }else
- {
- return 1;
- }
- }
- }else
- {
- return 1;
- }
- }else
- {
- return 1;
- }
- }
- public void updateBackgroundGridAroundAt(int x, int y)
- {
- if(checkRoadAt(x+1, y+1) == 0)
- {
- updateBackgroundGridAt(x+1, y+1);
- }
- if(checkRoadAt(x, y+1) == 0)
- {
- updateBackgroundGridAt(x, y+1);
- }
- if(checkRoadAt(x-1, y+1) == 0)
- {
- updateBackgroundGridAt(x-1, y+1);
- }
- if(checkRoadAt(x-1, y) == 0)
- {
- updateBackgroundGridAt(x-1, y);
- }
- if(checkRoadAt(x-1, y-1) == 0)
- {
- updateBackgroundGridAt(x-1, y-1);
- }
- if(checkRoadAt(x, y-1) == 0)
- {
- updateBackgroundGridAt(x, y-1);
- }
- if(checkRoadAt(x+1, y-1) == 0)
- {
- updateBackgroundGridAt(x+1, y-1);
- }
- if(checkRoadAt(x+1, y) == 0)
- {
- updateBackgroundGridAt(x+1, y);
- }
- }
- // public void updateBackgroundGrid()
- // {
- // for(int i=0; i<(int)GAME_PROPERTIES.rowLength; i++)
- // {
- // for(int j=(int)GAME_PROPERTIES.columnLength-1; j>-1; j--)
- // {
- // if(usedGrid[i,j] == true)
- // {
- // if(checkRoadAt(i+1, j+1) == 0)
- // {
- // updateBackgroundGridAt(i+1, j+1);
- // }
- // if(checkRoadAt(i, j+1) == 0)
- // {
- // updateBackgroundGridAt(i, j+1);
- // }
- // if(checkRoadAt(i-1, j+1) == 0)
- // {
- // updateBackgroundGridAt(i-1, j+1);
- // }
- // if(checkRoadAt(i-1, j) == 0)
- // {
- // updateBackgroundGridAt(i-1, j);
- // }
- // if(checkRoadAt(i-1, j-1) == 0)
- // {
- // updateBackgroundGridAt(i-1, j-1);
- // }
- // if(checkRoadAt(i, j-1) == 0)
- // {
- // updateBackgroundGridAt(i, j-1);
- // }
- // if(checkRoadAt(i+1, j-1) == 0)
- // {
- // updateBackgroundGridAt(i+1, j-1);
- // }
- // if(checkRoadAt(i+1, j) == 0)
- // {
- // updateBackgroundGridAt(i+1, j);
- // }
- // }
- // else if((i==prevClickX) && (j==prevClickY))
- // {
- // replaceBackgroundGraphicGridAt(i, j, (int)BG_TYPE.GRASS);
- // }
- // }
- // }
- // }
- public void updateBackgroundGridAt(int x, int y)
- {
- if((gameGrid[x,y] != (int)PIECE_TYPE.ROAD) && (gameGrid[x,y] != (int)PIECE_TYPE.ALIEN_BASIC) && (gameGrid[x,y] != (int)PIECE_TYPE.ALIEN_TELEPORTER))
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.GRASS);
- } else {
- int valor = 0;
- //Check North
- valor |= checkRoadAt(x, y+1) << 1;
- //Check West
- valor |= checkRoadAt(x-1, y) << 3;
- //Check South
- valor |= checkRoadAt(x, y-1) << 5;
- //Check East
- valor |= checkRoadAt(x+1, y) << 7;
- if(valor == 170)
- {
- replaceBackgroundGraphicGridAt(x, y, backgroundGraphic.Length-1);
- }else if(valor == 42)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_LEFT_DOWN);
- }else if(valor == 138)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_LEFT_RIGHT);
- }else if(valor == 162)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_DOWN_RIGHT);
- }else if(valor == 168)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_DOWN_RIGHT);
- }else if(valor == 34)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.HORIZONTAL_GRASS);
- }else if(valor == 136)
- {
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.VERTICAL_GRASS);
- }else
- {
- //Check NorthEast
- valor |= checkRoadAt(x+1, y+1) << 0;
- //Check NorthWest
- valor |= checkRoadAt(x-1, y+1) << 2;
- //Check SouthWest
- valor |= checkRoadAt(x-1, y-1) << 4;
- //Check SouthEast
- valor |= checkRoadAt(x+1, y-1) << 6;
- switch(valor)
- {
- case 0:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.ROAD);
- break;
- case 1:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1);
- break;
- case 4:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_2);
- break;
- case 5:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_2);
- break;
- case 16:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_3);
- break;
- case 17:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_3);
- break;
- case 20:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_2_3);
- break;
- case 21:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_2_3);
- break;
- case 64:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_4);
- break;
- case 65:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_4);
- break;
- case 68:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_2_4);
- break;
- case 69:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_2_4);
- break;
- case 80:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_3_4);
- break;
- case 81:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_3_4);
- break;
- case 84:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_2_3_4);
- break;
- case 85:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.CORNER_1_2_3_4);
- break;
- default:
- int range = this.BGRange(valor);
- switch(range)
- {
- case 1:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_LEFT);
- break;
- case 2:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_DOWN);
- break;
- case 3:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_RIGHT);
- break;
- case 4:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN_RIGHT);
- break;
- case 5:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_LEFT_CORNER_4);
- break;
- case 6:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_DOWN_CORNER_1);
- break;
- case 7:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN_RIGHT_CORNER_2);
- break;
- case 8:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_RIGHT_CORNER_3);
- break;
- case 9:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP);
- break;
- case 10:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_CORNER_3);
- break;
- case 11:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_CORNER_4);
- break;
- case 12:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.TOP_CORNER_3_4);
- break;
- case 13:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT);
- break;
- case 14:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_CORNER_1);
- break;
- case 15:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_CORNER_4);
- break;
- case 16:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.LEFT_CORNER_1_4);
- break;
- case 17:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN);
- break;
- case 18:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN_CORNER_1);
- break;
- case 19:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN_CORNER_2);
- break;
- case 20:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.DOWN_CORNER_1_2);
- break;
- case 21:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.RIGHT);
- break;
- case 22:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.RIGHT_CORNER_2);
- break;
- case 23:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.RIGHT_CORNER_3);
- break;
- case 24:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.RIGHT_CORNER_2_3);
- break;
- default:
- replaceBackgroundGraphicGridAt(x, y, (int)BG_TYPE.ROAD);
- break;
- }
- break;
- }
- }
- }
- }
- public void replaceBackgroundGraphicGridAt(int x, int y, int backGroundToLoad)
- {
- int index = y*6+x;
- gameGridSprites[index].spriteId = gameGridSprites[index].collection.GetSpriteIdByName(backgroundGraphic[backGroundToLoad]);
- }
- public void getNeighBorsListAt(ref List<int> list,int originX,int originY,int x,int y, PIECE_TYPE pieceType)
- {
- if(pieceType == PIECE_TYPE.RUBY || pieceType == PIECE_TYPE.FUTURE_CITY) {
- return;
- }
- int index = y*6 + x;
- if((x==originX) && (y==originY))
- {
- }
- else
- {
- if(gameGrid[x,y]==(int)pieceType && !list.Contains(index))
- {
- list.Add(index);
- }
- else
- {
- return;
- }
- }
- //Searching north
- if(y < (int)GAME_PROPERTIES.columnLength - 1)
- {
- getNeighBorsListAt(ref list,originX,originY,x, y + 1, pieceType);
- }
- //Search West
- if(x > 0)
- {
- getNeighBorsListAt(ref list,originX,originY,x - 1, y, pieceType);
- }
- //Search south
- if(y > 0)
- {
- getNeighBorsListAt(ref list,originX,originY,x, y - 1, pieceType);
- }
- //Search East
- if(x < (int)GAME_PROPERTIES.rowLength - 1)
- {
- getNeighBorsListAt(ref list,originX,originY, x + 1, y, pieceType);
- }
- }
- //Animate neighbors on the Y axis 10px Up and back, after being identified.
- public void animateNeighbors()
- {
- angleRadians += (Mathf.PI/9f);
- angleRadians = angleRadians%(2f*Mathf.PI);
- foreach (int index in neighborsList) {
- gamePiecesAnimations[index].transform.Translate(Vector3.up*Mathf.Sin(angleRadians));
- }
- }
- public void turnOnOffHighLightGrid(bool encender) {
- foreach (int index in neighborsList) {
- this.lightCells[index].active = encender;
- }
- }
- //If animated/highlighted frames of the Grid aren't changed, reset positions
- public void resetPositionsOfAnimatedNeighbors()
- {
- Vector3 originalPos;
- if (neighborsList.Count > 0) {
- foreach (int index in neighborsList) {
- originalPos = gameGridSprites[index].transform.position;
- originalPos.Set(originalPos.x, originalPos.y, gamePiecesAnimations[5*6+0].transform.position.z);
- gamePiecesAnimations[index].transform.position = originalPos;
- }
- } else {
- for (int index = 0; index < 6*6; index++) {
- if (index == (5*6 + 1)) {
- continue;
- }
- originalPos = gameGridSprites[index].transform.position;
- originalPos.Set(originalPos.x, originalPos.y, gamePiecesAnimations[5*6+0].transform.position.z);
- gamePiecesAnimations[index].transform.position = originalPos;
- }
- }
- angleRadians = 0;
- turnOnOffHighLightGrid(false);
- }
- public void hideSelector() {
- selector.transform.Translate(Vector3.forward*10f);
- }
- public void updateSelectorPosition(int x, int y)
- {
- int index = 6*y + x;
- Vector3 newPos = gameGridSprites[index].transform.position;// - Vector3.forward * 2f;//moverlo sobre todo
- newPos.Set(newPos.x, newPos.y, 0.85f);
- selector.transform.position = newPos;
- }
- private void changeSelectorAnimationColor(Color newColor)
- {
- if (selectorAnimation.color != newColor) {
- selectorAnimation.color = newColor;
- }
- }
- private void changeSelectorAnimation(bool allowMove) {
- int idAnimation = selectorAnimation.clipId;
- if (allowMove) {
- if (idAnimation != selectorAnimation.GetClipIdByName("Selector")) {
- selectorAnimation.Play(selectorAnimation.GetClipIdByName("Selector"));
- }
- } else {
- if (idAnimation != selectorAnimation.GetClipIdByName("Selector_wrong")) {
- selectorAnimation.Play(selectorAnimation.GetClipIdByName("Selector_wrong"));
- }
- }
- }
- public void playFX(AudioSource sound)
- {
- //setFX(FX[FXpath], loopCount);
- if (!SoundController.enabledSound) {
- return;
- }
- AudioUtils.playSound(sound);
- }
- public void playFX(AudioSource sound, float delay)
- {
- //setFX(FX[FXpath], loopCount);
- if (!SoundController.enabledSound) {
- return;
- }
- AudioUtils.playSound(sound, delay);
- }
- public void playFX(List<AudioSource> soundList)
- {
- //setFX(FX[FXpath], loopCount);
- if (!SoundController.enabledSound) {
- return;
- }
- AudioUtils.playSoundFromList(soundList);
- }
- public void playFX(List<AudioSource> soundList, float delay)
- {
- //setFX(FX[FXpath], loopCount);
- if (!SoundController.enabledSound) {
- return;
- }
- AudioUtils.playSoundFromList(soundList);
- }
- public void playBGMusic()
- {
- /*
- if(gameOver)
- {
- if(Globals.soundEnabled)
- {
- TUtils.getSoundManager().setMusic("/City_of_Ages_In_game_v1_3.mp3");
- }else
- {
- TUtils.getSoundManager().stopSound();
- }
- }
- */
- }
- public void enableOrDisableUFOGuiButtons(bool shouldEnable) {
- ((tk2dButton)btnBuy.GetComponent(typeof(tk2dButton))).enabled = shouldEnable;
- btnMuteSoundScript.isSpriteClickeable = shouldEnable;
- ((tk2dButton)btnHelp.GetComponent(typeof(tk2dButton))).enabled = shouldEnable;
- ((tk2dButton)btnPause.GetComponent(typeof(tk2dButton))).enabled = shouldEnable;
- }
- public void closeShopWindow() {
- Destroy(buyScreen);
- buyScreen = null;
- enableOrDisableUFOGuiButtons(true);
- STATE = Estados.WAITING_FOR_CLICK;
- }
- public void openShopWindow() {
- enableOrDisableUFOGuiButtons(false);
- buyScreen = Instantiate(buyScreenPrefab as GameObject) as GameObject;
- buyScreen.transform.FindChild("btnCerrar").GetComponent<tk2dButton>().targetObject = this.gameObject;
- //buyScreen.transform.FindChild("btnClose").GetComponent<tk2dButton>().enabled = true;
- STATE = Estados.BUYING;
- checkForEnableShopButtons ();
- }
- private void checkForEnableShopButtons ()
- {
- tk2dSprite[] listaSprites = buyScreen.GetComponentsInChildren<tk2dSprite>(true);
- for(int i = 0; i < listaSprites.Length; i++) {
- tk2dSprite sprite = listaSprites[i];
- if (sprite.name == "bushBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.BUSH]) {
- //
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_bush");
- if (btn.enabled) {
- btn.enabled = false;
- }
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Bush");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "rucaBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.RUCA]) {
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_ruca");
- if (btn.enabled) {
- btn.enabled = false;
- }
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Ruca_1");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "treeBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.TREE]) {
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_tree");
- if (btn.enabled) {
- btn.enabled = false;
- }
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Tree");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "blackHoleBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.BLACK_HOLE]) {
- // ((tk2dAnimatedSprite)sprite).Pause();
- ((tk2dAnimatedSprite)sprite).playAutomatically = false;
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_blackhole");
- if (btn.enabled) {
- btn.enabled = false;
- }
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Black_Hole_A/20");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "greenGemBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.MAGIC_CRISTAL_GREEN]) {
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_crystals");
- if (btn.enabled) {
- btn.enabled = false;
- }
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Magic_Cristal_Green2");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "purpleGemBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- if (currentGold < (int)tablaBuyForCoinsValue[PIECE_TYPE.MAGIC_CRISTAL_PURPLE]) {
- sprite.spriteId = sprite.GetSpriteIdByName("disabled_crystals");
- if (btn.enabled) {
- btn.enabled = false;
- }
- btn.enabled = false;
- } else {
- sprite.spriteId = sprite.GetSpriteIdByName("Magic_Cristal_Purple2");
- if (!btn.enabled) {
- btn.enabled = true;
- }
- }
- }
- if (sprite.name == "coinBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- }
- if (sprite.name == "freecoinBuy") {
- tk2dButton btn = (tk2dButton)sprite.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- }
- }
- }
- private tk2dSprite spriteHelp = null;
- private tk2dSprite btnHelpBack = null;
- private tk2dSprite btnHelpNext = null;
- public void openHelpWindow() {
- enableOrDisableUFOGuiButtons(false);
- helpScreen = Instantiate(helpScreenPrefab as GameObject) as GameObject;
- spriteHelp = (tk2dSprite)helpScreen.GetComponent(typeof(tk2dSprite));
- helpScreen.transform.FindChild("btnCloseHelp").GetComponent<tk2dButton>().targetObject = this.gameObject;
- //buyScreen.transform.FindChild("btnClose").GetComponent<tk2dButton>().enabled = true;
- STATE = Estados.PAUSE;
- tk2dSprite[] listaSprites = helpScreen.GetComponentsInChildren<tk2dSprite>(true);//.GetComponents<Component>();
- for(int i = 0; i < listaSprites.Length; i++) {
- tk2dSprite sprite = listaSprites[i];
- if (sprite.name == "btnHelpBack") {
- btnHelpBack = sprite;
- tk2dButton btn = (tk2dButton)btnHelpBack.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- // btnHelpBack.spriteId = btnHelpBack.collection.GetSpriteIdByName("botons of menu/0");
- btn.enabled = false;
- }
- if (sprite.name == "btnHelpNext") {
- btnHelpNext = sprite;
- tk2dButton btn = (tk2dButton)btnHelpNext.GetComponent(typeof(tk2dButton));
- btn.targetObject = this.gameObject;
- }
- }
- }
- public void closeHelpScreen() {
- Destroy(helpScreen);
- if (coinsHelp != null) {
- Destroy(coinsHelp);
- coinsHelp = null;
- }
- helpScreen = null;
- btnHelpBack = null;
- btnHelpNext = null;
- enableOrDisableUFOGuiButtons(true);
- helpScreenNumber = 0;
- STATE = Estados.WAITING_FOR_CLICK;
- }
- public enum HELP_SCREEN {
- PIECES_COMBINATIONS
- , ALIENS
- , GEMS
- , COINS
- }
- HELP_SCREEN screenToShow;
- public int helpScreenNumber = 0;
- public void backHelpScreen() {
- if (helpScreenNumber > 0) {
- helpScreenNumber--;
- screenToShow = (HELP_SCREEN)helpScreenNumber;
- changeHelpScreen(screenToShow);
- }
- }
- public void nextHelpScreen() {
- if (helpScreenNumber < (int)HELP_SCREEN.COINS) {
- helpScreenNumber++;
- screenToShow = (HELP_SCREEN)helpScreenNumber;
- changeHelpScreen(screenToShow);
- }
- }
- public GameObject coinsPivotPrefab;
- private GameObject coinsHelp = null;
- public void changeHelpScreen(HELP_SCREEN screenToShow) {
- tk2dButton btnBack = (tk2dButton)btnHelpBack.GetComponent(typeof(tk2dButton));
- tk2dButton btnNext = (tk2dButton)btnHelpNext.GetComponent(typeof(tk2dButton));
- if (screenToShow!= HELP_SCREEN.COINS && coinsHelp != null) {
- Destroy(coinsHelp);
- coinsHelp = null;
- }
- switch(screenToShow) {
- case HELP_SCREEN.PIECES_COMBINATIONS:
- btnBack.enabled = false;
- // btnHelpBack.spriteId = btnHelpBack.collection.GetSpriteIdByName("botons of menu/0");
- spriteHelp.spriteId = spriteHelp.collection.GetSpriteIdByName("townPiecesCombinations");
- break;
- case HELP_SCREEN.ALIENS:
- if (!btnBack.enabled) {
- btnBack.enabled = true;
- }
- if (!btnNext.enabled) {
- btnNext.enabled = true;
- }
- spriteHelp.spriteId = spriteHelp.collection.GetSpriteIdByName("TutorialsBG");
- break;
- case HELP_SCREEN.GEMS:
- if (!btnBack.enabled) {
- btnBack.enabled = true;
- }
- if (!btnNext.enabled) {
- btnNext.enabled = true;
- }
- spriteHelp.spriteId = spriteHelp.collection.GetSpriteIdByName("TutorialsBG2");
- break;
- case HELP_SCREEN.COINS:
- btnNext.enabled = false;
- // btnHelpNext.spriteId = btnHelpNext.collection.GetSpriteIdByName("botons of menu/0");
- spriteHelp.spriteId = spriteHelp.collection.GetSpriteIdByName("TutorialsBG3");
- coinsHelp = Instantiate(coinsPivotPrefab) as GameObject;
- tk2dTextMesh txtSilver = coinsHelp.transform.Find("txtSilver").GetComponent<tk2dTextMesh>();
- txtSilver.text = " = " + SILVER_COIN_VALUE + " COINS";
- txtSilver.Commit();
- break;
- default:
- break;
- }
- }
- public void closePauseScreen() {
- Destroy(pauseScreen);
- pauseScreen = null;
- enableOrDisableUFOGuiButtons(true);
- STATE = Estados.WAITING_FOR_CLICK;
- }
- public void openPauseScreen() {
- enableOrDisableUFOGuiButtons(false);
- pauseScreen = Instantiate(pauseScreenPrefab as GameObject) as GameObject;
- GameObject SubGameChangeScreen = pauseScreen.transform.FindChild("GameChangeScreen").gameObject;
- //pauseScreen.transform.FindChild("btnPauseBack").GetComponent<tk2dButton>().targetObject = this.gameObject;
- if (!gameOver) {
- SubGameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dButton>().targetObject = this.gameObject;
- SubGameChangeScreen.transform.FindChild("btnFB/FBborder").gameObject.active = false;
- SubGameChangeScreen.transform.FindChild("btnFB").gameObject.active = false;
- }
- SubGameChangeScreen.transform.FindChild("btnGameRetry").GetComponent<tk2dButton>().targetObject = this.gameObject;
- SubGameChangeScreen.transform.FindChild("btnSaveGame").GetComponent<tk2dButton>().targetObject = this.gameObject;
- if (gameOver) {
- txtGameOver.gameObject.active = true;
- txtGameOver.transform.FindChild("frameGameOver").gameObject.active = true;
- // SubGameChangeScreen.transform.position += Vector3.up*-20f;
- // SubGameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dButton>().enabled = false;
- // SubGameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dSprite>().spriteId =
- // SubGameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dSprite>().collection.GetSpriteIdByName("botons of menu/0");
- tk2dTextMesh txtExit = SubGameChangeScreen.transform.FindChild("btnSaveGame/TextMesh").GetComponent<tk2dTextMesh>();
- txtExit.text = "Exit";
- txtExit.Commit();
- SubGameChangeScreen.transform.FindChild("btnSaveGame/barra/Sprite0").GetComponent<tk2dSprite>().spriteId =
- SubGameChangeScreen.transform.FindChild("btnSaveGame/barra/Sprite0").GetComponent<tk2dSprite>().collection.GetSpriteIdByName("navegation_indexes/3");
- SubGameChangeScreen.transform.FindChild("btnGameResume/Sprite0").gameObject.active = false;
- SubGameChangeScreen.transform.FindChild("btnGameResume").gameObject.active = false;
- GameObject go = SubGameChangeScreen.transform.Find("btnGameResume/barra/txtResume").gameObject;
- tk2dTextMesh txtMesh = go.GetComponent<tk2dTextMesh>();
- txtMesh.gameObject.transform.localScale = new Vector3(0.44f, 1f, 1f);
- txtMesh.text = "SHARE SCORE";
- txtMesh.maxChars = txtMesh.text.Length;
- txtMesh.Commit();
- GameObject btnFB = SubGameChangeScreen.transform.FindChild("btnFB").gameObject;
- btnFB.active = true;
- btnFB.GetComponent<tk2dButton>().targetObject = GameObject.Find("FacebookEventListener").gameObject;
- SubGameChangeScreen.transform.Find("btnGameResume/barra").parent = btnFB.transform;
- // InitiateFontColors txtColorsToInitiate = SubGameChangeScreen.transform.Find("btnGameResume/barra/txtResume").GetComponent<InitiateFontColors>();
- // txtColorsToInitiate.color1 = new Color(0.8f, 0.8f, 0.8f, 1f);
- // txtColorsToInitiate.color2 = new Color(0.4f, 0.4f, 0.4f, 1f);
- //txtColorsToInitiate.Commit();
- pauseScreen.transform.FindChild("imgNanos").gameObject.active = false;
- pauseScreen.transform.FindChild("imgPausa").gameObject.active = false;
- // pauseScreen.active = false;
- }
- STATE = Estados.PAUSE;
- }
- // public void closeGameChangeScreen() {
- // Destroy(gameChangeScreen);
- // gameChangeScreen = null;
- // enableOrDisableUFOGuiButtons(true);
- // STATE = Estados.WAITING_FOR_CLICK;
- // }
- // public void openGameChangeScreen() {
- //
- // enableOrDisableUFOGuiButtons(false);
- // gameChangeScreen = Instantiate(gameChangeScreenPrefab as GameObject) as GameObject;
- // gameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dButton>().targetObject = this.gameObject;
- // gameChangeScreen.transform.FindChild("btnGameRetry").GetComponent<tk2dButton>().targetObject = this.gameObject;
- // gameChangeScreen.transform.FindChild("btnGameExit").GetComponent<tk2dButton>().targetObject = this.gameObject;
- // if (gameOver) {
- // txtGameOver.gameObject.active = true;
- // gameChangeScreen.transform.position += Vector3.up*-20f;
- // gameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dButton>().enabled = false;
- // gameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dSprite>().spriteId =
- // gameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dSprite>().collection.GetSpriteIdByName("botons of menu/0");
- // }
- // STATE = Estados.PAUSE;
- // }
- public void enableOrDisablePauseButtons(bool shouldEnable) {
- GameObject SubGameChangeScreen = pauseScreen.transform.FindChild("GameChangeScreen").gameObject;
- SubGameChangeScreen.transform.FindChild("btnGameResume").GetComponent<tk2dButton>().enabled = shouldEnable;
- SubGameChangeScreen.transform.FindChild("btnGameRetry").GetComponent<tk2dButton>().enabled = shouldEnable;
- SubGameChangeScreen.transform.FindChild("btnSaveGame").GetComponent<tk2dButton>().enabled = shouldEnable;
- }
- private string[] popUpDialogues = {
- "Start a NEW GAME?"
- ,"Do you want to\nsave before exit?"
- ,"Buying 15000 coins for $0.99\nAre you sure?"
- };
- private enum POP_UP_DIALOGOS {
- NEW_GAME
- ,SAVE
- ,CONFIRM_PURCHASE
- }
- public void OpenPopUpFromRetryGame() {
- if (gameOver) {
- closePauseScreen();
- txtGameOver.gameObject.active = false;
- txtGameOver.transform.FindChild("frameGameOver").gameObject.active = false;
- STATE = Estados.INITIALIZE;
- LOAD_GAME_TYPE = TipoJuego.NEW_GAME;
- } else {
- enableOrDisablePauseButtons(false);
- popUpConfirmWindow = Instantiate(popUpConfirmWindowPrefab as GameObject) as GameObject;
- popUpConfirmWindow.transform.FindChild("btnYES").GetComponent<tk2dButton>().targetObject = this.gameObject;
- popUpConfirmWindow.transform.FindChild("btnNO").GetComponent<tk2dButton>().targetObject = this.gameObject;
- popUpQuestionString = popUpDialogues[(int)POP_UP_DIALOGOS.NEW_GAME];
- txtPopUpQuestion = popUpConfirmWindow.transform.FindChild("txtConfirmQuestion").GetComponent<tk2dTextMesh>();
- txtPopUpQuestion.text = popUpQuestionString;
- txtPopUpQuestion.Commit();
- }
- }
- public void OpenPopUpFromSaveGame() {
- if (gameOver) {
- goToMainMenu();
- return;
- }
- enableOrDisablePauseButtons(false);
- popUpSaveGameWindow = Instantiate(popUpSaveGameWindowPrefab as GameObject) as GameObject;
- popUpSaveGameWindow.transform.FindChild("btnSaveExit").GetComponent<tk2dButton>().targetObject = this.gameObject;
- popUpSaveGameWindow.transform.FindChild("btnSaveContinue").GetComponent<tk2dButton>().targetObject = this.gameObject;
- popUpSaveGameWindow.transform.FindChild("btnSaveCancel").GetComponent<tk2dButton>().targetObject = this.gameObject;
- //popUpQuestionString = popUpDialogues[(int)POP_UP_DIALOGOS.SAVE];
- //txtPopUpQuestion = popUpConfirmWindow.transform.FindChild("txtConfirmQuestion").GetComponent<tk2dTextMesh>();
- //txtPopUpQuestion.text = popUpQuestionString;
- //txtPopUpQuestion.Commit();
- }
- public void initPurchase() {
- //enableOrDisablePauseButtons(false);
- popUpPurchaseFeedbackWindow = Instantiate(popUpPurchaseFeedbackPrefab as GameObject) as GameObject;
- enableOrDisableBuyScreenButtons(false);
- //checkForEnableShopButtons();
- Debug.Log("init purchase clicked");
- // popUpPurchaseMessageWindow.transform.FindChild("btnOk").GetComponent<tk2dButton>().targetObject;
- }
- public void finishPurchase() {
- if (popUpPurchaseFeedbackWindow != null) {
- Destroy(popUpPurchaseFeedbackWindow);
- popUpPurchaseFeedbackWindow = null;
- enableOrDisableBuyScreenButtons(true);
- checkForEnableShopButtons();
- }
- }
- private void enableOrDisableBuyScreenButtons(bool shouldEnable) {
- if (buyScreen != null) {
- tk2dButton[] listaButtons = buyScreen.GetComponentsInChildren<tk2dButton>(true);
- for(int i = 0; i < listaButtons.Length; i++) {
- listaButtons[i].enabled = shouldEnable;
- }
- }
- }
- protected void openFreeCoinsWindow() {
- popUpFreeCoinsWindow = Instantiate(popUpFreeCoinsPrefab as GameObject) as GameObject;
- enableOrDisableBuyScreenButtons(false);
- //checkForEnableShopButtons();
- STATE = Estados.BUYING;
- }
- public void closeFreeCoinsWindow() {
- Destroy(popUpFreeCoinsWindow);
- popUpFreeCoinsWindow = null;
- enableOrDisableBuyScreenButtons(true);
- checkForEnableShopButtons();
- }
- public void popUpSaveExit() {
- saveData();
- Destroy(popUpSaveGameWindow);
- popUpSaveGameWindow = null;
- goToMainMenu();
- }
- public void popUpSaveContinue() {
- saveData();
- Destroy(popUpSaveGameWindow);
- popUpSaveGameWindow = null;
- closePauseScreen();
- }
- public void popUpSaveCancel() {
- Destroy(popUpSaveGameWindow);
- popUpSaveGameWindow = null;
- enableOrDisablePauseButtons(true);
- }
- public void closePopUpConfirm() {
- enableOrDisablePauseButtons(true);
- if (popUpQuestionString == popUpDialogues[(int)POP_UP_DIALOGOS.SAVE]) {
- goToMainMenu();
- }
- Destroy(popUpConfirmWindow);
- txtPopUpQuestion = null;
- popUpQuestionString = null;
- popUpConfirmWindow = null;
- // enableOrDisableUFOGuiButtons(true);
- }
- public void popUpYesSelected() {
- if (popUpQuestionString != null) {
- if (popUpQuestionString == popUpDialogues[(int)POP_UP_DIALOGOS.NEW_GAME]) {
- closePopUpConfirm();
- // closeGameChangeScreen();
- closePauseScreen();
- STATE = Estados.INITIALIZE;
- LOAD_GAME_TYPE = TipoJuego.NEW_GAME;
- }
- if (popUpQuestionString == popUpDialogues[(int)POP_UP_DIALOGOS.SAVE]) {
- closePopUpConfirm();
- saveData();
- // closeGameChangeScreen();
- closePauseScreen();
- goToMainMenu();
- // Destroy(this);
- }
- if (popUpQuestionString == popUpDialogues[(int)POP_UP_DIALOGOS.CONFIRM_PURCHASE]) {
- closePopUpConfirm();
- //codigo de compra aqui
- //saveData();
- // closeGameChangeScreen();
- //closePauseScreen();
- //goToMainMenu();
- // Destroy(this);
- }
- }
- }
- public void saveData()
- {
- DataGame.writeSaveGame();
- }
- public void goToMainMenu ()
- {
- MainMenu.gold = currentGold;
- MainMenu.highScore = highScore;
- Application.LoadLevel("mainMenu");
- }
- public void popUpNoSelected() {
- closePopUpConfirm();
- }
- /**
- * Unico Metodo de BG_TYPE.java
- * */
- public int BGRange(int num)
- {
- return connections[num];
- }
- public bool clickOnGrid ()
- {
- RaycastHit hitInfo;
- for (int aux = 0; aux < 6*6; aux++) {
- //if (clickReference[aux].gotHit) {
- if (gameGridSprites[aux].collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo, 1.0e8f)) {
- prevClickX = touchX;
- prevClickY = touchY;
- touchX = aux%6;
- touchY = aux/6;
- if(prevClickX==touchX && prevClickY == touchY)
- {
- firstClick = false;
- } else {
- firstClick = true;
- animateNeigbors = false;
- turnOnOffHighLightGrid(false);
- resetPositionsOfAnimatedNeighbors();
- }
- // debugTextGridClick = "x: " + touchX + " y: " + touchY + "\nValor es: " + gameGrid[touchX,touchY];
- //Debug.Log(debugTextGridClick);
- //Debug.Log("Prev. click x: " + prevClickX + " y: " + prevClickY);
- return true; //se clickeo en la grilla
- }
- }
- return false; //no se clickeo en la grilla
- }
- // private List<GameObject> listVillagers = new List<GameObject>();
- private GameObject villager;
- private List<GameObject> listAldeanos = new List<GameObject>();
- public void addVillager(Villager.TIPOS_VILLAGER tipoVillager, Vector3 posIni) {
- posIni.Set (posIni.x, posIni.y, 3f);
- villager = Instantiate(villagerPrefab, posIni, Quaternion.identity) as GameObject;
- Villager villagerScript = villager.GetComponent<Villager>();
- villagerScript.tipoVillager = tipoVillager;
- villagerScript.changeAnimation();
- villagerScript.setGameScript(this.GetComponent<Game>());
- // if (tipoVillager == Villager.TIPOS_VILLAGER.CAVERNICOLA) {
- // if (villagerScript.sex == Villager.GENERO.MALE) {
- // playFX((Instantiate(this.sndCavernicolaMPrefab) as GameObject).GetComponent<AudioSource>());
- // } else {
- // playFX((Instantiate(this.sndCavernicolaFPrefab) as GameObject).GetComponent<AudioSource>());
- // }
- // } else {
- // playFX((Instantiate(this.sndVillagerPrefab) as GameObject).GetComponent<AudioSource>());
- // }
- listAldeanos.Add(villager);
- }
- private List<List<GameObject>> listGoldCoins = new List<List<GameObject>>();
- private List<List<GameObject>> listSilverCoins = new List<List<GameObject>>();
- private List<List<GameObject>> listCopperCoins = new List<List<GameObject>>();
- public struct CoinParams {
- public List<GameObject> currentList;
- public int amountToAdd;
- public GameObject coinToDestroy;
- public bool mustRemoveCurrentList;
- }
- // private int amountGoldCoins;
- // private int amountSilverCoins;
- // private int amountCopperCoins;
- private readonly int GOLD_COIN_VALUE = 100;
- private readonly int SILVER_COIN_VALUE = 10;
- private readonly int COPPER_COIN_VALUE = 1;
- private readonly int MAX_AMOUNT_OF_COINS = 4;
- public void addCoins(int amount, int iniX, int iniY)
- {
- listCashSounds.Clear();
- listCashSounds.Add((Instantiate(this.sndCashSound1Prefab) as GameObject).GetComponent<AudioSource>());
- listCashSounds.Add((Instantiate(this.sndCashSound2Prefab) as GameObject).GetComponent<AudioSource>());
- playFX(listCashSounds);
- int amountGoldCoins = amount/GOLD_COIN_VALUE;
- int amountSilverCoins = (amount%GOLD_COIN_VALUE)/SILVER_COIN_VALUE;
- int amountCopperCoins = ((amount%GOLD_COIN_VALUE)%SILVER_COIN_VALUE)/COPPER_COIN_VALUE;
- Vector3 posIni = gameGridSprites[iniY*6+iniX].transform.position + Vector3.right*10f + Vector3.up*-10f + Vector3.forward*-5f;
- float totalGoldDelay = 0;
- if (amountGoldCoins > 0) {
- List<GameObject> listaGold = new List<GameObject>();
- listGoldCoins.Add(listaGold);
- for (int i = 1; i <= amountGoldCoins; i++) {
- listaGold.Add(Instantiate(goldCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- if (amountGoldCoins > MAX_AMOUNT_OF_COINS) {
- totalGoldDelay += (float)i/(MAX_AMOUNT_OF_COINS*4.5f);
- } else {
- totalGoldDelay += (float)i/(amountGoldCoins*4.5f);
- }
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaGold;
- coinParams.coinToDestroy = listaGold[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountGoldCoins <= MAX_AMOUNT_OF_COINS && i == amountGoldCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountGoldCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaGold[i-1].gameObject, iTween.Hash(
- "position", guiCoin.transform.position + Vector3.forward*-0.5f,
- "easetype", iTween.EaseType.easeInOutQuad,
- "time", 0.8f,
- "delay", totalGoldDelay + 0.5f,
- "oncomplete", "addGoldCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- totalGoldDelay += 0.5f;
- }
- float totalSilverDelay = 0;
- if (amountSilverCoins > 0) {
- List<GameObject> listaSilver = new List<GameObject>();
- listSilverCoins.Add(listaSilver);
- for (int i = 1; i <= amountSilverCoins; i++) {
- listaSilver.Add(Instantiate(silverCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- totalSilverDelay += (float)i/(amountSilverCoins*4.5f);
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaSilver;
- coinParams.coinToDestroy = listaSilver[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountSilverCoins <= MAX_AMOUNT_OF_COINS && i == amountSilverCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountSilverCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaSilver[i-1].gameObject, iTween.Hash(
- "position", guiCoin.transform.position + Vector3.forward*-0.5f,
- "time", 0.8f,
- "easetype", iTween.EaseType.easeInOutQuad,
- "delay", totalGoldDelay + totalSilverDelay + 0.5f,
- "oncomplete", "addSilverCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- totalSilverDelay += 0.5f;
- }
- float totalCopperDelay = 0;
- if (amountCopperCoins > 0) {
- List<GameObject> listaCopper = new List<GameObject>();
- listCopperCoins.Add(listaCopper);
- for (int i = 1; i <= amountCopperCoins; i++) {
- listaCopper.Add(Instantiate(copperCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- if (amountCopperCoins > MAX_AMOUNT_OF_COINS) {
- totalCopperDelay += (float)i/(MAX_AMOUNT_OF_COINS*4.5f);
- } else {
- totalCopperDelay += (float)i/(amountCopperCoins*4.5f);
- }
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaCopper;
- coinParams.coinToDestroy = listaCopper[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountCopperCoins <= MAX_AMOUNT_OF_COINS && i == amountCopperCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountCopperCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaCopper[i-1].gameObject, iTween.Hash(
- "position", guiCoin.transform.position + Vector3.forward*-0.5f,
- "time", 0.8f,
- "delay", totalGoldDelay + totalSilverDelay + totalCopperDelay + 0.5f,
- "easetype", iTween.EaseType.easeInOutQuad,
- "oncomplete", "addCopperCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- }
- }
- public void addCoinsFromBuyScreen(int amount, Vector3 posIni, float zeta)
- {
- listCashSounds.Clear();
- listCashSounds.Add((Instantiate(this.sndCashSound1Prefab) as GameObject).GetComponent<AudioSource>());
- listCashSounds.Add((Instantiate(this.sndCashSound2Prefab) as GameObject).GetComponent<AudioSource>());
- playFX(listCashSounds);
- posIni.Set(posIni.x, posIni.y, zeta);
- int amountGoldCoins = amount/GOLD_COIN_VALUE;
- int amountSilverCoins = (amount%GOLD_COIN_VALUE)/SILVER_COIN_VALUE;
- int amountCopperCoins = ((amount%GOLD_COIN_VALUE)%SILVER_COIN_VALUE)/COPPER_COIN_VALUE;
- //Vector3 posIni = gameGridSprites[iniY*6+iniX].transform.position + Vector3.right*10f + Vector3.up*-10f + Vector3.forward*-5f;
- float totalGoldDelay = 0;
- if (amountGoldCoins > 0) {
- List<GameObject> listaGold = new List<GameObject>();
- listGoldCoins.Add(listaGold);
- for (int i = 1; i <= amountGoldCoins; i++) {
- listaGold.Add(Instantiate(goldCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- if (amountGoldCoins > MAX_AMOUNT_OF_COINS) {
- totalGoldDelay += (float)i/(MAX_AMOUNT_OF_COINS*4.5f);
- } else {
- totalGoldDelay += (float)i/(amountGoldCoins*4.5f);
- }
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaGold;
- coinParams.coinToDestroy = listaGold[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountGoldCoins <= MAX_AMOUNT_OF_COINS && i == amountGoldCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountGoldCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaGold[i-1].gameObject, iTween.Hash(
- "position", new Vector3(guiCoin.transform.position.x, guiCoin.transform.position.y, zeta),
- "easetype", iTween.EaseType.easeInOutQuad,
- "time", 0.8f,
- "delay", totalGoldDelay + 0.5f,
- "oncomplete", "addGoldCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- totalGoldDelay += 0.5f;
- }
- float totalSilverDelay = 0;
- if (amountSilverCoins > 0) {
- List<GameObject> listaSilver = new List<GameObject>();
- listSilverCoins.Add(listaSilver);
- for (int i = 1; i <= amountSilverCoins; i++) {
- listaSilver.Add(Instantiate(silverCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- totalSilverDelay += (float)i/(amountSilverCoins*4.5f);
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaSilver;
- coinParams.coinToDestroy = listaSilver[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountSilverCoins <= MAX_AMOUNT_OF_COINS && i == amountSilverCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountSilverCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaSilver[i-1].gameObject, iTween.Hash(
- "position", new Vector3(guiCoin.transform.position.x, guiCoin.transform.position.y, zeta),
- "time", 0.8f,
- "easetype", iTween.EaseType.easeInOutQuad,
- "delay", totalGoldDelay + totalSilverDelay + 0.5f,
- "oncomplete", "addSilverCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- totalSilverDelay += 0.5f;
- }
- float totalCopperDelay = 0;
- if (amountCopperCoins > 0) {
- List<GameObject> listaCopper = new List<GameObject>();
- listCopperCoins.Add(listaCopper);
- for (int i = 1; i <= amountCopperCoins; i++) {
- listaCopper.Add(Instantiate(copperCoinPrefab as GameObject, posIni, Quaternion.identity) as GameObject);
- if (amountCopperCoins > MAX_AMOUNT_OF_COINS) {
- totalCopperDelay += (float)i/(MAX_AMOUNT_OF_COINS*4.5f);
- } else {
- totalCopperDelay += (float)i/(amountCopperCoins*4.5f);
- }
- CoinParams coinParams = new CoinParams();
- coinParams.amountToAdd = 1;
- coinParams.currentList = listaCopper;
- coinParams.coinToDestroy = listaCopper[i-1];
- coinParams.mustRemoveCurrentList = false;
- if (amountCopperCoins <= MAX_AMOUNT_OF_COINS && i == amountCopperCoins) {
- coinParams.mustRemoveCurrentList = true;
- } else {
- if (i > MAX_AMOUNT_OF_COINS) {
- coinParams.amountToAdd = amountCopperCoins - MAX_AMOUNT_OF_COINS;
- coinParams.mustRemoveCurrentList = true;
- }
- }
- iTween.MoveTo(listaCopper[i-1].gameObject, iTween.Hash(
- "position", new Vector3(guiCoin.transform.position.x, guiCoin.transform.position.y, zeta),
- "time", 0.8f,
- "delay", totalGoldDelay + totalSilverDelay + totalCopperDelay + 0.5f,
- "easetype", iTween.EaseType.easeInOutQuad,
- "oncomplete", "addCopperCoins",
- "oncompleteparams", coinParams,
- "oncompletetarget", this.gameObject
- ));
- if (i > MAX_AMOUNT_OF_COINS) {
- break;
- }
- }
- }
- }
- // private int numGoldCoins = 0;
- private void addGoldCoins(CoinParams coinParams) {
- currentGold += coinParams.amountToAdd*GOLD_COIN_VALUE;
- // numCopperCoins++;
- Destroy(coinParams.coinToDestroy);//listCopperCoins[listCopperCoins.Count - 1]);
- coinParams.currentList.Remove(coinParams.coinToDestroy);//[listCopperCoins.Count - 1]
- if (coinParams.mustRemoveCurrentList) {
- listGoldCoins.Remove(coinParams.currentList);
- }
- }
- // private int numSilverCoins = 0;
- private void addSilverCoins(CoinParams coinParams) {
- currentGold += coinParams.amountToAdd*SILVER_COIN_VALUE;
- // numSilverCoins++;
- Destroy(coinParams.coinToDestroy);//listCopperCoins[listCopperCoins.Count - 1]);
- coinParams.currentList.Remove(coinParams.coinToDestroy);//[listCopperCoins.Count - 1]
- if (coinParams.mustRemoveCurrentList) {
- listSilverCoins.Remove(coinParams.currentList);
- }
- }
- // private int numCopperCoins = 0;
- private void addCopperCoins(CoinParams coinParams) {
- currentGold += coinParams.amountToAdd*COPPER_COIN_VALUE;
- Destroy(coinParams.coinToDestroy);
- coinParams.currentList.Remove(coinParams.coinToDestroy);
- if (coinParams.mustRemoveCurrentList) {
- listCopperCoins.Remove(coinParams.currentList);
- }
- }
- private void addLastCopperCoin(CoinParams coinParams) {
- currentGold += coinParams.amountToAdd;//(int)Mathf.Abs(amountCopperCoins - numCopperCoins);
- Destroy(coinParams.coinToDestroy);//listCopperCoins[listCopperCoins.Count - 1]);
- coinParams.currentList.Remove(coinParams.coinToDestroy);
- listCopperCoins.Remove(coinParams.currentList);
- }
- private bool isGameOver() {
- if (wildCard == (int)PIECE_TYPE.BLACK_HOLE || wildCard == (int)PIECE_TYPE.MAGIC_CRISTAL_GREEN || wildCard == (int)PIECE_TYPE.ROAD
- || nextPiece == (int)PIECE_TYPE.BLACK_HOLE || nextPiece == (int)PIECE_TYPE.MAGIC_CRISTAL_GREEN) {
- return false;
- } else {
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.rowLength; j++) {
- if (i == 0 && j == (int)GAME_PROPERTIES.rowLength - 1) {
- continue;
- }
- if (gameGrid[i,j] == (int)PIECE_TYPE.ROAD) {
- return false;
- }
- }
- }
- //si llega hasta aca, gg
- return true;
- }
- }
- private void initializeMouseColliderHelper ()
- {
- for (int aux = 0; aux < 6*6; aux++) {
- if (this.gameGridSprites[aux].collider == null) {
- BoxCollider newCollider = gameGridSprites[aux].gameObject.AddComponent<BoxCollider>();
- Vector3 colliderExtents = newCollider.extents;
- colliderExtents.z = 0.2f;
- newCollider.extents = colliderExtents;
- }
- }
- }
- public void initializeArrayConnections ()
- {
- connections[10]=1;
- connections[11]=1;
- connections[14]=1;
- connections[15]=1;
- connections[26]=1;
- connections[27]=1;
- connections[30]=1;
- connections[31]=1;
- connections[40]=2;
- connections[44]=2;
- connections[56]=2;
- connections[60]=2;
- connections[104]=2;
- connections[108]=2;
- connections[120]=2;
- connections[124]=2;
- connections[130]=3;
- connections[131]=3;
- connections[134]=3;
- connections[135]=3;
- connections[194]=3;
- connections[195]=3;
- connections[198]=3;
- connections[199]=3;
- connections[160]=4;
- connections[161]=4;
- connections[176]=4;
- connections[177]=4;
- connections[224]=4;
- connections[225]=4;
- connections[240]=4;
- connections[241]=4;
- connections[74]=5;
- connections[75]=5;
- connections[78]=5;
- connections[79]=5;
- connections[90]=5;
- connections[91]=5;
- connections[94]=5;
- connections[95]=5;
- connections[41]=6;
- connections[45]=6;
- connections[57]=6;
- connections[61]=6;
- connections[105]=6;
- connections[109]=6;
- connections[121]=6;
- connections[125]=6;
- connections[164]=7;
- connections[165]=7;
- connections[180]=7;
- connections[181]=7;
- connections[228]=7;
- connections[229]=7;
- connections[244]=7;
- connections[245]=7;
- connections[146]=8;
- connections[147]=8;
- connections[150]=8;
- connections[151]=8;
- connections[210]=8;
- connections[211]=8;
- connections[214]=8;
- connections[215]=8;
- connections[2]=9;
- connections[3]=9;
- connections[6]=9;
- connections[7]=9;
- connections[18]=10;
- connections[19]=10;
- connections[22]=10;
- connections[23]=10;
- connections[66]=11;
- connections[67]=11;
- connections[70]=11;
- connections[71]=11;
- connections[82]=12;
- connections[83]=12;
- connections[86]=12;
- connections[87]=12;
- connections[8]=13;
- connections[12]=13;
- connections[24]=13;
- connections[28]=13;
- connections[9]=14;
- connections[13]=14;
- connections[25]=14;
- connections[29]=14;
- connections[72]=15;
- connections[76]=15;
- connections[88]=15;
- connections[92]=15;
- connections[73]=16;
- connections[77]=16;
- connections[89]=16;
- connections[93]=16;
- connections[32]=17;
- connections[48]=17;
- connections[96]=17;
- connections[112]=17;
- connections[33]=18;
- connections[49]=18;
- connections[97]=18;
- connections[113]=18;
- connections[36]=19;
- connections[52]=19;
- connections[100]=19;
- connections[116]=19;
- connections[37]=20;
- connections[53]=20;
- connections[101]=20;
- connections[117]=20;
- connections[128]=21;
- connections[129]=21;
- connections[192]=21;
- connections[193]=21;
- connections[132]=22;
- connections[133]=22;
- connections[196]=22;
- connections[197]=22;
- connections[144]=23;
- connections[145]=23;
- connections[208]=23;
- connections[209]=23;
- connections[148]=24;
- connections[149]=24;
- connections[212]=24;
- connections[213]=24;
- }
- public void initializeTablaAllAnimations ()
- {
- tablaAllAnimations = new Hashtable();
- tablaAllAnimations.Add((int)PIECE_TYPE.OUT_OF_BOUNDS, "OutOfBounds");
- tablaAllAnimations.Add((int)PIECE_TYPE.ROAD, "RoadT");
- tablaAllAnimations.Add((int)PIECE_TYPE.BUSH, "Bush");
- tablaAllAnimations.Add((int)PIECE_TYPE.TREE, "Tree");
- tablaAllAnimations.Add((int)PIECE_TYPE.RUCA, "Ruca_1");
- tablaAllAnimations.Add((int)PIECE_TYPE.HOME, "Home");
- tablaAllAnimations.Add((int)PIECE_TYPE.CASTLE, "Castle");
- tablaAllAnimations.Add((int)PIECE_TYPE.BUILDING, "Building");
- tablaAllAnimations.Add((int)PIECE_TYPE.FUTURE_HOME, "Future_Home_1");
- tablaAllAnimations.Add((int)PIECE_TYPE.FUTURE_HOME_HOVERING, "Future_Home_2");
- tablaAllAnimations.Add((int)PIECE_TYPE.FUTURE_CITY, "Future_City");
- tablaAllAnimations.Add((int)PIECE_TYPE.ALIEN_BASIC, "Alien_1");
- tablaAllAnimations.Add((int)PIECE_TYPE.ALIEN_TELEPORTER, "Alien_2");
- tablaAllAnimations.Add((int)PIECE_TYPE.MOAI, "Moai_Single");
- tablaAllAnimations.Add((int)PIECE_TYPE.MOAIS, "Moais_Triple");
- tablaAllAnimations.Add((int)PIECE_TYPE.STONEHENGE, "Stonehenge");
- tablaAllAnimations.Add((int)PIECE_TYPE.ROCK, "Rock");
- tablaAllAnimations.Add((int)PIECE_TYPE.CAVE, "Cave");
- tablaAllAnimations.Add((int)PIECE_TYPE.DIAMOND, "Diamond");
- tablaAllAnimations.Add((int)PIECE_TYPE.RUBY, "Ruby");
- tablaAllAnimations.Add((int)PIECE_TYPE.MAGIC_CRISTAL_PURPLE, "Magic_Cristal_Purple");
- tablaAllAnimations.Add((int)PIECE_TYPE.MAGIC_CRISTAL_GREEN, "Magic_Cristal_Green");
- tablaAllAnimations.Add((int)PIECE_TYPE.BLACK_HOLE, "Black_Hole_Icon_A");
- }
- public void initializeArrayPieceChance ()
- {
- pieceChance = new List<PIECE_TYPE>();
- addPiecesToChanceList(1, PIECE_TYPE.MAGIC_CRISTAL_PURPLE);
- addPiecesToChanceList(1, PIECE_TYPE.MAGIC_CRISTAL_GREEN);
- addPiecesToChanceList(2, PIECE_TYPE.BLACK_HOLE);
- addPiecesToChanceList(1, PIECE_TYPE.RUCA);
- addPiecesToChanceList(1, PIECE_TYPE.ALIEN_BASIC);
- addPiecesToChanceList(14, PIECE_TYPE.TREE);
- addPiecesToChanceList(20, PIECE_TYPE.BUSH);
- // {
- // (int)PIECE_TYPE.MAGIC_CRISTAL_PURPLE
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.MAGIC_CRISTAL_GREEN
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.ALIEN_TELEPORTER
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BLACK_HOLE
- // ,(int)PIECE_TYPE.BLACK_HOLE
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.BUSH
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.ALIEN_TELEPORTER
- // ,(int)PIECE_TYPE.ALIEN_TELEPORTER
- // ,(int)PIECE_TYPE.ALIEN_TELEPORTER
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.TREE
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.ALIEN_BASIC
- // ,(int)PIECE_TYPE.RUCA
- // ,(int)PIECE_TYPE.RUCA
- // ,(int)PIECE_TYPE.MAGIC_CRISTAL_GREEN
- // };
- }
- private void addPiecesToChanceList(int amount, PIECE_TYPE pieza) {
- if (amount <= 0) {
- return;
- }
- for (int i = 0; i < amount; i++) {
- pieceChance.Add(pieza);
- }
- }
- public void initializeTablaScorePerPiece ()
- {
- tablaScorePerPiece = new Hashtable();
- tablaScorePerPiece.Add(PIECE_TYPE.ROAD, 0);
- tablaScorePerPiece.Add(PIECE_TYPE.BUSH, 5);
- tablaScorePerPiece.Add(PIECE_TYPE.TREE, 10);
- tablaScorePerPiece.Add(PIECE_TYPE.RUCA, 15);
- tablaScorePerPiece.Add(PIECE_TYPE.HOME, 20);
- tablaScorePerPiece.Add(PIECE_TYPE.CASTLE, 25);
- tablaScorePerPiece.Add(PIECE_TYPE.BUILDING, 30);
- tablaScorePerPiece.Add(PIECE_TYPE.FUTURE_HOME, 35);
- tablaScorePerPiece.Add(PIECE_TYPE.FUTURE_HOME_HOVERING, 40);
- tablaScorePerPiece.Add(PIECE_TYPE.FUTURE_CITY, 45);
- tablaScorePerPiece.Add(PIECE_TYPE.ALIEN_BASIC, 0);
- tablaScorePerPiece.Add(PIECE_TYPE.ALIEN_TELEPORTER, 0);
- tablaScorePerPiece.Add(PIECE_TYPE.BLACK_HOLE, 0);
- tablaScorePerPiece.Add(PIECE_TYPE.MOAI, 65);
- tablaScorePerPiece.Add(PIECE_TYPE.MOAIS, 70);
- tablaScorePerPiece.Add(PIECE_TYPE.STONEHENGE, 75);
- tablaScorePerPiece.Add(PIECE_TYPE.ROCK, 90);
- tablaScorePerPiece.Add(PIECE_TYPE.CAVE, 100);
- tablaScorePerPiece.Add(PIECE_TYPE.DIAMOND, 90);
- tablaScorePerPiece.Add(PIECE_TYPE.RUBY, 100);
- tablaScorePerPiece.Add(PIECE_TYPE.MAGIC_CRISTAL_PURPLE, 90);
- tablaScorePerPiece.Add(PIECE_TYPE.MAGIC_CRISTAL_GREEN, 100);
- }
- public void initializeTablaBuyForCoinsValue() {
- tablaBuyForCoinsValue = new Hashtable();
- tablaBuyForCoinsValue.Add(PIECE_TYPE.BUSH, 50);
- tablaBuyForCoinsValue.Add(PIECE_TYPE.TREE, 100);
- tablaBuyForCoinsValue.Add(PIECE_TYPE.RUCA, 200);
- tablaBuyForCoinsValue.Add(PIECE_TYPE.MAGIC_CRISTAL_GREEN, 600);
- tablaBuyForCoinsValue.Add(PIECE_TYPE.MAGIC_CRISTAL_PURPLE, 1500);
- tablaBuyForCoinsValue.Add(PIECE_TYPE.BLACK_HOLE, 1500);
- }
- public void initializeTablaSellForCoinsValue() {
- tablaSellForCoinsValue = new Hashtable();
- tablaSellForCoinsValue.Add(PIECE_TYPE.ROAD, 1);
- tablaSellForCoinsValue.Add(PIECE_TYPE.BUSH, 1);
- tablaSellForCoinsValue.Add(PIECE_TYPE.TREE, 2);
- tablaSellForCoinsValue.Add(PIECE_TYPE.RUCA, 4);
- tablaSellForCoinsValue.Add(PIECE_TYPE.HOME, 8);
- tablaSellForCoinsValue.Add(PIECE_TYPE.CASTLE, 16);
- tablaSellForCoinsValue.Add(PIECE_TYPE.BUILDING, 32);
- tablaSellForCoinsValue.Add(PIECE_TYPE.FUTURE_HOME, 64);
- tablaSellForCoinsValue.Add(PIECE_TYPE.FUTURE_HOME_HOVERING, 128);
- tablaSellForCoinsValue.Add(PIECE_TYPE.FUTURE_CITY, 256);
- tablaSellForCoinsValue.Add(PIECE_TYPE.ALIEN_BASIC, 1);
- tablaSellForCoinsValue.Add(PIECE_TYPE.ALIEN_TELEPORTER, 2);
- tablaSellForCoinsValue.Add(PIECE_TYPE.MOAI, 3);
- tablaSellForCoinsValue.Add(PIECE_TYPE.MOAIS, 4);
- tablaSellForCoinsValue.Add(PIECE_TYPE.STONEHENGE, 5);
- tablaSellForCoinsValue.Add(PIECE_TYPE.ROCK, 150);
- tablaSellForCoinsValue.Add(PIECE_TYPE.CAVE, 250);
- tablaSellForCoinsValue.Add(PIECE_TYPE.DIAMOND, 1500);
- tablaSellForCoinsValue.Add(PIECE_TYPE.RUBY, 2000);
- }
- // private Hashtable tablaDemoCases;
- // public void initializeTablaDemoCases() {
- // initializeTablaDemoCases = new Hashtable();
- // int[,] casoVacio = new int[6,6]();
- //
- // }
- public void initializeMoaiIndexes() {
- //listMoaiIndexes.Clear();
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (i != 0 && j != (int)GAME_PROPERTIES.columnLength - 1) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.MOAI && !listMoaiIndexes.Contains(j*6+i)) {
- listMoaiIndexes.Add(j*6+i);
- }
- }
- }
- }
- }
- public void showNextPieceInSelectorAndGui(int pieceToShow)
- {
- this.selectorNextPiece.Play((string)tablaAllAnimations[pieceToShow]);
- ufoNextPiece.Play (ufoNextPiece.GetClipIdByName((string)tablaAllAnimations[pieceToShow]));//.spriteId = ufoNextPiece.collection.GetSpriteIdByName((string)tablaAllAnimations[pieceToShow]);
- if (pieceToShow == (int)PIECE_TYPE.BUSH || pieceToShow == (int)PIECE_TYPE.ROCK) {
- ufoNextPiece.transform.position = ufoNextPieceOriginPos + Vector3.up*5f;
- } else {
- ufoNextPiece.transform.position = ufoNextPieceOriginPos;
- }
- }
- public List<Vector2> getListaRucasAndCavesPostions() {
- List<Vector2> listaRetorno = new List<Vector2>();
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.RUCA || gameGrid[i,j] == (int)PIECE_TYPE.CAVE || gameGrid[i,j] == (int)PIECE_TYPE.HOME) {
- Vector2 vectorAprox = (Vector2)gamePiecesAnimations[j*6 + i].transform.position;
- vectorAprox.Set((float)((int)vectorAprox.x), (float)((int)vectorAprox.y));
- listaRetorno.Add(vectorAprox);
- }
- }
- }
- return listaRetorno;
- }
- public List<Vector2> getListaHomesOrCastlesPostions() {
- List<Vector2> listaRetorno = new List<Vector2>();
- for (int i = 0; i < (int)GAME_PROPERTIES.rowLength; i++) {
- for (int j = 0; j < (int)GAME_PROPERTIES.columnLength; j++) {
- if (gameGrid[i,j] == (int)PIECE_TYPE.HOME || gameGrid[i,j] == (int)PIECE_TYPE.CASTLE
- || gameGrid[i,j] == (int)PIECE_TYPE.FUTURE_HOME || gameGrid[i,j] == (int)PIECE_TYPE.FUTURE_HOME_HOVERING ) {
- Vector2 vectorAprox = (Vector2)gamePiecesAnimations[j*6 + i].transform.position;
- vectorAprox.Set((float)((int)vectorAprox.x), (float)((int)vectorAprox.y));
- listaRetorno.Add(vectorAprox);
- }
- }
- }
- return listaRetorno;
- }
- public void printGameGrid ()
- {
- string testMatrix = "";
- for(int j=(int)GAME_PROPERTIES.columnLength - 1; j > -1; j--)
- {
- for(int i=0; i < (int)GAME_PROPERTIES.rowLength; i++)
- {
- testMatrix += gameGrid[i,j].ToString() + " ";
- }
- testMatrix += "\n";
- }
- Debug.Log(testMatrix);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement