예제 #1
0
    public virtual void SetMovement(int value)
    {
        movementValue = value;

        if (dirs[direction].GetComponent <checkAvailability>().available)
        {
            if (dirs[direction].GetComponent <checkAvailability>().touchingEnemy&& movementValue > 1)
            {
                // this code captures pieces like normal chess, which is boring

                //targetTile = dirs[direction].GetComponent<checkAvailability>().NearestTile();
                //Destroy(dirs[direction].GetComponent<checkAvailability>().enemyPiece.gameObject);
                //movementValue = 1;

                //if (GetComponent<Outline>() != null)
                //    Destroy(GetComponent<Outline>());
                //if (!tc.coroutineIsRunning)
                //    tc.StartCoroutine(tc.SwitchTurns());

                // THIS code captures pieces like dumb bad chess, which is fun as shit

                cc.playerPiece = this;
                cc.enemyPiece  = dirs[direction].GetComponent <checkAvailability>().enemyPiece.GetComponent <basePiece>();
                isClashing     = true;
                cc.EnterClash();
                source.PlayOneShot(clashClip);
            }
            else
            {
                targetTile = dirs[direction].GetComponent <checkAvailability>().NearestTile();
                movementValue--;
                jumping = true;

                if (movementValue <= 0)
                {
                    if (GetComponent <Outline>() != null)
                    {
                        Destroy(GetComponent <Outline>());
                    }
                    jumping = false;
                    if (!wc.hasCheckedForVictory)
                    {
                        wc.CheckForVictory();
                    }
                }
            }
        }
        else
        {
            movementValue = 0;

            if (GetComponent <Outline>() != null)
            {
                Destroy(GetComponent <Outline>());
            }
            jumping = false;
            if (!wc.hasCheckedForVictory)
            {
                wc.CheckForVictory();
            }
        }
    }