//public string InflictDamage(string targetHealth, int hostileDamage) public string InflictDamage(string targetHealth, Components.DamageComponent hostileDamage) { int curHealth = Int32.Parse(targetHealth); Components.HealthComponent villageHealth = new Components.HealthComponent(curHealth); //Creates health component int curDamage = hostileDamage.getInflictableDamage(); //int curHealth = targetHP.getHealth(); //int curDamage = hostileDamage; int newHP = curHealth - curDamage; //Calculates new health of entity /* //Edit: Prototype won't use HealthComponent (for now) * if (newHP > 0) * targetHP.setHealth(newHP); //Sets new health * else * targetHP.setHealth(-1); // (!!!) TEMPORARY: Replace w/ Destroy Entity Function * return targetHP; */ if (newHP <= 0) { newHP = 0; //Resets Health to 0, avoid negative value } return(newHP.ToString()); }
public GameObject(int id, string name, Game1 game, float X, float Y, bool AcceptInput, Vector2 ColliderDimentions, Vector2 ColliderOffset, bool ColliderIsTrigger, bool HasAI, int Team, float MaxSpeed, float Acceleration, float MaxHealth, float DamageOnTouch) { Id = id; Name = name; Game = game; this.Team = Team; InputManeger = new Components.InputManeger(this); PositionComponent = new Components.PositionComponent(X, Y, AcceptInput, MaxSpeed, Acceleration, this); ColliderComponent = new Components.ColliderComponent(ColliderDimentions, ColliderOffset, ColliderIsTrigger, this); SpriteComponent = new Components.SpriteComponent(this); if (MaxHealth > 0) { HealthComponent = new Components.HealthComponent(MaxHealth, DamageOnTouch, this); } if (HasAI) { AI = new Components.AI(Team, this); } }