public override void Cast(float delta, IntVector2 _targetIndex)
        {
            targetIndex = _targetIndex;
            List <GridCell> cells = PinnedShapes.GetPinnedCells(skill, taticalMovement.currentIndex, targetIndex);

            animationHandler.PlayTargetAnimation("ShieldCharge");
            characterRigidBody.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY;
            characterStats.UseAP(skill.APcost);

            foreach (GridCell cell in cells)
            {
                if (cell.occupyingObject != null && cell.occupyingObject != this.gameObject)
                {
                    target     = cell.occupyingObject;
                    targetCell = cell;
                    break;
                }
            }

            if (targetCell == null)
            {
                targetCell = cells[cells.Count - 1];
            }

            targetPos = targetCell.transform.position;
            targetCell.index.Print();
            targetDirection   = (targetPos - taticalMovement.currentCell.transform.position);
            targetDirection.y = 0f;
            targetDirection.Normalize();
            characterStats.transform.LookAt(targetPos);
        }
Beispiel #2
0
        public void HighlightCastableRange(IntVector2 playerOrigin, IntVector2 castOrigin, Skill skill)
        {
            List <GridCell> rangeCells = new List <GridCell>();
            List <GridCell> castRange  = new List <GridCell>();
            List <GridCell> outerRange = new List <GridCell>();

            switch (skill.castType)
            {
            case CastType.Free:
                rangeCells = CastableShapes.GetRangeCells(skill, playerOrigin);
                castRange  = CastableShapes.GetCastableCells(skill, castOrigin);
                outerRange = CastableShapes.CircularCells(playerOrigin, skill.castableSettings.radius + skill.castableSettings.range, skill.castableSettings.range + 1);
                break;

            case CastType.Pinned:
                rangeCells = new List <GridCell>();
                castRange  = PinnedShapes.GetPinnedCells(skill, playerOrigin, castOrigin);
                outerRange = PinnedShapes.CircularCells(skill, playerOrigin);
                break;
            }
            foreach (GridCell cell in outerRange)
            {
                if (!castRange.Contains(cell))
                {
                    cell.RemoveHighlight();
                }
            }

            foreach (GridCell cell in rangeCells)
            {
                cell.ApplyHighlight(castableValidPrefab, CellHighlightType.InRange);
                allHighlightedTiles.Add(cell.index);
            }
            if (castOrigin.GetDistance(playerOrigin) <= skill.castableSettings.range)
            {
                foreach (GridCell cell in castRange)
                {
                    cell.ApplyHighlight(castableHighlightPrefab, CellHighlightType.Castable);
                    allHighlightedTiles.Add(cell.index);
                }
            }
        }