示例#1
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        List <Hex> movementCandidates = new List <Hex>();

        //cast out a line in each direction from the player to determine movement spots
        foreach (Hex dir in Hex.Directions)
        {
            List <Hex> line = GridHelper.CastLineInDirection(GameplayContext.Grid,
                                                             GameplayContext.Player.Position, dir, moveDistance, includeStart: false);

            movementCandidates.AddRange(line);
        }



        // Show the locations to the player and let them pick one
        SingleHexResult moveLocation
            = GameplayContext.Ui.OfferSingleHexSelection(movementCandidates);

        // Wait until the player has made a selection or cancels the action
        yield return(new WaitUntil(moveLocation.IsReadyOrCancelled));

        // If the player didn't cancel the selection
        if (!moveLocation.WasCancelled())
        {
            // Move to the location they selected
            GameplayContext.Player.MoveTo(moveLocation.GetResult());
            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
示例#2
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        List <Hex> movementCandidates = new List <Hex>();



        //cast out a line in each direction from the player to determine movement spots
        foreach (Hex dir in Hex.Directions)
        {
            List <Hex> line = GridHelper.CastLineInDirection(GameplayContext.Grid,
                                                             GameplayContext.Player.Position, dir, range, includeStart: false);

            movementCandidates.AddRange(line);
            movementCandidates.Remove(GameplayContext.Player.Position);
        }



        // Show the locations to the player and let them pick one
        SingleHexResult moveLocation
            = GameplayContext.Ui.OfferSingleHexSelection(movementCandidates);

        // Wait until the player has made a selection or cancels the action
        yield return(new WaitUntil(moveLocation.IsReadyOrCancelled));

        // If the player didn't cancel the selection
        if (!moveLocation.WasCancelled())
        {
            Hex targetpoint = moveLocation.GetResult();

            //get all 6 hexes around that point
            List <Hex> pointsAroundTarget =
                GridHelper.GetHexesInRange(GameplayContext.Grid, targetpoint, 1, false);

            //add the point we clicked to that list, so we now have all 7 hexes
            pointsAroundTarget.Add(targetpoint);
            pointsAroundTarget.Remove(GameplayContext.Player.Position);

            //for each hex
            foreach (Hex spot in pointsAroundTarget)
            {
                //find who's standing there
                Entity victim = GameplayContext.Grid.GetEntityAtHex(spot);
                if (victim != null)
                {
                    //hurt them
                    GameplayContext.Player.DealDamageTo(victim, 5);
                    victim.ApplyStatusEffect(new StunStatusEffect());
                    GameplayContext.Player.TriggerAttackEvent(victim);
                }
            }

            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
示例#3
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        List <Hex> movementCandidates = new List <Hex>();

        //cast out a line in each direction from the player to determine movement spots
        foreach (Hex dir in Hex.Directions)
        {
            List <Hex> line = GridHelper.CastLineInDirection(GameplayContext.Grid,
                                                             GameplayContext.Player.Position, dir, moveDistance, false, false, true);

            GridHelper.RemoveOccupiedHexes(GameplayContext.Grid, line);

            movementCandidates.AddRange(line);
        }



        // Show the locations to the player and let them pick one
        SingleHexResult moveLocation
            = GameplayContext.Ui.OfferSingleHexSelection(movementCandidates);

        // Wait until the player has made a selection or cancels the action
        yield return(new WaitUntil(moveLocation.IsReadyOrCancelled));

        // If the player didn't cancel the selection
        if (!moveLocation.WasCancelled())
        {
            // Move to the location they selected
            Hex moveDirection = GameplayContext.Player.Position.GetDirectionTo(moveLocation.GetResult());
            Hex moveFrom      = GameplayContext.Player.Position;
            Hex movePosition  = moveLocation.GetResult();
            GameplayContext.Player.MoveTo(moveLocation.GetResult());
            int        spotsToHit  = moveFrom.DistanceTo(GameplayContext.Player.Position);
            List <Hex> spotsInPath = GridHelper.CastLineInDirection(GameplayContext.Grid, moveFrom, moveDirection, spotsToHit, false, false, true);
            spotsInPath.Remove(GameplayContext.Player.Position);
            foreach (Hex spot in spotsInPath)
            {
                if (GameplayContext.Grid.GetEntityAtHex(spot) is Entity hit)
                {
                    if (hit.HasStatusEffect(typeof(WetStatusEffect)))
                    {
                        GameplayContext.Player.DealDamageTo(hit, baseDamage * 2);
                        hit.ApplyStatusEffect(new StunStatusEffect());
                        GameplayContext.Player.TriggerAttackEvent(hit);
                    }
                    else
                    {
                        GameplayContext.Player.DealDamageTo(hit, baseDamage);
                    }
                }
            }
            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
示例#4
0
    private Hex GetNearestInlinePosition(Entity with)
    {
        List <Hex> inlinePositions = new List <Hex>();
        Entity     player          = GameplayContext.Player;
        HexGrid    grid            = GameplayContext.Grid;

        foreach (Hex dir in Hex.Directions)
        {
            List <Hex> line =
                GridHelper.CastLineInDirection(grid, player.Position, dir, range, includeStart: false);

            inlinePositions.AddRange(line);
        }

        return(GridHelper.GetNearestHexInList(inlinePositions, with.Position));
    }
示例#5
0
    private bool InlineWithPlayer(Entity with)
    {
        HexGrid grid = GameplayContext.Grid;

        bool canhit = false;

        foreach (Hex dir in Hex.Directions)
        {
            List <Hex> line = GridHelper.CastLineInDirection(grid, with.Position, dir, range,
                                                             includeHit: true);
            Hex end = line[line.Count - 1];
            if (grid.GetEntityAtHex(end) == GameplayContext.Player)
            {
                canhit = true;
                break;
            }
        }

        return(canhit);
    }