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 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 (gridUnit.gameObject.layer == GridManager.FRIENDLY_UNITS_LAYER) { 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); } } else { return(true); } } return(false); }
public void Equip(HeroController hero) { if (LogisticsBonus != 0) { hero.Logistics.AddModifier(new StatModifier(LogisticsBonus, StatModType.FLAT, this)); } if (LuckBonus != 0) { hero.Luck.AddModifier(new StatModifier(LuckBonus, StatModType.FLAT, this)); } if (AttackBonus != 0) { hero.Attack.AddModifier(new StatModifier(AttackBonus, StatModType.FLAT, this)); } if (DefenseBonus != 0) { hero.Defense.AddModifier(new StatModifier(DefenseBonus, StatModType.FLAT, this)); } if (LogisticsPercentBonus != 0) { hero.Logistics.AddModifier(new StatModifier(LogisticsPercentBonus, StatModType.PERCENT_MULT, this)); } if (LuckPercentBonus != 0) { hero.Luck.AddModifier(new StatModifier(LuckPercentBonus, StatModType.PERCENT_MULT, this)); } if (AttackPercentBonus != 0) { hero.Attack.AddModifier(new StatModifier(AttackPercentBonus, StatModType.PERCENT_MULT, this)); } if (DefensePercentBonus != 0) { hero.Defense.AddModifier(new StatModifier(DefensePercentBonus, StatModType.PERCENT_MULT, this)); } }
public override void InteractTick(WorldManager worldManager, RaycastHit hit) { InteractionHook ih = hit.transform.GetComponentInParent <InteractionHook>(); if (ih != null) { HeroController hero = ih.GetComponentInParent <HeroController>(); if (hero != null) { if (hero.gameObject.layer == GridManager.FRIENDLY_UNITS_LAYER) { if (ih.GetType() != typeof(HeroInteractionHook)) { return; } } } } ISelectable selectable = hit.transform.GetComponentInParent <ISelectable>(); if (selectable != null && selectable.GetGridUnit().gameObject.layer != GridManager.ENEMY_UNITS_LAYER) { if (GameManager.instance.Mouse.leftButton.isPressed) { if (selectable.GetGridUnit() != worldManager.currentHero && selectable.GetType() == typeof(HeroController)) { worldManager.currentHero = (HeroController)selectable.GetGridUnit(); UiManager.instance.OnHeroSelected(worldManager.currentHero); } } } else { if (worldManager.currentHero != null) { Node targetNode = GridManager.instance.GetNode(hit.point, worldManager.currentHero.GridIndex); if (targetNode != null && targetNode.IsWalkable()) { if (GameManager.instance.Mouse.leftButton.isPressed) { targetNode = GridManager.instance.GetNode(hit.point, worldManager.currentHero.GridIndex); if (worldManager.currentHero.IsInteractionPointBlank) { worldManager.currentHero.IsInteractionPointBlank = false; } worldManager.currentHero.PreviewPathToNode(targetNode); } if (PathfinderMaster.instance.StoredPath.Count > 0 && GameManager.instance.Keyboard.spaceKey.isPressed) { worldManager.currentHero.IsInteractionInitialized = true; if (hitLookAt != null) { Destroy(hitLookAt); } hitLookAt = Instantiate(worldManager.hitLookAtPrefab); hitLookAt.transform.position = hit.point; hitLookAt.SetActive(true); worldManager.ActivateLookAtActionCamera(hitLookAt.transform); worldManager.currentHero.InitializeMoveToInteractionContainer(targetNode); } } else { //if (ih == null) // CursorManager.instance.SetToUninteractable(); } } } }
public abstract void InteractTick(WorldManager worldManager, HeroController heroController);
public void InitializeEnemyHero(HeroController heroController) { hero = Instantiate(heroController.heroModel); hero.transform.SetParent(this.transform); hero.transform.localScale = Vector3.one; }