public Pathfinder(Node start, Node target, GridManager gridManager, GridUnit unit) { startNode = start; endNode = target; grid = gridManager; this.unit = unit; }
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); }
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); }
public void StartMethod(GridUnit gridUnit) { if (!initialized) { OnStart(gridUnit); initialized = true; } }
protected override void OnStart(GridUnit gridUnit) { CursorManager.instance.SetToInteractionInitialized(); timer = gridUnit.animationClip.length; gridUnit.PlayAnimation(gridUnit.actionAnimation); gridUnit.Animator.SetBool("isInteracting", true); }
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(); } }
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 } }
public override void OnEnd(GridUnit gridUnit) { if (gridUnit.gameObject.layer == GridManager.ENEMY_UNITS_LAYER) { AiInitiatedBattle(gridUnit); } else { gridUnit.ClearInteractionData(); gridUnit.ActionIsDone(); } }
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); } }
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!"); } } }
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!"); } } }
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!"); } } }
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); }
public override void ActionDone(GridUnit gridUnit) { gridUnit.MovingToLocationCompleted(); }
protected override void OnStart(GridUnit gridUnit) { timer = 0.5f; gridUnit.PlayAnimation(gridUnit.actionAnimation); gridUnit.Animator.SetBool("isInteracting", true); }
public abstract void LoadAction(GridUnit gridUnit);
public override void OnEnd(GridUnit gridUnit) { gridUnit.ClearInteractionData(); gridUnit.ActionIsDone(); }
public abstract void ActionDone(GridUnit gridUnit);
public abstract bool TickIsFinished(GridUnit gridUnit, float deltaTime);
public abstract void OnEnd(GridUnit gridUnit);
protected abstract void OnStart(GridUnit gridUnit);
public override void ActionDone(GridUnit gridUnit) { gridUnit.InteractionCompleted(); }
public override void OnEnd(GridUnit gridUnit) { gridUnit.ActionIsDone(); }
public override void OnEnd(GridUnit gridUnit) { UnitController unitController = (UnitController)gridUnit; unitController.HitReceivedCompleted(); }
protected override void OnStart(GridUnit gridUnit) { timer = animationClip.length; gridUnit.PlayAnimation(animation); gridUnit.Animator.SetBool("isInteracting", true); }