public IGameObject MakeAirBurst(Position center, double intensity) { IGameSprite airBurstSprite = _spriteFactory.MakeAirBurstSprite(); AirBurst airBurst = new AirBurst(center, intensity, airBurstSprite); return (IGameObject)airBurst; }
public IGameObject MakeExplosion(Position center, double intensity) { IGameSprite explosionSprite = _spriteFactory.MakeExplosionSprite(); Explosion explosion = new Explosion(center, intensity, explosionSprite); return (IGameObject)explosion; }
//Mirv sprite is just a different color missile public IGameSprite MakeMirvSprite(Position initialPosition) { MissileSprite sprite = new MissileSprite(initialPosition, Color.YellowGreen, _missileImgPath, GameParameters.MISSILE_WIDTH, GameParameters.MISSILE_HEIGHT,_textureFlyweight); _spriteContainer.Add(sprite); return sprite; }
public IGameObject MakeCity(Position center) { IGameSprite citySprite = _spriteFactory.MakeCitySprite(); City city = new City(center,citySprite); return (IGameObject)city; }
public EventPacket MakeMouseEventPacket(MouseState mouseState, Position mousePosition) { MouseEvent mouseEvent = new MouseEvent(mouseState,mousePosition); byte[] data = EventCodec.Instance.Serialize<MouseEvent>(mouseEvent); EventPacket packet = new EventPacket(EventTypes.MOUSE_INPUT, data); return packet; }
public TurretShot(Particle newParticle, Position target, IGameSprite sprite) : base(newParticle,sprite) { _particle = newParticle; _particle.velocity = GameParameters.TURRET_SHOT_VELOCITY; _type = ObjectType.TURRET_SHOT; _target = target; }
public MissileSprite(Position initialPosition, Color missileColor, string resourcePath, int width, int height, SpriteLoaderFlyweight textureFlyweight) : base(resourcePath, width, height, textureFlyweight) { MissileColor = missileColor; _initialPosition = GameViewFramework.TranslateModelToViewPosition(initialPosition); _missileTrailWidth = 1; }
public IGameObject MakeTurretShot(Particle initialVector, Position target) { IGameSprite turretShotSprite = _spriteFactory.MakeTurretShotSprite(initialVector.position); TurretShot turretShot = new TurretShot(initialVector, target, turretShotSprite); turretShot.OnProximityDetonation += _eventMonitor.OnAirBurstDetonation; return (IGameObject)turretShot; }
/// <summary> /// TurretShotSprite is just a different color of missile sprite, for now. /// </summary> /// <param name="initialPosition"></param> /// <returns></returns> public IGameSprite MakeTurretShotSprite(Position initialPosition) { MissileSprite turretShotSprite = new MissileSprite(initialPosition, _missileImgPath, GameParameters.MISSILE_WIDTH, GameParameters.MISSILE_HEIGHT, _textureFlyweight); turretShotSprite.MissileColor = Color.BlueViolet; _spriteContainer.Add(turretShotSprite); return turretShotSprite; }
public IGameObject MakeTurret(Position center) { IGameSprite turretSprite = _spriteFactory.MakeTurretSprite(); Turret turret = new Turret(center,turretSprite); turret.OnShoot += _eventMonitor.OnTurretShot; return (IGameObject)turret; }
public EventPacket MakeExplosionEventPacket(Position position, double intensity) { ExplosionEvent explosion = new ExplosionEvent(position, intensity); Console.WriteLine("EvtFact, position is: " + position.X + ":" + position.Y); byte[] data = EventCodec.Instance.Serialize<ExplosionEvent>(explosion); EventPacket packet = new EventPacket(EventTypes.EXPLOSION, data); return packet; }
public EventPacket MakeAirBurstEventPacket(Position position, double intensity) { AirBurstEvent airBurstEvent = new AirBurstEvent(position, intensity); Console.WriteLine("EvtFact, airburst position is: " + position.X + ":" + position.Y); byte[] data = EventCodec.Instance.Serialize<AirBurstEvent>(airBurstEvent); EventPacket packet = new EventPacket(EventTypes.AIR_BURST, data); return packet; }
//add delegates as needed here public City(Position center, IGameSprite gameSprite) { _hullRadius = GameParameters.CITY_HULL_RADIUS; _type = ObjectType.CITY; _health = GameParameters.CITY_HEALTH; _center = center; _sprite = gameSprite; }
public Particle(double vel, double acc, double ang, Position initialPosition) { position = initialPosition; velocity = vel; acceleration = acc; theta = ang; //Console.WriteLine("rad: " + ang); }
public MissileSprite(Position initialPosition, string resourcePath, int width, int height, SpriteLoaderFlyweight textureFlyweight) : base(resourcePath, width, height, textureFlyweight) { _initialPosition = GameViewFramework.TranslateModelToViewPosition(initialPosition); MissileColor = Color.LawnGreen; _missileTrailWidth = 1; _hasTransparency = false; }
public GameSpriteUpdateData(Position newPosition, double sizeScalar) { NewPosition = newPosition; SizeScalar = sizeScalar; IsAlive = true; //user of this object is responsible for creating and serializing data[] Data = null; }
public Turret(Position center, IGameSprite gameSprite) { _center = center; _hullRadius = GameParameters.TURRET_HULL_RADIUS; _type = ObjectType.TURRET; _health = 100; _ammunition = GameParameters.TURRET_AMMO; _sprite = gameSprite; }
public SimpleSprite(string resourcePath, int width, int height, SpriteLoaderFlyweight textureFlyweight) { _textureFlyweight = textureFlyweight; _resourcePath = resourcePath; _center = new Position(0, 0); _height = height; _width = width; _isAlive = true; }
public Explosion(Position center, double intensity, IGameSprite gameSprite) { _scalar = 0; _start = DateTime.Now; _duration_ms = GameParameters.MISSILE_EXPLOSION_DURATION_MS; //explosion hull radius is a parabolic function of time _hullRadius = 0.0; _type = ObjectType.EXPLOSION; _health = 10; _intensity = intensity; _sprite = gameSprite; _center = center; _damage = GameParameters.EXPLOSION_DAMAGE; }
/// <summary> /// Returns a random position near to the fixedPosition within some tolerance. This seems /// unusual, but is a very common desire for certain effects, like having a missile detonate /// and generate a bunch of random explosions within some general area. /// </summary> /// <returns>A new random position within a square of edge-length 2*modulus, centered at fixedPosition</returns> public static Position GetFuzzyPosition(Position fixedPosition, int modulus) { //generate random position, local to the fixed detonation position int x_fuzz = RandomNumberGenerator.Instance.Rand() % GameParameters.MISSILE_DETONATION_FUZZ_FACTOR; if (x_fuzz % 2 == 0) { x_fuzz *= -1; } int y_fuzz = RandomNumberGenerator.Instance.Rand() % GameParameters.MISSILE_DETONATION_FUZZ_FACTOR; if (y_fuzz % 2 == 0) { y_fuzz *= -1; } Position fuzzyPosition = new Position(fixedPosition); fuzzyPosition.X += x_fuzz; fuzzyPosition.Y += y_fuzz; return fuzzyPosition; }
//there may be different types of explosions, projectiles, etc: flak, ballistic, etc. public void Shoot(Position target) { if (_ammunition > 0 && _health > 0) { //spawn explosion??? _ammunition--; if (OnShoot != null) { Position source = new Position(this.Center.X, this.Center.Y + this._sprite.GetHeight() / 2); OnShoot(source, target); } else { Console.WriteLine("ERROR OnShoot() event null in turret.shoot()"); } } else { Console.WriteLine("ERROR turret out of ammo or dead, cannot shoot!"); } }
public EventPacket MakeAirBurstEventPacket(Position center) { return MakeAirBurstEventPacket(center, GameParameters.AIR_BURST_INTENSITY); }
public void OnTurretShot(Position source, Position target) { EventPacket packet = _eventFactory.MakeTurretShotEventPacket(source, target); _eventBus.Receive(packet); }
/// <summary> /// Selects a random turret to take the shot. /// </summary> /// <param name="target"></param> void fireTurret(Position target) { List<IGameObject> armedTurrets = _objectContainer.ToList().Where(obj => (obj.MyType == ObjectType.TURRET && obj.Health > 0 && ((Turret)obj).HasAmmo())).ToList<IGameObject>(); if (armedTurrets.Count > 0) { int randomTurret = RandomNumberGenerator.Instance.Rand() % armedTurrets.Count; ((Turret)armedTurrets[randomTurret]).Shoot(target); } else { Console.WriteLine("NO ARMED TURRETS"); } }
public SpawnTurretShotEvent(Position source, Position target) { _source = source; _target = target; }
public EventPacket MakeTurretShotEventPacket(Position source, Position target) { SpawnTurretShotEvent turretShot = new SpawnTurretShotEvent(source, target); byte[] eventData = EventCodec.Instance.Serialize<SpawnTurretShotEvent>(turretShot); EventPacket eventPacket = new EventPacket(EventTypes.TURRET_SHOT, eventData); return eventPacket; }
/// <summary> /// This translates the position given by the game model into the /// coordinates of the view, which like most views, is dyslexically /// defined with the origin at top left. /// </summary> /// <param name="modelPosition"></param> /// TODO: remove these to elsewhere public static Position TranslateModelToViewPosition(Position modelPosition) { return new Position(modelPosition.X, GameParameters.VIEW_Y_TRANSLATION - modelPosition.Y);//GameParameters.VIEW_Y_TRANSLATION - modelPosition._y); }
public GameSpriteUpdateData(Position newPosition, double sizeScalar, bool isAlive) { NewPosition = newPosition; SizeScalar = sizeScalar; IsAlive = isAlive; }
public EventPacket MakeExplosionEventPacket(Position center) { return MakeExplosionEventPacket(center, GameParameters.MISSILE_EXPLOSION_INTENSITY); }
public ExplosionEvent(Position center, double intensity) { _position = center; _intensity = intensity; }