public override void Update() { ShooterLevel level = ShooterLevel.Current; if (!Hit) { foreach (GameObject building in ShooterLevel.Current.Buildings.VisibleBuildings) { if (!Collides(building)) { continue; } Hit = true; return; } if (level.Status == ShooterStatus.Running && Collides(level.Meteor.Ship)) { level.Crash(); Hit = true; return; } } Location.X -= level.DeltaTime * level.BaseSpeed; Motion.Update(this, level.DeltaTime); base.Update(); }
public override void Update(CanvasContext2D context) { if (_level.Status == ShooterStatus.Running) { foreach (GameObject building in _level.Buildings.VisibleBuildings) { if (!Ship.Collides(building)) { continue; } _level.Crash(); return; } foreach (Dino dino in _level.Dinos.VisibleDinos) { if (dino.Dead || !Ship.Collides(dino)) { continue; } _level.Crash(); return; } } Ship.Update(); if (_level.Status != ShooterStatus.Running) { return; } float vertical = 0; float horizontal = 0; if (_level.Up) { Ship.StartAnimation("Up"); vertical -= _speed; } if (_level.Down) { Ship.StartAnimation("Down"); vertical += _speed; } if (!(_level.Up ^ _level.Down)) { Ship.StartAnimation("Default"); } if (_level.Left) { horizontal -= _speed; } if (_level.Right) { horizontal += _speed; } Ship.Location.TranslateByCoordinates(horizontal * _level.DeltaTime, vertical * _level.DeltaTime); if (Ship.Location.X < 0) { Ship.Location.X = 0; } else if (Ship.Location.X > 700) { Ship.Location.X = 700; } if (Ship.Location.Y < 30) { Ship.Location.Y = 30; } else if (Ship.Location.Y > 550) { Ship.Location.Y = 550; } }