void apple_Removed(Item item) { AppleItem apple = new AppleItem(new Core.Vector2(Random.Next(150, 400), Random.Next(150, 400)), 250); InsertItem(apple); apple.Removed += apple_Removed; }
protected override void OnUpdate() { // Gewinnbedingung if (Engine.Round >= 4800 && Mode == LevelMode.Running) { Faction winner = null; foreach (var faction in Factions) { if (faction == null) { continue; } if (winner == null) { winner = faction; } } if (winner != null) { FinishPlayer(winner.SlotIndex); } else { Draw(); } } Index2 cells = Engine.Map.GetCellCount(); if (sugar == null) { Vector2 pos = new Vector2( ((float)Random.NextDouble() * (cells.X - 1)) * Map.CELLSIZE, ((float)Random.NextDouble() * (cells.Y - 1)) * Map.CELLSIZE); sugar = new SugarItem(Context, pos, 1000); Engine.InsertItem(sugar); } if (apple == null) { Vector2 pos = new Vector2( ((float)Random.NextDouble() * (cells.X - 1)) * Map.CELLSIZE, ((float)Random.NextDouble() * (cells.Y - 1)) * Map.CELLSIZE); apple = new AppleItem(Context, pos, 250); Engine.InsertItem(apple); } if (bugs.Count < 3) { Vector2 pos = new Vector2( ((float)Random.NextDouble() * (cells.X - 1)) * Map.CELLSIZE, ((float)Random.NextDouble() * (cells.Y - 1)) * Map.CELLSIZE); Angle orientation = Angle.FromDegree(Random.Next(0, 359)); ClassicBugItem bug = new ClassicBugItem(Context, pos, orientation); bugs.Add(bug); Engine.InsertItem(bug); } }
protected override void OnInit() { SugarItem sugar = new SugarItem(new Core.Vector2(300, 100), 1000); InsertItem(sugar); sugar.Removed += sugar_Removed; AppleItem apple = new AppleItem(new Core.Vector2(300, 300), 250); InsertItem(apple); apple.Removed += apple_Removed; }
protected override void OnRemoveItem(Item item) { if (item == sugar) { sugar = null; } if (item == apple) { apple = null; } if (item is ClassicBugItem) { bugs.Remove(item as ClassicBugItem); } }
/// <summary> /// Default Constructor for the Type Mapper. /// </summary> /// <param name="item">Related Engine Item</param> public AppleState(AppleItem item) : base(item) { }