public void DoAction(string TypeOfMove, Player player, int idEnnemy = 0) { if (!player.CurrentTerritory.Locked)//if in territorry locked means if in battle, so not accepting commands { float y; float x; switch (TypeOfMove) { case "UP": RotateMole(player.gameObject, 0); y = player.CurrentTerritory.transform.position.y + 1; if (!(y > m_territoryManager.m_nbrYTerritories - 1)) { int tempx = (int)player.CurrentTerritory.gameObject.transform.position.x; int tempy = (int)player.CurrentTerritory.gameObject.transform.position.y + 1; if (!m_territoryManager.m_battleField[tempx, tempy].Locked) { player.CurrentTerritory.GetListOfPlayerOnThisTerritory().Remove(player); player.transform.Translate(0f, 0f, 1f); player.CurrentTerritory = m_territoryManager.m_battleField[tempx, tempy]; if (player.HasGlasses) { ObjectsFollow.FollowCharacter(m_glasses.transform, player.transform.position); } if (player.supperShovelActive) { DIG(player); } } } break; case "DOWN": RotateMole(player.gameObject, 180); y = player.CurrentTerritory.transform.position.y - 1; if (!(y < 0)) { int tempx = (int)player.CurrentTerritory.gameObject.transform.position.x; int tempy = (int)player.CurrentTerritory.gameObject.transform.position.y - 1; if (!m_territoryManager.m_battleField[tempx, tempy].Locked) { player.CurrentTerritory.GetListOfPlayerOnThisTerritory().Remove(player); player.transform.Translate(0f, 0f, -1f); player.CurrentTerritory = m_territoryManager.m_battleField[tempx, tempy]; if (player.HasGlasses) { ObjectsFollow.FollowCharacter(m_glasses.transform, player.transform.position); } if (player.supperShovelActive) { DIG(player); } } } break; case "LEFT": RotateMole(player.gameObject, -90); x = player.CurrentTerritory.transform.position.x - 1; if (!(x < 0)) { int tempx = (int)player.CurrentTerritory.gameObject.transform.position.x - 1; int tempy = (int)player.CurrentTerritory.gameObject.transform.position.y; if (!m_territoryManager.m_battleField[tempx, tempy].Locked) { player.CurrentTerritory.GetListOfPlayerOnThisTerritory().Remove(player); player.transform.Translate(-1f, 0f, 0f); player.CurrentTerritory = m_territoryManager.m_battleField[tempx, tempy]; if (player.HasGlasses) { ObjectsFollow.FollowCharacter(m_glasses.transform, player.transform.position); } if (player.supperShovelActive) { DIG(player); } } } break; case "RIGHT": RotateMole(player.gameObject, 90); x = player.CurrentTerritory.transform.position.x + 1; if (!(x > m_territoryManager.m_nbrXTerritories - 1)) { int tempx = (int)player.CurrentTerritory.gameObject.transform.position.x + 1; int tempy = (int)player.CurrentTerritory.gameObject.transform.position.y; if (!m_territoryManager.m_battleField[tempx, tempy].Locked) { player.CurrentTerritory.GetListOfPlayerOnThisTerritory().Remove(player); player.transform.Translate(1f, 0f, 0f); player.CurrentTerritory = m_territoryManager.m_battleField[tempx, tempy]; if (player.HasGlasses) { ObjectsFollow.FollowCharacter(m_glasses.transform, player.transform.position); } if (player.supperShovelActive) { DIG(player); } } } break; case "DIG": DIG(player); break; case "LEVELUP": if (player.Gold > m_levelPrices[player.Level]) { if (player.Level < m_levelPrices.Length) { player.Gold -= m_levelPrices[player.Level]; player.Level = player.Level + 1; GameObject level = Instantiate(m_levelUpParticlePrefab); ObjectsFollow.FollowCharacter(level.transform, player.transform.position); } } break; case "GRENADE": //some condition based on inventory if ((player.NumberOfItem((int)Item.e_itemType.GRENADES)) > 0) { player.Inventory[(int)Item.e_itemType.GRENADES] -= 1; LaunchGrenade(player); player.PlayGrenade(); ItemEvent.NotifyItemUse(Item.e_itemType.GRENADES, player); } break; case "SHOVEL": if ((player.NumberOfItem((int)Item.e_itemType.SHOVEL)) > 0) { player.Inventory[(int)Item.e_itemType.SHOVEL] -= 1; ItemEvent.NotifyItemUse(Item.e_itemType.GRENADES, player); player.ActivateShovel(); DIG(player); } else { //some message "no shovel" } //handled by remi&françois break; case "BUYGRENADE": if (player.Gold > m_costOfGrenade) { if (player.Inventory.ContainsKey((int)Item.e_itemType.GRENADES)) { if (player.NumberOfItem((int)Item.e_itemType.GRENADES) == 0) { player.Inventory[(int)Item.e_itemType.GRENADES] += 1; player.Gold -= m_costOfGrenade; Item item = new Item(); item.ItemType = Item.e_itemType.GRENADES; item.EffectType = Item.e_effectType.INVENTORY; ItemEvent.NotifyNewItem(item, player); } } else { player.Inventory.Add((int)Item.e_itemType.GRENADES, 1); player.Gold -= m_costOfGrenade; } } break; case "BUYSHOVEL": if (player.Gold > m_costOfShovel) { if (player.Inventory.ContainsKey((int)Item.e_itemType.SHOVEL)) { if (player.NumberOfItem((int)Item.e_itemType.SHOVEL) == 0) { player.Inventory[(int)Item.e_itemType.SHOVEL] += 1; player.Gold -= m_costOfShovel; Item item = new Item(); item.ItemType = Item.e_itemType.SHOVEL; item.EffectType = Item.e_effectType.INVENTORY; ItemEvent.NotifyNewItem(item, player); } } else { player.Inventory.Add((int)Item.e_itemType.SHOVEL, 1); player.Gold -= m_costOfShovel; Item item = new Item(); item.ItemType = Item.e_itemType.SHOVEL; item.EffectType = Item.e_effectType.INVENTORY; ItemEvent.NotifyNewItem(item, player); } } break; } } }