public MapBase(SpriteSheetLoader loader, SpriteBatch spriteBatch) { MapSheetLoader = loader; MapBatch = spriteBatch; MapRender = new SpriteRender(MapBatch); }
public MapManager(SpriteSheetLoader spriteSheetLoader, SpriteBatch spriteBatch) { _spriteSheetLoader = spriteSheetLoader; _spriteBatch = spriteBatch; CurrentMap = new TestMap(_spriteSheetLoader, _spriteBatch); }
public PunchAttack(SpriteSheetLoader spriteSheetLoader, SpriteBatch spriteBatch) { _spriteBatch = spriteBatch; _spriteLoader = spriteSheetLoader; _spriteRender = new SpriteRender(_spriteBatch); }
public AssetManager(ContentManager content) { this._content = content; this._spriteSheetLoader = new SpriteSheetLoader(content); }
public TestMap(SpriteSheetLoader spriteSheetLoader, SpriteBatch spriteBatch) : base(spriteSheetLoader, spriteBatch) { }
void Manager_OnBeginMenuChange(object sender, MenuChangeEventArgs e) { offsetVelocity = Vector2.Zero; if (e.Menu == Manager.Menues["Campaing"]) { selectedEpisode = selectedCampaing.Episodes[0]; selectedMission = selectedEpisode.Missions[0]; TutorialMode = selectedCampaing.InternalName == "Tutorial"; TutorialProgress = 0; textManager.Text = selectedCampaing.Name + "\n\n\n" + selectedCampaing.ShortDescription; textManager.Parse(); RCS.PreCache<Texture2D>("Menues/Strategic/Strategy"); RCS.PreCache<Texture2D>("Menues/Strategic/06"); RCS.PreCache<Texture2D>("Menues/Strategic/Hex2"); RCS.PreCache<Texture2D>("Menues/Strategic/Screen"); RCS.PreCache<Texture2D>("Menues/Strategic/science_screen"); for (int i = 1; i <= 4; i++) { //Load science for (int j = 1; j <= 6; j++) { RCS.PreCache<Texture2D>(string.Format("Science/{0}_{1}", i, j)); } } RCS.PreCache<Texture2D>("Menues/Strategic/selection_tactical"); textSettings.Width = 310; textSettings.Offset = new Vector2(425, 60); textManager.Text = selectedCampaing.Name + "\n\n\n" + selectedCampaing.ShortDescription; textManager.Parse(); RCS.PreCache<Texture2D>("Menues/Strategic/06"); if (SSL == null) { SSL = new SpriteSheetLoader(); ScienceAnimator.AtStart = new Vector2(462, 8); ScienceAnimator.AtEnd = new Vector2(25, 319); ScienceAnimator.Duration = 1000; ScienceAnimatorReversed.AtEnd = new Vector2(462, 8); ScienceAnimatorReversed.AtStart = new Vector2(25, 319); ScienceAnimatorReversed.Duration = 1000; IAnimator<Vector2> Empty = new SmoothVectorAnimator(); Empty.AtStart = Vector2.Zero; Empty.AtEnd = Vector2.Zero; Empty.Duration = 0; IResourceObject<Texture2D> BaseOverlay = RCS.GetObject<Texture2D>("Menues/Base/Base"); Menu Three = new Menu(Empty, Empty, BuildMessageBox()); Three.OnDraw += CampaignDescriptionOnDraw; Manager.Menues.Add("Base", Three); Three.Controls.Add(new Image() { Texture = BaseOverlay, Position = Vector2.Zero, Depth = 0.48f }); Three.Controls.Add(new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Base/bg_ext"), Position = new Vector2(0, 0), Depth = 0.6f }); Three.Controls.Add(new AdControl(adManager) { Position = new Vector2(252, 415), Scale = 1, Depth = 0 }); HybridButton LeftBase = new HybridButton(RCS.GetObject<Texture2D>("Menues/LeftButton"), RCS.GetObject<Texture2D>("Menues/LeftButton"), new Vector2(43, 444)); LeftBase.Origin = new Vector2(0, 62); LeftBase.NextMenu = "%Back%"; LeftBase.CanOffset = false; LeftBase.Depth = 0.01f; LeftBase.Font = Font; LeftBase.HoverColor = new Color(50, 238, 50); LeftBase.UseSound = true; LeftBase.Sound = MenuItemSelected.CreateInstance(); LeftBase.TextPosition = -LeftBase.Origin + new Vector2(50, 23); LeftBase.Text = LocalizationData.Back; HybridButton RightBase = new HybridButton(RCS.GetObject<Texture2D>("Menues/RightButton"), RCS.GetObject<Texture2D>("Menues/RightButton"), new Vector2(757, 444)); RightBase.Origin = new Vector2(172, 62); RightBase.CanOffset = false; RightBase.Depth = 0.01f; RightBase.HoverColor = new Color(50, 238, 50); RightBase.UseSound = true; RightBase.Sound = MenuItemSelected.CreateInstance(); RightBase.NextMenu = "Strategic"; RightBase.Font = Font; RightBase.TextPosition = -RightBase.Origin + new Vector2(60, 23); RightBase.Text = LocalizationData.Select; Three.Controls.Add(LeftBase); Three.Controls.Add(RightBase); EpilogueMenu eMenu = new EpilogueMenu(); Manager.Menues.Add("Epilogue", eMenu); } } else if (e.Menu == Manager.Menues["Strategic"]) { if (TutorialMode) { if (TutorialProgress == 0) { e.Menu.MessageBox.Text = LocalizationData.Tutorial0; e.Menu.MessageBox.Show(true); e.Menu.MessageBox.OnClosed += new Action(MessageBox_OnClosed); TutorialProgress++; } } if (GalaxyImage == null) GalaxyImage = new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Strategic/06"), CanOffset = true, Depth = 0.9f }; ScienceDNA = RCS.GetObject<Texture2D>("Menues/Strategic/science_screen"); textManager.Settings.Width = 200; textManager.Settings.Offset = new Vector2(545, 50); textManager.Text = ""; textManager.Parse(); e.Menu.Controls.Clear(); e.Menu.Controls.Add(new AdControl(adManager) { Position = new Vector2(252, 415), Scale = 1, Depth = 0 }); HybridButton LeftStrategic = new HybridButton(RCS.GetObject<Texture2D>("Menues/LeftButton"), RCS.GetObject<Texture2D>("Menues/LeftButton"), new Vector2(43, 444)); LeftStrategic.Origin = new Vector2(0, 62); LeftStrategic.NextMenu = "%Back%"; LeftStrategic.UseSound = true; LeftStrategic.HoverColor = new Color(50, 238, 50); LeftStrategic.Sound = MenuItemSelected.CreateInstance(); LeftStrategic.CanOffset = false; LeftStrategic.Depth = 0.01f; LeftStrategic.Font = Font; LeftStrategic.TextPosition = -LeftStrategic.Origin + new Vector2(50, 23); LeftStrategic.Text = LocalizationData.Back; HybridButton RightStrategic = new HybridButton(RCS.GetObject<Texture2D>("Menues/RightButton"), RCS.GetObject<Texture2D>("Menues/RightButton"), new Vector2(757, 444)); RightStrategic.Origin = new Vector2(172, 62); RightStrategic.NextMenu = "Mission"; RightStrategic.CanOffset = false; RightStrategic.UseSound = true; RightStrategic.HoverColor = new Color(50, 238, 50); RightStrategic.Sound = MenuItemSelected.CreateInstance(); RightStrategic.Depth = 0.01f; RightStrategic.Font = Font; RightStrategic.TextPosition = -RightStrategic.Origin + new Vector2(60, 23); RightStrategic.Text = LocalizationData.Select; e.Menu.Controls.Add(new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Strategic/Strategy"), Position = Vector2.Zero, Depth = 0.1f }); e.Menu.Controls.Add(new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Strategic/Screen"), Position = Vector2.Zero, Depth = 0.7f }); e.Menu.Controls.Add(GalaxyImage); e.Menu.Controls.Add(LeftStrategic); e.Menu.Controls.Add(RightStrategic); int TextureNumber = playerData.Research["Growth"] + 1; if (TextureNumber >= 6) { TextureNumber = 6; } TexturedButton Science1 = new TexturedButton(RCS.GetObject<Texture2D>(string.Format("Science/1_{0}", TextureNumber)), RCS.GetObject<Texture2D>(string.Format("Science/1_{0}", TextureNumber)), new Vector2(100, 10) - new Vector2(37, 319)); TextureNumber = playerData.Research["Speed"] + 1; if (TextureNumber >= 6) { TextureNumber = 6; } TexturedButton Science2 = new TexturedButton(RCS.GetObject<Texture2D>(string.Format("Science/2_{0}", TextureNumber)), RCS.GetObject<Texture2D>(string.Format("Science/2_{0}", TextureNumber)), new Vector2(100 + 164, 10) - new Vector2(37, 319)); TextureNumber = playerData.Research["Attack"] + 1; if (TextureNumber >= 6) { TextureNumber = 6; } TexturedButton Science3 = new TexturedButton(RCS.GetObject<Texture2D>(string.Format("Science/3_{0}", TextureNumber)), RCS.GetObject<Texture2D>(string.Format("Science/3_{0}", TextureNumber)), new Vector2(100, 10 + 164) - new Vector2(37, 319)); TextureNumber = playerData.Research["Defense"] + 1; if (TextureNumber >= 6) { TextureNumber = 6; } TexturedButton Science4 = new TexturedButton(RCS.GetObject<Texture2D>(string.Format("Science/4_{0}", TextureNumber)), RCS.GetObject<Texture2D>(string.Format("Science/1_{0}", TextureNumber)), new Vector2(100 + 164, 10 + 164) - new Vector2(37, 319)); Science1.Visible = Science1.Enabled = true; Science1.Scale = 0.640625f; Science2.Visible = Science2.Enabled = true; Science2.Scale = 0.640625f; Science3.Visible = Science3.Enabled = true; Science3.Scale = 0.640625f; Science4.Visible = Science4.Enabled = true; Science4.Scale = 0.640625f; Science1.Tag = "Science1"; Science2.Tag = "Science2"; Science3.Tag = "Science3"; Science4.Tag = "Science4"; Science1.OnClick += ScienceOnClick; Science2.OnClick += ScienceOnClick; Science3.OnClick += ScienceOnClick; Science4.OnClick += ScienceOnClick; Science1.UseSound = true; Science2.UseSound = true; Science3.UseSound = true; Science4.UseSound = true; Science1.Sound = MenuItemSelected.CreateInstance(); Science2.Sound = MenuItemSelected.CreateInstance(); Science3.Sound = MenuItemSelected.CreateInstance(); Science4.Sound = MenuItemSelected.CreateInstance(); e.Menu.Controls.Add(Science1); e.Menu.Controls.Add(Science2); e.Menu.Controls.Add(Science3); e.Menu.Controls.Add(Science4); int tC = 4; Control[] controls = (from c in e.Menu.Controls where CheckScienceTag(c.Tag) select c).ToArray(); foreach (Control control in controls) { Image image = new Image(); image.CanOffset = false; image.Position = (control as TexturedButton).Position; image.Enabled = true; image.Visible = true; image.Scale = 1f; image.Depth = 0.72f; image.Color = Color.White; image.Tag = "Science" + (tC.ToString()); tC++; image.Texture = RCS.GetObject<Texture2D>("Science/science_icon_bg"); e.Menu.Controls.Add(image); } EpisodeProgressCounter = 0; HexControl hexControl = new HexControl(RCS.GetObject<Texture2D>("Menues/Strategic/Hex2"), factory.GetHexFill(410, new Vector2(512, 512))); hexControl.Depth = 0.8f; foreach (Episode episode in selectedCampaing.Episodes) { if (EpisodeProgressCounter < playerData.GetProgress(selectedCampaing.InternalName)) { selectedEpisode = episode; selectedMission = selectedEpisode.Missions[0]; hexControl[episode.Position].Color = Color.Yellow * 0.7f; EpisodeProgressCounter += episode.Missions.Count; } else { hexControl[episode.Position].Color = Color.White * 0.8f; } if (EpisodeProgressCounter < playerData.GetProgress(selectedCampaing.InternalName)) { hexControl[episode.Position].Color = new Color(53, 234, 28) * 0.7f; foreach (int cell in episode.Cells) hexControl[cell].Color = new Color(53, 234, 28) * 0.7f; } hexControl[episode.Position].Tag = episode; hexControl[episode.Position].OnClick += new Action<Cell>(hexControl_OnClick); } textManager.Text = selectedEpisode.Name + "\n\n\n\n\n" + selectedEpisode.Description; textManager.Parse(); e.Menu.Controls.Add(hexControl); /* foreach (Episode episode in selectedCampaing.Episodes) { AnimatedButton animated = new AnimatedButton(SSL.DescriptorList["StrategicEpisodeSelection"]); animated.Position = episode.Position; animated.Origin = new Vector2(32, 32); if (EpisodeProgressCounter < playerData.GetProgress(selectedCampaing.InternalName)) { animated.Enabled = true; EpisodeProgressCounter += episode.Missions.Count; } else { animated.Enabled = false; } animated.CanOffset = true; animated.Depth = 0.8f; animated.Color = animated.Enabled ? Color.Khaki : Color.Gray; animated.Tag = episode; animated.OnClick += new EventHandler(animated_OnClick); e.Menu.Controls.Add(animated); } */ EpisodeProgressCounter = 0; foreach (Episode ep in selectedCampaing.Episodes) { if (ep != selectedEpisode) EpisodeProgressCounter += ep.Missions.Count; else break; } e.Menu.InitializeControls(); } else if (e.Menu == Manager.Menues["Mission"]) { if (TutorialMode) if (TutorialProgress == 4) { e.Menu.MessageBox.Text = LocalizationData.Tutorial4; e.Menu.MessageBox.Show(true); TutorialProgress++; } MissionOffset = Vector2.Zero; textManager.Settings.Width = 200; textManager.Settings.Offset = new Vector2(545, 50); e.Menu.Controls.Clear(); e.Menu.Controls.Add(new AdControl(adManager) { Position = new Vector2(252, 415), Scale = 1, Depth = 0 }); HybridButton LeftMission = new HybridButton(RCS.GetObject<Texture2D>("Menues/LeftButton"), RCS.GetObject<Texture2D>("Menues/LeftButton"), new Vector2(43, 444)); LeftMission.Origin = new Vector2(0, 62); LeftMission.NextMenu = "%Back%"; LeftMission.CanOffset = false; LeftMission.Depth = 0.01f; LeftMission.HoverColor = new Color(50, 238, 50); LeftMission.UseSound = true; LeftMission.Sound = MenuItemSelected.CreateInstance(); LeftMission.Font = Font; LeftMission.TextPosition = -LeftMission.Origin + new Vector2(50, 23); LeftMission.Text = LocalizationData.Back; HybridButton RightMission = new HybridButton(RCS.GetObject<Texture2D>("Menues/RightButton"), RCS.GetObject<Texture2D>("Menues/RightButton"), new Vector2(757, 444)); RightMission.Origin = new Vector2(172, 62); RightMission.CanOffset = false; RightMission.Depth = 0.01f; RightMission.HoverColor = new Color(50, 238, 50); RightMission.Font = Font; RightMission.UseSound = true; RightMission.Sound = MenuItemSelected.CreateInstance(); RightMission.TextPosition = -RightMission.Origin + new Vector2(60, 23); RightMission.Text = LocalizationData.Play; RightMission.OnClick += new EventHandler(RightMission_OnClick); e.Menu.Controls.Add(LeftMission); e.Menu.Controls.Add(RightMission); e.Menu.Controls.Add(new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Strategic/Strategy"), Position = Vector2.Zero, Depth = 0.1f }); e.Menu.Controls.Add(new Image() { Texture = RCS.GetObject<Texture2D>("Menues/Strategic/Screen"), Position = Vector2.Zero, Depth = 0.7f }); e.Menu.Controls.Add(PopupMB); int Counter = EpisodeProgressCounter; if (EpisodeProgressCounter == playerData.GetProgress(selectedCampaing.InternalName) - 1) { if (!String.IsNullOrWhiteSpace(selectedEpisode.EpisodePopup)) { PopupTextManager.Text = selectedEpisode.EpisodePopup; PopupTextManager.Parse(); PopupMB.Show(true); } } foreach (Mission mission in selectedEpisode.Missions) { Vector2 Position = Vector2.Zero; if (Counter - EpisodeProgressCounter == 0 || Counter - EpisodeProgressCounter == selectedEpisode.Missions.Count - 1) { Position = new Vector2(150 + (Counter - EpisodeProgressCounter) * 256, 240); } else { bool Even = (Counter - EpisodeProgressCounter - 1) % 2 == 0; if (Even) { Position = new Vector2(150 + (Counter - EpisodeProgressCounter) * 256, 140); } else { Position = new Vector2(150 + (Counter - EpisodeProgressCounter) * 256, 340); } } Position.Y -= 30; TexturedButton tb = new TexturedButton(RCS.GetObject<Texture2D>("Menues/Strategic/selection_tactical"), RCS.GetObject<Texture2D>("Menues/Strategic/selection_tactical"), Position); tb.CanOffset = true; tb.Scale = 0.5f; tb.Origin = new Vector2(128, 128); tb.Color = Counter < playerData.GetProgress(selectedCampaing.InternalName) ? Color.White : Color.Black; if (tb.Color == Color.White) selectedMission=mission; tb.Depth = 0.8f; tb.Enabled = Counter < playerData.GetProgress(selectedCampaing.InternalName) ? true : false; tb.Tag = mission; tb.OnClick += new EventHandler(tb_OnClick); e.Menu.Controls.Add(tb); Counter++; } (from control in e.Menu.Controls where control.Tag == selectedMission select control).First().Color = Color.Gray; textManager.Text = selectedMission.Name + "\n\n\n\n\n" + selectedMission.Description; textManager.Parse(); e.Menu.InitializeControls(); } }
//EventHandler for EnemyDestroyed Animation //public event EnemyDestroyedHandler EnemyDestroyEvent; //public delegate void EnemyDestroyedHandler(EnemyClass enemy, EventArgs e, float elapsedSeconds); //public EventArgs e = null; public EnemyClass(ContentManager content, Random random, int screenWidth, SpriteBatch spriteBatch, SpriteSheetLoader spriteSheetLoader) { this.enemyHealth = 100; this.enemyBaseDamage = 25; this.enemyDamageMultiplier = 1f; this.enemyActive = true; this.spriteBatch = spriteBatch; this.enemySpriteRender = new SpriteRender(this.spriteBatch); this.enemySpriteSheet = TextureManager.enemySpriteSheet; this.enemyDeathAnimation = new EnemyDeathAnimation(this.spriteBatch, this.enemySpriteSheet, this.enemySpriteRender); Vector2 initialPosition = new Vector2(random.Next(100, (int)(screenWidth - (enemyTexture.Width * shipScale.X))), (0 - (enemyTexture.Height * shipScale.X))); this.enemyPosition = initialPosition; float hbScale = 0.2f; Vector2 initialEnemyHBPosition = (this.enemyPosition + (new Vector2((((enemyTexture.Width * shipScale.X) / 2) - (((HealthBar.healthBarTexture.Width * hbScale) / 2) + 5)), (enemyTexture.Height * shipScale.X) + 5))); enemyHealthBar = new HealthBar(spriteBatch, initialEnemyHBPosition, this.enemyHealth, hbScale); }
public PlayerAttackComponent(SpriteSheetLoader spriteSheetLoader, SpriteBatch spriteBatch) { _spriteBatch = spriteBatch; _spriteLoader = spriteSheetLoader; _punchAttack = new PunchAttack(_spriteLoader, _spriteBatch); }
public TestNpcGraphicsComponent(SpriteSheetLoader spriteSheetLoader, SpriteBatch spriteBatch) { _spriteBatch = spriteBatch; _spriteSheetLoader = spriteSheetLoader; _spriteRender = new SpriteRender(_spriteBatch); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Status"); SpriteSheetLoader loader = new SpriteSheetLoader(Content, _fileReader); var ss = loader.Load("fanatiblaster"); var frame = ss.SpriteList[SpriteNames.Down_spritesheetforthegame_1_0]; var animationCache = new AnimationCache(ss); animationCache.Animations.Add("down", new string[] { SpriteNames.Down_spritesheetforthegame_1_1, SpriteNames.Down_spritesheetforthegame_1_2, SpriteNames.Down_spritesheetforthegame_1_3, SpriteNames.Down_spritesheetforthegame_1_4, SpriteNames.Down_spritesheetforthegame_1_5, SpriteNames.Down_spritesheetforthegame_1_6, SpriteNames.Down_spritesheetforthegame_1_7, SpriteNames.Down_spritesheetforthegame_1_8 }); MovementSystem movementSystem = new MovementSystem(_channelManager, 25, new string[] { "default" }); TextRenderSystem textRenderSystem = new TextRenderSystem(spriteBatch, _channelManager, 100, "default"); TextureRenderSystem textureRenderSystem = new TextureRenderSystem(spriteBatch, _channelManager, 101, "default"); SpriteAnimationSystem spriteAnimationSystem = new SpriteAnimationSystem(animationCache, _channelManager, 30, "default"); _gameManager.AddSystem(textRenderSystem); _gameManager.AddSystem(movementSystem); _gameManager.AddSystem(textureRenderSystem); _gameManager.AddSystem(spriteAnimationSystem); var te = _gameManager.EntityManager.Get("text", new string[] { "default" }); te.CreateTextRenderEntity("Some Text", Color.Black, new Vector2(100, 100), 5, 1.0f, font); var teMove = _gameManager.EntityManager.Get("text2", new string[] { "default" }); teMove.CreateTextRenderEntity("I'm Moving!", Color.Black, new Vector2(1, 1), 5, 1.0f, font) .AddComponent(new VelocityComponent() { Direction = new Vector2(1, 1), Speed = new Vector2(15, 15) }); var teSprite = _gameManager.EntityManager.Get("sprite"); teSprite.MakeTextureRenderAspect(new Vector2(150, 150), frame.IsRotated, frame.Origin, frame.SourceRectangle, frame.Texture, SpriteEffects.None, Color.White, 1.0f, 0.0f) .AddComponent(new AnimationComponent() { Active = true, CurrentAnimation = "down", CurrentFrameIndex = 0, ShouldLoop = true, FPS = 8.0f }); _gameManager.AddEntity(te); _gameManager.AddEntity(teMove); _gameManager.AddEntity(teSprite); }