public TileSelector(EditorScreen parentScreen, SpriteBatch spriteBatch, RectangleF bounds, TileMapLayer tileMapLayer, InputMonitor inputMonitor) : base(parentScreen, spriteBatch, bounds) { this.tileMapLayer = tileMapLayer; this.tilePropertyComponents = new List<ITilePropertyComponent>(); this.inputMonitor = inputMonitor; this.selectButton = -1; this.selectedTileCoordinates = new List<int[]>(); this.selectingTileCoordinates = new List<int[]>(); }
/// <summary> /// Constructor for Flint Ironstag. /// </summary> /// <param name="parentScreen">The screen which this object is a part of.</param> /// <param name="spriteBatch">The sprite batch which handles drawing this object.</param> /// <param name="position">The initial position of this character.</param> public Player(World world, SpriteBatch spriteBatch, Vector2 position) : base(world, spriteBatch, position) { Mass = 1; //Set the character's Name name = "Flint Ironstag"; //Load the player information from the XML file LoadPlayerXmlFile(); //Load the Player's Roles SetUpRoles(); //Set current health currentHealth = maxHealth; //Set the character's transformation guage currentGauge = maxGauge; //Create the Animation Player and give it the Idle Animation this.animationPlayer = new AnimationPlayer(spriteBatch, currentRole.AnimationMap["Idle"]); //Set the current animation currentAnimation = animationPlayer.Animation; //Set the current state currentState = "Idle"; //Set the Velocity Velocity = new Vector2(0, 0); //Set the position this.Position = position; //Set the facing facing = SpriteEffects.None; //Max Jump Time //Initializes the player's hotspots. List<CollisionHotspot> hotspots = new List<CollisionHotspot>(); /*hotspots.Add(new CollisionHotspot(this, new Vector2(32, 3), HOTSPOT_TYPE.top)); hotspots.Add(new CollisionHotspot(this, new Vector2(20, 24), HOTSPOT_TYPE.left)); hotspots.Add(new CollisionHotspot(this, new Vector2(20, 42), HOTSPOT_TYPE.left)); hotspots.Add(new CollisionHotspot(this, new Vector2(36, 24), HOTSPOT_TYPE.right)); hotspots.Add(new CollisionHotspot(this, new Vector2(36, 42), HOTSPOT_TYPE.right)); hotspots.Add(new CollisionHotspot(this, new Vector2(30, 60), HOTSPOT_TYPE.bottom)); */ // hotspots.Add(new CollisionHotspot(this, new Vector2(3, -27), HOTSPOT_TYPE.top)); hotspots.Add(new CollisionHotspot(this, new Vector2(0, -27), HOTSPOT_TYPE.top)); hotspots.Add(new CollisionHotspot(this, new Vector2(-11, 20), HOTSPOT_TYPE.left)); hotspots.Add(new CollisionHotspot(this, new Vector2(-11, -20), HOTSPOT_TYPE.left)); hotspots.Add(new CollisionHotspot(this, new Vector2(11, 20), HOTSPOT_TYPE.right)); hotspots.Add(new CollisionHotspot(this, new Vector2(11, -20), HOTSPOT_TYPE.right)); hotspots.Add(new CollisionHotspot(this, new Vector2(-5, 32), HOTSPOT_TYPE.bottom)); hotspots.Add(new CollisionHotspot(this, new Vector2(5, 32), HOTSPOT_TYPE.bottom)); Hotspots = hotspots; //Set up the ShotCoolDown Timer UpdateShotCoolDown(); //Initialize the last fired shot time shotDelay = 0; //Sets the hitback Vector hitPushBack = new Vector2(-2f, 0f); //Sets the death push back vector deathPushBack = new Vector2(-2f, 0f); //Temp: Loads the gunshot sound. //gunShot = this.Game.Content.Load<SoundEffect>("System\\Sounds\\flintShot"); //Temp: Sets the input monitor up. input = InputMonitor.Instance; //Set the Bounding Box Height and Width // Lou note: We should define this in XML. this.boundingBoxHeight = 61; this.boundingBoxWidth = 33; this.boundingBoxOffset = new Vector2(); this.boundingBoxOffset.X = boundingBoxWidth/2; this.boundingBoxOffset.Y = boundingBoxHeight/2; halfJumpTime = maxJumpTime / 2; //Set Invincibility invincible = false; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> public override void Initialize() { if (!this.IsInitialized) { tileEngine = new TileEngine(); fullScreenSettings = new ResolutionSettings(640, 480, 640, 480, true); ScreenManager.Instance.ResolutionService.CurrentResolutionSettings = windowedSettings; batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService)); // Create a new, empty world: world = new World(this, WORLD_FILENAME); // We need to disable the SpriteSpriteCollisionManager because it makes some assumptions about // the gameScreen... world.SpriteCollisionManager.Enabled = false; // Create an empty, maximally-sized tilemap to center // the loaded map onto: TileMap bigMap = new TileMap(MAX_TILEMAP_WIDTH, MAX_TILEMAP_HEIGHT, DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT, LAYER_COUNT, SUB_LAYER_COUNT); bigMap.FileName = world.Map.FileName; // Backup the original map: TileMap map = world.Map; // Compute the point where we want to blit it onto the empty map: this.offsetX = (bigMap.Width / 2) - (map.Width / 2); this.offsetY = (bigMap.Height / 2) - (map.Height / 2); bigMap.BlitTileMap(map, offsetX, offsetY); world.Map = bigMap; foreach (TileMapLayer tml in world.interactiveLayers.Values) { Components.Remove(tml); } world.interactiveLayers.Clear(); world.ShiftWorldObjects(new Vector2(world.Map.TileWidth * offsetX, world.Map.TileWidth * offsetY)); for (int i = 0; i < world.Map.LayerCount; ++i) { TileMapLayer tml = new TileMapLayer(this, batchService.GetSpriteBatch(TileMapLayer.SpriteBatchName), world.Map, i); if (i == 0) { tml.DrawOrder = World.PLAYER_DRAW_ORDER - DEFAULT_LAYER_SPACING; } else { if (i == world.Map.LayerCount - 1) { tml.DrawBlanksEnabled = true; tml.DrawEdgesEnabled = true; tml.DrawDestructablesEnabled = true; } tml.DrawOrder = World.PLAYER_DRAW_ORDER + i * DEFAULT_LAYER_SPACING; } world.interactiveLayers[tml.DrawOrder] = tml; Components.Add(world.interactiveLayers[tml.DrawOrder]); } world.Initialize(); world.Camera.Position = world.Player.Position;// -new Vector2(world.Camera.VisibleArea.Width / 2, world.Camera.VisibleArea.Height / 2); world.Paused = true; Components.Add(world); // Set up editor controls: inputMonitor = InputMonitor.Instance; inputMonitor.AssignPressable("EditorLeft", new PressableKey(Keys.A)); inputMonitor.AssignPressable("EditorRight", new PressableKey(Keys.D)); inputMonitor.AssignPressable("EditorUp", new PressableKey(Keys.W)); inputMonitor.AssignPressable("EditorDown", new PressableKey(Keys.S)); inputMonitor.AssignPressable("EditorAppend", new PressableKey(Keys.LeftShift)); inputMonitor.AssignPressable("ToggleFullScreen", new PressableKey(Keys.F)); inputMonitor.AssignPressable("EditorCycleMode", new PressableKey(Keys.Tab)); Components.Add(inputMonitor); CreateUIComponents(); Mode = EditMode.SpriteEdit; CycleMode(); // Initialize all components base.Initialize(); } }