private void LateUpdate()
    {
        switch (currentState)
        {
        case PlayerExplorationState.Exploring:
            if (Input.GetButtonDown("Submit"))
            {
                Vector2 direction = Vector2.zero;
                switch (heading)
                {
                case Heading.Down:
                    direction = Vector2.down;
                    break;

                case Heading.Left:
                    direction = Vector2.left;
                    break;

                case Heading.Right:
                    direction = Vector2.right;
                    break;

                case Heading.Up:
                    direction = Vector2.up;
                    break;
                }
                RaycastHit2D[] hits     = Physics2D.RaycastAll(gameObject.transform.position, direction, 2f);
                Dialogue       dialogue = null;
                foreach (RaycastHit2D hit in hits)
                {
                    dialogue = hit.collider.gameObject.GetComponent <Dialogue>();
                    if (dialogue != null)
                    {
                        break;
                    }
                }

                if (dialogue != null)
                {
                    if (dialogue.StartDialog(this))
                    {
                        PlayerFootstepEmitter.SetParameter("Speed", 0);
                        PlayerFootstepEmitter.SetParameter("Grass", 0);
                        animator.SetBool(Moving, false);
                        currentState = PlayerExplorationState.InTalking;
                    }

                    Loot loot = dialogue.GetComponent <Loot>();
                    if (loot && !loot.triggered)
                    {
                        Player.GetPlayer(0).Loot(loot);
                        loot.triggered = true;

                        dialogue.GetComponent <ChestAnimation>().SetChestStat(true);
                    }
                }
            }
            break;
        }
    }
 private void Update()
 {
     if (cam == null)
     {
         GetCamera();
         return;
     }
     switch (currentState)
     {
     case PlayerExplorationState.Exploring:
         if (Input.GetButtonDown("Start" + PlayerID))
         {
             CurrentState = PlayerExplorationState.InMenu;
         }
         else
         {
             transform.Translate(Time.deltaTime * walkSpeed * new Vector3(Input.GetAxis("Horizontal" + PlayerID), Input.GetAxis("Vertical" + PlayerID), 0));
         }
         break;
     }
 }
 public void EndCombat()
 {
     CurrentState = PlayerExplorationState.Exploring;
 }
    public void StartCombat(EnemyProxy enemy, bool isBoss = false)
    {
        CurrentState = PlayerExplorationState.InCombat;

        enemy.StartCombat(this, isBoss);
    }
 private void Start()
 {
     CurrentState = PlayerExplorationState.Exploring;
 }
    private void Update()
    {
        if (cam == null)
        {
            GetCamera();
            return;
        }
        if (PlayerFootstepEmitter == null)
        {
            var player = GameObject.FindGameObjectWithTag("Player");
            PlayerFootstepEmitter = player.GetComponent <FMODUnity.StudioEventEmitter>();
        }
        switch (currentState)
        {
        case PlayerExplorationState.Exploring:
            if (Input.GetButtonDown("Start"))
            {
                CurrentState = PlayerExplorationState.InMenu;
            }
            else
            {
                float horizontal = Input.GetAxisRaw("Horizontal");
                float vertical   = Input.GetAxisRaw("Vertical");
                animator.ResetTrigger("Right");
                animator.ResetTrigger("Left");
                animator.ResetTrigger("Up");
                animator.ResetTrigger("Down");
                if (Mathf.Abs(horizontal) > Mathf.Abs(vertical))
                {
                    vertical = 0;
                    if (horizontal > 0)
                    {
                        animator.SetTrigger(Right);
                        PlayerFootstepEmitter.SetParameter("Speed", 1);
                        heading = Heading.Right;
                    }
                    else if (horizontal < 0)
                    {
                        animator.SetTrigger(Left);
                        PlayerFootstepEmitter.SetParameter("Speed", 1);
                        heading = Heading.Left;
                    }
                    else
                    {
                        PlayerFootstepEmitter.SetParameter("Speed", 0);
                        PlayerFootstepEmitter.SetParameter("Grass", 0);
                    }
                }
                else
                {
                    horizontal = 0;
                    if (vertical > 0)
                    {
                        animator.SetTrigger(Up);
                        PlayerFootstepEmitter.SetParameter("Speed", 1);
                        heading = Heading.Up;
                    }
                    else if (vertical < 0)
                    {
                        animator.SetTrigger(Down);
                        PlayerFootstepEmitter.SetParameter("Speed", 1);
                        heading = Heading.Down;
                    }
                    else
                    {
                        PlayerFootstepEmitter.SetParameter("Speed", 0);
                        PlayerFootstepEmitter.SetParameter("Grass", 0);
                    }
                }
                Vector3 move = Time.deltaTime * walkSpeed * new Vector3(horizontal, vertical, 0);
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    move *= 2;
                }
                transform.Translate(move);
                animator.SetBool(Moving, move.magnitude > 0.01f);
            }

            break;

        default:
            PlayerFootstepEmitter.SetParameter("Speed", 0);
            PlayerFootstepEmitter.SetParameter("Grass", 0);
            break;
        }



        if (transform.position.x > 50)
        {
            //MusicManager.Instance.PlayMusic("field");
            emitter.SetParameter("Forest", 1);
            emitter.SetParameter("NormalTown", 0);
            emitter.SetParameter("RuinedTown", 0);
        }
        else if (transform.position.x < -50)
        {
            emitter.SetParameter("DarkDimension", 1);
            emitter.SetParameter("NormalTown", 0);
            emitter.SetParameter("RuinedTown", 0);
            //MusicManager.Instance.PlayMusic("AnotherWorldP");
        }
        else
        {
            if (GameProgressManager.instance.TownDestroyed)
            {
                //MusicManager.Instance.PlayMusic("RuinTown");
                var target = GameObject.Find("Fire");
                FMODUnity.StudioEventEmitter fire = target.GetComponent <FMODUnity.StudioEventEmitter>();
                fire.SetParameter("MixFire", 1);
                emitter.SetParameter("RuinedTown", 1);
                emitter.SetParameter("Forest", 0);
            }
            else
            {
                emitter.SetParameter("NormalTown", 1);
                emitter.SetParameter("Forest", 0);
            }
        }
    }
 private void Start()
 {
     CurrentState          = PlayerExplorationState.Exploring;
     PlayerFootstepEmitter = null;
     animator = GetComponent <Animator>();
 }
 public void ReturnToExploration()
 {
     CurrentState = PlayerExplorationState.Exploring;
 }
    public void StartCombat(EnemyProxy enemy, string desiredLevel)
    {
        CurrentState = PlayerExplorationState.InCombat;

        enemy.StartCombat(this, desiredLevel);
    }