public void Execute(GameObject tower, int player) { gM.GetComponent <SoundScriptPT>().PlaySound(Sounds.SWAP); gM.SwapTowers(tower, player); if (player == 1) { gM.ChangeState(new IEnemyMoveStatePT()); gM.UndoPowerPoints(1, 1); gM.GetComponent <GUIControllerScriptPT>().LockUnlockPowers(false, gM.GetPowerPoints(1)); } else { gM.UndoPowerPoints(1, 2); } }
public void Execute(GameObject tower, int player) { int hp = gM.GetMaxHP(); gM.GetComponent <SoundScriptPT>().PlaySound(Sounds.HEAL); tower.GetComponent <PokeTowerScript>().HealTower(hp); if (player == 1) { gM.ChangeState(new IEnemyMoveStatePT()); gM.UndoPowerPoints(3, 1); gM.GetComponent <GUIControllerScriptPT>().LockUnlockPowers(false, gM.GetPowerPoints(1)); } else { gM.UndoPowerPoints(3, 2); } }
public void Execute(GameObject tower, int player) { gM.GetComponent <SoundScriptPT>().PlaySound(Sounds.TRANSFORM); int pT = (int)tower.GetComponent <PokeTowerScript>().GetPokeType(); PokeType newType = generateType(pT); Sprite towerSprite = gM.GetComponent <ConstDataScript>().GetTowerSprite(newType); tower.GetComponent <PokeTowerScript>().ChangeType(newType, towerSprite); if (player == 1) { gM.ChangeState(new IEnemyMoveStatePT()); gM.UndoPowerPoints(2, 1); gM.GetComponent <GUIControllerScriptPT>().LockUnlockPowers(false, gM.GetPowerPoints(1)); } else { gM.UndoPowerPoints(2, 2); } }
public void Execute(GameObject tower, int player) { int xOffset = -2; Vector2 force = new Vector2(-500, 0); if (player == 1) { xOffset = 2; force = new Vector2(500, 0); gM.GetComponent <GUIControllerScriptPT>().LockUnlockPowers(false, gM.GetPowerPoints(1)); } PokeType pT = tower.GetComponent <PokeTowerScript>().GetPokeType(); Vector3 position = new Vector3(tower.transform.position.x + xOffset, tower.transform.position.y, tower.transform.position.z); tower.GetComponent <PokeTowerScript>().Attack(gM.GetComponent <ConstDataScript>().GetAttackSprite(pT), position, force); if (player == 1) { gM.ChangeState(new IWaitStatePT()); } }
public void OnStateEnter(GameManagerScriptPT gameManager) { gM = gameManager; IGameStatesPT gS = new IHealStatePT(); int points = gM.GetPowerPoints(2); int height = gM.GetTowerHeight(); int index = Random.Range(0, height); float prob = Random.Range(0.0f, 1.0f); List <int> list; switch (points) { case 0: gS = new IAttackStatePT(); list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, false)) { int g = i; list.Add(g); } } if (list.Count > 0) { index = list[Random.Range(0, list.Count)]; } break; case 1: gS = new IAttackStatePT(); list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, false)) { int g = i; list.Add(g); } } if (list.Count > 0) { index = list[Random.Range(0, list.Count)]; } if (Random.Range(0.0f, 1.0f) < 0.05f && gM.GetTowerHeightP2() > 1) { gS = new ISwapStatePT(); index = Random.Range(0, gM.GetTowerHeightP2()); } break; case 2: gS = new IAttackStatePT(); list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, false)) { int g = i; list.Add(g); } } if (list.Count > 0) { index = list[Random.Range(0, list.Count)]; } if (prob < 0.05f && gM.GetTowerHeightP2() > 1) { gS = new ISwapStatePT(); index = Random.Range(0, gM.GetTowerHeightP2()); } else if (prob < 0.25f) { list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, true)) { int g = i; list.Add(g); } } if (list.Count > 0) { gS = new IChangeTowerStatePT(); index = list[Random.Range(0, list.Count)]; } } break; default: gS = new IAttackStatePT(); list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, false)) { int g = i; list.Add(g); } } if (list.Count > 0) { index = list[Random.Range(0, list.Count)]; } if (prob < 0.01f * points && gM.GetTowerHeightP2() > 1) { gS = new ISwapStatePT(); index = Random.Range(0, gM.GetTowerHeightP2()); } else if (prob < 0.05f * points) { list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.HasDisadvantage(i, true)) { int g = i; list.Add(g); } } if (list.Count > 0) { gS = new IChangeTowerStatePT(); index = list[Random.Range(0, list.Count)]; } } else if (prob < 0.20f * points) { height = gM.GetTowerHeightP2(); list = new List <int>(); for (int i = 0; i < height; i++) { if (gM.GetTowerHp(i) <= 2) { int g = i; list.Add(g); } } if (list.Count > 0) { gS = new IHealStatePT(); index = list[Random.Range(0, list.Count)]; } } break; } gS.OnStateEnter(gM); gS.Execute(gM.GetTowerP2(index), 2); gM.AddPowerPoints(2); gM.Wait(2, new IAttackStatePT(), 2); }