Ejemplo n.º 1
0
 public Pathfinder(Node start, Node target, GridManager gridManager, GridUnit unit)
 {
     startNode = start;
     endNode   = target;
     grid      = gridManager;
     this.unit = unit;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public void StartMethod(GridUnit gridUnit)
 {
     if (!initialized)
     {
         OnStart(gridUnit);
         initialized = true;
     }
 }
Ejemplo n.º 5
0
        protected override void OnStart(GridUnit gridUnit)
        {
            CursorManager.instance.SetToInteractionInitialized();

            timer = gridUnit.animationClip.length;
            gridUnit.PlayAnimation(gridUnit.actionAnimation);
            gridUnit.Animator.SetBool("isInteracting", true);
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 public void LoadAction(GridUnit gridUnit)
 {
     if (action != null)
     {
         action.LoadAction(gridUnit);
     }
     else
     {
         //Do something if can't perform action
     }
 }
Ejemplo n.º 9
0
 public override void OnEnd(GridUnit gridUnit)
 {
     if (gridUnit.gameObject.layer == GridManager.ENEMY_UNITS_LAYER)
     {
         AiInitiatedBattle(gridUnit);
     }
     else
     {
         gridUnit.ClearInteractionData();
         gridUnit.ActionIsDone();
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 12
0
 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!");
         }
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 14
0
 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!");
         }
     }
 }
Ejemplo n.º 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!");
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 17
0
 public override void ActionDone(GridUnit gridUnit)
 {
     gridUnit.MovingToLocationCompleted();
 }
Ejemplo n.º 18
0
 protected override void OnStart(GridUnit gridUnit)
 {
     timer = 0.5f;
     gridUnit.PlayAnimation(gridUnit.actionAnimation);
     gridUnit.Animator.SetBool("isInteracting", true);
 }
Ejemplo n.º 19
0
 public abstract void LoadAction(GridUnit gridUnit);
Ejemplo n.º 20
0
 public override void OnEnd(GridUnit gridUnit)
 {
     gridUnit.ClearInteractionData();
     gridUnit.ActionIsDone();
 }
Ejemplo n.º 21
0
 public abstract void ActionDone(GridUnit gridUnit);
Ejemplo n.º 22
0
 public abstract bool TickIsFinished(GridUnit gridUnit, float deltaTime);
Ejemplo n.º 23
0
 public abstract void OnEnd(GridUnit gridUnit);
Ejemplo n.º 24
0
 protected abstract void OnStart(GridUnit gridUnit);
Ejemplo n.º 25
0
 public override void ActionDone(GridUnit gridUnit)
 {
     gridUnit.InteractionCompleted();
 }
Ejemplo n.º 26
0
 public override void OnEnd(GridUnit gridUnit)
 {
     gridUnit.ActionIsDone();
 }
Ejemplo n.º 27
0
        public override void OnEnd(GridUnit gridUnit)
        {
            UnitController unitController = (UnitController)gridUnit;

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