void Start() { if (breakTimer == null) { breakTimer = GetComponentInChildren <ComplexTimer>(); } breakTimer.JumpToStart(); breakTimer.Pause(); }
public void OnReachedWaypoint() { waitTimer.Pause(); waitTimer.JumpToStart(); if (backTracking) { currentWaypoint--; } else { currentWaypoint++; } switch (moveType) { case MoveType.Once: if (currentWaypoint == wayPoints.Count) { hasTraveledFullCycle = true; currentWaypoint = wayPoints.Count - 1; } else if (currentWaypoint == -1) { hasTraveledFullCycle = true; currentWaypoint = 0; } return; case MoveType.Loop: if (currentWaypoint == wayPoints.Count) { currentWaypoint = 0; } else if (currentWaypoint == -1) { currentWaypoint = wayPoints.Count - 1; } return; case MoveType.PingPong: if (currentWaypoint == wayPoints.Count) { currentWaypoint -= 2; backTracking = !backTracking; hasTraveledFullCycle = true; } else if (currentWaypoint == -1) { currentWaypoint += 2; backTracking = !backTracking; hasTraveledFullCycle = true; } return; } }
public void DoUpdate() { if (GameManager.paused) { return; } shootDir = VectorExtensions.NULL; for (int i = Snake.instance.verticies.Count; i >= 0; i--) { snakeVertex = Snake.instance.GetVertexPosition(i); toSnakeVertex = snakeVertex - trs.position; trs.rotation = Quaternion.LookRotation(Vector3.forward, toSnakeVertex); laser.DoUpdate(); if (laser.hitBlocker.collider != null && laser.hitBlocker.transform.root == Snake.instance.trs) { shootDir = toSnakeVertex; line.SetPosition(1, Vector2.up * toSnakeVertex.magnitude); break; } } if (shootDir != (Vector2)VectorExtensions.NULL) { trs.rotation = Quaternion.LookRotation(Vector3.forward, shootDir); line.startColor = lockedOnColor; line.endColor = lockedOnColor; if (fireRate.IsAtEnd()) { fireRate.JumpToStart(); ObjectPool.Instance.Spawn(bulletPrefabIndex, trs.position, Quaternion.LookRotation(Vector3.forward, shootDir)); } } else { transform.rotation = Quaternion.LookRotation(Vector3.forward, Snake.instance.GetHeadPosition() - (Vector2)trs.position); line.startColor = searchingColor; line.endColor = searchingColor; } }