public static Projectile ReflectiveInitialize(string prjName, GameCore game, Tanks.Tank tank, bool authorized, byte[] state = null) { long totalMem = 0; if (GlobalSettings.Debug) { totalMem = GC.GetTotalMemory(true); } if (!_prjTypes.ContainsKey(prjName.ToLower())) { throw new Exception("Projectile type does not exist."); } var inst = (Projectile)Activator.CreateInstance(_prjTypes[prjName.ToLower()], tank, game, authorized); if (state != null) { inst.ReceiveStateData(state); } if (GlobalSettings.Debug) { var memUsageBytes = (GC.GetTotalMemory(true) - totalMem) / 1024f; game.Logger.Trace($"Allocating (Projectile)Object {prjName}, size is: {memUsageBytes.ToString("N2")} KiB"); } return(inst); }
public Projectile(Tanks.Tank owner, GameCore game, bool authorized, float density = 1, float bounciness = 0.1f, Vector2 position = default(Vector2), float rotation = 0) : base(game, authorized, density, bounciness, position, rotation) { Owner = owner; //Default for projectiles Flags.Add("PassesThroughTankBlocks"); }
public static Projectile ReflectiveInitialize(string prjName, Tanks.Tank owner, GameCore game, bool authorized, Vector2 position = default(Vector2), float rotation = 0, byte[] state = null) { if (!_prjTypes.ContainsKey(prjName.ToLower())) { throw new Exception("Projectile type does not exist."); } var inst = (Projectile)Activator.CreateInstance(_prjTypes[prjName.ToLower()], owner, game, authorized, position, rotation); if (state != null) { inst.ReceiveStateData(state); } return(inst); }
public static T ReflectiveInitialize <T>(string prjName, Tanks.Tank owner, GameCore game, bool authorized, byte[] state = null) where T : Projectile { return((T)ReflectiveInitialize(prjName, game, owner, authorized, state)); }
public virtual bool CanDamage(Tanks.Tank tank, bool friendlyFireEnabled) { return(true); }
public virtual void CollidedWithTank(Tanks.Tank tank) { Kill(tank); }