/// <summary> /// Return the cost of the obstacle according to the spawn type /// </summary> /// <param name="mSpawnType">The spawn type of the desired obstacle</param> /// <returns>The cost of the osbtacle</returns> public int GetObstacleCost(ActiveObstacle.ObstacleType obstacleType) { int obstacleCost = int.MaxValue; switch (obstacleType) { case ActiveObstacle.ObstacleType.SimpleWall: obstacleCost = GetObstacleToSpawn(obstacleType, GameManager.Instance.GetLocalPlayer()).GetComponent <ActiveObstacle>().GetBuildingCost(); break; case ActiveObstacle.ObstacleType.SlopeLeft: obstacleCost = GetObstacleToSpawn(obstacleType, GameManager.Instance.GetLocalPlayer()).GetComponent <ActiveObstacle>().GetBuildingCost(); break; case ActiveObstacle.ObstacleType.SlopeRight: obstacleCost = GetObstacleToSpawn(obstacleType, GameManager.Instance.GetLocalPlayer()).GetComponent <ActiveObstacle>().GetBuildingCost(); break; case ActiveObstacle.ObstacleType.Pillar: obstacleCost = GetObstacleToSpawn(obstacleType, GameManager.Instance.GetLocalPlayer()).GetComponent <ActiveObstacle>().GetBuildingCost(); break; case ActiveObstacle.ObstacleType.Trap: obstacleCost = GetObstacleToSpawn(obstacleType, GameManager.Instance.GetLocalPlayer()).GetComponent <ActiveObstacle>().GetBuildingCost(); break; } return(obstacleCost); }
public void BuildObstacle(ActiveObstacle.ObstacleType obstacleType, PlayerEntity.Player playerNumber) { if (m_currentState != EState.Buildable) { return; } NetworkConnection conn = GameManager.Instance.GetPlayer(playerNumber).connectionToClient; GameObject obstacleToSpawn = GetObstacleToSpawn(obstacleType, playerNumber); int cost = obstacleToSpawn.GetComponent <ActiveObstacle>().GetBuildingCost(); if (null != conn) { if (!m_territory.IsAvailable(playerNumber)) { TargetShowWarningTerritory(conn); } if (GameManager.Instance.GetPlayer(playerNumber).GetBuildGold() < cost) { TargetShowWarningObstacle(conn); } TargetSoundConstruction(GameManager.Instance.GetLocalPlayerEntity().connectionToClient); } if (GameManager.Instance.GetPlayer(playerNumber).GetBuildGold() < cost) { if (playerNumber != PlayerEntity.Player.Bot) { TargetShowWarningObstacle(GameManager.Instance.GetPlayer(playerNumber).connectionToClient); } return; } GameManager.Instance.GetPlayer(playerNumber).GainBuildGold(-cost); m_currentState = EState.Invulnerable; RpcSetCurrentState(EState.Invulnerable); RpcEnableObstacleConstructor(false); RpcDisableUI(); GameObject obstacleSpawnned = Instantiate(obstacleToSpawn); NetworkServer.Spawn(obstacleSpawnned); obstacleSpawnned.GetComponent <ActiveObstacle>().RpcInitOnConstruction(gameObject, playerNumber); int childCount = 0; foreach (Transform child in transform) { if (child.gameObject.GetComponent <ActiveObstacle>()) { if (childCount > 1) { Destroy(child); } childCount++; } } }
private void CallBuildObstacle(int indexOfObstacleConstructor, ActiveObstacle.ObstacleType wallsType, Animator animator) { if (EnoughBuildGold(wallsType) && m_listObstacles[indexOfObstacleConstructor].GetCurrentState() == ObstacleConstructor.EState.Buildable) { m_counter++; m_aiBuildObstacles.SetIndex(indexOfObstacleConstructor); m_aiBuildObstacles.SetTypeBuild(wallsType); animator.SetTrigger(Constant.BotTransition.s_buildObstacle); } }
public void PreviewObstacle(ActiveObstacle.ObstacleType obstacleType, PlayerEntity.Player playerNumber) { if (EState.Buildable != m_currentState) { return; } GameObject obstacleToSpawn = GetObstacleToSpawn(obstacleType, playerNumber); visualObstacle = Instantiate(obstacleToSpawn); if (ActiveObstacle.ObstacleType.Trap != obstacleType) { foreach (NavMeshObstacle navObs in visualObstacle.GetComponentsInChildren <NavMeshObstacle>()) { navObs.enabled = false; } } Destroy(visualObstacle.GetComponent <ObjectSelection>()); Destroy(visualObstacle.GetComponent <ActiveObstacle>()); if (playerNumber == PlayerEntity.Player.Player1) { visualObstacle.GetComponent <Renderer>().material = m_transparentSyca; } else { visualObstacle.GetComponent <Renderer>().material = m_transparentArca; } visualObstacle.transform.SetParent(gameObject.transform); visualObstacle.transform.localPosition = Vector3.zero; visualObstacle.transform.localRotation = Quaternion.identity; if (obstacleType == ActiveObstacle.ObstacleType.SlopeLeft) { visualObstacle.transform.localPosition = new Vector3(0, 0, 1.5f); visualObstacle.transform.Rotate(Vector3.up, 180); } else if (obstacleType == ActiveObstacle.ObstacleType.SlopeRight) { visualObstacle.transform.localPosition = new Vector3(0, 0, -1.5f); } EnableObstacleConstructor(false); }
private bool EnoughBuildGold(ActiveObstacle.ObstacleType wallType) { return(GameManager.Instance.GetPlayer(PlayerEntity.Player.Bot).GetBuildGold() >= m_pricesBuildList[m_TypeBuildList.IndexOf(wallType)]); }
public void SetBuildType(ActiveObstacle.ObstacleType type) { m_buildType = type; }
public GameObject GetObstacleToSpawn(ActiveObstacle.ObstacleType spawnType, PlayerEntity.Player playerNumber) { return(m_prefabObstacle[playerNumber][spawnType]); }
public void CmdCreateObstacle(GameObject parentGo, ActiveObstacle.ObstacleType spawnType) { parentGo.GetComponent <ObstacleConstructor> ().BuildObstacle(spawnType, m_playerNumber); }
public void SetTypeBuild(ActiveObstacle.ObstacleType type) { m_typeBuild = type; }