Exemple #1
0
 public ActionRotate(GameObject owner, float angle, ROTATE_DIRECTION direction) : base(owner)
 {
     m_actionType = ACTION_TYPE.ACTION_rotate;
     m_angle      = angle;
     m_direction  = direction;
     if (m_direction == ROTATE_DIRECTION.ROTATE_left)
     {
         m_angle *= -1.0f;
     }
 }
Exemple #2
0
    void RpcRotateQuadrant(int quadrantIndex, ROTATE_DIRECTION direction)
    {
        Debug.Log("Player " + netId.ToString() + " executing action: Rotate quadrant " + quadrantIndex + " " + direction.ToString());

        /*
         * if (board == null)
         * {
         *  Debug.LogError("Board hasn't been assigned to network player yet.");
         *  return;
         * }
         *
         * board.RotateQuadrant(this, quadrantIndex, direction);
         */
    }
Exemple #3
0
    // Attempt to visually rotate the quadrant in the game world and execute a ActionRotateQuadrant action on the Game.
    public void RotateQuadrant(IPlayer player, int quadrantIndex, ROTATE_DIRECTION direction)
    {
        // TODO: Replace check when IPlayer components are working
        //Debug.Assert(player != null, "Reference to player that is attempting the move is required.");

        if (!gameInProgress)
        {
            return;
        }

        if (actionInProgress)
        {
            return;
        }

        StartCoroutine(RotateQuadrantCoroutine(quadrantIndex, direction));
    }
Exemple #4
0
    // Visually roatate quadrant
    private IEnumerator RotateQuadrantVisual(int quadrantIndex, ROTATE_DIRECTION direction)
    {
        var quadrantRotator = quadrants[quadrantIndex].GetComponent <IQuadrantRotator>();

        switch (direction)
        {
        case ROTATE_DIRECTION.CLOCKWISE:
            quadrantRotator.RotateClockwise();
            break;

        case ROTATE_DIRECTION.COUNTERCLOCKWISE:
            quadrantRotator.RotateCounterClockwise();
            break;
        }

        while (quadrantRotator.IsBusyRotating())
        {
            yield return(null);
        }
    }
Exemple #5
0
    private IEnumerator RotateQuadrantCoroutine(int quadrantIndex, ROTATE_DIRECTION direction)
    {
        actionInProgress = true;

        var action = new ActionRotateQuadrant(quadrantIndex, direction);

        if (!action.IsValid(game.GetState()))
        {
            Debug.Log(game.GetState().currentPlayer.ToString() + " attempted to illegaly rotate a quadrant.");
            onIllegalQuadrantRotation?.Invoke();
            actionInProgress = false;
            yield break;
        }

        PlaceMarbleHidePreview();

        yield return(StartCoroutine(RotateQuadrantVisual(quadrantIndex, direction)));

        game.ExecuteAction(action);

        actionInProgress = false;
    }
Exemple #6
0
 [Command] // This function is called from a single client and is executed on the server
 void CmdRotateQuadrant(int quadrantIndex, ROTATE_DIRECTION direction)
 {
     RpcRotateQuadrant(quadrantIndex, direction);
 }
    public void ExecuteRotateQuadrant(int quadrantIndex, ROTATE_DIRECTION direction)
    {
        Debug.Assert(board != null, "Board reference required.");

        board.RotateQuadrant(this, quadrantIndex, direction);
    }
 public ActionRotateQuadrant(int quadrantIndex, ROTATE_DIRECTION rotateDirection)
 {
     this.quadrantIndex   = quadrantIndex;
     this.rotateDirection = rotateDirection;
 }