private void recycle()
 {
     data.nextDeploy();
     if (!data.getPlayer().Equals(controller.getPlayer()) && !controller.isLocalMode())
     {
         nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
         string message = manageMessage.messagePhase(data.getPlayer(), data.getPhase());
         DataSender.SendnextPhaseLoad(message);
     }
     else
     {
         nextPhaseLoad = new StateStartDeploy(controller, data, manageMessage, view);
     }
 }
コード例 #2
0
        private void next()
        {
            if (!controller.isLocalMode())
            {
                view.updatePhase(data.getPlayer(), data.getPhase());
                nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
            }

            else
            {
                controller.setLocalMode();
                nextPhaseLoad = new StateDeploy(controller, data, manageMessage, view);
            }
        }
コード例 #3
0
 private void AttackMessage()
 {
     view.updateLogEvent(manageMessage.readInitiateCombat(messageData));
     data.setDefendPhase(manageMessage.getLandEnd());
     view.updatePhase(data.getPlayer(), data.getPhase());
     if (!data.getPlayer().Equals(controller.getPlayer()))//check if the player is NOT the one targeted
     {
         nextPhaseLoad = this;
     }
     else
     {
         view.changeCanvasOption("Defend phase");
         nextPhaseLoad = new StateDefend(controller, data, manageMessage, view);
     }
 }
コード例 #4
0
 public StateAttack(ControllGameMap controller, DataManager data, MessageManager manageMessage, ViewGameMap view)
 {
     this.controller    = controller;
     this.data          = data;
     this.view          = view;
     this.manageMessage = manageMessage;
     nextPhaseLoad      = this;
     firstLand          = "";
     secondLand         = "";
     nTanks             = -1;
     controller.resetMemoryBuffer();
     view.updatePhase(data.getPlayer(), data.getPhase());
     view.changeCanvasOption("Attack phase");
     view.updateTwoSelected("", "");
     Debug.Log("Data phase: " + data.getPhase() + " - State : Attack");
 }
コード例 #5
0
 public StateDefend(ControllGameMap controller, DataManager data, MessageManager manageMessage, ViewGameMap view)
 {
     this.controller    = controller;
     this.data          = data;
     this.manageMessage = manageMessage;
     this.view          = view;
     firstLand          = null;
     secondLand         = null;
     nextPhaseLoad      = this;
     nTanksAttacker     = -1;
     nTanksDefender     = -1;
     view.changeCanvasOption("Defend phase");
     view.updatePhase(data.getPlayer(), data.getPhase());
     view.updateTanksRemain(data.getTankOfLand(controller.getSecondLand()));
     Debug.Log("Data phase: " + data.getPhase() + " - State : Defense Deploy");
 }
コード例 #6
0
 private void DefendMessage()
 {
     view.updateLogEvent(manageMessage.readDefend(messageData));
     data.setAttackPhase(manageMessage.getLandStart());
     view.updatePhase(data.getPlayer(), data.getPhase());
     if (!data.getPlayer().Equals(controller.getPlayer()))//check if the player is NOT the one who engaged the battle
     {
         nextPhaseLoad = this;
     }
     else
     {
         view.changeCanvasOption("Attack phase");
         view.updateTwoSelected(null, null);
         nextPhaseLoad = new StateAttack(controller, data, manageMessage, view);
     }
 }
コード例 #7
0
 private void MoveMessage()
 {
     view.updateLogEvent(manageMessage.readMove(messageData));
     data.passTurn();
     view.updatePhase(data.getPlayer(), data.getPhase());
     if (!data.getPlayer().Equals(controller.getPlayer()))
     {
         nextPhaseLoad = this;
     }
     else
     {
         view.changeCanvasOption("Deployment phase");
         view.updateDeploySelected("Select a Land !!!");
         nextPhaseLoad = new StateDeploy(controller, data, manageMessage, view);
     }
 }
 private void loadStart()
 {
     data.startGame();
     if (data.getPlayer().Equals(controller.getPlayer()) || controller.isLocalMode())//cheking if the player the the one who start
     {
         Debug.Log("STATE CONFIRMED");
         nextPhaseLoad = new StateDeploy(controller, data, manageMessage, view);
         string message = manageMessage.messagePhase(data.getPlayer(), data.getPhase());
         DataSender.SendnextPhaseLoad(message);
     }
     else
     {
         nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
         string message = manageMessage.messagePhase(data.getPlayer(), data.getPhase());
         DataSender.SendnextPhaseLoad(message);
     }
 }
