Пример #1
0
    void FacePlayer()
    {
        Vector2 dif = GameManager.Instance.Player.transform.position - transform.position;

        forward = dif.normalized;
        myAnimator.SetInteger("Direction", (int)DirectionHandler.GetClosestDirection(dif));
    }
Пример #2
0
 void Dash()
 {
     state = ElementalState.Dash;
     trailDropTimer.Start();
     forward = Vector2.one.Rotate(Random.Range(0, 8) * 45);
     myAnimator.SetInteger("Direction", (int)DirectionHandler.GetClosestDirection(forward));
 }
Пример #3
0
    void ConnectRooms(Room one, Room two, bool onMainPath = true)
    {
        Directions         roomDirection = DirectionHandler.GetClosestDirection(two.DungeonPosition - one.DungeonPosition);
        RoomConnectionInfo rci           = new RoomConnectionInfo(roomDirection, onMainPath);

        one.AddConnection(rci);
        rci = new RoomConnectionInfo(DirectionHandler.GetOppositeDirection(roomDirection), true);
        two.AddConnection(rci);
    }
Пример #4
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Wall"))
     {
         Vector2 fwd = -forward;
         fwd     = fwd.Rotate(Random.Range(-2, 3) * 45);
         forward = fwd;
         myAnimator.SetInteger("Direction", (int)DirectionHandler.GetClosestDirection(forward));
     }
 }
Пример #5
0
    private void Awake()
    {
        myAnimator = GetComponent <Animator>();
        moveTimer  = new Timer(moveTime);

        moveTimer.OnComplete.AddListener(() =>
        {
            FacePlayer();
            travelDirection = Vector3.zero;
            pauseTimer.Start();
        });

        pauseTimer = new Timer(pauseTime);
        pauseTimer.OnComplete.AddListener(() =>
        {
            FacePlayer();
            FireProjectile();

            moveStyle = (MovementStyle)(Random.Range(1, 3));

            if (moveStyle == MovementStyle.Rotate)
            {
                rotationDirection = Random.Range(0, 1) * 2 - 1;
                travelDirection   = Vector2.down.RotateDeg(Random.Range(-4, 3) * 45);
                myAnimator.SetInteger("Direction", (int)DirectionHandler.GetClosestDirection(travelDirection));
            }
            else
            {
                travelDirection = Vector2.down.RotateDeg(Random.Range(0, 4) * 90);
                myAnimator.SetInteger("Direction", (int)DirectionHandler.GetClosestDirection(travelDirection));
            }
            moveTimer.Start();
        });


        moveStyle = MovementStyle.Rotate;
    }
Пример #6
0
 /// <summary>
 /// Gets the closest direction to the normal of this collision
 /// </summary>
 /// <param name="collision">The collision</param>
 /// <returns>The closest direction to the normal of this collision</returns>
 public static Directions GetClosestDirection(this Collision2D collision)
 {
     return(DirectionHandler.GetClosestDirection(collision.GetContact(0).normal));
 }