Beispiel #1
0
    /// <summary>
    /// Used to initialize any variables or game state before the game starts.
    /// </summary>
    void Awake()
    {
        Instance = this;

        Player1.Name = GameManager.Instance.Player1Name;
        Player2.Name = GameManager.Instance.Player2Name;
        Player1.PlayerControlMode = GameManager.Instance.Player1ControlMode;
        Player2.PlayerControlMode = GameManager.Instance.Player2ControlMode;
        IsCrawfordRuleEnabled     = GameManager.Instance.IsCrawfordRuleEnabled;
        IsMurphyRuleEnabled       = GameManager.Instance.IsMurphyRuleEnabled;
        Variant       = GameManager.Instance.BackgammonVariant;
        PlayMode      = GameManager.Instance.BackgammonPlayMode;
        MatchScore    = GameManager.Instance.MatchScore;
        InitialStakes = GameManager.Instance.InitialStakes;

        if (IsMultiplayerGame)
        {
            m_Client = FindObjectOfType <BackgammonClient>();
        }
    }
 /// <summary>
 /// Sets the Backgammon game variant with the specified int value.
 /// </summary>
 /// <param name="gameMode"></param>
 public void SetBackgammonVariant(int backgammonVariant)
 {
     m_BackgammonVariant = (BackgammonVariants)backgammonVariant;
 }
