public void SetData(DrawableGameComponent component) { Position = component.Position; Rotation = component.Rotation; Scale = component.Scale; Velocity = component.Velocity; }
public Vector3 GetDirection(DrawableGameComponent component) { Vector3 direction = component.Position - Position; direction.Y = 0; direction.Normalize(); return direction; }
public Trap IntersectsEnemyTrap(DrawableGameComponent component, byte playerId) { foreach (Trap trap in trapList) if (trap.PlayerId != playerId && trap.Intersects(component)) return trap; return null; }
public void SetSpellTarget(DrawableGameComponent target) { if (target != null && !(target is OldNPCRenderer || target is OldCharacterRenderer)) //don't set target when it isn't valid! { return; } SpellTarget = target; }
private void SwitchDemo(DrawableGameComponent newDemo) { if (activeDemo != null) { Components.Remove(activeDemo); } activeDemo = newDemo; activeDemo.Initialize(); Components.Add(newDemo); }
public EOChatBubble(NPC following) : base(EOGame.Instance) { m_ref = following; isChar = false; DrawOrder = following.Index + (int)ControlDrawLayer.BaseLayer + 1; //use index for draw order _initLabel(); Visible = false; EOGame.Instance.Components.Add(this); }
public EOChatBubble(EOCharacterRenderer following) : base(EOGame.Instance) { m_ref = following; isChar = true; DrawOrder = following.Character.ID + (int)ControlDrawLayer.BaseLayer + 1; //use ID for draw order _initLabel(); Visible = false; EOGame.Instance.Components.Add(this); }
public void SetScreen(DrawableGameComponent newScreen) { if (screens.Count >= 1) { this.PreviousScreen = screens.Peek(); } this.screens.Push(newScreen); this.ActiveScreen = newScreen; }
/// <summary> /// Removes a life of the counter when the player dies. /// </summary> /// <param name="player">The player object</param> /// <param name="points">There are no points assigned in this method</param> private void removeLives(DrawableGameComponent player, int points) { lives -= 1; bomb.SpawnProtection(); ((PlayerSprite)player).ResetPosition(); if (lives == 0) { gameOver = true; } }
private EffectRenderer(INativeGraphicsManager gfxManager, DrawableGameComponent target, Action cleanupAction) { _target = target; _cleanupAction = cleanupAction; _effectSpriteManager = new EffectSpriteManager(gfxManager); _effectSoundManager = new EffectSoundManager(new SoundManager()); SetEffectInfoTypeAndID(EffectType.Invalid, -1); }
public void AddPlugin(Plugin plugin) { ActivePlugin = plugin; if (plugin is DrawableGameComponent) { DrawableGameComponent pluginComp = (DrawableGameComponent)plugin; pluginComp.UpdateOrder = 10; pluginComp.DrawOrder = 10; Components.Add(pluginComp); } }
private async void CanvasAnimatedControl_CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args) { _interopDrawing = new InteropDrawingSession(); _game = DrawableGameComponent.CreateGame <ReversiXNAGame.ReversiXNAGame>( _interopDrawing, new InteropKeyboard(), new InteropMouse()); _interopDrawing.Game = _game; _game.Initialize(); _game.LoadAllContents(); await _interopDrawing.CreateResources(sender, args); }
/// <summary> /// Keeps track of the player's score. Also gives the player extra lives once they reach a certain amount of points. /// </summary> /// <param name="killedAlien">The alien that was killed</param> /// <param name="points">The value of the alien in points when it gets killed</param> private void setScore(DrawableGameComponent killedAlien, int points) { score += points; extraLifeAccumulator += points; if ((extraLifeAccumulator / 5000) >= 1) { extraLifeAccumulator -= 5000; lives++; extraLifeSoundInstance.Play(); } }
public Trap IntersectsEnemyTrap(DrawableGameComponent component, byte playerId) { foreach (Trap trap in trapList) { if (trap.PlayerId != playerId && trap.Intersects(component)) { return(trap); } } return(null); }
/// <summary> /// This adds the alien's opponent. /// </summary> /// <param name="component">The player</param> /// <exception cref="ArgumentException">Thrown if the component is not a /// PlayerSprite.</exception> public override void AddOpponent(DrawableGameComponent component) { if (component is PlayerSprite) { opponent = component as PlayerSprite; } else { throw new ArgumentException ("The opponent must be of PlayerSprite type."); } }
/// <summary> /// This is called when the player is hit by a projectile. /// (The player parameter could be used if in the future a multiplayer /// level is added.) /// </summary> /// <param name="player">The player</param> /// <param name="projectile">The projectile</param> private void onPlayerHit(DrawableGameComponent player, ProjectileSprite projectile) { health = health - projectile.Damage; if (health <= 0) { if (GameOver != null) { GameOver(); } } }
/// <summary> /// Adds to the score when an opponent dies. /// </summary> /// <param name="alien"></param> /// <param name="projectile"></param> private void onAlienHit(DrawableGameComponent component, ProjectileSprite projectile) { if (component is AlienSprite) { score += (ulong)(component as AlienSprite).Point; } else if (component is MotherShipSprite) { score += (ulong)(component as MotherShipSprite).Point; } }
public override void Draw(GameTime gameTime) { base.Draw(gameTime); foreach (GameComponent component in Components) { DrawableGameComponent drawable = component as DrawableGameComponent; if (drawable != null && drawable.Visible) { drawable.Draw(gameTime); } } }
public void SetState(GameState newState) { switch (newState) { case GameState.TitleScreen: _screen = new TitleScreen(this); break; case GameState.GameScreen: _screen = new GameScreen(this); break; } }
public ProjectileHandler GetNewHandler(DrawableGameComponent emitter) { if (projectileHandlers.ContainsKey(emitter)) { return(projectileHandlers[emitter]); } else { ProjectileHandler t = new ProjectileHandler(Game, spriteBatch); t.Initialize(); projectileHandlers.Add(emitter, t); return(t); } }
//Method which sets state for the scene public virtual void SetState(bool state) { this.Enabled = state; this.Visible = state; foreach (GameComponent item in Components) { item.Enabled = state; if (item is DrawableGameComponent) { DrawableGameComponent comp = (DrawableGameComponent)item; comp.Visible = state; } } }
/// <summary> /// Called when a collision is detected between an AlienSprite and a Projectile from the /// LaserFactory. /// </summary> /// <param name="killedAlien">The killed Alien from which the collision was detected on.</param> private void killAlien(DrawableGameComponent killedAlien, int points) { AlienSprite alien = ((AlienSprite)killedAlien); // remove a hit point from alien alien.SetHitPoints(alien.GetHitPoints() - 1); if (alien.GetHitPoints() <= 0) { alien.SetAlienState(AlienState.INACTIVE); alienKillSoundInstance.Play(); killedCount++; //Increases speed of squad once a certain number are killed if ((killedCount % 8) == 0) { Alien.IncreaseSpeed(); } //Resets squad if all are killed if (killedCount == alienSquad.Length) { level++; alienLevel++; resetAlienSquad(); } //Spawns mothership once a certain number are killed if (killedCount == (alienSquad.Length / 2)) { mothershipSprite.RandomizeMothershipSpawn(); mothershipSprite.SetAlienState(AlienState.ACTIVE); mothershipSprite.SetSpawnMother(true); } } else { // check what type of alien was hit, change texture to a hit sprite alien of that type if (alien.GetAlienType() == AlienType.SPACESHIP) { alien.SetTexture(hitAlienTexture1); } else if (alien.GetAlienType() == AlienType.BUG) { alien.SetTexture(hitAlienTexture2); } else if (alien.GetAlienType() == AlienType.FLYINGSAUCER) { alien.SetTexture(hitAlienTexture3); } } }
/// <summary> /// Pause the game. /// </summary> private void PauseCurrentGame() { // Move to the pause screen ScreenManager.AddScreen(new Screens.BackGround(), null); ScreenManager.AddScreen(new Screens.PauseScreen(), null); // Hide and disable all components which are related to the gameplay screen pauseEnabledComponents.Clear(); pauseVisibleComponents.Clear(); foreach (IGameComponent component in ScreenManager.Game.Components) { if (component is CardsGame.Misc.BetGameComponent || component is BlackJack21.CardFramework.AnimatedGameComponent || component is _21BlackJack.CardsFrameWork.UserInterface.GameTable || component is InputHelper) { DrawableGameComponent pauseComponent = (DrawableGameComponent)component; if (pauseComponent.Enabled) { pauseEnabledComponents.Add(pauseComponent); pauseComponent.Enabled = false; } if (pauseComponent.Visible) { pauseVisibleComponents.Add(pauseComponent); pauseComponent.Visible = false; } } } }
public void CreateItem(byte id) { var item = new DrawableGameComponent(Config.ItemsCylinderRadius, Config.ItemsCylinderHeight); item.Scale = new Vector3(Config.ItemsScale); do { item.Position = Server.Terrain.GetRandomPositionOnTerrain(); }while (Server.VegetationManager.IntersectsAny(item)); items[id] = item; Server.Send(new NetworkPacketAddItem(id, item)); }
public override void Draw(GameTime gameTime) { foreach (GameComponent component in components) { if (component is DrawableGameComponent) { DrawableGameComponent drawComponent = (DrawableGameComponent)component; if (drawComponent.Visible) { drawComponent.Draw(gameTime); } } } }
/// <summary> /// This constructor makes the DamageCounter follow 'actor' on the screen. /// </summary> /// <param name="actor">EOCharacterRenderer or NPC</param> /// <param name="actorType">actor.GetType()</param> public DamageCounter(DrawableGameComponent actor, Type actorType) { m_ref = actor; if (actorType == typeof(NPC)) { m_isCharacter = false; } else if (actorType == typeof(EOCharacterRenderer)) { m_isCharacter = true; } else { throw new ArgumentException("Invalid actor type. Use Character or NPC", "actorType"); } lock (gfx_init_lock) { Texture2D wholeSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58, true); //lazy init of spritesheet - static so same texture in use for all damage counters //this sheet is a subsheet of GFX002/158 that has only the numbers and 'miss' text if (s_NumberSprites == null) { Color[] data = new Color[122 * 23]; wholeSheet.GetData(0, new Rectangle(41, 29, 122, 23), data, 0, data.Length); s_NumberSprites = new Texture2D(Game.GraphicsDevice, 122, 23); s_NumberSprites.SetData(data); } //same with health bars - subsheet of GFX002/158 that has only the health bars if (s_HealthBarSprites == null) { Color[] data = new Color[40 * 35]; wholeSheet.GetData(0, new Rectangle(0, 28, 40, 35), data, 0, data.Length); s_HealthBarSprites = new Texture2D(Game.GraphicsDevice, 40, 35); s_HealthBarSprites.SetData(data); } } m_numbersToDraw = new List <Rectangle>(); Visible = false; if (!Game.Components.Contains(this)) { Game.Components.Add(this); } }
public void Show(bool show) { Enabled = show; Visible = show; foreach (GameComponent component in Components) { component.Enabled = show; DrawableGameComponent drawable = component as DrawableGameComponent; if (drawable != null) { drawable.Visible = show; } } }
/// <summary> /// Drawing any drawable component in this screen. /// </summary> /// <param name="i_GameTime">Game Time.</param> public override void Draw(GameTime i_GameTime) { SpriteBatch spriteBatch = Game.Services.GetService(typeof(SpriteBatch)) as SpriteBatch; spriteBatch.Begin(); if (m_screenMode.HasFlag(eScreenMode.Visible)) { for (int i = 0; i < m_gameDrawableComponentCollection.Count; i++) { DrawableGameComponent component = m_gameDrawableComponentCollection[i] as DrawableGameComponent; component.Draw(i_GameTime); } } spriteBatch.End(); }
private void DisableServicesComponents() { var components = this.Components; Int32 count = components.Count(); for (Int16 i = 0; i < count; i++) { GameComponent component = components.ElementAt(i) as GameComponent; component.Enabled = false; DrawableGameComponent comp = component as DrawableGameComponent; if (comp != null) { comp.Visible = false; } } }
/// <summary> /// This adds the player's opponents. /// </summary> /// <param name="component">The opponent to be added.</param> public override void AddOpponent(DrawableGameComponent component) { if (component is AlienSquad) { opponent = component as AlienSquad; } else if (component is MotherShipSprite) { motherShip = component as MotherShipSprite; } else { throw new ArgumentException ("The opponent must be of AlienSquad or MotherShipSprite type."); } }
/// <summary> /// Draw /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { DrawableGameComponent comp = null; foreach (GameComponent item in Components) { if (item is DrawableGameComponent) { comp = (DrawableGameComponent)item; if (comp.Visible) { comp.Draw(gameTime); } } } base.Draw(gameTime); }
/// <summary> /// This method is to draw for components in visible screen. /// </summary> /// <param name="gameTime"></param> public override void Draw(GameTime gameTime) { DrawableGameComponent GameComponent = null; foreach (GameComponent item in components) { if (item is DrawableGameComponent) { GameComponent = (DrawableGameComponent)item; if (GameComponent.Visible) { // Draw components in the visible component GameComponent.Draw(gameTime); } } } base.Draw(gameTime); }
/// <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); // TODO: use this.Content to load your game content here shotHandlerGroup = new ProjectileHandlerGroup(this, spriteBatch); shotHandlerGroup.Initialize(); bg = new Background(this as Game); bg.Initialize(); fps = new FPSCounter(this as Game); fps.Initialize(); planet = new HomePlanet(this as Game); planet.Initialize(); planetHud = new PlanetStatusDisplay(this as Game, planet as HomePlanet); planetHud.Initialize(); planetBasis = new PlanetBasis(this as Game, spriteBatch, shotHandlerGroup); planetBasis.Initialize(); enemy = new BaseEnemy(this, spriteBatch, 1.0f, new Vector2(900, 800)); enemy.Initialize(); }
public NetworkPacketDrawable(byte type, byte id, byte additionalDataSize = 0, DrawableGameComponent component = null) : base(type, id, (byte)(size + additionalDataSize)) { if (component != null) SetData(component); }
public bool Intersects(DrawableGameComponent component) { return GetBoundingCylinder().Intersects(component.GetBoundingCylinder()); }
/// <summary> /// Removes the specified Component from the game /// </summary> /// <param name="component">The component to Remove</param> public void RemoveComponent(DrawableGameComponent component) { this.Components.Remove(component); }
public void RegisterNewComponent(DrawableGameComponent component) { GameComponents.Add(component); }