//TODO: Move to a child class? public virtual void SpawnAtMe(GameObject objectToSpawn) { if (SceneGraph != null) { objectToSpawn.Position = this.AbsolutePosition; SceneGraph.Add(objectToSpawn); } }
public Fireball(SceneGraph sceneGraph, Texture2D texture, Dictionary<AnimationKey, Animation> animation) : base(texture, animation) { this.SceneGraph = sceneGraph; this.NoClip = false; this.IsAnimating = true; this.Speed = 4f; this.ObjectCollision += new GameObjectCollisionEventHandler(Fireball_ObjectCollision); }
protected override void LoadContent() { ContentManager Content = GameRef.Content; ShipTexture = Content.Load<Texture2D>(@"Sprites\block_64"); LaserTexture = Content.Load<Texture2D>(@"Sprites\laser"); Asteriod64 = Content.Load<Texture2D>(@"Sprites\asteriod_64"); Asteriod32 = Content.Load<Texture2D>(@"Sprites\asteriod_32"); StarTexture = Content.Load<Texture2D>(@"Sprites\Star_256"); PlanetBlueTexture = Content.Load<Texture2D>(@"Sprites\Planet_Blue_128"); PlanetPurpleTexture = Content.Load<Texture2D>(@"Sprites\Planet_Purple_128"); CreatureTexture = Content.Load<Texture2D>(@"Sprites\Creature_32"); LaserTurretTexture = Content.Load<Texture2D>(@"Sprites\Weapon_16"); SpaceTexture = Content.Load<Texture2D>(@"Backgrounds\Nebula_1920X1200"); fontArial = Content.Load<SpriteFont>(@"Fonts\Arial"); LaserFireTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); LaserFireTexture.SetData(new[] { Color.Yellow }); FpsCounter.Font = fontArial; RNG = new Random(3); //TODO: Randomize seed SolarSystem solarSystem = new SolarSystem(); solarSystem.Generate(RNG, 1000000); Camera2D camera = new Camera2D(ScreenRectangle); SceneGraph = new SceneGraph(camera, null); SceneGraph.Sky = SpaceTexture; foreach (GameObject obj in solarSystem.Stars) { SceneGraph.Add(obj); } foreach (GameObject obj in solarSystem.Planets) { SceneGraph.Add(obj); } foreach (GameObject obj in solarSystem.Asteroids) { SceneGraph.Add(obj); } Ship = GetShip(); Ship.Position = Vector2.Zero; SceneGraph.Add(Ship); camera.CameraMode = CameraMode.Follow; camera.FollowTarget = Ship; SpaceCreature creature = new SpaceCreature(); creature.Position = new Vector2(600f, 600f); creature.AI = new SimpleFollowAI(); creature.Target = Ship; SceneGraph.Add(creature); //SpaceCreature creature2 = new SpaceCreature(); //creature2.Position = new Vector2(400f, 300f); //creature2.AI = new SimpleFollowAI(); //creature2.Target = Ship; //SceneGraph.Add(creature2); base.LoadContent(); }
private GameObjectStatistics GetObjectTotals(SceneGraph graph) { GameObjectStatistics stats = new GameObjectStatistics(); foreach (IGameObjectCounter obj in graph.RootGraph) { stats.CollisionCount += obj.Stats.CollisionCount; stats.CollisionTestCount += obj.Stats.CollisionTestCount; stats.DrawCount += obj.Stats.DrawCount; stats.UpdateCount += obj.Stats.UpdateCount; } return stats; }
protected override void LoadContent() { ContentManager Content = GameRef.Content; CharacterTexture = Content.Load<Texture2D>(@"Sprites\malepriest"); NPCTexture = Content.Load<Texture2D>(@"Sprites\malefighter"); SunTexture = Content.Load<Texture2D>(@"Sprites\sun_32"); FireBallTexture = Content.Load<Texture2D>(@"Sprites\FireBall"); ExplosionTexture = Content.Load<Texture2D>(@"Sprites\explosions"); fontArial = Content.Load<SpriteFont>(@"Fonts\Arial"); FpsCounter.Font = fontArial; aCharacter = GetCharacter(); aCharacter.Position = new Vector2(70f, 50f); Sprite sprite = GetSun(); aCharacter.AddChild(sprite); map = Content.Load<Map>("Map"); Camera camera = new Camera(ScreenRectangle); camera.CameraMode = CameraMode.Follow; camera.FollowTarget = aCharacter; SceneGraph = new SceneGraph(camera, map); SceneGraph.Map = map; SceneGraph.Add(aCharacter); Character npc = GetNPC(); npc.Position = new Vector2(512f, 512f); SceneGraph.Add(npc); base.LoadContent(); }