Example #1
0
File: Snake.cs Project: 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());
        }
    }
Example #2
0
File: Snake.cs Project: 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());
        }
    }