예제 #1
0
 protected virtual bool AttackUpdate()
 {
     time += Time.smoothDeltaTime;
     if (time > 1f)
     {
         animator.SetFloat("AttackTime", 2f);
         character = CharacterManager.Singleton.GetCharacterByPositon(Utils.GetPositonByDirction(currentPosition, currentDirction));
         if (character != null)
         {
             PerformAttack();
             if (character != null)
             {
                 if (character.IsHero)
                 {
                     SceneManager.Singleton.MainCameraShake(0f, 0.5f);
                 }
                 else
                 {
                     OtherActionQueue.Enqueue(character.BeAttack);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
예제 #2
0
 public void SetQueueByActionType(ActionType type)
 {
     if ((int)type <= 4)
     {
         MoveActionQueue.Enqueue(GetFuncByActionType(type));
     }
     else
     {
         OtherActionQueue.Enqueue(GetFuncByActionType(type));
     }
 }
예제 #3
0
    protected virtual bool LimitSkillUpdate()
    {
        if (Utils.IsReachEndPosByDirection(go.transform.localPosition, endPos, currentDirction))
        {
            if (!hasSet)
            {
                go.transform.localPosition = endPos;
                animator.speed             = 1f;
                hasSet = true;
            }

            time += Time.smoothDeltaTime;
            if (time > 1f)
            {
                ShowLimitSkill();
                SceneManager.Singleton.DelayCall(0.5f, () => {
                    limitSkill.gameObject.SetActive(false);
                });
                animator.SetFloat("AttackTime", 2f);
                if (character != null)
                {
                    PerformAttack();
                    if (character != null)
                    {
                        if (character.IsHero)
                        {
                            SceneManager.Singleton.MainCameraShake(0f, 0.5f);
                        }
                        else
                        {
                            OtherActionQueue.Enqueue(character.BeAttack);
                            if (DungeonManager.Singleton.CurrentDungeon.CanMove(currentDirction, character.currentPosition))
                            {
                                Position position = Utils.GetPositonByDirction(character.currentPosition, currentDirction);
                                character.go.transform.localPosition = Utils.GetPosByPositon(character.go.transform.localPosition, position - character.currentPosition);
                                character.currentPosition            = position;
                            }
                        }
                    }
                }
                return(true);
            }
        }
        else
        {
            go.transform.localPosition += Utils.GetDirVectorByCharacterDirction(currentDirction) * Time.smoothDeltaTime * 8f * Utils.TILE_SIZE;
        }

        return(false);
    }
예제 #4
0
    public void WhatToDo(Position heroPositon, Position myPosition)
    {
        ClearQueue();

        if (!(heroPositon - myPosition < sightArea))
        {
            SetQueueByActionType((ActionType)UnityEngine.Random.Range(1, 5));
            return;
        }

        Debug.LogWarning("myPosition row: " + myPosition.row + " col: " + myPosition.col);
        Debug.LogWarning("heroPositon row: " + heroPositon.row + " col: " + heroPositon.col);

        if (Utils.IsInAttackRange(myPosition, heroPositon))
        {
            OtherActionQueue.Enqueue(Attack);
            return;
        }

        ActionType type = (ActionType)DungeonManager.Singleton.CurrentDungeon.GetNextDirection(myPosition);

        SetQueueByActionType(type);
    }
예제 #5
0
 public void ClearQueue()
 {
     MoveActionQueue.Clear();
     OtherActionQueue.Clear();
 }