Beispiel #3
0
    /// <summary>
    /// Sets up the players' checkers according to the specified Backgammon game variant.
    /// </summary>
    /// <param name="gameMode"></param>
    /// <param name="player1"></param>
    /// <param name="player2"></param>
    public void SetupCheckers(BackgammonVariants gameMode, Player player1, Player player2)
    {
        foreach (Point point in Points)
        {
            point.Clear();
        }

        HomeP1.Clear();
        HomeP2.Clear();
        JailP1.Clear();
        JailP2.Clear();

        switch (gameMode)
        {
        case (BackgammonVariants.Standard):
        {
            Points[(int)BGPointID.Point24].PlaceInstantly(player1.Checkers[0]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player1.Checkers[1]);
            Points[(int)BGPointID.Point13].PlaceInstantly(player1.Checkers[2]);
            Points[(int)BGPointID.Point13].PlaceInstantly(player1.Checkers[3]);
            Points[(int)BGPointID.Point13].PlaceInstantly(player1.Checkers[4]);
            Points[(int)BGPointID.Point13].PlaceInstantly(player1.Checkers[5]);
            Points[(int)BGPointID.Point13].PlaceInstantly(player1.Checkers[6]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[7]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[8]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[9]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[10]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[11]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[12]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[13]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[14]);

            Points[(int)BGPointID.Point1].PlaceInstantly(player2.Checkers[0]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player2.Checkers[1]);
            Points[(int)BGPointID.Point12].PlaceInstantly(player2.Checkers[2]);
            Points[(int)BGPointID.Point12].PlaceInstantly(player2.Checkers[3]);
            Points[(int)BGPointID.Point12].PlaceInstantly(player2.Checkers[4]);
            Points[(int)BGPointID.Point12].PlaceInstantly(player2.Checkers[5]);
            Points[(int)BGPointID.Point12].PlaceInstantly(player2.Checkers[6]);
            Points[(int)BGPointID.Point17].PlaceInstantly(player2.Checkers[7]);
            Points[(int)BGPointID.Point17].PlaceInstantly(player2.Checkers[8]);
            Points[(int)BGPointID.Point17].PlaceInstantly(player2.Checkers[9]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[10]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[11]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[12]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[13]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[14]);
        }
        break;

        case (BackgammonVariants.SuddenDeath):
        {
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[0]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[1]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[2]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[3]);
            Points[(int)BGPointID.Point3].PlaceInstantly(player1.Checkers[4]);
            Points[(int)BGPointID.Point3].PlaceInstantly(player1.Checkers[5]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[6]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[7]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[8]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[9]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[10]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[11]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[12]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[13]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[14]);

            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[0]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[1]);
            Points[(int)BGPointID.Point23].PlaceInstantly(player2.Checkers[2]);
            Points[(int)BGPointID.Point23].PlaceInstantly(player2.Checkers[3]);
            Points[(int)BGPointID.Point22].PlaceInstantly(player2.Checkers[4]);
            Points[(int)BGPointID.Point22].PlaceInstantly(player2.Checkers[5]);
            Points[(int)BGPointID.Point21].PlaceInstantly(player2.Checkers[6]);
            Points[(int)BGPointID.Point21].PlaceInstantly(player2.Checkers[7]);
            Points[(int)BGPointID.Point20].PlaceInstantly(player2.Checkers[8]);
            Points[(int)BGPointID.Point20].PlaceInstantly(player2.Checkers[9]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[10]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[11]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[12]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[13]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[14]);
        }
        break;

        case (BackgammonVariants.Rush):
        {
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[0]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[1]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[2]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[3]);
            Points[(int)BGPointID.Point3].PlaceInstantly(player1.Checkers[4]);
            Points[(int)BGPointID.Point3].PlaceInstantly(player1.Checkers[5]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[6]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[7]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[8]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[9]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[10]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[11]);
            Points[(int)BGPointID.Point18].PlaceInstantly(player1.Checkers[12]);
            Points[(int)BGPointID.Point17].PlaceInstantly(player1.Checkers[13]);
            Points[(int)BGPointID.Point16].PlaceInstantly(player1.Checkers[14]);

            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[0]);
            Points[(int)BGPointID.Point24].PlaceInstantly(player2.Checkers[1]);
            Points[(int)BGPointID.Point23].PlaceInstantly(player2.Checkers[2]);
            Points[(int)BGPointID.Point23].PlaceInstantly(player2.Checkers[3]);
            Points[(int)BGPointID.Point22].PlaceInstantly(player2.Checkers[4]);
            Points[(int)BGPointID.Point22].PlaceInstantly(player2.Checkers[5]);
            Points[(int)BGPointID.Point21].PlaceInstantly(player2.Checkers[6]);
            Points[(int)BGPointID.Point21].PlaceInstantly(player2.Checkers[7]);
            Points[(int)BGPointID.Point20].PlaceInstantly(player2.Checkers[8]);
            Points[(int)BGPointID.Point20].PlaceInstantly(player2.Checkers[9]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[10]);
            Points[(int)BGPointID.Point19].PlaceInstantly(player2.Checkers[11]);
            Points[(int)BGPointID.Point7].PlaceInstantly(player2.Checkers[12]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player2.Checkers[13]);
            Points[(int)BGPointID.Point9].PlaceInstantly(player2.Checkers[14]);
        }
        break;

        case (BackgammonVariants.Test1):
        {
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[0]);
            Points[(int)BGPointID.Point1].PlaceInstantly(player1.Checkers[1]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[2]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[3]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[4]);
            Points[(int)BGPointID.Point2].PlaceInstantly(player1.Checkers[5]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[6]);
            Points[(int)BGPointID.Point4].PlaceInstantly(player1.Checkers[7]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[8]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[9]);
            Points[(int)BGPointID.Point5].PlaceInstantly(player1.Checkers[10]);
            Points[(int)BGPointID.Point6].PlaceInstantly(player1.Checkers[11]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[12]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[13]);
            Points[(int)BGPointID.Point8].PlaceInstantly(player1.Checkers[14]);

            HomeP2.PlaceInstantly(player2.Checkers[0]);
            HomeP2.PlaceInstantly(player2.Checkers[1]);
            HomeP2.PlaceInstantly(player2.Checkers[2]);
            HomeP2.PlaceInstantly(player2.Checkers[3]);
            HomeP2.PlaceInstantly(player2.Checkers[4]);
            HomeP2.PlaceInstantly(player2.Checkers[5]);
            HomeP2.PlaceInstantly(player2.Checkers[6]);
            HomeP2.PlaceInstantly(player2.Checkers[7]);
            HomeP2.PlaceInstantly(player2.Checkers[8]);
            HomeP2.PlaceInstantly(player2.Checkers[9]);
            HomeP2.PlaceInstantly(player2.Checkers[10]);
            HomeP2.PlaceInstantly(player2.Checkers[11]);
            HomeP2.PlaceInstantly(player2.Checkers[12]);
            HomeP2.PlaceInstantly(player2.Checkers[13]);
            Points[(int)BGPointID.Point21].PlaceInstantly(player2.Checkers[14]);
        }
        break;
        }
    }