/// <summary> /// Hurts this entity for the specified amount. /// </summary> /// <param name="amount">Number of damage points.</param> public void Hurt(int amount) { Health -= amount; if (Health <= 0) { Engine2D.DespawnEntity(Entity); } }
/// <summary> /// Highlights the entity. /// </summary> public void Select() { Effect = Engine2D.SpawnEntity(new Entity2DRenderableBaseCircleProperty() { Radius = UnitSize * 0.75f, CircleTexture = Entity.Engine.Textures.White, RenderAt = Entity.LastKnownPosition - new Location(0, 0, 5), CastShadows = false }); Entity.OnPositionChanged += PositionChanged; }
private void collide(GameTime gameTime) { ennemiesCollision(); shieldCollision(); obstaclesCollision(); if (!lvlOver && Engine2D.testCollision(who, tardis.tardisBbox)) { who.enterTardis(); tardis.dematerialise(gameTime); this.timer = 0f; this.lvlOver = true; } }
private void shieldCollision() { foreach (Foe baddy in baddies) { if (baddy is Dalek) { Dalek dalek = (Dalek)baddy; foreach (LaserBeam laser in dalek.DalekLove) { if (Engine2D.testShield(laser.Bbox, this.tardis.shieldBbox)) { laser.State = Status.DEAD; } } } } }
// public float threshold = 0.3f; private void Start() { Engine = GetComponent<Engine2D>(); if (Engine == null) { Debug.LogWarning("PlayerMove : Engine2D not found"); } UserEvent.Instance.OnUserInputAxis += EventHandler; PivotToGround = (GetComponent<BoxCollider>().size.y)/2; animator = GetComponent<Animator>(); /*var audio = GetComponent<AudioSource> (); audio.clip = runLoop; audio.loop = true; audio.Play ();*/ }
static void Main(string[] args) { Engine2D.Draw( new Shape[] { new Star(2, 2), new AnyStar(2, 5, ConsoleColor.Yellow), new Star(Console.WindowWidth - 3, 2, ConsoleColor.Red), new MovableSquare(30, 2, 3, MoveDirection.ToBottom), new MovableTriangle(50, Console.WindowHeight - 1, 5, MoveDirection.ToTop, ConsoleColor.Green), new MovableSquare(2, 10, 2, MoveDirection.ToRight, ConsoleColor.Red), new MovableTriangle(Console.WindowWidth - 3, 20, 3, MoveDirection.ToLeft, ConsoleColor.Gray), new Square(2, Console.WindowHeight - 1, 4, ConsoleColor.Cyan), new Triangle(8, Console.WindowHeight - 1, 7, ConsoleColor.Magenta), }); Console.Read(); }
private void obstaclesCollision() { foreach (Obstacle obs in obstacles) { if (Engine2D.testCollision(who, obs.Bbox)) { who.State = Status.BLOCKED; who.Velocity = new Vector2(0, who.Velocity.Y); Vector2 bounce = who.Position; Vector2 backSlide = new Vector2(-0.1f, 0); while (who.Position.X > bounce.X - 2) { who.Position += backSlide; } } else { who.State = Status.FREE; } } }
public MainWindow() { this.DataContext = this; //TODO: use IoC var engine2D = new Engine2D(); var layout = new GraphLayoutEngine(engine2D); this._graphFacade = new ContentAwareGraphFacade(new GraphFacade(layout)); this._graphFacade.Change += this.OnChange; ApplicationCommands.Close.InputGestures.Add(new KeyGesture(Key.F4, ModifierKeys.Alt)); ApplicationCommands.SaveAs.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift)); this.InitializeComponent(); this.UpdateTitle(); this.Canvas.Engine2D = engine2D; this.Canvas.Start(); }
private void ennemiesCollision() { foreach (Foe baddy in baddies) { if (Engine2D.testCollision(who, baddy.Bbox)) { Exit(); } if (baddy is Cyberman) { if (Engine2D.testSonicAttack(who.SonicBbox, baddy.Bbox)) { baddy.kill(); } if (Engine2D.testCollision(baddy, this.tardis.shieldBbox)) { baddy.kill(); } } else if (baddy is Dalek) { if (Engine2D.testLaserAttack(who.Bbox, (Dalek)baddy) && who.DoctorMouvement != Mouvement.GLISSADE) { Exit(); who.State = Status.DEAD; } } else if (baddy is WeepingAngel) { if (Engine2D.testCollision(baddy, this.tardis.shieldBbox)) { baddy.State = Status.BLOCKED; } } } }
/// <summary> /// Stops highlighting the entity. /// </summary> public void Deselect() { Entity.OnPositionChanged -= PositionChanged; Engine2D.DespawnEntity(Effect); Effect = null; }
public EngineControl(Engine2D engine2D) : this() { this.Engine2D = engine2D; }
public Camera2D(Engine2D engine, int width, int height, PixelFormat formatoPixel) { this.engine = engine; IniciarCamera(width, height, formatoPixel); }
public GraphLayoutEngine(Engine2D engine) { this._engine = engine; }