예제 #1
0
    // Use this for initialization
    void Start()
    {
        // Get all the stuff necessary for player movement
        _PlayerObject = GameObject.Find("Player");
        _Player = _PlayerObject.GetComponent<Player>();
        _CameraTransform = this.transform;
        _CameraTransform.position = _CameraPos;

        // Find the UI
        _PlayButton = GameObject.Find("PlayButton").GetComponent<Button>();
        _CreditsBackButton = GameObject.Find("CreditsBackButton").GetComponent<Button>();
        _Title = GameObject.Find("Title").GetComponent<Image>();
        _Credits = GameObject.Find("Credits").GetComponent<Image>();
        _LevelInfo = GameObject.Find("LevelInfo").GetComponent<Image>();

        // Build the screens
        ScreenContainer pTitleScreen = new ScreenContainer();

        pTitleScreen.AddButton("PlayButton");
        pTitleScreen.AddButton("CloseButton");
        pTitleScreen.AddButton("WhoMadeThisButton");
        pTitleScreen.AddButton("HighScoreTableButton");
        pTitleScreen.AddButton("TwitterButton");
        pTitleScreen.AddButton("SettingsButton");

        pTitleScreen.AddCompound("LogoContainer");

        _Screens.Add("TITLE",pTitleScreen);

        ScreenContainer pCredits = new ScreenContainer();
        pCredits.AddButton("CreditsBackButton");

        pCredits.AddUIGO("CreditsByron");
        pCredits.AddUIGO("CreditsGavin");
        pCredits.AddUIGO("CreditsNatalie");
        pCredits.AddUIGO("CreditsSusan");
        pCredits.AddUIGO("CreditsWill");
        pCredits.AddUIGO("CreditsDes");
        pCredits.AddUIGO("CreditsDugan");
        pCredits.AddUIGO("CreditsDan");
        pCredits.AddUIGO("CreditsThanks");

        _Screens.Add("CREDITS",pCredits);

        ScreenContainer pHowTo = new ScreenContainer();
        pHowTo.AddButton("CreditsBackButton");
        pHowTo.AddImage("HowToPlay");
        _Screens.Add("HOW_TO_PLAY",pHowTo);

        ScreenContainer pPlay = new ScreenContainer();
        pPlay.AddUIGO("Land");
        pPlay.AddUIGO("Land2");
        _Screens.Add("PLAY",pPlay);

        ScreenContainer pPathEditor = new ScreenContainer();
        _Screens.Add("PATH",pPathEditor);

        ScreenContainer pScores = new ScreenContainer();
        pScores.AddButton("HighScoreBackButton");
        pScores.AddButton("HSUpButton");
        pScores.AddButton("HSDownButton");
        _Screens.Add("SCORES",pScores);

        ScreenContainer pName = new ScreenContainer();
        pName.AddButton("CreditsBackButton");
        pName.AddButton("OneUpButton");
        pName.AddButton("OneDownButton");
        pName.AddButton("TwoUpButton");
        pName.AddButton("TwoDownButton");
        pName.AddButton("ThreeUpButton");
        pName.AddButton("ThreeDownButton");
        pName.AddButton("FourUpButton");
        pName.AddButton("FourDownButton");
        pName.AddButton("FiveUpButton");
        pName.AddButton("FiveDownButton");
        pName.AddButton("SixUpButton");
        pName.AddButton("SixDownButton");
        pName.AddButton("SevenUpButton");
        pName.AddButton("SevenDownButton");
        pName.AddButton("EightUpButton");
        pName.AddButton("EightDownButton");
        pName.AddButton("NineUpButton");
        pName.AddButton("NineDownButton");
        pName.AddButton("TenUpButton");
        pName.AddButton("TenDownButton");

        pName.AddButton("MusicVolumeUpButton");
        pName.AddButton("MusicVolumeDownButton");
        pName.AddButton("SFXVolumeUpButton");
        pName.AddButton("SFXVolumeDownButton");
        pName.AddCompound("MusicVolumeContainer");
        pName.AddCompound("SFXVolumeContainer");
        pName.AddCompound("MusicVolumeNameContainer");
        pName.AddCompound("SFXNameContainer");
        pName.AddCompound("NameContainer");

        _Screens.Add("NAME",pName);

        ScreenContainer pNewVersion = new ScreenContainer();
        pNewVersion.AddButton("GoGetButton");
        pNewVersion.AddButton("GoGetBackButton");
        pNewVersion.AddUIGO("NewVersion");
        _Screens.Add("NEW_VERSION",pNewVersion);

        ScreenContainer pCompany = new ScreenContainer();
        pCompany.AddUIGO("Company");
        _Screens.Add("COMPANY",pCompany);

        _Number = new Number();
        _Number._Z = 10.0f;
        _Number.Disable();

        // Setup the initial game state
        //_CurrentState = eGameState.GAMESTATE_SETUP_COMPANY;
        _CurrentState = eGameState.GAMESTATE_SETUP_TITLE;

        _Camera = GetComponent<Camera>();

        // Disable components to start
        _Player.Disable();

        _Samples = new Dictionary<string,AudioClip>();
        _SamplesTimeStamp = new Dictionary<string, float>();
        _SamplePlayAlways = new Dictionary<string, bool>();
        _AudioSource = this.GetComponent<AudioSource>();

        // Add samples
        AddSample("ALIEN_SHOT","SFX/Enemy");
        AddSample("PLAYER_SHOT","SFX/PlayerShot2");
        AddSample("EXPLOSION","SFX/Explosion");
        AddSample("COIN","SFX/Coin");
        AddSample("POWERUP","SFX/PowerUp");
        AddSample("PLAYERDEATH","SFX/PlayerDeath",true);
        AddSample("RAPIDFIRE","SFX/RapidFire",true);
        AddSample("GAMEON","SFX/GameOn",true);
        AddSample("WIPEOUT","SFX/WipeOut",true);
        AddSample("CLICK","SFX/Click",true);
        AddSample("PRESS","SFX/Press",true);
        AddSample("THREEWAY","SFX/ThreeWay",true);
        AddSample("MAGNET","SFX/Magnatism",true);

        // Create lives sprites
        _LivesSprites = new List<Sprite>();

        float fLX = Ground._Instance._HigherX + 2.0f;
        float fLZ = Ground._Instance._LowerZ - 2.0f;

        for(int i = 0; i < 20; ++i)
        {
            Sprite pSprite = Sprite.Spawn(1);

            pSprite.AddFrame("Life.png");
            pSprite._Width = 0.5f;
            pSprite._Height = 0.5f;
            pSprite._Animate = false;;
            pSprite._Y = 1.0f;
            pSprite._X = fLX;
            pSprite._Z = fLZ;
            pSprite._Alive = false;
            _LivesSprites.Add(pSprite);

            fLX += 0.6f;
        }

        _Starfield = GameObject.Find("Starfield").GetComponent<Renderer>().sharedMaterial;
        _Warp = 0.0f;
        _Speed = 1.0f;

        _PatheEditor = false;
        _Generator = new Generator();

        _Scores = GameObject.Find("Scores").GetComponent<Scores>();

        // Load HUD indicators
        _BulletSpeedUp = Sprite.Spawn(1);
        _BulletSpeedUp.AddFrame("FasterShot1.png");
        _BulletSpeedUp.AddFrame("FasterShot2.png");
        _BulletSpeedUp.AddFrame("FasterShot3.png");
        _BulletSpeedUp.AddFrame("FasterShot4.png");
        _BulletSpeedUp.AddFrame("FasterShot5.png");
        _BulletSpeedUp.AddFrame("FasterShot6.png");
        _BulletSpeedUp.AddFrame("FasterShot7.png");
        _BulletSpeedUp.AddFrame("FasterShot8.png");
        _BulletSpeedUp.AddFrame("FasterShot9.png");
        _BulletSpeedUp.AddFrame("FasterShot10.png");
        _BulletSpeedUp._X = -10.0f;
        _BulletSpeedUp._Z = 10.0f;
        _BulletSpeedUp._Height = 1.2f;
        _BulletSpeedUp._Width = 1.2f;
        _BulletSpeedUp._Animate = false;
        _BulletSpeedUp._Y = 0.1f;
        _BulletSpeedUp._Alive = false;
    }