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()); } }
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()); } }
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 { } }