Example #1
0
        public HexCell Create(CellTypes type, NetworkGamePlayerHex owner, int cellID)
        {
            var cell = CreateCell(type);

            if (cell == null)
            {
                return(cell);
            }

            cell.SetupTech(data, owner.ID);

            cell.Init(this, data, owner);
            allCells.Add(cellID, cell);

            foreach (var observer in cellEventObservers)
            {
                cell.RegisterEventObserver(observer);
            }

            foreach (var observer in cellLifecycleObservers)
            {
                observer.OnCellCreated(cell);
            }

            return(cell);
        }
Example #2
0
        public PlayerActions(NetworkGamePlayerHex player, GameManager game)
        {
            this.player = player;
            this.game   = game;

            indicator = new CellIndicator(game.Cells, game.UI);

            input = new PlayerInput();
            input.RegisterObserver(this);

            state = States.None;
        }
Example #3
0
        public void Init(Cells cells, GameData data, NetworkGamePlayerHex owner)
        {
            GameData = data;
            CellData = cells;
            Owner    = owner;
            PlayerId = Owner.ID;

            foreach (var action in actions)
            {
                action.Init(data, PlayerId);
            }
            OnInit();
        }
Example #4
0
        /// <summary>
        /// Called by the server to validate placement
        /// </summary>
        public void TryPlace(NetworkGamePlayerHex player, Int16 x, Int16 z, Cells.CellTypes type)
        {
            if (!IsCurrentPlayer(player))
            {
                return;
            }

            var playerData = Data.GetPlayerData(player);
            var cost       = Cells.GetCost(type);

            if (!playerData.CurrencyData.CanAfford(cost))
            {
                return;
            }
            if (!playerData.TechnologyData.HasTechnologyForCell(type))
            {
                return;
            }

            if (Grid.TryPlace(x, z, player.ID, type))
            {
                playerData.CurrencyData.Purchase(cost);
            }
        }
Example #5
0
 public PlayerData(NetworkGamePlayerHex player)
 {
     Player = player;
 }
Example #6
0
 public void RemoveGamePlayer(NetworkGamePlayerHex player)
 {
     GamePlayers.Remove(player);
     Game.Data.UnregisterPlayer(player);
 }
Example #7
0
 public void AddGamePlayer(NetworkGamePlayerHex player)
 {
     GamePlayers.Add(player);
 }
Example #8
0
 public void SetGamePlayer(NetworkGamePlayerHex player)
 {
     gamePlayer = player;
     UI.Init(player);
 }
Example #9
0
 public bool IsCurrentPlayer(NetworkGamePlayerHex player) => Data.IsCurrentPlayer(player.ID);
Example #10
0
        public void SetStartingLocation(NetworkGamePlayerHex player)
        {
            var startLocation = GetStartLocation(player.ID);

            TryPlace((Int16)startLocation.X, (Int16)startLocation.Z, (Int16)player.ID, Cells.CellTypes.Home);
        }
Example #11
0
 public void UnregisterPlayer(NetworkGamePlayerHex player)
 {
     playerData.RemoveAt(playerData.FindIndex(p => p.Player.ID == player.ID));
 }
Example #12
0
 public PlayerData GetPlayerData(NetworkGamePlayerHex player)
 {
     return(playerData.First(p => p.Player.ID == player.ID));
 }
Example #13
0
 public void OnSuppliesChanged(NetworkGamePlayerHex player, int newSupplies)
 {
     RpcSetSupplies((Int16)player.ID, (Int16)newSupplies);
 }
Example #14
0
 public void OnPopulationUtilisationChanged(NetworkGamePlayerHex player, int newUtilisation)
 {
     RpcSetPopulationUtilisation((Int16)player.ID, (Int16)newUtilisation);
 }
Example #15
0
 public void OnMaxPopulationChanged(NetworkGamePlayerHex player, int newPopulation)
 {
     RpcSetMaxPopulation((Int16)player.ID, (Int16)newPopulation);
 }