Esempio n. 1
0
 public virtual bool IsDone()
 {
     foreach (MoveObject mover in moveObjects)
     {
         if (!mover.hasTraveledFullCycle)
         {
             return(false);
         }
     }
     ComplexTimer.Resume();
     return(ComplexTimer.IsAtEnd());
 }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
 void FixedUpdate()
 {
     if (GameManager.paused || GameManager.isInSceneTransition)
     {
         return;
     }
     if (moveSpeed != 0)
     {
         transform.position = Vector2.Lerp(transform.position, wayPoints[currentWaypoint].transform.position, moveSpeed * (1f / Vector2.Distance(transform.position, wayPoints[currentWaypoint].transform.position)));
     }
     if (rotateSpeed != 0)
     {
         transform.rotation = Quaternion.Slerp(transform.rotation, wayPoints[currentWaypoint].transform.rotation, rotateSpeed * (1f / Quaternion.Angle(transform.rotation, wayPoints[currentWaypoint].transform.rotation)));
     }
     if ((transform.position == wayPoints[currentWaypoint].transform.position || moveSpeed == 0) && (transform.up == wayPoints[currentWaypoint].transform.up || rotateSpeed == 0))
     {
         waitTimer.value.max = wayPoints[currentWaypoint].waitTime;
         waitTimer.Resume();
         if (waitTimer.IsAtEnd())
         {
             OnReachedWaypoint();
         }
     }
 }