public void DIG(Player player) { Instantiate(m_holeInTheGround, player.CurrentTerritory.transform); player.PlayDig(); if (player.CurrentTerritory.HasItem) { if (m_debug) { Debug.Log("PlayerManager: " + "player " + player.NumPlayer + " digged an item out"); } Item item = player.CurrentTerritory.TerritoryItem; //item.m_PlayerAction = this; if (item.ItemType == Item.e_itemType.COINCHEST) { player.Gold += m_goldPerCoinChest; player.PlayCoin(); //lance animation cedric } if (item.ItemType == Item.e_itemType.GLASSES) { player.HasGlasses = true; m_glasses = Instantiate(m_glassesPrefab); player.Glasses = m_glasses; ObjectsFollow.FollowCharacter(m_glasses.transform, player.transform.position); //active objet glasses cedric } if (item.ItemType == Item.e_itemType.STRAIN) { player.PlayHurt(); } else if (item.ItemType == Item.e_itemType.PARCHEMENT) { player.PlayPaper(); GameObject parchement = Instantiate(m_starStun); ObjectsFollow.FollowCharacter(parchement.transform, player.transform.position); } else { player.PlayDig(); } player.CurrentTerritory.HasItem = false; Destroy(player.CurrentTerritory.gameObject.GetComponent("Item")); ItemEvent.NotifyNewItem(item, player); m_territoryManager.RePopSpecial(); } else { //message nothing to dig? } }
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]; } } 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]; } } 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]; } } 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]; } } break; case "DIG": Instantiate(m_holeInTheGround, player.CurrentTerritory.transform); // player.CurrentTerritory.GetComponent<Collider>().enabled = false; // player.CurrentTerritory.GetComponent<Collider>().enabled = true; //----------------- Dirty hack to wake that f***ing collider up !!!! Collider collider = player.CurrentTerritory.GetComponent <Collider>(); collider.enabled = false; collider.enabled = true; //------------------------------------------------------------------ player.PlayDig(); if (player.CurrentTerritory.HasItem) { if (m_debug) { Debug.Log("PlayerManager: " + "player " + player.NumPlayer + " digged an item out"); } Item item = player.CurrentTerritory.TerritoryItem; //item.m_PlayerAction = this; if (item.ItemType == Item.e_itemType.COINCHEST) { player.Gold += m_goldPerCoinChest; player.PlayCoin(); //lance animation cedric } if (item.ItemType == Item.e_itemType.GLASSES) { player.HasGlasses = true; GameObject glasses = Instantiate(m_glassesPrefab, player.transform); player.Glasses = glasses; ObjectsFollow.FollowCharacter(glasses.transform, player.transform.position); //active objet glasses cedric } if (item.ItemType == Item.e_itemType.STRAIN) { player.PlayHurt(); } else if (item.ItemType == Item.e_itemType.PARCHEMENT) { player.PlayPaper(); GameObject parchement = Instantiate(m_starStun); ObjectsFollow.FollowCharacter(parchement.transform, player.transform.position); } else { player.PlayDig(); } player.CurrentTerritory.HasItem = false; Destroy(player.CurrentTerritory.gameObject.GetComponent("Item")); ItemEvent.NotifyNewItem(item, player); m_territoryManager.RePopSpecial(); } else { //message nothing to dig? } break; case "LEVELUP": if (player.Gold > m_levelPrices[player.Level]) { 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(); } break; case "SHOVEL": //handled by remi&françois break; /* * case "PEBBLE": * if (player.NumberOfItem((int)Item.e_itemType.PEBBLE) > 0) * { * player.Inventory[(int)Item.e_itemType.PEBBLE] -= 1; * Player ennemy; * if (listPlayerById.TryGetValue(2, out ennemy)) { * StartCoroutine(LaunchPebble(ennemy.CurrentTerritory.transform.position,player,ennemy)); * } * } * break; */ case "BUY_GRENADE": if (player.Gold > m_costOfGrenade) { player.Gold -= m_costOfGrenade; if (player.NumberOfItem(2) > 0) { player.Inventory.Add(2, 1); } else { player.Inventory[2] += 1; } } break; case "BUY_SHOVEL": if (player.Gold > m_costOfShovel) { player.Gold -= m_costOfShovel; if (player.NumberOfItem(3) > 0) { player.Inventory.Add(3, 1); } else { player.Inventory[3] += 1; } } break; } } }
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; } } }