Beispiel #1
0
    public void StartGame()
    {
        //Instantiate(sf);
        isPause = false;

        Debug.Log("Start gameManager");
        //if (currentShape != null)
        //{
        //    currentShape.Resume();
        //}

        foreach (Shape child in mList)
        {
            if (child != null)
            {
                child.Resume();
            }
        }

        if (currentSF == null)
        {
            currentSF = Instantiate(sf);
        }
        else
        {
            currentSF.Resume();
        }


        //isPause = false;
    }
Beispiel #2
0
        private static SpaceFighter GetShip()
        {
            SpaceFighter character = new SpaceFighter();

            character.SceneGraph = SceneGraph;
            character.AI         = new PlayerController();

            return(character);
        }
Beispiel #3
0
    public void ReStart()
    {
        isOver = false;
        Destroy(currentSF.gameObject);
        currentSF = null;
        foreach (Shape s in mList)
        {
            Destroy(s.gameObject);
            //s = null;
        }

        mList = new List <Shape>();

        //control.playState.popup = false;
    }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        private static SpaceFighter GetShip()
        {
            SpaceFighter character = new SpaceFighter();
            character.SceneGraph = SceneGraph;
            character.AI = new PlayerController();

            return character;
        }
Beispiel #6
0
        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();
        }