Exemplo n.º 1
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        //get a list of adjacent entities
        List <Entity> adjacentEnts = GridHelper.GetAdjacentEntities(GameplayContext.Grid,
                                                                    GameplayContext.Player.Position);

        //let the player select one of the adjacent entities
        SingleEntityResult target =
            GameplayContext.Ui.OfferSingleEntitySelection(adjacentEnts);

        //wait for the player to make a selection
        yield return(new WaitUntil(target.IsReadyOrCancelled));

        // If the player didn't cancel the selection
        if (!target.WasCancelled())
        {
            //hit 'em
            Entity victim = target.GetResult();
            GameplayContext.Player.DealDamageTo(victim, baseDamage);
            GameplayContext.Player.TriggerAttackEvent(victim);

            FXHelper.PlaySound("MetalHit");

            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
Exemplo n.º 2
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        Hex pos = GameplayContext.Player.Position;

        //TODO: replace this with a line of sight check maybe?
        List <Entity> targets =
            GridHelper.GetEntitiesInRange(GameplayContext.Grid, pos, range);

        //don't let the player shoot themselves
        targets.Remove(GameplayContext.Player);

        SingleEntityResult target = GameplayContext.Ui.OfferSingleEntitySelection(targets);

        yield return(new WaitUntil(target.IsReadyOrCancelled));

        if (!target.WasCancelled())
        {
            Entity victim = target.GetResult();
            GameplayContext.Player.DealDamageTo(victim, baseDamage);
            GameplayContext.Player.TriggerAttackEvent(victim);

            FXHelper.FireTracerBetween(GameplayContext.Player, victim);
            FXHelper.PlaySound("rifleShot");
            FXHelper.PlaySound(victim.rangedHitSoundName, 0.1f);

            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
Exemplo n.º 3
0
    public override IEnumerator CardBehaviour(CardActionResult outcome)
    {
        // Get the list of possible locations to move to
        List <Hex> movementCandidates =
            GridHelper.GetHexesInRange(GameplayContext.Grid, GameplayContext.Player.Position,
                                       moveDistance);

        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())
        {
            // Move to the location they selected
            GameplayContext.Player.MoveTo(moveLocation.GetResult());
            FXHelper.PlaySound("MechStep");
            outcome.Complete();
        }
        else
        {
            outcome.Cancel();
        }
    }
Exemplo n.º 4
0
    public void MoveAlong(List <Hex> path, int maxSteps = int.MaxValue,
                          Action callback = null, string stepSound = "MechStep")
    {
        int step = 0;

        maxSteps = Math.Min(maxSteps, path.Count);
        LTSeq stepSequence = LeanTween.sequence();
        Hex   pos          = Position;

        while (step < maxSteps)
        {
            pos = path[step];
            if (stepSound != "")
            {
                stepSequence.append(() => { FXHelper.PlaySound(stepSound); });
            }
            stepSequence.append(LeanTween.moveLocal(gameObject, Grid.GetWorldPosition(pos), 0.25f).setEaseInOutQuart());
            step++;
        }
        Position = pos;

        if (callback != null)
        {
            stepSequence.append(callback);
        }
    }
Exemplo n.º 5
0
    public void Do(Entity with)
    {
        with.DealDamageTo(GameplayContext.Player, baseDamage);
        with.TriggerAttackEvent(GameplayContext.Player);
        LeanTween.moveLocal(with.gameObject, GameplayContext.Player.transform.position, 0.1f)
        .setEaseInCubic().setLoopPingPong(1);

        FXHelper.PlaySound(attackSound);

        LeanTween.delayedCall(0.2f, () =>
        {
            OnActionFinish?.Invoke();
            OnActionFinish = null;
        });
    }
Exemplo n.º 6
0
    public void Do(Entity with)
    {
        List <Hex> path = GridHelper.GetPathToHex(GameplayContext.Grid, with.Position,
                                                  GameplayContext.Player.Position);

        path.Remove(GameplayContext.Player.Position);

        //this is gross, it works but make it cleaner later
        with.MoveAlong(path, maxSteps: range, callback: () => {
            with.DealDamageTo(GameplayContext.Player, baseDamage);
            with.TriggerAttackEvent(GameplayContext.Player);
            LeanTween.moveLocal(with.gameObject, GameplayContext.Player.transform.position, 0.1f)
            .setEaseInCubic().setLoopPingPong(1);

            FXHelper.PlaySound("MetalHit");

            LeanTween.delayedCall(0.2f, () =>
            {
                OnActionFinish?.Invoke();
                OnActionFinish = null;
            });
        });
    }
Exemplo n.º 7
0
 public static void PlaySound(string soundName, float delay)
 {
     LeanTween.delayedCall(delay, () => { FXHelper.PlaySound(soundName); });
 }