bool ReachedCheckPoint(pointDirection pointDirection) { if (direction == Vector3.forward && pointDirection.point.z + 0.05f <= this.transform.position.z) { return(true); } else if (direction == Vector3.left && pointDirection.point.x - 0.05f >= this.transform.position.x) { return(true); } else if (direction == Vector3.back && pointDirection.point.z - 0.05f >= this.transform.position.z) { return(true); } else if (direction == Vector3.right && pointDirection.point.x + 0.05f <= this.transform.position.x) { return(true); } return(false); }
private void Update() { if (!Manager.isGameOver) { if (path != null && path.Count > 0) { pointDir = path[0]; if (ReachedCheckPoint(pointDir)) { Debug.Log("Point is " + pointDir.point); direction = pointDir.direction; if (snakeFollow != null) { snakeFollow.addPath(path[0]); } path.RemoveAt(0); } } CheckDistance(); } //if (path.Count > 0 && CheckDistance()) //{ // if(Math.Round(path[0].z,2) == Math.Round(this.transform.position.z,2) && Math.Round(path[0].x,2) == Math.Round(this.transform.position.x,2)) // { // path.RemoveAt(0); // iTween.MoveUpdate(gameObject, path[0], 1f); // } // else // { // iTween.MoveUpdate(gameObject, path[0], 1); // } //} }
public void addPath(pointDirection point) { path.Add(point); }