// Update is called once per frame void Update() { if (player == null & Utilities.IsLevelLoaded() && !Utilities.IsGameOver()) { player = PlayerManager.GetControllablePlayer(); if (player != null) { networkedPlayer = player.GetComponent <NetworkedPlayer>(); playerScore = player.GetComponent <PlayerScore>(); } fleetShips = PlayerManager.GetOwnedFleetAI(); fleetShipToSpawn = GetFleetShipToSpawn(); } if (networkedPlayer != null) { if (networkedPlayer.IslandWithinRange != null) { nearbyIsland = networkedPlayer.IslandWithinRange.GetComponent <IslandDiscoveryTrigger>(); fleetButton.interactable = true; patrolButton.interactable = true; //TODO: Enable cannonButton once cannon upgrades have been implemented. //cannonButton.interactable = true; } else { nearbyIsland = null; fleetButton.interactable = false; patrolButton.interactable = false; cannonButton.interactable = false; } } if (fleetButton.IsInteractable() && Input.GetAxis("BuyFleetShip") == 1 && fleetButtonTimer >= buttonPressCooldown) { FleetButtonPress(); fleetButtonTimer = 0.0f; } if (patrolButton.IsInteractable() && Input.GetAxis("BuyPatrolShip") == 1 && patrolButtonTimer >= buttonPressCooldown) { PatrolButtonPress(); patrolButtonTimer = 0.0f; } //TODO: Add cannon upgrade button. if (fleetButtonTimer < buttonPressCooldown) { fleetButtonTimer += Time.deltaTime; } if (patrolButtonTimer < buttonPressCooldown) { patrolButtonTimer += Time.deltaTime; } }
/// <summary> /// Compiles a score board from all game players /// </summary> void Update() { Dictionary <int, int> islandsOwned = IslandDiscoveryTrigger.GetIslandsOwned(); List <GameObject> players = PlayerManager.GetAllPlayersByScore(); int maxShown = Mathf.Min(players.Count, m_scoreBack.Count); int i = 0; for (; i < maxShown; ++i) { var obj = players[i]; if (obj != null) { m_scoreBack[i].gameObject.SetActive(true); m_scoreFront[i].color = Utilities.GetPlayerColor(obj); int ID = Utilities.GetPlayerID(obj); string text = Utilities.GetPlayerScore(obj).ToString() + ": " + Utilities.GetPlayerName(obj) + " ["; if (islandsOwned.ContainsKey(ID)) { text += islandsOwned[ID].ToString(); } else { text += "0"; } text += "]"; m_scoreBack[i].text = text; m_scoreFront[i].text = text; } } for (; i < m_scoreBack.Count; ++i) { m_scoreBack[i].gameObject.SetActive(false); } }
// Update is called once per frame void Update() { if (player == null & Utilities.IsLevelLoaded() && !Utilities.IsGameOver()) { player = PlayerManager.GetControllablePlayer(); if(player != null) { networkedPlayer = player.GetComponent<NetworkedPlayer>(); playerScore = player.GetComponent<PlayerScore>(); } fleetShips = PlayerManager.GetOwnedFleetAI(); fleetShipToSpawn = GetFleetShipToSpawn(); } if (networkedPlayer != null) { if (networkedPlayer.IslandWithinRange != null) { nearbyIsland = networkedPlayer.IslandWithinRange.GetComponent<IslandDiscoveryTrigger>(); fleetButton.interactable = true; patrolButton.interactable = true; //TODO: Enable cannonButton once cannon upgrades have been implemented. //cannonButton.interactable = true; } else { nearbyIsland = null; fleetButton.interactable = false; patrolButton.interactable = false; cannonButton.interactable = false; } } if (fleetButton.IsInteractable() && Input.GetAxis("BuyFleetShip") == 1 && fleetButtonTimer >=buttonPressCooldown) { FleetButtonPress(); fleetButtonTimer = 0.0f; } if (patrolButton.IsInteractable() && Input.GetAxis("BuyPatrolShip") == 1 && patrolButtonTimer >= buttonPressCooldown) { PatrolButtonPress(); patrolButtonTimer = 0.0f; } //TODO: Add cannon upgrade button. if (fleetButtonTimer < buttonPressCooldown) { fleetButtonTimer += Time.deltaTime; } if (patrolButtonTimer < buttonPressCooldown) { patrolButtonTimer += Time.deltaTime; } }
/// <summary> /// Setst the associated trigger /// </summary> public void SetTrigger(IslandDiscoveryTrigger trigger) { m_trigger = trigger; }