コード例 #1
0
        /// <summary>
        /// Execute all stacked actions, create projectiles and calculate damage
        /// </summary>
        private void ExecuteActions()
        {
            Stack <TurnAction> actionsClone = new Stack <TurnAction>(m_turnActionsStack);

            while (m_turnActionsStack.Count > 0)
            {
                TurnAction action = m_turnActionsStack.Pop();
                //create path and get collisions with terrain
                ProjectilePath path           = new ProjectilePath(action.Player.ControlledTank.Position, action.Force);
                Coordinate     collisionPoint = m_terrain.GetCollisionPoint(path);
                //for each collision damage the terrain
                m_terrain.DoDamange(collisionPoint, action.Weapon);
                //find all tanks effected and damage them
                TestTanksCollisionAt(collisionPoint, action.Weapon);
            }

            // if someone is listening for action executions,
            // then let it know that actions were executed, and send NextTurn as callback to be called by the listenr
            if (ActionsExecuted != null)
            {
                ActionsExecuted(actionsClone, NextTurn);
            }
            else
            {
                //if no one listens (meaning no external use for game) skip to next Turn
                NextTurn();
            }
        }
コード例 #2
0
    public void SetPlayerControl(bool hasControl)
    {
        playerHasControl = hasControl;
        Cursor.visible   = !hasControl;

        // TODO: Disable all player contrables at once.
        PlayerMovement   playerMov        = FindObjectOfType <PlayerMovement>();
        PlayerContainers playerCont       = playerMov.GetComponent <PlayerContainers>();
        HandMovement     playerHand       = playerMov.GetComponentInChildren <HandMovement>();
        ProjectilePath   playerProjectile = playerMov.GetComponentInChildren <ProjectilePath>();

        playerMov.ChangeControl(hasControl);
        playerCont.ChangeControl(hasControl);
        playerHand.ChangeControl(hasControl);
        playerProjectile.ChangeControl(hasControl);


        //TODO: Check this one out.
        // It highlights the first button in the menu if there is no mouse.
        //StartCoroutine(HighLightBtnCR());
    }
コード例 #3
0
 /// <summary>
 /// Return the future collisionPoint point of the terrain object with given path
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public Coordinate GetCollisionPoint(ProjectilePath path)
 {
     //TODO - implement when terrain object is done
     return(new Coordinate());
 }