public override void Act(GameObject executioner) { Building selectedBuilding = executioner.GetComponent <Building>(); PlayerOnline buildingPlayer = MultiplayerController.Instance.Players.Find(item => item.PlayerType == selectedBuilding.Owner); Unit unitToTrain = Units.Instance.GetUnitPrefab(unitType, selectedBuilding.Owner).GetComponent <Unit>(); string messageToShow = ""; if (unitToTrain.GoldCost > buildingPlayer.GoldAmount || unitToTrain.FoodCost > buildingPlayer.FoodMaxAmount - buildingPlayer.FoodAmount) { if (unitToTrain.GoldCost > buildingPlayer.GoldAmount) { messageToShow += "Not enough gold\n"; } if (unitToTrain.FoodCost > buildingPlayer.FoodMaxAmount - buildingPlayer.FoodAmount) { messageToShow += "Not enough food\n"; } MessagesController.Instance.RpcShowMessage(messageToShow.Remove(messageToShow.Length - 1), buildingPlayer.PlayerType); } else { buildingPlayer.GoldAmount -= unitToTrain.GoldCost; selectedBuilding.Train(unitToTrain); } }
private void Start() { if (MultiplayerController.Instance.LocalPlayer.PlayerType == MultiplayerController.Instance.winner) { outcomeText.text = playerVictoryText; } else { outcomeText.text = playerDefeatText; } PlayerOnline player1 = MultiplayerController.Instance.Players.Find(item => item.PlayerType == PlayerType.Player1); PlayerOnline player2 = MultiplayerController.Instance.Players.Find(item => item.PlayerType == PlayerType.Player2); player1GoldStatistic.Set(player1.AllGatheredGold, Mathf.Max(player1.AllGatheredGold, player2.AllGatheredGold)); player1LumberStatistic.Set(player1.AllGatheredLumber, Mathf.Max(player1.AllGatheredLumber, player2.AllGatheredLumber)); player1UnitsStatistic.Set(player1.AllUnitsAmount, Mathf.Max(player1.AllUnitsAmount, player2.AllUnitsAmount)); player1BuildingsStatistic.Set(player1.AllBuildingsAmount, Mathf.Max(player1.AllBuildingsAmount, player2.AllBuildingsAmount)); player1KillsStatistic.Set(player1.Kills, Mathf.Max(player1.Kills, player2.Kills)); player1RazingsStatistic.Set(player1.Razings, Mathf.Max(player1.Razings, player2.Razings)); player2GoldStatistic.Set(player2.AllGatheredGold, Mathf.Max(player1.AllGatheredGold, player2.AllGatheredGold)); player2LumberStatistic.Set(player2.AllGatheredLumber, Mathf.Max(player1.AllGatheredLumber, player2.AllGatheredLumber)); player2UnitsStatistic.Set(player2.AllUnitsAmount, Mathf.Max(player1.AllUnitsAmount, player2.AllUnitsAmount)); player2BuildingsStatistic.Set(player2.AllBuildingsAmount, Mathf.Max(player1.AllBuildingsAmount, player2.AllBuildingsAmount)); player2KillsStatistic.Set(player2.Kills, Mathf.Max(player1.Kills, player2.Kills)); player2RazingsStatistic.Set(player2.Razings, Mathf.Max(player1.Razings, player2.Razings)); }
void Awake() { player = gameObject.GetComponent <PlayerOnline>(); whiteBall = GameObject.Find("WhiteBall"); thrust = 1f; rotationSpeed = 100f; offset = GameManager.Instance.offset; playerOnline = (PlayerOnline)player; onlineGameManager = (Online2PlayerGameManager)GameManager.Instance; }
public void Spectate() { PlayerOnline Player = FindObjectOfType <PlayerOnline>(); Player.Spectate(); ChooseCharacter.SetActive(false); GhostError.SetActive(false); ColorGhostError.SetActive(false); Spectator.SetActive(false); SpectateButton.SetActive(false); }
protected override void CreatePlayers() { playerList = new Player[2]; GameObject currentObject; for (int i = 0; i < playerList.Length; i++) { currentObject = Instantiate(playerPrefab, GameObject.Find("WhiteBall").transform.position + offset, Quaternion.identity, GameObject.Find("Players").transform); playerList[i] = currentObject.AddComponent <PlayerOnline>(); playerList[i].Score = 0; playerList[i].Model = currentObject; playerList[i].Model.name = "Player" + (i + 1); playerList[i].PlayerName = "Player " + (i + 1); playerList[i].Cue = playerList[i].Model.transform.GetChild(0).gameObject; } if (GalaxyManager.Instance.Matchmaking.LobbyOwnerID == GalaxyManager.Instance.MyGalaxyID) { me = (PlayerOnline)playerList[0]; opponent = (PlayerOnline)playerList[1]; me.Active = true; opponent.Active = false; PassivePlayer = opponent; ActivePlayer = me; } else { me = (PlayerOnline)playerList[1]; opponent = (PlayerOnline)playerList[0]; me.Active = false; opponent.Active = true; PassivePlayer = me; ActivePlayer = opponent; } PassivePlayer.PlayerState = PlayerState.Passive; ActivePlayer.PlayerState = PlayerState.ActiveWIH; me.Controller = me.gameObject.AddComponent <PlayerOnlineController>(); opponent.Cue.SetActive(false); me.PlayerName = GalaxyManager.Instance.Friends.GetMyUsername(); opponent.PlayerName = GalaxyManager.Instance.Friends.GetFriendPersonaName(GalaxyManager.Instance.Matchmaking.GetSecondPlayerID()); }
public void SetUp() { GameObject player = Instantiate(playerPrefab, positions[0], new Quaternion()); player.transform.Rotate(90f, 0f, 0f, Space.Self); player.GetComponent <SpriteRenderer>().sprite = FromNameToSprite(playerDic[myUid]); player.name = playerDic[myUid]; player.AddComponent <PlayerOnline>(); PlayerOnline p = player.GetComponent <PlayerOnline>(); p.User = new FirebaseUser(); p.User.uid = myUid; p.moveSound = this.moveSound; p.gameOverWindow = this.gameOverWindow; p.questionWindow = this.questionWindow; p.eventWindow = this.eventWindow; dice.GetComponent <DiceOnline>().appPlayer = p; int i = 0; foreach (KeyValuePair <string, string> item in playerDic) { if (item.Key == myUid) { continue; } GameObject enemy = Instantiate(playerPrefab, positions[i + 1], new Quaternion()); enemy.transform.Rotate(90f, 0f, 0f, Space.Self); enemy.GetComponent <SpriteRenderer>().sprite = FromNameToSprite(playerDic[item.Key]); enemy.name = playerDic[item.Key]; enemy.AddComponent <EnemyOnline>(); EnemyOnline e = enemy.GetComponent <EnemyOnline>(); e.questionWindow = this.questionWindow; e.user = new FirebaseUser(); e.user.uid = item.Key; i++; } }
private void Awake() { player = GetComponent <PlayerOnline>(); }
private void Awake() { player = gameObject.GetComponent <PlayerOnline>(); }