/// <summary> /// activates a specific mode of operation /// </summary> /// <param name="handler"></param> /// <param name="entity"></param> public void ActivateModeHandler(ModeHandler handler, Entity entity = null) { if (this.currentModeHandler != null) { this.DisposeCurrentModeHandler(); } switch (handler) { case ModeHandler.Unit: this.currentModeHandler = this.unitHandler; this.unitHandler.Activate(entity); break; case ModeHandler.BuildTunnel: this.currentModeHandler = this.buildTunnelHandler; this.buildTunnelHandler.Activate(null); break; case ModeHandler.ClearTunnel: this.currentModeHandler = this.clearTunnelHandler; this.clearTunnelHandler.Activate(null); break; case ModeHandler.BuildCaveSmall: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.smallCave); break; case ModeHandler.BuildCaveMedium: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.mediumCave); break; case ModeHandler.BuildCaveLarge: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.largeCave); break; default: this.currentModeHandler = null; break; } }
/// <summary> /// prepares a new world /// </summary> public void InitializeWorld() { // initialize variables this.blocks = new Dictionary <Point, Block> [this.Properties.MaxBlockDepth]; for (int i = 0; i < this.Properties.MaxBlockDepth; i++) { this.blocks[i] = new Dictionary <Point, Block>(); } this.markers = new Dictionary <Point, Marker>(); this.units = new List <Entities.Unit>(); this.buildings = new List <Building>(); this.caves = new List <Cave>(); this.units.Add(new Entities.Unit(DataIdentifier.modelPlayerUnit, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0, 4, -1), "Herbert")); this.units.Add(new Entities.Unit(DataIdentifier.modelPlayerUnit, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-2, 4, -1), "Torben")); this.buildings.Add(new Building(DataIdentifier.modelBuildingCampfire, new Vector3(2, 1, 1), new Vector3(-4, 4, -3))); this.mouseSurface = new Plane(Vector3.UnitZ, 0); // generate the world this.GenerateNewWorld(); // generate cave models this.smallCave = new SmallCave(); this.mediumCave = new MediumCave(); this.largeCave = new LargeCave(); this.unitHandler = new ControlModeHandler.UnitHandler(this); this.buildCaveHandler = new ControlModeHandler.BuildCaveHandler(this); this.buildTunnelHandler = new ControlModeHandler.BuildTunnelHandler(this); this.clearTunnelHandler = new ControlModeHandler.ClearTunnelHandler(this); this.currentModeHandler = null; }
/// <summary> /// prepares a new world /// </summary> public void InitializeWorld() { // initialize variables this.blocks = new Dictionary<Point, Block>[this.Properties.MaxBlockDepth]; for (int i = 0; i < this.Properties.MaxBlockDepth; i++) this.blocks[i] = new Dictionary<Point, Block>(); this.markers = new Dictionary<Point, Marker>(); this.units = new List<Entities.Unit>(); this.buildings = new List<Building>(); this.caves = new List<Cave>(); this.units.Add(new Entities.Unit(DataIdentifier.modelPlayerUnit, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0, 4, -1), "Herbert")); this.units.Add(new Entities.Unit(DataIdentifier.modelPlayerUnit, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-2, 4, -1), "Torben")); this.buildings.Add(new Building(DataIdentifier.modelBuildingCampfire, new Vector3(2, 1, 1), new Vector3(-4, 4, -3))); this.mouseSurface = new Plane(Vector3.UnitZ, 0); // generate the world this.GenerateNewWorld(); // generate cave models this.smallCave = new SmallCave(); this.mediumCave = new MediumCave(); this.largeCave = new LargeCave(); this.unitHandler = new ControlModeHandler.UnitHandler(this); this.buildCaveHandler = new ControlModeHandler.BuildCaveHandler(this); this.buildTunnelHandler = new ControlModeHandler.BuildTunnelHandler(this); this.clearTunnelHandler = new ControlModeHandler.ClearTunnelHandler(this); this.currentModeHandler = null; }
/// <summary> /// exits the current mode /// </summary> public void DisposeCurrentModeHandler() { this.currentModeHandler.Deactivate(); this.currentModeHandler = null; }
/// <summary> /// activates a specific mode of operation /// </summary> /// <param name="handler"></param> /// <param name="entity"></param> public void ActivateModeHandler(ModeHandler handler, Entity entity = null) { if(this.currentModeHandler != null) this.DisposeCurrentModeHandler(); switch (handler) { case ModeHandler.Unit: this.currentModeHandler = this.unitHandler; this.unitHandler.Activate(entity); break; case ModeHandler.BuildTunnel: this.currentModeHandler = this.buildTunnelHandler; this.buildTunnelHandler.Activate(null); break; case ModeHandler.ClearTunnel: this.currentModeHandler = this.clearTunnelHandler; this.clearTunnelHandler.Activate(null); break; case ModeHandler.BuildCaveSmall: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.smallCave); break; case ModeHandler.BuildCaveMedium: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.mediumCave); break; case ModeHandler.BuildCaveLarge: this.currentModeHandler = this.buildCaveHandler; this.buildCaveHandler.Activate(this.largeCave); break; default: this.currentModeHandler = null; break; } }