public void Unload() { foreach (MachineComponent removeMe in machineComponentList) { if (removeMe != null) { removeMe.RemoveFromAutoDrawSet(); } } machineComponentList.Clear(); foreach (EnvironmentObject removeMe in environmentObjectList) { if (removeMe != null) { removeMe.RemoveFromAutoDrawSet(); } } machineComponentList.Clear(); levelSpawner.Unload(); levelSpawner = null; levelReceptacle = null; }
internal void newReceptacle(Receptacle someNewReceptacle) { levelReceptacle = someNewReceptacle; }
/// <summary> /// Updates the Spawner object. Update its coins separately. Odd /// behaviour occurs when coins are updated here. --Tony /// </summary> /// <param name="obj"></param> public void Update( ref Receptacle levelReceptacle, ref LinkedList<EnvironmentObject> environmentObjectList, ref LinkedList<MachineComponent> machineComponentList) { if (this.movingSpawner) { // update positions... this.movingArt.CenterX = this.CenterX += this.VelocityDirection.X * this.unitsMovedPerTick; this.travelTicks--; if (this.travelTicks <= 0) { // reverse direction this.VelocityDirection *= -1.0f; this.travelTicks = XNACS1Base.World.TicksInASecond * 10; } } switch(this.state) { case(SpawnState.Idle): this.SetTextureSpriteAnimationFrames(0, 0, 0, 0, 40, SpriteSheetAnimationMode.AnimateForward); this.UseSpriteSheetAnimation = true; break; case(SpawnState.Spawning): LinkedList<Money> removeUs = new LinkedList<Money>(); // update any spawned money. foreach (Money dinero in this.coins) { Spawner.removeMoney = false; // update against the level environment objects of level. foreach (EnvironmentObject envObj in environmentObjectList) { envObj.UpdateAgainst(dinero); } // update against any machine components in the world. foreach (MachineComponent component in machineComponentList) { if (component != null) { component.UpdateAgainst(dinero); } } dinero.Update(); // update against the piggybank. levelReceptacle.UpdateAgainst(dinero); // is this dinero to be removed? if (Spawner.removeMoney) { // add this money to the list of objects to be removed... removeUs.AddLast(dinero); } } while (removeUs.Count > 0) { LinkedListNode<Money> removeMe = removeUs.First; removeUs.RemoveFirst(); this.coins.Remove(removeMe.Value); removeMe.Value.collected(); removeMe.Value = null; } this.SpawnMoney(); break; } }