public DeathComponentSpawner(string name, GameComponent parent, Matrix localTransform, Vector3 boundingExtents, Vector3 boundingBoxPos, List<Body> spawns) : base(name, parent, localTransform, boundingExtents, boundingBoxPos, false) { Spawns = spawns; ThrowSpeed = 5.0f; AddToCollisionManager = false; }
public Mesh(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, string modelType, bool addToCollisionManager) : base(name, parent, localTransform, Vector3.Zero, Vector3.Zero, addToCollisionManager) { ModelType = modelType; Instance = PlayState.InstanceManager.AddInstance(ModelType, GlobalTransform, Tint); instanceVisible = true; }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = screenManager.Game.Content; Viewport viewport = screenManager.Game.GraphicsDevice.Viewport; viewportSize = new Vector2(viewport.TitleSafeArea.Width, viewport.TitleSafeArea.Height); blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground"); mainMenuTitle = content.Load<Texture2D>("Graphics/mainMenuTitle"); tile = content.Load<Texture2D>("Graphics/tile"); road = content.Load<Texture2D>("Graphics/road"); block = content.Load<Texture2D>("Graphics/block"); playerCar = content.Load<Texture2D>("Graphics/Road_Fighter_Player"); playerCarOrigin = new Vector2(playerCar.Width / 2, playerCar.Height); debugFont = content.Load<SpriteFont>("Fonts/debugFont"); //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = screenManager.Game.Content; Viewport viewport = screenManager.Game.GraphicsDevice.Viewport; //viewportSize = new Vector2(800, 600); blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground2"); background = content.Load<Texture2D>("Graphics/background"); for (int i = 0; i < walk.Length; i++) { walk[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Walk"); idle[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Idle"); die[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Die"); } mouseOver = content.Load<Texture2D>("Graphics/mouseOver"); mouseOverOrigin = new Vector2(mouseOver.Width, mouseOver.Height) / 2; for (int i = 0; i < castle.Length; i++) castle[i] = content.Load<Texture2D>("Graphics/" + (Shape)i + "Castle"); castleOrigin = new Vector2(castle[0].Width / 2, castle[0].Height); pathArrow = content.Load<Texture2D>("Graphics/pathArrow"); pathCross = content.Load<Texture2D>("Graphics/pathCross"); healthBar = content.Load<Texture2D>("Graphics/healthBar"); for (int i = 0; i < MaxRank; i++) { weapon[i] = content.Load<Texture2D>("Graphics/" + (Rank)i + "Weapon"); //armyOverlay[i] = content.Load<Texture2D>("Graphics/" + ((Rank)(i)).ToString() + "Overlay"); bullet[i] = content.Load<Texture2D>("Graphics/" + (Rank)i + "Bullet"); } for (int i = 0; i < tutorial.Length; i++) tutorial[i] = content.Load<Texture2D>("Graphics/tutotrial" + i); levelUp = content.Load<Texture2D>("Graphics/levelUp"); retry = content.Load<Texture2D>("Graphics/retry"); debugFont = content.Load<SpriteFont>("Fonts/debugFont"); gameFont = content.Load<SpriteFont>("Fonts/bicho_plumon50"); audioEngine = new AudioEngine("Content/Audio/Audio.xgs"); soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb"); waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); soundBank.PlayCue("Marching by Pill"); //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = screenManager.Game.Content; Viewport viewport = screenManager.Game.GraphicsDevice.Viewport; viewportSize = new Vector2(viewport.Width, viewport.Height); blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground"); mainMenuTitle = content.Load<Texture2D>("Graphics/mainMenuTitle"); debugFont = content.Load<SpriteFont>("Fonts/debugFont"); gameFontSize = 60; gameFont = content.Load<SpriteFont>("Fonts/chunky" + gameFontSize.ToString()); //MediaPlayer.Volume = 1; MediaPlayer.IsRepeating = true; //SoundEffect.MasterVolume = 1; // Initialize audio objects. //audioEngine = new AudioEngine("Content/Audio/Audio.xgs"); //soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb"); //waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); //soundBank.GetCue("music").Play(); //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
public TrapSensor(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos) : base(name, parent, localTransform, boundingBoxExtents, boundingBoxPos) { OnSensed += TrapSensor_OnSensed; Tags.Add("Sensor"); DrawBoundingBox = true; FireTimer = new Timer(0.5f, false); }
public VoxelListener(ComponentManager manager, GameComponent parent, ChunkManager chunkManager, Voxel vref) : base("VoxelListener", parent) { Chunk = vref.Chunk; VoxelID = new Point3(vref.GridPosition); Chunk.OnVoxelDestroyed += VoxelListener_OnVoxelDestroyed; ChunkID = Chunk.ID; }
public Fixture(Vector3 position, SpriteSheet asset, Point frame, GameComponent parent) : base("Fixture", parent, Matrix.CreateTranslation(position), Vector3.One * 0.45f, Vector3.Zero, true) { Sprite = new Sprite(Manager, "Sprite", this, Matrix.Identity, asset, false); Sprite.AddAnimation(new Animation(asset.GenerateFrame(frame))); AddToCollisionManager = false; CollisionType = CollisionManager.CollisionType.Static; }
public Sprite(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, SpriteSheet spriteSheet, bool addToCollisionManager) : base(name, parent, localTransform, Vector3.Zero, Vector3.Zero, addToCollisionManager) { SpriteSheet = spriteSheet; Animations = new Dictionary<string, Animation>(); OrientationType = OrientMode.Spherical; BillboardRotation = 0.0f; }
public TintableComponent(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, bool octree) : base(manager, name, parent, localTransform, boundingBoxExtents, boundingBoxPos, octree) { Tint = Color.White; LightingTimer = new Timer(1.0f, false); TargetTint = Tint; TintChangeRate = 1.0f; }
public BillboardSpriteComponent(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Texture2D spriteSheet, bool addToOctree) : base(manager, name, parent, localTransform, Vector3.Zero, Vector3.Zero, addToOctree) { SpriteSheet = spriteSheet; Animations = new Dictionary<string, Animation> (); OrientsToCamera = true; BillboardRotation = 0.0f; Offset = Vector3.Zero; }
public EnemySensor(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos) : base(name, parent, localTransform, boundingBoxExtents, boundingBoxPos) { Enemies = new List<CreatureAI>(); OnEnemySensed += EnemySensor_OnEnemySensed; Tags.Add("Sensor"); SenseTimer = new Timer(0.5f, false); SenseRadius = 15 * 15; }
public ParticleTrigger(string emitter, ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos) : base(name, parent, localTransform, boundingBoxExtents, boundingBoxPos, false) { SoundToPlay = ContentPaths.Audio.explode; EmitterName = emitter; TriggerOnDeath = true; TriggerAmount = 2; BoxTriggerTimes = 10; TriggerInBox = true; }
public Shadow(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, SpriteSheet spriteSheet) : base(manager, name, parent, localTransform, spriteSheet, false) { OrientationType = OrientMode.Fixed; GlobalScale = LocalTransform.Left.Length(); LightsWithVoxels = false; UpdateTimer = new Timer(0.5f, false); Tint = Color.Black; OriginalTransform = LocalTransform; }
public EmitterComponent(ParticleManager particles, string emitter, ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos) : base(manager, name, parent, localTransform, boundingBoxExtents, boundingBoxPos, false) { ParticleManager = particles; Emitter = emitter; TriggerOnDeath = true; TriggerAmount = 10; BoxTriggerTimes = 10; TriggerInBox = true; }
public ShadowComponent(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Texture2D spriteSheet) : base(manager, name, parent, localTransform, spriteSheet, false) { OrientsToCamera = false; GlobalScale = 1.0f; DrawBoundingBox = false; UpdateTimer = new Timer(0.5f,false); Tint = Color.White; Height = 0.1f; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { string[] menuItems = { "Start Game", "High Scores", "End Game" }; spriteBatch = new SpriteBatch(GraphicsDevice); menuComponent = new GameComponent(this, spriteBatch, Content.Load<SpriteFont>("menufont"), menuItems); Components.Add(menuComponent); }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = screenManager.Game.Content; Viewport viewport = screenManager.Game.GraphicsDevice.Viewport; viewportSize = new Vector2(viewport.Width, viewport.Height); blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground"); playerIdle = content.Load<Texture2D>("Graphics/playerIdle"); playerWalk = content.Load<Texture2D>("Graphics/playerWalk"); playerDie = content.Load<Texture2D>("Graphics/playerDie"); ship = content.Load<Texture2D>("Graphics/ship"); for (int i = 0; i < land.Length; i++) land[i] = content.Load<Texture2D>("Graphics/land" + i); for (int i = 0; i < water.Length; i++) water[i] = content.Load<Texture2D>("Graphics/water" + i); sandBed = content.Load<Texture2D>("Graphics/sandBed"); for (int i = 0; i < enemy.Length; i++) enemy[i] = content.Load<Texture2D>("Graphics/enemy" + i); healthBar = content.Load<Texture2D>("Graphics/healthBar"); heart = content.Load<Texture2D>("Graphics/heart"); collect = content.Load<Texture2D>("Graphics/collect"); crossMark = content.Load<Texture2D>("Graphics/crossMark"); gameOver = content.Load<Texture2D>("Graphics/gameOver"); retry = content.Load<Texture2D>("Graphics/retry"); levelUp = content.Load<Texture2D>("Graphics/levelUp"); tutorial = content.Load<Texture2D>("Graphics/tutorial"); //debugFont = content.Load<SpriteFont>("Fonts/debugFont"); gameFont = content.Load<SpriteFont>("Fonts/Visitor TT2 BRK 40"); gameFont.Spacing = 2; // Initialize audio objects. audioEngine = new AudioEngine("Content/Audio/Audio.xgs"); soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb"); waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); soundBank.GetCue("music").Play(); //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
public void SwitchTo(GameComponent component) { foreach (var component1 in _currentComponents) { Components.Remove(component1); } _currentComponents.Add(component); Components.Add(component); }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = new ContentManager(screenManager.Game.Services, "Content"); viewport = screenManager.Game.GraphicsDevice.Viewport; blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); introBackground = content.Load<Texture2D>("Graphics/introBackground"); instBackground = content.Load<Texture2D>("Graphics/instBackground"); levelBackground = content.Load<Texture2D>("Graphics/levelBackground"); background = content.Load<Texture2D>("Graphics/background"); gameOver = content.Load<Texture2D>("Graphics/gameOver"); gameoverCenter = new Vector2(gameOver.Width, gameOver.Height) / 2; for (int i = 0; i < elements.Length; i++) elements[i] = content.Load<Texture2D>("Graphics/element" + (i + 1)); elementCenter = new Vector2(elements[0].Width, elements[0].Height) / 2; shine = content.Load<Texture2D>("Graphics/shine"); for (int i = 0; i < eyes.Length; i++) eyes[i] = content.Load<Texture2D>("Graphics/eye" + i); eyeCenter = new Vector2(eyes[0].Width, eyes[0].Height) / 2; for (int i = 0; i < bond.Length; i++) { bond[i] = content.Load<Texture2D>("Graphics/bond" + (i+1)); bondCenter[i] = new Vector2(bond[i].Width, bond[i].Height) / 2; } menufont = content.Load<SpriteFont>("Fonts/menufont"); symbolfont = content.Load<SpriteFont>("Fonts/font40"); simpleColorEffect = new BasicEffect(screenManager.Game.GraphicsDevice, null); simpleColorEffect.VertexColorEnabled = true; vertexDecl = new VertexDeclaration(screenManager.Game.GraphicsDevice, VertexPositionColor.VertexElements); for (int i = 0; i < broop.Length; i++) broop[i] = content.Load<SoundEffect>("Audio/broop" + i); song = content.Load<Song>("Audio/May - Alexander Blu"); MediaPlayer.Play(song); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = 0.3f; //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
public Tinter(string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, bool collisionManager) : base(name, parent, localTransform, boundingBoxExtents, boundingBoxPos, collisionManager) { LightsWithVoxels = true; Tint = new Color(255, 255, 0); LightingTimer = new Timer(0.2f, true); StartTimer = new Timer(0.5f, true); TargetTint = Tint; TintChangeRate = 1.0f; LightsWithVoxels = true; VoxelUnder = new Voxel(); }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { content = screenManager.Game.Content; blank = content.Load<Texture2D>("Graphics/blank"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground"); grid = content.Load<Texture2D>("Graphics/grid"); for (int i = 0; i < 2; i++) { idle[i] = content.Load<Texture2D>("Graphics/" + ((Shape)i).ToString() + "Idle"); walk[i] = content.Load<Texture2D>("Graphics/" + ((Shape)i).ToString() + "Walk"); } moveArrow = content.Load<Texture2D>("Graphics/moveArrow"); ring = content.Load<Texture2D>("Graphics/ring"); ringDashed = content.Load<Texture2D>("Graphics/ringDashed"); ringOrigin = new Vector2(ring.Width, ring.Height) / 2; bg0 = content.Load<Texture2D>("Graphics/bg0"); bg1 = content.Load<Texture2D>("Graphics/bg1"); water = content.Load<Texture2D>("Graphics/water"); debugFont = content.Load<SpriteFont>("Fonts/debugFont"); gameFontSize = 60; gameFont = content.Load<SpriteFont>("Fonts/chunky" + gameFontSize.ToString()); MediaPlayer.IsRepeating = true; #if DEBUG MediaPlayer.Volume = .4f; SoundEffect.MasterVolume = .4f; #else MediaPlayer.Volume = 1; SoundEffect.MasterVolume = 1; #endif // Initialize audio objects. //audioEngine = new AudioEngine("Content/Audio/Audio.xgs"); //soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb"); //waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); //soundBank.GetCue("music").Play(); //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
public BillboardList(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Texture2D spriteSheet, int numBillboards) : base(manager, name, parent, localTransform, spriteSheet, false) { LocalTransforms = new List<Matrix>(numBillboards); Rotations = new List<float>(numBillboards); Tints = new List<Color>(numBillboards); FrustrumCull = 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> protected override void Initialize() { gc = new GameComponent(GraphicsDevice); UIComponent.Instance.spriteBatch = new SpriteBatch(GraphicsDevice); UIComponent.Instance.callbackShell = HandleUICallbacks; gc.Initialize(); UpdateGameState(GameStates.PLAYING); base.Initialize(); }
public void AddComponent(GameComponent component) { if (component == null) return; lock (components) { int componentInListIndex = components.IndexOf(component); if (componentInListIndex != -1) components[componentInListIndex] = component; else components.Add(component); } }
/// <summary> /// Load GameContents /// </summary> public GameContent(GameComponent screenManager) { if (content == null) content = new ContentManager(screenManager.Game.Services, "Content"); blank = content.Load<Texture2D>("Graphics/blank"); gradient = content.Load<Texture2D>("Graphics/gradient"); menuBackground = content.Load<Texture2D>("Graphics/menuBackground"); ship = content.Load<Texture2D>("Graphics/ship"); background[0] = content.Load<Texture2D>("Graphics/background0"); background[1] = content.Load<Texture2D>("Graphics/background1"); flame = content.Load<Texture2D>("Graphics/flame"); intro = content.Load<Texture2D>("Graphics/intro"); info = content.Load<Texture2D>("Graphics/info"); bar = content.Load<Texture2D>("Graphics/bar"); for (int i = 0; i < 16; i++) asteroid[i] = content.Load<Texture2D>("Graphics/asteroid" + i.ToString("00")); for (int i = 0; i < 3; i++) combo[i] = content.Load<Texture2D>("Graphics/combo" + i); levelUp = content.Load<Texture2D>("Graphics/levelUp"); gameOver = content.Load<Texture2D>("Graphics/gameOver"); font = content.Load<SpriteFont>("Fonts/lunaFont"); for (int i = 0; i < 3; i++) boom[i] = content.Load<SoundEffect>("Audio/boom" + i); explosion = content.Load<SoundEffect>("Audio/explosion"); engine = content.Load<SoundEffect>("Audio/engine"); song = content.Load<Song>("Audio/PILL - MU.S.GA Music for Strategy Games 03 - Fearless"); MediaPlayer.Play(song); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = 1.0f; SoundEffect.MasterVolume = 1.0f; //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. screenManager.Game.ResetElapsedTime(); }
public LocatableComponent(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, bool addToOctree) : base(manager, name, parent) { AddToOctree = addToOctree; BoundingBoxPos = boundingBoxPos; DrawBoundingBox = false; BoundingBox = new BoundingBox(localTransform.Translation - boundingBoxExtents / 2.0f + boundingBoxPos, localTransform.Translation + boundingBoxExtents / 2.0f + boundingBoxPos); LocalTransform = localTransform; HasMoved = true; DepthSort = true; FrustrumCull = true; DrawInFrontOfSiblings = false; IsStocked = false; }
public static void gainControl(GameComponent controlTaker) { foreach (GameComponent gc in Game1.getComponents()) { if (gc != controlTaker) { gc.Enabled = false; if (gc is DrawableGameComponent) { ((DrawableGameComponent)gc).Visible = false; } } } }
public static void returnControl(GameComponent controlGiver) { foreach (GameComponent gc in Game1.getComponents()) { if (gc != controlGiver) { gc.Enabled = true; if (gc is DrawableGameComponent) { ((DrawableGameComponent)gc).Visible = true; } } } }
/// <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> protected override void Initialize() { // TODO: Add your initialization logic here startComponent = new StartComponent(this); gameComponent = new MyGameComponent(this); endComponent = new EndComponent(this); Components.Add(startComponent); Resourse.init(Content.Load<Texture2D>(@"Images\\bg"), Content.Load<Texture2D>(@"Images\\ball"), Content.Load<Texture2D>(@"Images\\ball")); //��ʼ��ȫ�������� ,Ӧ�÷���LoadContent��,�����Ե�ʱ���ֻ��ָ��,Ӧ������ִ���� Components��LoadContent,�Ż����� this.IsMouseVisible = true; base.Initialize(); }