Esempio n. 1
0
        // Executes action for the controlling player.
        public void ExecuteAction(ActionParameters param)
        {
            // If action is not specified.
            if (param.Tag == ActionTag.None)
            {
                return;
            }

            // If no specified action.
            if (!_players[Control].ControlledUnit.Actions.ContainsKey(param.Tag))
            {
                return;
            }

            // If no targets.
            if (param.Targets == null)
            {
                _players[Control].ControlledUnit.Actions[param.Tag].Execute(Map);
                return;
            }

            // synchronize the random state
            Random.InitState(param.randomSeed);

            // Forms cells list.
            List <Cell> cells = new List <Cell>();

            foreach (Coordinates pos in param.Targets)
            {
                // If no cell for position.
                if (!Map.Cells.ContainsKey(pos) || Map.Cells[pos] == null)
                {
                    return;
                }
                cells.Add(Map.Cells[pos]);
            }

            // Executes action.
            _players[Control].ControlledUnit.Actions[param.Tag].Execute(cells, Map);


            // Notifies GameController that move was made.
            this.PostNotification(DidExecuteActionNotification);
        }
Esempio n. 2
0
 private void RpcExecuteAction(ActionParameters param)
 {
     // Notifies GameController that action is to be executed.
     this.PostNotification(RequestExecuteAction, param);
 }
Esempio n. 3
0
 public void CmdExecuteAction(ActionParameters param)
 {
     // Calls every client.
     RpcExecuteAction(param);
 }