Example #1
0
        public PlayGameScreen(Game i_Game, LevelTransitionScreeen i_TransitionScreen) : base(i_Game)
        {
            m_FirstLevelTransitionScreen = i_TransitionScreen;
            m_BackGround    = new Background(i_Game, this, @"Sprites\BG_Space01_1024x768", 1);
            m_ShootsManager = new ShootsManager(this.Game);
            m_SoundManager  = SoundEffectsManager.GetInstance(i_Game);
            const bool k_IsFirstPlayer = true;

            PlayerSpaceShip[] players = new PlayerSpaceShip[2];
            players[0] = new PlayerSpaceShip(this.Game, this, m_ShootsManager, k_IsFirstPlayer);
            players[1] = new PlayerSpaceShip(this.Game, this, @"Sprites/Ship02_32x32", m_ShootsManager, !k_IsFirstPlayer);


            EnemyMotherShip       motherShip      = new EnemyMotherShip(this.Game, this, m_ShootsManager);
            EnemySpaceShipsMatrix spaceshipMatrix = new EnemySpaceShipsMatrix(this.Game, this, m_ShootsManager);
            WallMatrix            wallMatrix      = new WallMatrix(this.Game, this, m_ShootsManager);

            m_ShootsManager.EnemyGotShot += players[0].EnemyGotShot;
            m_ShootsManager.EnemyGotShot += players[1].EnemyGotShot;
            m_PauseScreen    = new PauseScreen(this.Game);
            m_GameOverScreen = new GameOverScreen(this.Game, this, m_FirstLevelTransitionScreen);

            m_Players = players;
            r_Enemys  = new List <Sprite>();
            r_Enemys.Add(motherShip);
            r_Enemys.Add(spaceshipMatrix);
            m_WallsMatrix = wallMatrix;
            m_EnemyMatrix = spaceshipMatrix;
            m_Level       = 1;

            this.Add(m_Players[0]);
            this.Add(m_Players[1]);
            this.Add(motherShip);
            this.Add(spaceshipMatrix);
            this.Add(wallMatrix);
            this.Add(m_BackGround);

            List <PlayerSpaceShip> playersList = new List <PlayerSpaceShip>();

            playersList.Add(m_Players[0] as PlayerSpaceShip);
            playersList.Add(m_Players[1] as PlayerSpaceShip);
            m_CollisionManager = new CollisionManager(this.Game, playersList, spaceshipMatrix.Sprites, wallMatrix.Sprites);
        }
Example #2
0
    // Use this for initialization
    void Start()
    {
        asteroidGen = gameObject.GetComponentInChildren <AsteroidGenerator>();
        enemyGen    = gameObject.GetComponentInChildren <EnemyGenerator>();
        //enabled = player = GameObject.FindGameObjectWithTag("Player");

        float t = 0 - Time.realtimeSinceStartup;

        asteroidGen.levelSeed = levelSeed;


        initializedChunks = new Chunk[levelSize, levelSize];
        Load();
        t += Time.realtimeSinceStartup;

        if (boss)
        {
            EnemyMotherShip eship = Instantiate(bossprefab, new Vector2(0, 200), Quaternion.identity) as EnemyMotherShip;
            //DontDestroyOnLoad(eship);
            //print (eship.name);
        }

        UnityEngine.Random.seed = levelSeed;
        float r, g, b;

        r = UnityEngine.Random.Range(0.2f, 0.3f);
        g = UnityEngine.Random.Range(0.2f, 0.3f);
        b = UnityEngine.Random.Range(0.2f, 0.3f);
        asteroidGen.baseColor = new Color(r, g, b);

        if (clouds)
        {
            clouds.material.SetColor("_MultColor", new Color(UnityEngine.Random.Range(0.7f, 1),
                                                             UnityEngine.Random.Range(0.7f, 1), UnityEngine.Random.Range(0.7f, 1),
                                                             UnityEngine.Random.Range(0.2f, 0.3f)));
            clouds.material.SetColor("_AddColor", new Color(UnityEngine.Random.Range(0.4f, 1), UnityEngine.Random.Range(0.4f, 1), UnityEngine.Random.Range(0.4f, 1), 0));
        }

        //print ("Loaded Chunks in: " + t);

        ShipBuilder.instance.SpawnShip();
    }