public override void Animate(InGameEngine engine) { if (AnimatedObject == null) { return; } switch (Direction) { case Direction.Right: AnimatedObject.Position = AnimatedObject.Position.Add(new Coordinate(Speed, 0)); break; case Direction.Down: AnimatedObject.Position = AnimatedObject.Position.Add(new Coordinate(0, Speed)); break; case Direction.Left: AnimatedObject.Position = AnimatedObject.Position.Add(new Coordinate(-Speed, 0)); break; case Direction.Up: AnimatedObject.Position = AnimatedObject.Position.Add(new Coordinate(0, -Speed)); break; } if (AnimatedObject is MainPlayer) { Tracer.TracePosition(engine.MousePosition, AnimatedObject); } }
protected Player(float rotation, int lives, Coordinate position, Coordinate size, Colour colour, Coordinate startPosition, decimal shootTimeLag, InGameEngine engine, Type bulletType) : base( position, size, rotation, new ShapeCollection(new ObservableCollection <Shape> { new Line(new Coordinate(57, 57), new Coordinate(149, 57), new Colour(Color.FromArgb(-16711936)), 7), new Rectangle(2, new Colour(Color.FromArgb(-65536)), new Coordinate(17, 15), new Coordinate(84, 84), new Colour(Color.Empty), 0), new Ellipse(0, new Colour(Color.Empty), new Coordinate(7, 8), new Coordinate(100, 100), new Colour(Color.FromArgb(-16777216)), 0) }) { Position = new Coordinate(0, 0) }, engine.CurrentId) { BulletType = bulletType; ShootTimeLag = shootTimeLag; StartPosition = startPosition; Lives = lives; Engine = engine; View.Shapes[0].MainColour = new Colour(Color.FromArgb(colour.Color.ToArgb() * 3)); Moves = new ObservableCollection <Direction>(); var polygon = View.Shapes[1] as Rectangle; if (polygon != null) { polygon.LineColour = colour; } }
public EvilPlayer(Coordinate position, Coordinate size, float rotation, Coordinate startPosition, int intelligenceLevel, InGameEngine engine, int lives = 1) : base( rotation, lives, position, size, new Colour(Color.Red), startPosition, (decimal)1E7, engine, typeof(NormalBullet)) { IntelligenceLevel = intelligenceLevel; }
public override void Animate(InGameEngine engine) { if (AnimatedObject == null) { return; } AnimatedObject.Rotation = Arithmetic.RealAngle(AnimatedObject.Rotation + Speed /* * (Aim - AnimatedObject.Rotation < 180 ? 1 : -1)*/); }
public override void Animate(InGameEngine engine) { if (AnimatedObject == null) { return; } AnimatedObject.Position = AnimatedObject.Position.Add(new Coordinate((float)Math.Cos(Physomatik.ToRadian(Direction)) * Speed, (float)Math.Sin(Physomatik.ToRadian(Direction)) * Speed)); }
public override void Animate(InGameEngine engine) { Mine obj; if (AnimatedObject == null || (obj = AnimatedObject as Mine) == null) { return; } obj.Timer -= Speed / 100; obj.View.Shapes.Last().MainColour = (int)Math.Ceiling(obj.Timer) % 2 == 0 ? obj.SpecialColour : obj.NormalColour; }
public override void Animate(InGameEngine engine) { Explosion obj; if (AnimatedObject == null || (obj = AnimatedObject as Explosion) == null) { return; } AnimatedObject.ChangeSizeAtCentre(AnimatedObject.Size.Add(Speed)); if (obj.Destroying) { //Todo Destroying Explosions (from mines) have not been implemented yet - destroy the stuff! } }
private void MainWindow_Load(object sender, EventArgs e) { MinimumSize = Size; MaximumSize = Size; _inGameEngine = new InGameEngine(this); }
public MainPlayer(Coordinate position, Coordinate size, float rotation, int lives, Coordinate startPosition, InGameEngine engine) : base(rotation, lives, position, size, new Colour(Color.GreenYellow), startPosition, (decimal)5E6, engine, typeof(NormalBullet)) { }
public EvilPlayer0(Coordinate position, Coordinate size, float rotation, Coordinate startPosition, InGameEngine engine, int lives) : base(position, size, rotation, startPosition, 0, engine, lives) { }
public void AddObject(AddableObjects obj, InGameEngine engine, Coordinate position = null, int evilPlayerLevel = 0, Player player = null) { if (AddableObjectsFunctionality.PositionRequired(obj) && position == null) { throw new Exception("Position not specified!"); } switch (obj) { case AddableObjects.MainPlayer: Objects.Add(new MainPlayer(new Coordinate(100, 100), new Coordinate(100, 100), 0, 3, new Coordinate(100, 100), engine)); break; case AddableObjects.EvilPlayer: switch (evilPlayerLevel) { case 0: Objects.Add(new EvilPlayer0(position, new Coordinate(100, 100), 0, position, engine, engine.Debugging ? 100 : 1)); break; case 1: Objects.Add(new EvilPlayer1(position, new Coordinate(100, 100), 0, position, engine, engine.Debugging ? 100 : 1)); break; } break; case AddableObjects.NormalBullet: player = player ?? GetMainPlayer; if (player == null) { throw new Exception("No Player defined!"); } var bullet = new NormalBullet( player.Position.Sub(new Coordinate(0, 10)) .Add(player.Size.Div(2)) .Add( new Coordinate( (float)Math.Cos(Physomatik.ToRadian(player.Rotation)) * (player.Size.Pyth() / 2 + 20), (float)Math.Sin(Physomatik.ToRadian(player.Rotation)) * (player.Size.Pyth() / 2 + 20))), PublicStuff.NormalBulletSize, player.Rotation, engine.CurrentId); Objects.Add(bullet); engine.Animations.Add(new AngularMoveAnimation(bullet, bullet.Rotation, 10)); break; case AddableObjects.NormalBlock: Objects.Add(new Block(position, new Coordinate(100, 100), engine.CurrentId, false, new Colour(Color.FromArgb(-4144960)))); break; case AddableObjects.DestroyableBlock: Objects.Add(new Block(position, new Coordinate(100, 100), engine.CurrentId, true, new Colour(Color.FromArgb(173, 102, 31)))); break; case AddableObjects.Hole: Objects.Add(new Hole(position, new Coordinate(100, 100), engine.CurrentId)); break; case AddableObjects.NotDestroyingExplosion: Objects.Add(new Explosion(position, new Coordinate(1, 1), engine.CurrentId, new Colour(Color.Black), new Colour(Color.Red), false, 5)); break; case AddableObjects.DestroyingExplosion: Objects.Add(new Explosion(position, new Coordinate(1, 1), engine.CurrentId, new Colour(Color.Black), new Colour(Color.OrangeRed), true, 5)); break; case AddableObjects.Mine: Objects.Add(new Mine(position, new Coordinate(30, 30), engine.CurrentId, 5, new Colour(Color.FromArgb(-256)), new Colour(Color.Orange), new Coordinate(150, 150))); engine.Animations.Add(new MineAnimation(Objects.Last(), 2)); break; default: throw new ArgumentOutOfRangeException(nameof(obj), obj, null); } Objects = Objects; }
public virtual void Animate(InGameEngine engine) { }