예제 #1
0
파일: Snake.cs 프로젝트: akil03/bx
    public IEnumerator MoveToTurningPoint()
    {
        while (true)
        {
            //			if (!lastReachedGroundPiece)
            //				SnakesSpawner.instance.FixSpawnBug (this);

            if (lastReachedGroundPiece.IsBoundPiece())
            {
                //currentHP = 0;
                KillSnake(this);
                ReasonDeath = name + " decided to hit the wall !!";
                if (!PlayerPrefs.HasKey("TutorialComplete") && !isBot)
                {
                    GUIManager.instance.ShowTutorialLog(1, "Do not hit the wall !!", 3);
                }
                else
                {
                    GUIManager.instance.ShowLog(name + " decided to hit the wall !!", 3);
                }
            }

            if (currentHP == 0)
            {
                KillSnake(this);
                ReasonDeath = name + " got hit pretty badly !!";
                GUIManager.instance.ShowLog(name + " got hit pretty badly !!", 3);
            }
            if (haveToDie && !PhotonNetwork.inRoom)
            {
                print("kill by local");
                StartCoroutine(Die());
                break;
            }

            if (currentMoveDirection == -nextMoveDirection)
            {
                nextMoveDirection = currentMoveDirection;
                SwipeHandler.instance.isSwiped = false;
            }

            groundPieceToReach    = GetNewGroundPieceToReach();
            previousMoveDirection = currentMoveDirection;
            currentMoveDirection  = nextMoveDirection;
            Vector3 targetPos = groundPieceToReach.transform.position;
            targetPos.z = transform.position.z;
            while (transform.position != targetPos)
            {
                transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
                yield return(new WaitForEndOfFrame());
            }
            CheckReachedGroundPiece(groundPieceToReach);
            if (isBot)
            {
                AI.Notify(groundPieceToReach, isCollectingNewGroundPieces);
            }
            lastReachedGroundPiece = groundPieceToReach;
            yield return(new WaitForEndOfFrame());
        }
    }
예제 #2
0
파일: Snake.cs 프로젝트: akil03/BC
    public IEnumerator MoveToTurningPoint()
    {
        while (true)
        {
            if (lastReachedGroundPiece.IsBoundPiece())
            {
                haveToDie = true;
            }

            if (haveToDie)
            {
                StartCoroutine(Die());
                break;
            }

            if (currentMoveDirection == -nextMoveDirection)
            {
                nextMoveDirection = currentMoveDirection;
            }

            groundPieceToReach = GetNewGroundPieceToReach();

            previousMoveDirection = currentMoveDirection;
            currentMoveDirection  = nextMoveDirection;

            Vector3 targetPos = groundPieceToReach.transform.position;
            targetPos.z = transform.position.z;

            while (transform.position != targetPos)
            {
                transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
                yield return(new WaitForEndOfFrame());
            }

            CheckReachedGroundPiece(groundPieceToReach);

            if (isBot)
            {
                AI.Notify(groundPieceToReach, isCollectingNewGroundPieces);
            }

            lastReachedGroundPiece = groundPieceToReach;

            yield return(new WaitForEndOfFrame());
        }
    }
예제 #3
0
파일: Poly.cs 프로젝트: akil03/BC
    public static void SetReachableBlocks(GroundPiece groundPiece, Snake snake)
    {
        if (groundPiece.tempReachableState == true || groundPiece.collectingSnake == snake || groundPiece.IsBoundPiece())
        {
            return;
        }

        groundPiece.tempReachableState = true;

        try {
            SetReachableBlocks(groundPiece.GroundPieceOnOvest(), snake);
        } catch {
        }

        try {
            SetReachableBlocks(groundPiece.GroundPieceOnEst(), snake);
        } catch {
        }

        try {
            SetReachableBlocks(groundPiece.GroundPieceOnNorth(), snake);
        } catch {
        }

        try {
            SetReachableBlocks(groundPiece.GroundPieceOnSouth(), snake);
        } catch {
        }
    }