コード例 #1
0
    public IGameObject MakeAirBurst(Position center, double intensity)
    {
      IGameSprite airBurstSprite = _spriteFactory.MakeAirBurstSprite();
      AirBurst airBurst = new AirBurst(center, intensity, airBurstSprite);

      return (IGameObject)airBurst;
    }
コード例 #2
0
    public IGameObject MakeExplosion(Position center, double intensity)
    {
      IGameSprite explosionSprite = _spriteFactory.MakeExplosionSprite();
      Explosion explosion = new Explosion(center, intensity, explosionSprite);

      return (IGameObject)explosion;
    }
コード例 #3
0
    //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;
    }
コード例 #4
0
    public IGameObject MakeCity(Position center)
    {
      IGameSprite citySprite = _spriteFactory.MakeCitySprite();
      City city = new City(center,citySprite);

      return (IGameObject)city;
    }
コード例 #5
0
 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;
 }
コード例 #6
0
ファイル: TurretShot.cs プロジェクト: niceyeti/MissileCommand
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
    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;
    }
コード例 #9
0
    /// <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;
    }
コード例 #10
0
    public IGameObject MakeTurret(Position center)
    {
      IGameSprite turretSprite = _spriteFactory.MakeTurretSprite();
      Turret turret = new Turret(center,turretSprite);
      turret.OnShoot += _eventMonitor.OnTurretShot;

      return (IGameObject)turret;
    }
コード例 #11
0
 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;
 }
コード例 #12
0
 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;
 }
コード例 #13
0
ファイル: City.cs プロジェクト: niceyeti/MissileCommand
    //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;
    }
コード例 #14
0
ファイル: Particle.cs プロジェクト: niceyeti/MissileCommand
 public Particle(double vel, double acc, double ang, Position initialPosition)
 {
   position = initialPosition;
   velocity = vel;
   acceleration = acc;
   theta = ang;
   //Console.WriteLine("rad: " + ang);
 }
コード例 #15
0
 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;
 }
コード例 #16
0
 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;
 }
コード例 #17
0
ファイル: Turret.cs プロジェクト: niceyeti/MissileCommand
 public Turret(Position center, IGameSprite gameSprite)      
 {
   _center = center;
   _hullRadius = GameParameters.TURRET_HULL_RADIUS;
   _type = ObjectType.TURRET;
   _health = 100;
   _ammunition = GameParameters.TURRET_AMMO;
   _sprite = gameSprite;
 }
コード例 #18
0
 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;
 }
コード例 #19
0
ファイル: Explosion.cs プロジェクト: niceyeti/MissileCommand
 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;
 }
コード例 #20
0
ファイル: Position.cs プロジェクト: niceyeti/MissileCommand
    /// <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;
    }
コード例 #21
0
ファイル: Turret.cs プロジェクト: niceyeti/MissileCommand
 //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!");
   }
 }
コード例 #22
0
 public EventPacket MakeAirBurstEventPacket(Position center)
 {
   return MakeAirBurstEventPacket(center, GameParameters.AIR_BURST_INTENSITY);
 }
コード例 #23
0
 public void OnTurretShot(Position source, Position target)
 {
   EventPacket packet = _eventFactory.MakeTurretShotEventPacket(source, target);
   _eventBus.Receive(packet);
 }
コード例 #24
0
    /// <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");
      }
    }
コード例 #25
0
 public SpawnTurretShotEvent(Position source, Position target)
 {
   _source = source;
   _target = target;
 }
コード例 #26
0
    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;
    }
コード例 #27
0
 /// <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);
 }
コード例 #28
0
 public GameSpriteUpdateData(Position newPosition, double sizeScalar, bool isAlive)
 {
   NewPosition = newPosition;
   SizeScalar = sizeScalar;
   IsAlive = isAlive;
 }
コード例 #29
0
 public EventPacket MakeExplosionEventPacket(Position center)
 {
   return MakeExplosionEventPacket(center, GameParameters.MISSILE_EXPLOSION_INTENSITY);
 }
コード例 #30
0
 public ExplosionEvent(Position center, double intensity)
 {
   _position = center;
   _intensity = intensity;
 }