Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
 public PlayerData(NetworkGamePlayerHex player)
 {
     Player = player;
 }
Ejemplo n.º 6
0
 public void RemoveGamePlayer(NetworkGamePlayerHex player)
 {
     GamePlayers.Remove(player);
     Game.Data.UnregisterPlayer(player);
 }
Ejemplo n.º 7
0
 public void AddGamePlayer(NetworkGamePlayerHex player)
 {
     GamePlayers.Add(player);
 }
Ejemplo n.º 8
0
 public void SetGamePlayer(NetworkGamePlayerHex player)
 {
     gamePlayer = player;
     UI.Init(player);
 }
Ejemplo n.º 9
0
 public bool IsCurrentPlayer(NetworkGamePlayerHex player) => Data.IsCurrentPlayer(player.ID);
Ejemplo n.º 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);
        }
Ejemplo n.º 11
0
 public void UnregisterPlayer(NetworkGamePlayerHex player)
 {
     playerData.RemoveAt(playerData.FindIndex(p => p.Player.ID == player.ID));
 }
Ejemplo n.º 12
0
 public PlayerData GetPlayerData(NetworkGamePlayerHex player)
 {
     return(playerData.First(p => p.Player.ID == player.ID));
 }
Ejemplo n.º 13
0
 public void OnSuppliesChanged(NetworkGamePlayerHex player, int newSupplies)
 {
     RpcSetSupplies((Int16)player.ID, (Int16)newSupplies);
 }
Ejemplo n.º 14
0
 public void OnPopulationUtilisationChanged(NetworkGamePlayerHex player, int newUtilisation)
 {
     RpcSetPopulationUtilisation((Int16)player.ID, (Int16)newUtilisation);
 }
Ejemplo n.º 15
0
 public void OnMaxPopulationChanged(NetworkGamePlayerHex player, int newPopulation)
 {
     RpcSetMaxPopulation((Int16)player.ID, (Int16)newPopulation);
 }