Example #1
0
        public void CheckState(GameModel gameState)
        {
            IEnumerable <CharacterModel> characterCollection = gameState.CharacterCollection.Where(c => c.Owner == this);

            if (characterCollection.Any() == false)
            {
                data.IsAlive = false;
                Defeated?.Invoke(this);
            }
        }
Example #2
0
        private void EnemyTurn()
        {
            if (monster.MonsterCurrentHp <= 0)
            {
                player.Exp  += monster.MonsterExp;
                player.Gold += monster.MonsterGold;
                Done?.Invoke(this, EventArgs.Empty);
                Defeated?.Invoke(this, EventArgs.Empty);
            }

            for (int attack = 0; attack < monster.MonsterAttacks; attack++)
            {
                Attack();
                if (player.CurrentHp <= 0)
                {
                    Environment.Exit(0);
                }
            }
            isMyTurn = true;
        }
Example #3
0
        private void ChangeHealth(int change, IGameObject source)
        {
            int newHealth = (int)CurrentHealth + change;

            if (newHealth < 0)
            {
                newHealth = 0;
            }
            if (newHealth > Stats.BaseHealth)
            {
                newHealth = (int)Stats.BaseHealth;
            }

            CurrentHealth = (uint)newHealth;
            HealthChanged.Invoke(this, new HealthChangedEventArgs(change, this, source));

            if (!IsAlive)
            {
                Defeated.Invoke(this, new DefeatedEventArgs(this, source));
            }
        }
Example #4
0
 protected void Audio()
 {
     Defeated?.Invoke();
 }