コード例 #9
0
        // Button methods

        public void onClickAction()
        {
            Debug.Log("state : " + state);
            List <string> error = state.getMissingData();

            if (error.Count != 0)
            {
                int    count            = 0;
                string messageToDisplay = "You can't do that action because are missing some data : ";
                foreach (string missing in error)
                {
                    messageToDisplay += missing;
                    if (count != error.Count)
                    {
                        messageToDisplay += ", ";
                    }
                }
                view.showMessage(messageToDisplay);
            }
            else
            {
                string errorAction = state.action();
                if (errorAction.Equals("FORCE_NEXT_PHASE"))
                {
                    state = state.nextPhaseForced();
                }
                else if (!errorAction.Equals(""))
                {
                    view.showMessage(errorAction);
                }
            }
            view.updateTextPlayerData(model.getPlayerData(player));
            if (firstLand != null && !firstLand.Equals(""))
            {
                view.updateLandText(model.getLandData(firstLand));
            }

            if (model.hasWon(player))
            {
                view.showMessage(player + " has won!");
            }
        }
コード例 #10
0
        public override string action()
        {
            string error = "";

            loadNecessaryData();
            int lossTanksAttacker = data.getTankOfLand(firstLand);
            int lossTanksDefender = data.getTankOfLand(secondLand);

            error = data.attack(firstLand, secondLand, nTanksAttacker, nTanksDefender);
            if (error.Equals(""))
            {
                error = "FORCE_NEXT_PHASE";
                data.setAttackPhase(firstLand);
                lossTanksAttacker -= data.getTankOfLand(firstLand);
                lossTanksDefender -= data.getTankOfLand(secondLand);
                string result = "";
                if (data.getPlayerByLand(secondLand).Equals(data.getPlayerByLand(firstLand)))
                {
                    result = "The land has been conquered";
                }
                else
                {
                    result = "The land has not been conquered";
                }
                string message = manageMessage.messageDefend(secondLand, firstLand, lossTanksAttacker, lossTanksDefender, "" + nTanksDefender, result);
                view.updateLogEvent(manageMessage.readDefend(message));
                DataSender.SendAttacco(message);
                if (!controller.isLocalMode())
                {
                    nextPhaseLoad = new StateWait(controller, data, manageMessage, view);
                }
                else
                {
                    controller.setLocalMode();
                    nextPhaseLoad = new StateAttack(controller, data, manageMessage, view);
                }
            }
            return(error);
        }
 public StateStartDeploy(ControllGameMap controller, DataManager data, MessageManager manageMessage, ViewGameMap view)
 {
     this.controller    = controller;
     this.data          = data;
     this.view          = view;
     this.manageMessage = manageMessage;
     nextPhaseLoad      = this;
     land   = null;
     nTanks = -1;
     if (data.getPlayerTanksReinforcement(data.getPlayer()) < MAX_TANKS_PER_TIME)
     {
         nTanksRemain = data.getPlayerTanksReinforcement(data.getPlayer());
     }
     else
     {
         nTanksRemain = MAX_TANKS_PER_TIME;
     }
     view.updatePhase(data.getPlayer(), data.getPhase());
     view.changeCanvasOption("Initial Deploy phase");
     view.updateTanksRemain(nTanksRemain);
     view.updateDeploySelected("Select a state !!!");
     Debug.Log("Data phase: " + data.getPhase() + " - State : Intial Deploy");
 }
 public override StateControl nextPhaseForced()
 {
     if (nTanksRemain > 0)
     {
         nextPhaseLoad = this;
         view.showMessage("You have to deploy ALL your tanks !!!");
     }
     else
     {
         if (!data.isAllPlayerRunOutOfTanks())
         {
             recycle();
         }
         else
         {
             loadStart();
         }
     }
     if (controller.isLocalMode())
     {
         controller.setLocalMode();
     }
     return(nextPhaseLoad);
 }
コード例 #13
0
 private void initializeController()
 {
     state = new StateStartDeploy(this, model, messageManager, view);
 }
コード例 #14
0
 public void onClickNextPhase()
 {
     state = state.nextPhase();
 }
コード例 #15
0
 private void DeployMessage()
 {
     view.updateLogEvent(manageMessage.readDeploy(messageData));
     data.addTanks(manageMessage.getLandStart(), manageMessage.getNTank1());
     nextPhaseLoad = this;
 }
コード例 #16
0
 private void CardMessage()
 {
     view.updateLogEvent(manageMessage.readUsedCards(messageData));
     data.useCards(manageMessage.getCard1(), manageMessage.getCard2(), manageMessage.getCard3());
     nextPhaseLoad = this;
 }