Пример #1
0
        public static void Activate(CharacterStats characterStats, AnimationHandler animationHandler, TaticalMovement taticalMovement, Skill skill, float delta)
        {
            IntVector2 index = taticalMovement.GetMouseIndex();

            GridManager.Instance.HighlightCastableRange(taticalMovement.currentIndex, index, skill);
            int distance = taticalMovement.GetRequiredMoves(index, taticalMovement.path);

            if (index.x >= 0 && characterStats.currentAP >= skill.APcost)
            {
                if (Input.GetMouseButtonDown(0) || InputHandler.instance.tacticsXInput)
                {
                    InputHandler.instance.tacticsXInput = false;

                    animationHandler.PlayTargetAnimation("Attack");
                    characterStats.UseAP(skill.APcost);
                    GridManager.Instance.RemoveAllHighlights();
                    List <GridCell> cells = CastableShapes.GetCastableCells(skill, index);
                    foreach (GridCell cell in cells)
                    {
                        AlchemyManager.Instance.ApplyLiquid(cell.alchemyState, LiquidPhaseState.Oil);
                    }
                }
            }
        }
        public override void Act(float delta)
        {
            if (target == null)
            {
                List <(PlayerManager, int)> playersHealthList = new List <(PlayerManager, int)>();
                foreach (PlayerManager player in GameManager.instance.playersDict.Values.ToArray())
                {
                    List <IntVector2> targetsPath = NavigationHandler.instance.GetPath(taticalMovement.currentTargetsNavDict,
                                                                                       player.taticalMovement.currentIndex, taticalMovement.currentIndex);

                    int distance = taticalMovement.GetRequiredMoves(player.taticalMovement.currentIndex, targetsPath);

                    if (distance != -1 && player.characterStats.currentHealth > 0)
                    {
                        Debug.Log("Checking Player" + player.characterStats.characterName);
                        playersHealthList.Add((player, player.characterStats.currentHealth));
                    }
                }

                playersHealthList.Sort((c1, c2) => c1.Item2.CompareTo(c2.Item2));

                //set the target destination
                for (int i = 0; i < playersHealthList.Count; i++)
                {
                    target = playersHealthList[i].Item1;
                    IntVector2        targetIndex = target.taticalMovement.currentIndex;
                    List <IntVector2> targetPath  = NavigationHandler.instance.GetPath(taticalMovement.currentTargetsNavDict,
                                                                                       targetIndex, taticalMovement.currentIndex);
                    if (taticalMovement.GetRequiredMoves(targetIndex, targetPath) <= characterStats.currentAP)
                    {
                        targetPath.RemoveAt(targetPath.Count - 1);
                        taticalMovement.path = targetPath;
                        int targetDistance = taticalMovement.GetRequiredMoves(targetIndex, taticalMovement.path);
                        taticalMovement.SetTargetDestination(targetPath[targetPath.Count - 1], targetDistance);
                        return;
                    }
                }

                target = playersHealthList[0].Item1;
                List <IntVector2> secondaryPath = NavigationHandler.instance.GetPath(taticalMovement.currentTargetsNavDict,
                                                                                     target.taticalMovement.currentIndex, taticalMovement.currentIndex);
                taticalMovement.SetTargetDestination(secondaryPath[characterStats.currentAP - 1], characterStats.currentAP);
            }

            else
            {
                if (taticalMovement.transform.position == taticalMovement.moveLocation)
                {
                    DestinationReached = true;
                }

                if (DestinationReached)
                {
                    if (characterStats.currentAP > 0 && GameManager.instance.gameState == GameState.Ready)
                    {
                        if (target.characterStats.currentHealth <= 0)
                        {
                            target = null;
                            taticalMovement.SetCurrentNavDict();
                        }
                    }
                }

                else
                {
                    taticalMovement.TraverseToDestination(delta);
                }
            }
        }