Ejemplo n.º 1
0
        private void currAIPlayerTurn(ePlayerStatus i_CurrPlayerStatus, int i_CurrRow, int i_CurrCol, int i_NextRow, int i_NextCol)
        {
            bool      isContinuousJump = false;
            eMoveList moveType;
            int       currRow = i_CurrRow, currCol = i_CurrCol, nextRow = i_NextRow, nextCol = i_NextCol;

            //// game gets stuck on generating valid AI move, if valid AI move was to be returned then the game would continue as planned
            moveType = returnValidAIMove(ref currRow, ref currCol, ref nextRow, ref nextCol);

            if (i_CurrPlayerStatus == ePlayerStatus.MustJump || isContinuousJump == true)
            {
                if (moveType.ToString().Contains("Jump"))
                {
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update
                    i_CurrPlayerStatus = checkAvailableMoves();                                                                                                                        // check if continuous jumps are available
                    m_ChessPieceMoved.Invoke();

                    if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                    {
                        turnEnd();
                        isContinuousJump = false;
                    }
                    else
                    {
                        isContinuousJump = true;
                        m_CurrJumpRow    = nextRow;
                        m_CurrJumpCol    = nextCol;
                    }
                }
                else if (isContinuousJump == false)
                {
                    if (moveType.ToString().Contains("Jump"))
                    {
                        m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update

                        m_ChessPieceMoved.Invoke();

                        i_CurrPlayerStatus = checkAvailableMoves(); // check if continuous jumps are available

                        if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                        {
                            turnEnd();
                        }
                    }
                }
            }
            else
            {
                //// regular move, already received valid move
                if (moveType != eMoveList.Quit && moveType != eMoveList.InvalidMove)
                {
                    //// move/erase the checkers piece(s) after valid play
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType);
                    m_ChessPieceMoved.Invoke();
                    turnEnd();
                }
            }
        }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        xTimeCurrent = Time.time;

        // true = contatto con ground
        isGround = xController.isGrounded;

        // dimensione attuale del player
        xFuriaDimStart = xController.transform.localScale;
        // posizione attuale del player
        xFuriaPosition = xController.transform.position;


        // ** GROUND ********************************************
        if (isGround)
        {
            if ((xTimeStart == -1) || ((xTimeCurrent - xTimeStart) > 0.5))
            {
                PlayerStatus = ePlayerStatus.Ground;
            }
            xTimeStart = -1;
        }

        // ** JUMP ********************************************
        if (PlayerStatus == ePlayerStatus.Ground && Input.GetButtonDown("JUMP"))
        {
            xTimeStart   = -1;
            PlayerStatus = ePlayerStatus.Jump;
            xAnimator.Play("Player.JUMP", 0, 1f);
            xStaccoFX.Play();
            xAudioManager.Play("JUMP2", 0);
            xAudioManager.Play("URLO", 2f);
        }

        // ** FIRE ********************************************
        if (PlayerStatus == ePlayerStatus.Ground && Input.GetButtonDown("FIRE"))
        {
            xTimeStart   = xTimeCurrent;
            PlayerStatus = ePlayerStatus.Fire;
            xaggiunta    = this.transform.lossyScale;
            xposWeaponFX = new Vector3(this.transform.position.x + 1, this.transform.position.y + xaggiunta.y, BulletObject.transform.position.z);
            Bullet       = Instantiate(BulletObject, xposWeaponFX, BulletObject.transform.rotation);
            xAnimator.Play("Player.FIRE", 0, 0.1f);
            xAudioManager.Play("STACCO", 0);
            xAudioManager.Play("FIRE", 0.2f);
            xSmokeFX.Play();
            xGunShotFX.Play();
        }

        // ** FIRE ALTO ********************************************
        if (PlayerStatus == ePlayerStatus.Ground && Input.GetButtonDown("FIREALTO"))
        {
            //if (!ExplosionInstance)
            xTimeStart   = -1;
            PlayerStatus = ePlayerStatus.FireAlto;
            xStaccoFX.Play();
            xAnimator.Play("Player.FIREALTO", 0, 1f);
            xAudioManager.Play("STACCO", 0);
            xAudioManager.Play("FIREALTO", 0.9f);
            xaggiunta        = this.transform.lossyScale;
            FireAltoInstance = Instantiate(FireAltoObject, this.transform);
            xposWeaponFX     = new Vector3(FireAltoInstance.transform.position.x, FireAltoInstance.transform.position.y + (xaggiunta.y * -1f), FireAltoInstance.transform.position.z);
            FireAltoInstance.transform.position = xposWeaponFX;
        }

        // ** RELOAD ********************************************
        if (PlayerStatus == ePlayerStatus.Ground && Input.GetButtonDown("RELOAD"))
        {
            xTimeStart   = -1;
            PlayerStatus = ePlayerStatus.Reload;
            xAnimator.Play("Player.RELOAD", 0, 3f);
            xAudioManager.Play("STACCO", 0);
            xAudioManager.Play("RELOAD", 0.5f);
        }


        // ** FURIA********************************************
        if (PlayerStatus == ePlayerStatus.Ground)
        {
            if ((FuriaTimeStatus == -1) && (FuriaStatus == eFuriaStatus.NORMAL))
            {
                if (Input.GetButtonDown("FURIA"))
                {
                    xTimeStart      = -1;
                    FuriaTimeStatus = xTimeCurrent;
                    PlayerStatus    = ePlayerStatus.Furia;
                    xAnimator.Play("Player.FURIA", 0, 1f);
                    xAudioManager.Play("STACCO", 0);
                    xStaccoFX.Play();
                }
            }
        }
        // NORMAL --> BIG
        if ((FuriaTimeStatus != -1) && (FuriaStatus == eFuriaStatus.NORMAL))
        {
            if ((xTimeCurrent - FuriaTimeStatus) < FuriaTime)
            {
                if (xFuriaDimStart.y < 2.00000000001)
                {
                    xFuriaDimEnd = new Vector3(2f, 2f, 2f);
                    xController.transform.localScale += (xFuriaDimEnd * Time.deltaTime);
                }
                if (xFuriaPosition.x < -17)
                {
                    xMovement.x = 1f;
                    xController.Move(xMovement * Time.deltaTime);
                    //xController.transform.position += (xMovement * Time.deltaTime);
                }
            }
            else
            {
                FuriaTimeStatus = xTimeCurrent;
                FuriaStatus     = eFuriaStatus.BIG;
            }
        }
        // BIG --> NORMAL
        if ((FuriaTimeStatus != -1) && (FuriaStatus == eFuriaStatus.BIG))
        {
            if ((xTimeCurrent - FuriaTimeStatus) < (FuriaTime * 2))
            {
                if (xFuriaDimStart.y > 1.00000000001)
                {
                    xFuriaDimEnd = new Vector3(1f, 1f, 1f);
                    xController.transform.localScale -= (xFuriaDimEnd * Time.deltaTime);
                }
                if (xFuriaPosition.x > -22.33)
                {
                    xMovement.x = -1f;
                    xController.Move(xMovement * Time.deltaTime);
                    //xController.transform.position += (xMovement * Time.deltaTime);
                }
            }
            else
            {
                FuriaTimeStatus = -1;
                FuriaStatus     = eFuriaStatus.NORMAL;
            }
        }


        // ** FIRE3 ********************************************



        // sposto leggermente in su per staccarlo dal ground..il primo frame
        if (PlayerStatus != ePlayerStatus.Ground)
        {
            yMovement.y = 0.01f;
            xController.Move(yMovement);
        }


        // se indietro (per esempio urtando nuvola)
        // lo riporto al solito posto
        if (xFuriaPosition.x < -22.33f)
        {
            xMovement.x = 1f;
            xController.Move(xMovement * Time.deltaTime);
        }
    }
