Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (Vector2.Distance(_destiny, transform.position) < 0.2 && _stop)
     {
         _movement = Vector3.zero;
         _stop     = false;
     }
     else
     {
         if (_inCombat)
         {
             if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
             {
                 var touchLocation = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                 if (Vector2.Distance(touchLocation, _monster.transform.position) < .7f)
                 {
                     _actionHandler.AttackMonster();
                 }
                 else
                 {
                     SetMovement(touchLocation);
                 }
             }
         }
         //todo: Debug: Use keyboard
         Vector3 keyboardUse = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
         if (keyboardUse != Vector3.zero)
         {
             _movement = keyboardUse;
         }
     }
     //Change Sprite or Animation according to the direction of moving
     if (_playerCharacter.IsAnimated)
     {
         HandleAnimation(_movement);
     }
     else
     {
         HandleSprite(_movement);
     }
 }