コード例 #1
0
        void EnterTheBattle(HeroController heroController, string targetScene)
        {
            InteractionHook interactionHook = SceneStateHandler.instance.InteractionHooks
                                              .Find(hook => hook.GetInstanceID() == heroController.currentInteractionHook.GetInstanceID());

            SceneStateHandler.instance.UpdateActiveState(interactionHook.transform.name);
            heroController.ClearInteractionData();

            GameReferencesManager.instance.PrepareInteractionUnit(unitItem, stackSize);
            GameReferencesManager.instance.LoadTargetScene(targetScene);
        }
コード例 #2
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!");
         }
     }
 }
コード例 #3
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!");
         }
     }
 }
コード例 #4
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!");
                }
            }
        }
コード例 #5
0
        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();
                    }
                }
            }
        }