Exemplo n.º 1
0
 private void WriteHealth(CombatEncounter c)
 {
     if (c.enemy.isDead)
     {
         return;
     }
     GameEngine.game.AppendText($"{c.enemy.name} : {c.enemy.currentHealth}");
 }
        public static CombatEncounter GenerateEncounter()
        {
            Enemy           enemy     = Enemy.GenerateEnemy();
            string          prompt    = $"{prompts[RandomHelper.rand.Next(prompts.Length)]} {enemy.name}. {enemy.name}: {enemy.currentHealth}";
            CombatEncounter encounter = new CombatEncounter("Fight!", prompt, new List <ActionButton>(), enemy);

            return(encounter);
        }
Exemplo n.º 3
0
        private void Strike(Encounter encounter)
        {
            CombatEncounter e      = (CombatEncounter)encounter;
            int             amount = e.player.Attack(e.enemy);
            string          text   = DoEnemyTurn(e);

            GameEngine.game.WriteText($"You punch the {enemy.name} for {amount} kinetic damage. {text}.");
            GameEngine.game.UpdatePlayerStats();
        }
Exemplo n.º 4
0
        private string DoEnemyTurn(CombatEncounter encounter)
        {
            int amount = encounter.enemy.Attack(encounter.player);

            if (amount < 0)
            {
                return("The elf has died.");
            }
            return($"{enemy.name} attacks you back for {amount} kinetic damage. {enemy.name}: {enemy.currentHealth}");
        }
Exemplo n.º 5
0
 public override void StartEncounter(Player player)
 {
     base.StartEncounter(player);
     foreach (EncounterAction action in player.GetCombatActions())
     {
         actions.Add(new ActionButton(action.item.name, (Encounter encounter) => {
             CombatEncounter e = (CombatEncounter)encounter;
             GameEngine.game.WriteText("");
             action.action(e, e.player, e.enemy);
             e.enemy.FightBack(e, e.player);
             WriteHealth(e);
             GameEngine.game.UpdatePlayerStats();
         }));
     }
 }
Exemplo n.º 6
0
        public void FightBack(CombatEncounter encounter, Player player)
        {
            if (isDead)
            {
                GameEngine.game.AppendText($"{name} has died.");
                return;
            }
            EncounterAction[] actions = GetCombatActions().ToArray();
            EncounterAction.EncounterActionDelegate action;
            if (actions == null || actions.Length < 1)
            {
                action = Strike;
            }
            else
            {
                action = actions[RandomHelper.rand.Next(0, actions.Length)].action;
            }

            action(encounter, this, player);
        }
Exemplo n.º 7
0
 public override void StartEncounter(Player player)
 {
     base.StartEncounter(player);
     foreach (EncounterAction action in player.GetCombatActions())
     {
         actions.Add(new ActionButton(action.item.name, (Encounter encounter) => {
             CombatEncounter e = (CombatEncounter)encounter;
             GameEngine.game.WriteText("");
             action.action(e, e.player, e.enemy);
             e.enemy.FightBack(e, e.player);
             WriteHealth(e);
             GameEngine.game.UpdatePlayerStats();
             if (e.enemy.isDead)
             {
                 e.player.inventory.AddRange(e.enemy.inventory);
                 encounter.actions.Clear();
                 encounter.actions.Add(new ActionButton("Continue", (Encounter en) => { GameEngine.instance.DoNextEncounter(); }));
                 encounter.RefreshActions();
             }
         }));
     }
 }
Exemplo n.º 8
0
 public void DoNextEncounter()
 {
     game.SetEncounter(CombatEncounter.GenerateEncounter());
 }