示例#1
0
 public Pathfinder(Node start, Node target, GridManager gridManager, GridUnit unit)
 {
     startNode = start;
     endNode   = target;
     grid      = gridManager;
     this.unit = unit;
 }
示例#2
0
        public override bool TickIsFinished(GridUnit gridUnit, float deltaTime)
        {
            timer -= deltaTime;
            Vector3 direction = (gridUnit.currentInteractionHook.transform.position - gridUnit.transform.position).normalized;

            direction.y = 0;
            Quaternion rotation = Quaternion.LookRotation(direction);

            gridUnit.transform.rotation = Quaternion.Slerp(gridUnit.transform.rotation, rotation, deltaTime / .3f);

            if (gridUnit.currentInteractionHook.interactionAnimation.Length != 0)
            {
                gridUnit.currentInteractionHook.PlayAnimation();
            }

            if (timer <= 0)
            {
                if (gridUnit.currentInteractionHook.particles != null)
                {
                    gridUnit.currentInteractionHook.DestroyParticles();
                }

                return(true);
            }
            return(false);
        }
示例#3
0
        public override bool TickIsFinished(GridUnit gridUnit, float deltaTime)
        {
            timer -= deltaTime;

            if (!dialogInitialized)
            {
                Vector3 direction = (gridUnit.currentInteractionHook.transform.position - gridUnit.transform.position).normalized;
                direction.y = 0;
                Quaternion rotation = Quaternion.LookRotation(direction);
                gridUnit.transform.rotation = Quaternion.Slerp(gridUnit.transform.rotation, rotation, deltaTime / .3f);
            }

            if (timer <= 0)
            {
                if (!dialogInitialized)
                {
                    HeroController heroController = (HeroController)gridUnit;
                    dialogPrompt = heroController.ReallyEnterTheBattlePrompt;

                    dialogPrompt.Show();
                    dialogPrompt.OnYesEvent += () => EnterTheBattle(heroController, targetScene);
                    dialogPrompt.OnNoEvent  += () => OnEnd(heroController);

                    dialogInitialized = true;
                }
                if (!dialogPrompt.gameObject.activeSelf)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#4
0
 public void StartMethod(GridUnit gridUnit)
 {
     if (!initialized)
     {
         OnStart(gridUnit);
         initialized = true;
     }
 }
示例#5
0
        protected override void OnStart(GridUnit gridUnit)
        {
            CursorManager.instance.SetToInteractionInitialized();

            timer = gridUnit.animationClip.length;
            gridUnit.PlayAnimation(gridUnit.actionAnimation);
            gridUnit.Animator.SetBool("isInteracting", true);
        }
示例#6
0
 public override void LoadAction(GridUnit gridUnit)
 {
     if (gridUnit != null)
     {
         //Could create default interaction then interaction itself could be one determinating
         //how unit will move etc.
         gridUnit.MoveToLocation();
     }
 }
示例#7
0
        void AiInitiatedBattle(GridUnit gridUnit)
        {
            HeroController heroController = (HeroController)gridUnit;

            heroController.ClearInteractionData();

            HeroInteractionHook hook = heroController.GetComponentInChildren <HeroInteractionHook>();

            GameReferencesManager.instance.PrepareInteractionWithHero(hook.Items);
            GameReferencesManager.instance.LoadTargetScene(targetScene);
        }
 public void LoadAction(GridUnit gridUnit)
 {
     if (action != null)
     {
         action.LoadAction(gridUnit);
     }
     else
     {
         //Do something if can't perform action
     }
 }
示例#9
0
 public override void OnEnd(GridUnit gridUnit)
 {
     if (gridUnit.gameObject.layer == GridManager.ENEMY_UNITS_LAYER)
     {
         AiInitiatedBattle(gridUnit);
     }
     else
     {
         gridUnit.ClearInteractionData();
         gridUnit.ActionIsDone();
     }
 }
示例#10
0
        void RotateTargetUnit(GridUnit gridUnit, float deltaTime)
        {
            UnitController targetUnit = gridUnit.currentInteractionHook.GetComponentInParent <UnitController>();

            if (targetUnit != null)
            {
                Vector3 direction = (gridUnit.transform.position - targetUnit.transform.position).normalized;
                direction.y = 0;
                Quaternion rotation = Quaternion.LookRotation(direction);

                targetUnit.transform.rotation = Quaternion.Slerp(targetUnit.transform.rotation, rotation, deltaTime / .3f);
            }
        }
示例#11
0
        public override bool TickIsFinished(GridUnit gridUnit, float deltaTime)
        {
            timer -= deltaTime;
            Vector3 direction = (initiator.transform.position - gridUnit.transform.position).normalized;

            direction.y = 0;
            Quaternion rotation = Quaternion.LookRotation(direction);

            gridUnit.transform.rotation = Quaternion.Slerp(gridUnit.transform.rotation, rotation, deltaTime / .3f);

            if (timer < 0)
            {
                return(true);
            }
            return(false);
        }
 public override void LoadAction(GridUnit gridUnit)
 {
     if (gridUnit != null)
     {
         InteractionHook ih = gridUnit.currentInteractionHook;
         if (ih != null)
         {
             ih.interaction = new WorldInteraction();
             gridUnit.StoreInteractionHook(ih);
             return;
         }
         else
         {
             Debug.Log("Ih is null!");
         }
     }
 }
示例#13
0
        public override void OnEnd(GridUnit gridUnit)
        {
            HeroController heroController = (HeroController)gridUnit;

            if (gridUnit.currentInteractionHook.Amount == 1)
            {
                heroController.Inventory.AddItem(gridUnit.currentInteractionHook.Item);
            }
            else
            {
                heroController.Inventory.AddItems(gridUnit.currentInteractionHook.Item, gridUnit.currentInteractionHook.Amount);
            }

            UiManager.instance.DisplayObtainedItem(gridUnit.currentInteractionHook);

            gridUnit.ActionIsDone();
        }
 public override void LoadAction(GridUnit gridUnit)
 {
     if (gridUnit != null)
     {
         InteractionHook ih = gridUnit.currentInteractionHook;
         if (ih != null)
         {
             ih.interaction = new SceneTriggerInteraction(targetScene, unitItem, stackSize);
             gridUnit.StoreInteractionHook(ih);
             return;
         }
         else
         {
             Debug.Log("Ih is null!");
         }
     }
 }
示例#15
0
        public override void LoadAction(GridUnit gridUnit)
        {
            if (gridUnit != null)
            {
                UnitController  unitController = (UnitController)gridUnit;
                InteractionHook ih             = gridUnit.currentInteractionHook;

                if (ih != null)
                {
                    //Basically always the same, since we just want to store interactionHook
                    if (unitController.AttackType.Equals(UnitAttackType.RANGED))
                    {
                        ih.interaction = new InitiateRangedAttack();
                    }
                    else if (unitController.AttackType.Equals(UnitAttackType.MELEE))
                    {
                        ih.interaction = new InitiateMeleeAttack();
                    }
                    else if (unitController.AttackType.Equals(UnitAttackType.MAGIC))
                    {
                        Debug.Log("Future magic attack");
                        //ih.interaction = new InitiateMagicAttack();
                    }
                    else
                    {
                        Debug.Log("Missing attack type!");
                    }

                    gridUnit.StoreInteractionHook(ih);
                    return;
                }
                else
                {
                    Debug.Log("Ih is null!");
                }
            }
        }
示例#16
0
        public override bool TickIsFinished(GridUnit gridUnit, float deltaTime)
        {
            timer -= deltaTime;

            RotateTargetUnit(gridUnit, deltaTime);

            Vector3 direction = (gridUnit.currentInteractionHook.transform.position - gridUnit.transform.position).normalized;

            direction.y = 0;
            Quaternion rotation = Quaternion.LookRotation(direction);

            gridUnit.transform.rotation = Quaternion.Slerp(gridUnit.transform.rotation, rotation, deltaTime / .3f);

            UnitController unitController = (UnitController)gridUnit;

            if (timer <= 0)
            {
                if (unitController.ProjectileHitTarget)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#17
0
 public override void ActionDone(GridUnit gridUnit)
 {
     gridUnit.MovingToLocationCompleted();
 }
示例#18
0
 protected override void OnStart(GridUnit gridUnit)
 {
     timer = 0.5f;
     gridUnit.PlayAnimation(gridUnit.actionAnimation);
     gridUnit.Animator.SetBool("isInteracting", true);
 }
示例#19
0
 public abstract void LoadAction(GridUnit gridUnit);
示例#20
0
 public override void OnEnd(GridUnit gridUnit)
 {
     gridUnit.ClearInteractionData();
     gridUnit.ActionIsDone();
 }
示例#21
0
 public abstract void ActionDone(GridUnit gridUnit);
示例#22
0
 public abstract bool TickIsFinished(GridUnit gridUnit, float deltaTime);
示例#23
0
 public abstract void OnEnd(GridUnit gridUnit);
示例#24
0
 protected abstract void OnStart(GridUnit gridUnit);
 public override void ActionDone(GridUnit gridUnit)
 {
     gridUnit.InteractionCompleted();
 }
示例#26
0
 public override void OnEnd(GridUnit gridUnit)
 {
     gridUnit.ActionIsDone();
 }
示例#27
0
        public override void OnEnd(GridUnit gridUnit)
        {
            UnitController unitController = (UnitController)gridUnit;

            unitController.HitReceivedCompleted();
        }
示例#28
0
 protected override void OnStart(GridUnit gridUnit)
 {
     timer = animationClip.length;
     gridUnit.PlayAnimation(animation);
     gridUnit.Animator.SetBool("isInteracting", true);
 }