public FloatingText(Character owner, string text, string color) : base("Arial", 14, color) { this.owner = owner; name = string.Format("{0}_floatingtext_{1}", ((Game) owner.engine.objects["game"]).currentFloor.currentRoom.name, Guid.NewGuid()); order = owner.order - 1; this.text = text; xPadding = (float) (new Random((int) DateTime.Now.Ticks).NextDouble()); }
public virtual int GetDamage(Character enemy, Func<Character, Character, int> damageFunc) { LevelCheck (); // could happen that the player kills the enemy before he fully spawn (before Start "starts") enemy.LevelCheck(); int dmg = damageFunc (this, enemy); level.hp -= dmg;//enemy.level.attack; if (hud != null) hud.UpdateHPBar (); FloatingText floatingText = new FloatingText (this, "-" + dmg, "orange"); engine.SpawnObject ( floatingText.name, floatingText ); return level.hp; }
public override int GetDamage(Character enemy, Func<Character, Character, int> damageFunc) { redWindow.width = engine.width; redWindow.height = engine.height; Console.WriteLine("Player got damaged."); var thr = new Thread( () => { Thread.Sleep(50); redWindow.width = 0; redWindow.height = 0; } ); thr.Start(); return base.GetDamage(enemy, damageFunc); }
// character hits enemy public bool Hits(Character character, Character enemy, Collision collision, Func<Character, Character, int> damageFunc) { if (damageFunc == null) damageFunc = (Character ch0, Character ch1) => { return ch1.level.attack; }; enemy.GetDamage(character, damageFunc); if (!enemy.isAlive) { collision.other.Destroy(); if (player != null) { player.xp = player.xp + enemy.level.xpReward; } var enemyObj = enemy as Enemy; if (enemyObj != null) { currentFloor.currentRoom.RemoveEnemy(enemyObj); Console.WriteLine("Enemies to go in current room: " + currentFloor.currentRoom.enemies.Count); foreach (var en in currentFloor.currentRoom.enemies) { Console.Write("{0} - ", en.name); } } } return enemy.isAlive; }
// bullet hits enemy public bool Hits(Bullet bullet, Character enemy, Collision collision) { return Hits((Character) bullet.owner, enemy, collision, (Character ch0, Character ch1) => { return (int) (ch0.level.attack*((double) bullet.speed/bullet.startingSpeed)); }); }
public Orb(Character owner) { this.order = 5; this.owner = owner; this.fill = true; }