Ejemplo n.º 3
0
        private void currPlayerTurn(ePlayerStatus i_CurrPlayerStatus, int i_CurrRow, int i_CurrCol, int i_NextRow, int i_NextCol)
        {
            bool isContinuousJump = false;

            eMoveList moveType;
            int       currRow = i_CurrRow, currCol = i_CurrCol, nextRow = i_NextRow, nextCol = i_NextCol;

            moveType = returnValidMove(ref currRow, ref currCol, ref nextRow, ref nextCol); // get the user's move type (jump, move) if the input is invalid then returnValidMove loops until valid input is recieved

            //// must jump (also check continuous jump)
            if (i_CurrPlayerStatus == ePlayerStatus.MustJump || isContinuousJump == true)
            {
                if (moveType.ToString().Contains("Jump"))
                {
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType);
                    i_CurrPlayerStatus = checkAvailableMoves(); // check if continuous jumps are available
                    m_ChessPieceMoved.Invoke();

                    if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                    {
                        turnEnd();
                        isContinuousJump = false;
                    }
                    else
                    {
                        isContinuousJump = true;
                        m_CurrJumpRow    = nextRow;
                        m_CurrJumpCol    = nextCol;
                    }
                }
                else if (isContinuousJump == false)
                {
                    if (moveType.ToString().Contains("Jump"))
                    {
                        m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update

                        m_ChessPieceMoved.Invoke();

                        i_CurrPlayerStatus = checkAvailableMoves(); // check if continuous jumps are available

                        if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                        {
                            turnEnd();
                        }
                    }
                    else
                    {
                        MessageBox.Show("You must jump", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                //// regular move, already received valid move
                if (moveType != eMoveList.Quit && moveType != eMoveList.InvalidMove)
                {
                    //// move/erase the checkers piece(s) after valid play
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update
                    m_ChessPieceMoved.Invoke();
                    turnEnd();
                }
                else
                {
                    MessageBox.Show("Invalid Player Move", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            i_CurrPlayerStatus = checkAvailableMoves();

            if (i_CurrPlayerStatus == ePlayerStatus.UnableToMove)
            {
                PlayerLose();
            }
        }
Ejemplo n.º 4
0
        /*private void button1_Click(object sender, RoutedEventArgs e)
        {
            // Create a collection of points for a polygon
            Turn();
            
        }*/
        /// <summary>
        /// Makes the next valid turn
        /// </summary>
        public void Turn()
        {
            
            bool AllWon = true;
            /*
             * Bug No. 4
             */
            if ((DiceNo != 4 && DiceNo != 8) || NoMoreMoveFlag)
            {
                /*
                 * Bug No. 10
                 */
                for (uint i = 0; i < MaxPlayer; i++)
                {
                    if (ScoreCard[i] != 4)
                    {
                        AllWon = false;
                        break;
                    }

                }
                if (!AllWon)
                {
                    /*
                     * Bug No. 7
                     */
                    while (true)
                    {
                        /*
                         * Bug No. 12
                         */
                        TurnState = TurnState >= (MaxPlayer - 1) ? 0 : TurnState + 1;
                        if (ScoreCard[TurnState] != MaxKayi)
                            break;
                    }
                    Point Point1 = new Point(0 + (TurnState * 60), 40);
                    Point Point2 = new Point(10 + (TurnState * 60), 50);
                    Point Point3 = new Point(20 + (TurnState * 60), 40);
                    Point Point4 = new Point(0 + (TurnState * 60), 40);

                    if (TurnDisplayTri.Dispatcher.CheckAccess())
                    {
                        PointCollection polygonPoints = new PointCollection();
                        polygonPoints.Add(Point1);
                        polygonPoints.Add(Point2);
                        polygonPoints.Add(Point3);
                        polygonPoints.Add(Point4);
                        TurnDisplayTri.Points = polygonPoints;
                        TurnDisplayTri.Fill = TurnFill[TurnState];
                        TurnDisplayRect.Fill = TurnFill[TurnState];
                    }
                    else
                    {
                        TurnDisplayTri.Dispatcher.BeginInvoke((Action)delegate()
                        {
                            PointCollection PolygonPoints = new PointCollection();
                            PolygonPoints.Add(Point1);
                            PolygonPoints.Add(Point2);
                            PolygonPoints.Add(Point3);
                            PolygonPoints.Add(Point4);
                            TurnDisplayTri.Points = PolygonPoints;
                            TurnDisplayTri.Fill = TurnFill[TurnState];

                        }, null);

                        TurnDisplayRect.Dispatcher.BeginInvoke((Action)delegate()
                        {
                            TurnDisplayRect.Fill = TurnFill[TurnState];

                        }, null);
                    }
                    if (ServerConnectionStatus == (ushort)eServerConnectionStatus.CONNECTED)
                    {
                        if (TurnState != WhoIAm - 1)
                        {
                            PlayerStatus = ePlayerStatus.OthersTurn;
                            SendObject.ClientMessage = "TURN";
                            SendObject.KayiMove = 0;
                            SendObject.KayiNo = 0;
                            SendObject.TurnState = (byte)TurnState;
                            ws.Send(SendObject.ToJsonString());
                        }
                    }
                }
                else
                {
                    Display("All have won");
                    if (DiceBtn.Dispatcher.CheckAccess())
                        DiceBtn.IsEnabled = false;
                    else
                        DiceBtn.Dispatcher.Invoke((Action)delegate()
                        {
                            DiceBtn.IsEnabled = false;
                        }, null);
                }
            }
            
        }