Example #1
0
 // Use this for initialization
 void Start()
 {
     m_Game = GameObject.Find("_Game").GetComponent<CGame>();
     m_fTimerAffichage = 0.0f;
     m_fHeightText = m_Game.m_fHeightText;
     m_bactive = false;
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     m_Game = GameObject.Find("_Game").GetComponent<CGame>();
     m_fTimerAffichage = 0.0f;
     m_fHeightText = m_Game.m_fHeightText;
     m_bactive = false;
     repairCount = GetComponentsInChildren<CFissure>().Length;
 }
Example #3
0
        private static void _Run(string[] args)
        {
            Application.DoEvents();

            try
            {
                // Create data folder
                Directory.CreateDirectory(CSettings.DataFolder);

                // Init Log
                CLog.Init();

                if (!CProgrammHelper.CheckRequirements())
                {
                    return;
                }
                CProgrammHelper.Init();

                CLog.StartBenchmark("Init Program");
                CMain.Init();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark("Init Language");
                if (!CLanguage.Init())
                {
                    throw new CLoadingException("Language");
                }
                CLog.StopBenchmark("Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark("Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark("Init Config");

                // Create folders
                CSettings.CreateFolders();

                _SplashScreen = new CSplashScreen();
                Application.DoEvents();

                // Init Draw
                CLog.StartBenchmark("Init Draw");
                if (!CDraw.Init())
                {
                    throw new CLoadingException("drawing");
                }
                CLog.StopBenchmark("Init Draw");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark("Init Playback");
                if (!CSound.Init())
                {
                    throw new CLoadingException("playback");
                }
                CLog.StopBenchmark("Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark("Init Record");
                if (!CRecord.Init())
                {
                    throw new CLoadingException("record");
                }
                CLog.StopBenchmark("Init Record");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark("Init Videodecoder");
                if (!CVideo.Init())
                {
                    throw new CLoadingException("video");
                }
                CLog.StopBenchmark("Init Videodecoder");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark("Init Database");
                if (!CDataBase.Init())
                {
                    throw new CLoadingException("database");
                }
                CLog.StopBenchmark("Init Database");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark("Init Webcam");
                if (!CWebcam.Init())
                {
                    throw new CLoadingException("webcam");
                }
                CLog.StopBenchmark("Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark("Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark("Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark("Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark("Init Profiles");

                Application.DoEvents();

                // Init Fonts
                CLog.StartBenchmark("Init Fonts");
                if (!CFonts.Init())
                {
                    throw new CLoadingException("fonts");
                }
                CLog.StopBenchmark("Init Fonts");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark("Init Theme");
                if (!CThemes.Init())
                {
                    throw new CLoadingException("theme");
                }
                CLog.StopBenchmark("Init Theme");

                CLog.StartBenchmark("Load Theme");
                CThemes.Load();
                CLog.StopBenchmark("Load Theme");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark("Init Cover");
                if (!CCover.Init())
                {
                    throw new CLoadingException("covertheme");
                }
                CLog.StopBenchmark("Init Cover");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark("Init Screens");
                CGraphics.Init();
                CLog.StopBenchmark("Init Screens");

                Application.DoEvents();

                // Init Server
                CLog.StartBenchmark("Init Server");
                CVocaluxeServer.Init();
                CLog.StopBenchmark("Init Server");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark("Init Input");
                CController.Init();
                CController.Connect();
                CLog.StopBenchmark("Init Input");

                Application.DoEvents();

                // Init Game;
                CLog.StartBenchmark("Init Game");
                CGame.Init();
                CProfiles.Update();
                CConfig.UsePlayers();
                CLog.StopBenchmark("Init Game");

                Application.DoEvents();

                // Init Party Modes;
                CLog.StartBenchmark("Init Party Modes");
                if (!CParty.Init())
                {
                    throw new CLoadingException("Party Modes");
                }
                CLog.StopBenchmark("Init Party Modes");

                Application.DoEvents();
                //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
                //Rely on GC doing its job afterwards and call Dispose methods where appropriate
                GC.Collect();
                CLog.StopBenchmark("Init Program");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message);
                CLog.LogError("Error on start up: " + e);
                if (_SplashScreen != null)
                {
                    _SplashScreen.Close();
                }
                _CloseProgram();
                return;
            }
            Application.DoEvents();

            // Start Main Loop
            if (_SplashScreen != null)
            {
                _SplashScreen.Close();
            }

            CDraw.MainLoop();
        }
Example #4
0
    //-------------------------------------------------------------------------------
    /// Unity
    //-------------------------------------------------------------------------------
    void OnGUI()
    {
        CGame game = gameObject.GetComponent <CGame>();

        switch (m_EState)
        {
        case EmenuState.e_menuState_splash:
        {
            if (m_fTempsSplash > 0.0f)
            {
                float fCoeffScale = 1.0f + (m_fTempsSplashInit - m_fTempsSplash) / (10.0f * m_fTempsSplashInit);
                float fWidth      = 1280 * fCoeffScale;
                float fHeight     = 800 * fCoeffScale;
                GUI.DrawTexture(new Rect((1280 - fWidth) / 2.0f, (800 - fHeight) / 2.0f, fWidth, fHeight), m_Texture_Splash);
            }
            else
            {
                m_EState = EmenuState.e_menuState_movie;
            }
            break;
        }

        case EmenuState.e_menuState_movie:
        {
            GUI.DrawTexture(new Rect(0, 0, 1280, 800), m_Texture_movie_intro);
            if (m_fTempsVideoIntro == 0.0f)
            {
                m_Texture_movie_intro.Play();
            }
            if (m_Texture_movie_intro.isPlaying)
            {
                m_fTempsVideoIntro += Time.deltaTime;
            }
            else
            {
                //m_Texture_movie_intro.Stop();
                m_EState = EmenuState.e_menuState_main;
            }
            break;
        }

        case EmenuState.e_menuState_main:
        {
            GUI.DrawTexture(new Rect(0, 0, 1280, 800), m_Texture_Fond);

            if (GUI.Button(new Rect(390, 100, 500, 150), m_Texture_ButtonPlay))
            {
                game.StartGame();
                ResumeGame();
                m_EState = EmenuState.e_menuState_inGame;
            }

            if (GUI.Button(new Rect(390, 400, 500, 150), m_Texture_ButtonCredit))
            {
                m_EState = EmenuState.e_menuState_credits;
            }

            if (GUI.Button(new Rect(940, 10, 200, 60), m_Texture_ButtonMenu))
            {
                m_EState = EmenuState.e_menuState_main;
            }

            if (GUI.Button(new Rect(1160, 10, 60, 60), m_Texture_ButtonQuit))
            {
                Application.Quit();
            }
            break;
        }

        case EmenuState.e_menuState_credits:
        {
            GUI.DrawTexture(new Rect(0, 0, 1280, 800), m_Texture_Credit);

            if (GUI.Button(new Rect(940, 10, 200, 60), m_Texture_ButtonMenu))
            {
                m_EState = EmenuState.e_menuState_main;
            }

            if (GUI.Button(new Rect(1160, 10, 60, 60), m_Texture_ButtonQuit))
            {
                Application.Quit();
            }
            break;
        }

        case EmenuState.e_menuState_inGame:
        {
            //if (GUI.Button(new Rect(940, 10, 200, 60), m_Texture_ButtonMenu))
            if (GUI.Button(new Rect(10, 10, 200, 60), m_Texture_ButtonMenu))
            {
                m_EState = EmenuState.e_menuState_main;
                PauseGame();
            }

            if (GUI.Button(new Rect(1160, 10, 60, 60), m_Texture_ButtonQuit))
            {
                Application.Quit();
            }

            if (GUI.Button(new Rect(250, 10, 60, 60), m_Texture_ButtonPause))
            {
                if (!m_bGamePaused)
                {
                    PauseGame();
                }
                else
                {
                    ResumeGame();
                }
            }
            break;
        }
        }
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     m_Etincelle = gameObject.transform.FindChild("Etincelles").gameObject;
     m_fTimerEtincelle = 0.0f;
     m_Game = GameObject.Find("_Game").GetComponent<CGame>();
     m_Etincelle.SetActiveRecursively(false);
     m_Etincelle.active = true;
     m_bSoundLaunched = false;
     m_Game.GetSoundEngine().setSwitch("Soudure","Aire", gameObject);
     m_bLost = false;
     m_fSoudureRestante = m_Game.m_fQuantiteSoudureDepart-1;
     m_nNbChargeurs = 0;
 }
Example #6
0
        private void FindRefrain()
        {
            if (this.IsDuet)
            {
                this.Medley.Source = EMedleySource.None;
                return;
            }

            if (this.Medley.Source == EMedleySource.Tag)
            {
                return;
            }

            if (!this.CalculateMedley)
            {
                return;
            }

            CLines lines = this.Notes.GetLines(0);

            if (lines.LineCount == 0)
            {
                return;
            }

            // build sentences list
            List <string> sentences = new List <string>();

            foreach (CLine line in lines.Line)
            {
                if (line.Points != 0)
                {
                    sentences.Add(line.Lyrics);
                }
                else
                {
                    sentences.Add(String.Empty);
                }
            }

            // find equal sentences series
            List <Series> series = new List <Series>();

            for (int i = 0; i < lines.LineCount - 1; i++)
            {
                for (int j = i + 1; j < lines.LineCount; j++)
                {
                    if (sentences[i] == sentences[j] && sentences[i] != String.Empty)
                    {
                        Series tempSeries = new Series();
                        tempSeries.start = i;
                        tempSeries.end   = i;

                        int max = 0;
                        if (j + j - i - 1 > lines.LineCount - 1)
                        {
                            max = lines.LineCount - 1 - j;
                        }
                        else
                        {
                            max = j - i - 1;
                        }

                        for (int k = 1; k <= max; k++)
                        {
                            if (sentences[i + k] == sentences[j + k] && sentences[i + k] != String.Empty)
                            {
                                tempSeries.end = i + k;
                            }
                            else
                            {
                                break;
                            }
                        }

                        tempSeries.length = tempSeries.end - tempSeries.start + 1;
                        series.Add(tempSeries);
                    }
                }
            }

            // search for longest series
            int longest = 0;

            for (int i = 0; i < series.Count; i++)
            {
                if (series[i].length > series[longest].length)
                {
                    longest = i;
                }
            }

            // set medley vars
            if (series.Count > 0 && series[longest].length > CSettings.MedleyMinSeriesLength)
            {
                this.Medley.StartBeat = lines.Line[series[longest].start].FirstNoteBeat;
                this.Medley.EndBeat   = lines.Line[series[longest].end].LastNoteBeat;

                bool foundEnd = false;

                // set end if duration > MedleyMinDuration
                if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration >
                    CGame.GetTimeFromBeats(this.Medley.EndBeat, this.BPM))
                {
                    foundEnd = true;
                }

                if (!foundEnd)
                {
                    for (int i = series[longest].start + 1; i < lines.LineCount - 1; i++)
                    {
                        if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration >
                            CGame.GetTimeFromBeats(lines.Line[i].LastNoteBeat, this.BPM))
                        {
                            foundEnd            = true;
                            this.Medley.EndBeat = lines.Line[i].LastNoteBeat;
                        }
                    }
                }

                if (foundEnd)
                {
                    this.Medley.Source      = EMedleySource.Calculated;
                    this.Medley.FadeInTime  = CSettings.DefaultMedleyFadeInTime;
                    this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime;
                }
            }

            if (this.PreviewStart == 0f)
            {
                if (this.Medley.Source == EMedleySource.Calculated)
                {
                    this.PreviewStart = CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM);
                }
            }
        }
Example #7
0
        private void _UpdateRatings()
        {
            CSong song    = null;
            var   players = new SPlayer[CGame.NumPlayers];

            if (_Round >= 0)
            {
                song = CGame.GetSong(_Round);
                if (song == null)
                {
                    return;
                }

                _Texts[_TextSong].Text = song.Artist + " - " + song.Title;
                if (_Points.NumRounds > 1)
                {
                    _Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")";
                }
                players = _Points.GetPlayer(_Round, CGame.NumPlayers);
            }
            else
            {
                _Texts[_TextSong].Text = "TR_SCREENSCORE_OVERALLSCORE";
                for (int i = 0; i < CGame.NumRounds; i++)
                {
                    SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayers);
                    for (int p = 0; p < players.Length; p++)
                    {
                        if (i < 1)
                        {
                            players[p].ProfileID = points[p].ProfileID;
                        }
                        players[p].Points += points[p].Points;
                    }
                }
                for (int p = 0; p < players.Length; p++)
                {
                    players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds);
                }
            }

            for (int p = 0; p < players.Length; p++)
            {
                string name = CProfiles.GetPlayerName(players[p].ProfileID, p);
                if (song != null && song.IsDuet)
                {
                    if (song.Notes.VoiceNames.IsSet(players[p].VoiceNr))
                    {
                        name += " (" + song.Notes.VoiceNames[players[p].VoiceNr] + ")";
                    }
                }
                _Texts[_TextNames[p, CGame.NumPlayers - 1]].Text = name;

                if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue())
                {
                    _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS");
                }
                else
                {
                    _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000");
                }
                if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue())
                {
                    _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " +
                                                                            CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString());
                }
                else
                {
                    _Texts[_TextDifficulty[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString());
                }
                if (CGame.NumPlayers < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue())
                {
                    _Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " +
                                                                         CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
                }
                else
                {
                    _Texts[_TextRatings[p, CGame.NumPlayers - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
                }

                _ProgressBars[_ProgressBarPoints[p, CGame.NumPlayers - 1]].Progress = (float)players[p].Points / CSettings.MaxScore;

                if (CProfiles.IsProfileIDValid(players[p].ProfileID))
                {
                    _Statics[_StaticAvatar[p, CGame.NumPlayers - 1]].Texture = CProfiles.GetAvatarTextureFromProfile(players[p].ProfileID);
                }
            }
        }
Example #8
0
    override public void update()
    {
        int tileWidth  = CGame.inst().getMap().getTileWidth();
        int tileHeight = CGame.inst().getMap().getTileHeight();

        //Debug.Log (getState ());

        // Guardar la posicion anterior del objeto.
        setOldYPosition();

        base.update();

        if (getState() == STATE_STAND)
        {
            /*
             *
             * // En stand no deberia pasar nunca que quede metido en una pared.
             * // Si estamos en una pared, corregirnos.
             * if (isWallLeft (getX (), getY ())) {
             *      // Reposicionar el personaje contra la pared.
             *      setX ((mLeftX + 1) * tileWidth);
             * }
             * if (isWallRight (getX (), getY ())) {
             *      // Reposicionar el personaje contra la pared.
             *      setX (((mRightX) * tileWidth) - getWidth ());
             * }
             *
             * // Si en el pixel de abajo del jugador no hay piso, caemos.
             * if (!isFloor (getX (), getY () + 1)) {
             *      setState (STATE_FALLING);
             *      return;
             * }
             *
             * if (!isWallRight (getX () + 1, getY ()))
             * {
             *      setVelX (400);
             *      setState (STATE_WALKING);
             *      return;
             * }
             *
             * if (!isWallLeft (getX () - 1, getY ()))
             * {
             *      setVelX (-400);
             *      setState (STATE_WALKING);
             *      return;
             * }
             *
             */
        }
        else if (getState() == STATE_WALKING)
        {
            if (isWallLeft(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX((mLeftX + 1) * tileWidth);

                setVelX(getVelX() * -1);
            }
            if (isWallRight(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX(((mRightX) * tileWidth) - getWidth());
                setVelX(getVelX() * -1);
            }

            // Si en el pixel de abajo del jugador no hay piso, caemos.
            if (!isFloor(getX(), getY() + 1))
            {
                setState(STATE_FALLING);
                return;
            }

            if (getVelX() < 0)
            {
                // Chequear pared a la izquierda.
                // Si hay pared a la izquierda vamos a stand.
                if (isWallLeft(getX(), getY()))
                {
                    // Reposicionar el personaje contra la pared.
                    //setX((((int) getX ()/tileWidth)+1)*tileWidth);
                    setX((mLeftX + 1) * tileWidth);

                    setVelX(getVelX() * -1);

                    return;
                }
                else
                {
                    // No hay pared, se puede mover.
                    setVelX(-400);
                    setFlip(true);

                    if (getType() == TYPE_DONT_FALL)
                    {
                        checkPoints(getX(), getY() + 1);
                        if (mTileDownLeft)
                        {
                            setVelX(getVelX() * -1);
                        }
                    }
                }
            }
            else if (getVelX() > 0)
            {
                // Chequear pared a la derecha.
                // Si hay pared a la derecha vamos a stand.
                if (isWallRight(getX(), getY()))
                {
                    // Reposicionar el personaje contra la pared.
                    setX(((mRightX) * tileWidth) - getWidth());

                    setVelX(getVelX() * -1);
                    return;
                }
                else
                {
                    // No hay pared, se puede mover.
                    setVelX(400);
                    setFlip(false);

                    if (getType() == TYPE_DONT_FALL)
                    {
                        checkPoints(getX(), getY() + 1);
                        if (mTileDownRight)
                        {
                            setVelX(getVelX() * -1);
                        }
                    }
                }
            }
        }
        else if (getState() == STATE_FALLING)
        {
            controlMoveHorizontal();

            if (isFloor(getX(), getY() + 1))
            {
                setY(mDownY * tileHeight - getHeight());
                setState(STATE_STAND);
                return;
            }
        }

        // Spark emmiter.
        if (CMath.randomIntBetween(1, 50) == 1)
        {
            CSpark  spark = new CSpark();
            CVector pos   = new CVector(getX() + getWidth() / 2, getY() + getHeight() / 2);
            spark.setPos(pos + new CVector(CMath.randomIntBetween(-10, 10), CMath.randomIntBetween(-10, 10)));
            CParticleManager.inst().add(spark);
        }
    }
Example #9
0
        private void UpdateRatings()
        {
            CSong song = null;

            SPlayer[] player = new SPlayer[CGame.NumPlayer];
            if (_Round != 0)
            {
                song = CGame.GetSong(_Round);
                if (song == null)
                {
                    return;
                }

                Texts[htTexts(TextSong)].Text = song.Artist + " - " + song.Title;
                if (_Points.NumRounds > 1)
                {
                    Texts[htTexts(TextSong)].Text += " (" + _Round + "/" + _Points.NumRounds + ")";
                }
                player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
            }
            else
            {
                Texts[htTexts(TextSong)].Text = "TR_SCREENSCORE_OVERALLSCORE";
                for (int i = 0; i < CGame.NumRounds; i++)
                {
                    SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer);
                    for (int p = 0; p < player.Length; p++)
                    {
                        if (i < 1)
                        {
                            player[p].ProfileID  = points[p].ProfileID;
                            player[p].Name       = points[p].Name;
                            player[p].Difficulty = points[p].Difficulty;
                        }
                        player[p].Points += points[p].Points;
                    }
                }
                for (int p = 0; p < player.Length; p++)
                {
                    player[p].Points = (int)(player[p].Points / CGame.NumRounds);
                }
            }

            for (int p = 0; p < player.Length; p++)
            {
                if (song != null)
                {
                    if (!song.IsDuet)
                    {
                        Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name;
                    }
                    else
                    if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1")
                    {
                        Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name + " (" + song.DuetPart1 + ")";
                    }
                    else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2")
                    {
                        Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name + " (" + song.DuetPart2 + ")";
                    }
                    else
                    {
                        Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name;
                    }
                }
                else
                {
                    Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name;
                }

                Texts[htTexts(TextScores[p, CGame.NumPlayer - 1])].Text = ((int)Math.Round(player[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS");
                if (CGame.NumPlayer <= 3)
                {
                    Texts[htTexts(TextRatings[p, CGame.NumPlayer - 1])].Text    = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + CLanguage.Translate(GetRating((int)Math.Round(player[p].Points)));
                    Texts[htTexts(TextDifficulty[p, CGame.NumPlayer - 1])].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + CLanguage.Translate(player[p].Difficulty.ToString());
                }
                else
                {
                    Texts[htTexts(TextRatings[p, CGame.NumPlayer - 1])].Text    = CLanguage.Translate(GetRating((int)Math.Round(player[p].Points)));
                    Texts[htTexts(TextDifficulty[p, CGame.NumPlayer - 1])].Text = CLanguage.Translate(player[p].Difficulty.ToString());
                }
                StaticPointsBarDrawnPoints[p] = 0.0;
                Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = 0;
                Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H;
                if (player[p].ProfileID >= 0 && player[p].ProfileID < CProfiles.NumProfiles)
                {
                    Statics[htStatics(StaticAvatar[p, CGame.NumPlayer - 1])].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture;
                }
            }

            if (CConfig.ScoreAnimationTime < 1)
            {
                for (int p = 0; p < CGame.NumPlayer; p++)
                {
                    Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = ((float)player[p].Points) * (Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H / 10000);
                    Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H;
                    StaticPointsBarDrawnPoints[p] = player[p].Points;
                }
            }

            timer = new Stopwatch();
            timer.Start();
        }
Example #10
0
        private void create()
        {
            CDivision         clDiv   = new CDivision(connect);
            List <STDivision> lst_div = new List <STDivision>();

            CGame         clGame   = new CGame(connect);
            List <STGame> lst_game = new List <STGame>();
            STGameParam   paramGame;



            try
            {
                filename = string.Format("символичесике пятерки_{0}-{1}.txt", dtbegin.ToShortDateString(),
                                         dtend.ToShortDateString());

                fullpath = Path.Combine(clParamApp.s_Path.pathreport, filename);


                FileInfo     fi1 = new FileInfo(fullpath);
                StreamWriter sw  = fi1.CreateText();

                lst_div = clDiv.GetListDivision(IS.idseason);

                if (flag == 1)
                {
                    paramGame          = new STGameParam();
                    paramGame.idseason = IS.idseason;
                    paramGame.dtbegin  = dtbegin;
                    paramGame.dtend    = dtend;
                    paramGame.type     = 2;

                    lst_game = clGame.GetListGames(paramGame);

                    insert_report(lst_game, sw, "стыковые игры");
                }
                else if (flag == 2)
                {
                    paramGame          = new STGameParam();
                    paramGame.idseason = IS.idseason;
                    paramGame.dtbegin  = dtbegin;
                    paramGame.dtend    = dtend;

                    lst_game = clGame.GetListGames(paramGame);

                    insert_report(lst_game, sw, "все дивизионы");
                }
                else
                {
                    foreach (STDivision division in lst_div)
                    {
                        paramGame            = new STGameParam();
                        paramGame.idseason   = IS.idseason;
                        paramGame.dtbegin    = dtbegin;
                        paramGame.dtend      = dtend;
                        paramGame.iddivision = division.id;


                        lst_game = clGame.GetListGames(paramGame);

                        insert_report(lst_game, sw, division.name);
                    }// конец цикла по дивизионам
                }


                sw.WriteLine("-");
                sw.Close();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
Example #11
0
 public OXForm()
 {
     InitializeComponent();
     m_pGame = new CGame();
     h_Refresh();
 }
Example #12
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver);

            // Close program if there is another instance running
            if (!EnsureSingleInstance())
            {
                //TODO: put it into language file
                MessageBox.Show("Another Instance of Vocaluxe is already runnning!");
                return;
            }

            Application.DoEvents();

            try
            {
                // Init Log
                CLog.Init();

                CSettings.CreateFolders();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark(0, "Init Language");
                CLanguage.Init();
                CLog.StopBenchmark(0, "Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark(0, "Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark(0, "Init Config");

                Application.DoEvents();
                _SplashScreen = new SplashScreen();
                Application.DoEvents();

                // Init Draw
                CLog.StartBenchmark(0, "Init Draw");
                CDraw.InitDraw();
                CLog.StopBenchmark(0, "Init Draw");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark(0, "Init Database");
                CDataBase.Init();
                CLog.StopBenchmark(0, "Init Database");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark(0, "Init Playback");
                CSound.PlaybackInit();
                CLog.StopBenchmark(0, "Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark(0, "Init Record");
                CSound.RecordInit();
                CLog.StopBenchmark(0, "Init Record");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark(0, "Init Webcam");
                CWebcam.Init();
                CLog.StopBenchmark(0, "Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark(0, "Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark(0, "Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark(0, "Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark(0, "Init Profiles");

                Application.DoEvents();

                // Init Font
                CLog.StartBenchmark(0, "Init Font");
                CFonts.Init();
                CLog.StopBenchmark(0, "Init Font");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark(0, "Init Videodecoder");
                CVideo.Init();
                CLog.StopBenchmark(0, "Init Videodecoder");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark(0, "Init Cover");
                CCover.Init();
                CLog.StopBenchmark(0, "Init Cover");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark(0, "Init Theme");
                CTheme.InitTheme();
                CLog.StopBenchmark(0, "Init Theme");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark(0, "Init Screens");
                CGraphics.InitGraphics();
                CLog.StopBenchmark(0, "Init Screens");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark(0, "Init Input");
                CInput.Init();
                CLog.StopBenchmark(0, "Init Input");

                // Init Game;
                CLog.StartBenchmark(0, "Init Game");
                CGame.Init();
                CLog.StopBenchmark(0, "Init Game");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message + e.StackTrace);
                CLog.LogError("Error on start up: " + e.Message + e.StackTrace);
                CloseProgram();
                Environment.Exit(Environment.ExitCode);
            }
            Application.DoEvents();

            // Start Main Loop
            _SplashScreen.Close();

            try
            {
                CDraw.MainLoop();
            }
            catch (Exception e)
            {
                MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
                CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
            }

            CloseProgram();
        }
Example #13
0
        public override bool HandleInput(KeyEvent KeyEvent)
        {
            switch (KeyEvent.Key)
            {
            case Keys.Add:
                if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer)
                {
                    SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer;
                    UpdatePlayerNumber();
                    //Update Tiles-List
                    NameSelections[htNameSelections(NameSelection)].UpdateList();
                }
                break;

            case Keys.Subtract:
                if (CConfig.NumPlayer - 1 > 0)
                {
                    SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer - 2;
                    UpdatePlayerNumber();
                    //Update Tiles-List
                    NameSelections[htNameSelections(NameSelection)].UpdateList();
                }
                break;

            case Keys.P:
                if (!selectingKeyboardActive)
                {
                    selectingKeyboardPlayerNr  = 1;
                    selectingKeyboardUnendless = true;
                }
                else
                {
                    if (selectingKeyboardPlayerNr + 1 <= CGame.NumPlayer)
                    {
                        selectingKeyboardPlayerNr++;
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 1;
                    }
                    NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, selectingKeyboardPlayerNr);
                }
                break;
            }
            //Check if selecting with keyboard is active
            if (selectingKeyboardActive)
            {
                //Handle left/right/up/down
                NameSelections[htNameSelections(NameSelection)].HandleInput(KeyEvent);
                switch (KeyEvent.Key)
                {
                case Keys.Enter:
                    //Check, if a player is selected
                    if (NameSelections[htNameSelections(NameSelection)].Selection > -1)
                    {
                        SelectedPlayerNr = NameSelections[htNameSelections(NameSelection)].Selection;
                        //Update Game-infos with new player
                        CGame.Player[selectingKeyboardPlayerNr - 1].Name       = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
                        CGame.Player[selectingKeyboardPlayerNr - 1].Difficulty = CProfiles.Profiles[SelectedPlayerNr].Difficulty;
                        CGame.Player[selectingKeyboardPlayerNr - 1].ProfileID  = SelectedPlayerNr;
                        //Update config for default players.
                        CConfig.Players[selectingKeyboardPlayerNr - 1] = CProfiles.Profiles[SelectedPlayerNr].ProfileFile;
                        CConfig.SaveConfig();
                        //Update texture and name
                        Statics[htStatics(StaticPlayerAvatar[selectingKeyboardPlayerNr - 1])].Texture = CProfiles.Profiles[SelectedPlayerNr].Avatar.Texture;
                        Texts[htTexts(TextPlayer[selectingKeyboardPlayerNr - 1])].Text = CProfiles.Profiles[SelectedPlayerNr].PlayerName;
                        //Update profile-warning
                        CheckPlayers();
                        //Update Tiles-List
                        NameSelections[htNameSelections(NameSelection)].UpdateList();
                        SetInteractionToButton(Buttons[htButtons(ButtonStart)]);
                    }
                    //Started selecting with 'P'
                    if (selectingKeyboardUnendless)
                    {
                        if (selectingKeyboardPlayerNr == CGame.NumPlayer)
                        {
                            //Reset all values
                            selectingKeyboardPlayerNr = 0;
                            selectingKeyboardActive   = false;
                            NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                        }
                        else
                        {
                            selectingKeyboardPlayerNr++;
                            NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, selectingKeyboardPlayerNr);
                        }
                    }
                    else
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    if (selectingKeyboardPlayerNr == 1)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 1;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 1);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    if (selectingKeyboardPlayerNr == 2)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 2;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 2);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    if (selectingKeyboardPlayerNr == 3)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 3;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 3);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    if (selectingKeyboardPlayerNr == 4)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 4;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 4);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    if (selectingKeyboardPlayerNr == 5)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 5;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 5);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    if (selectingKeyboardPlayerNr == 6)
                    {
                        //Reset all values
                        selectingKeyboardPlayerNr = 0;
                        selectingKeyboardActive   = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    }
                    else
                    {
                        selectingKeyboardPlayerNr = 6;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, 6);
                    }
                    selectingKeyboardUnendless = false;
                    break;

                case Keys.Escape:
                    //Reset all values
                    selectingKeyboardPlayerNr  = 0;
                    selectingKeyboardActive    = false;
                    selectingKeyboardUnendless = false;
                    NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    break;

                case Keys.Delete:
                    //Delete profile-selection
                    CGame.Player[selectingKeyboardPlayerNr - 1].ProfileID  = -1;
                    CGame.Player[selectingKeyboardPlayerNr - 1].Name       = String.Empty;
                    CGame.Player[selectingKeyboardPlayerNr - 1].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
                    //Update config for default players.
                    CConfig.Players[selectingKeyboardPlayerNr - 1] = String.Empty;
                    CConfig.SaveConfig();
                    //Update texture and name
                    Statics[htStatics(StaticPlayerAvatar[selectingKeyboardPlayerNr - 1])].Texture = OriginalPlayerAvatarTextures[selectingKeyboardPlayerNr - 1];
                    Texts[htTexts(TextPlayer[selectingKeyboardPlayerNr - 1])].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + selectingKeyboardPlayerNr.ToString();
                    //Update profile-warning
                    CheckPlayers();
                    //Reset all values
                    selectingKeyboardPlayerNr = 0;
                    selectingKeyboardActive   = false;
                    NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                    //Update Tiles-List
                    NameSelections[htNameSelections(NameSelection)].UpdateList();
                    break;

                case Keys.F10:
                    if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
                    {
                        if (SelectSlides[htSelectSlides(SelectSlideDuetPlayer[selectingKeyboardPlayerNr - 1])].Selection == 0)
                        {
                            SelectSlides[htSelectSlides(SelectSlideDuetPlayer[selectingKeyboardPlayerNr - 1])].SetSelectionByValueIndex(1);
                        }
                        else
                        {
                            SelectSlides[htSelectSlides(SelectSlideDuetPlayer[selectingKeyboardPlayerNr - 1])].SetSelectionByValueIndex(0);
                        }
                        //Reset all values
                        selectingKeyboardPlayerNr  = 0;
                        selectingKeyboardActive    = false;
                        selectingKeyboardUnendless = false;
                        NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1);
                        SetInteractionToButton(Buttons[htButtons(ButtonStart)]);
                    }
                    break;
                }
            }
            //Normal Keyboard handling
            else
            {
                base.HandleInput(KeyEvent);
                bool processed = false;
                switch (KeyEvent.Key)
                {
                case Keys.Escape:
                case Keys.Back:
                    CGraphics.FadeTo(EScreens.ScreenSong);
                    break;

                case Keys.Enter:

                    if (!processed && Buttons[htButtons(ButtonBack)].Selected)
                    {
                        processed = true;
                        CGraphics.FadeTo(EScreens.ScreenSong);
                    }

                    if (!processed /* && Buttons[htButtons(ButtonStart)].Selected */)
                    {
                        processed = true;
                        StartSong();
                    }

                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    selectingKeyboardPlayerNr = 1;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    selectingKeyboardPlayerNr = 2;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    selectingKeyboardPlayerNr = 3;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    selectingKeyboardPlayerNr = 4;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    selectingKeyboardPlayerNr = 5;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    selectingKeyboardPlayerNr = 6;
                    break;
                }

                if (!processed)
                {
                    UpdatePlayerNumber();
                }

                if (selectingKeyboardPlayerNr > 0 && selectingKeyboardPlayerNr <= CConfig.NumPlayer)
                {
                    selectingKeyboardActive = true;
                    NameSelections[htNameSelections(NameSelection)].KeyboardSelection(true, selectingKeyboardPlayerNr);
                }
            }

            return(true);
        }
Example #14
0
        public override bool HandleInput(SKeyEvent keyEvent)
        {
            switch (keyEvent.Key)
            {
            case Keys.Add:
                if (CConfig.Config.Game.NumPlayers + 1 <= CSettings.MaxNumPlayer)
                {
                    _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers;
                    _UpdatePlayerNumber();
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                }
                break;

            case Keys.Subtract:
                if (CConfig.Config.Game.NumPlayers - 1 > 0)
                {
                    _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers - 2;
                    _UpdatePlayerNumber();
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                }
                break;

            case Keys.P:
                if (!_SelectingKeyboardActive)
                {
                    _SelectingFastPlayerNr = 1;
                    _SelectingFast         = true;
                    _ResetPlayerSelections();
                }
                else
                {
                    if (_SelectingFastPlayerNr + 1 <= CGame.NumPlayers)
                    {
                        _SelectingFastPlayerNr++;
                    }
                    else
                    {
                        _SelectingFastPlayerNr = 1;
                    }
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
                break;
            }
            //Check if selecting with keyboard is active
            if (_SelectingKeyboardActive)
            {
                //Handle left/right/up/down
                _NameSelections[_NameSelection].HandleInput(keyEvent);
                int  numberPressed  = -1;
                bool resetSelection = false;
                switch (keyEvent.Key)
                {
                case Keys.Enter:
                    //Check, if a player is selected
                    if (_NameSelections[_NameSelection].Selection > -1)
                    {
                        _SelectedProfileID = _NameSelections[_NameSelection].Selection;

                        if (!CProfiles.IsProfileIDValid(_SelectedProfileID))
                        {
                            return(true);
                        }

                        _UpdateSelectedProfile(_SelectingFastPlayerNr - 1, _SelectedProfileID);
                    }
                    //Started selecting with 'P'
                    if (_SelectingFast)
                    {
                        if (_SelectingFastPlayerNr == CGame.NumPlayers)
                        {
                            resetSelection = true;
                            _SelectElement(_Buttons[_ButtonStart]);
                        }
                        else
                        {
                            _SelectingFastPlayerNr++;
                            _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                        }
                    }
                    else
                    {
                        resetSelection = true;
                    }
                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    numberPressed = 1;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    numberPressed = 2;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    numberPressed = 3;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    numberPressed = 4;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    numberPressed = 5;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    numberPressed = 6;
                    break;

                case Keys.Escape:
                    resetSelection = true;
                    _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]);
                    break;

                case Keys.Delete:
                    //Delete profile-selection
                    _ResetPlayerSelection(_SelectingFastPlayerNr - 1);
                    //Reset all values
                    _SelectingFastPlayerNr   = 0;
                    _SelectingKeyboardActive = false;
                    _NameSelections[_NameSelection].FastSelection(false, -1);
                    //Update Tiles-List
                    _NameSelections[_NameSelection].UpdateList();
                    break;

                case Keys.F10:
                    if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
                    {
                        CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingFastPlayerNr - 1]];
                        selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
                        //Reset all values
                        _SelectingFastPlayerNr   = 0;
                        _SelectingKeyboardActive = false;
                        _SelectingFast           = false;
                        _NameSelections[_NameSelection].FastSelection(false, -1);
                        _SelectElement(_Buttons[_ButtonStart]);
                    }
                    break;
                }
                if (numberPressed > 0 || resetSelection)
                {
                    if (numberPressed == _SelectingFastPlayerNr || resetSelection)
                    {
                        //Reset all values
                        _SelectingFastPlayerNr   = 0;
                        _SelectingKeyboardActive = false;
                        _SelectElement(_SelectSlides[_SelectSlidePlayerNumber]);
                        _NameSelections[_NameSelection].FastSelection(false, -1);
                    }
                    else if (numberPressed <= CConfig.Config.Game.NumPlayers)
                    {
                        _SelectingFastPlayerNr = numberPressed;
                        _NameSelections[_NameSelection].FastSelection(true, numberPressed);
                    }
                    _SelectingFast = false;
                }
            }
            //Normal Keyboard handling
            else
            {
                base.HandleInput(keyEvent);
                switch (keyEvent.Key)
                {
                case Keys.Escape:
                case Keys.Back:
                    CGraphics.FadeTo(EScreen.Song);
                    break;

                case Keys.Enter:

                    if (_Buttons[_ButtonBack].Selected)
                    {
                        CGraphics.FadeTo(EScreen.Song);
                    }
                    else if (_Buttons[_ButtonStart].Selected)
                    {
                        _StartSong();
                    }

                    break;

                case Keys.D1:
                case Keys.NumPad1:
                    _SelectingFastPlayerNr = 1;
                    break;

                case Keys.D2:
                case Keys.NumPad2:
                    _SelectingFastPlayerNr = 2;
                    break;

                case Keys.D3:
                case Keys.NumPad3:
                    _SelectingFastPlayerNr = 3;
                    break;

                case Keys.D4:
                case Keys.NumPad4:
                    _SelectingFastPlayerNr = 4;
                    break;

                case Keys.D5:
                case Keys.NumPad5:
                    _SelectingFastPlayerNr = 5;
                    break;

                case Keys.D6:
                case Keys.NumPad6:
                    _SelectingFastPlayerNr = 6;
                    break;

                default:
                    _UpdatePlayerNumber();
                    break;
                }

                if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.Config.Game.NumPlayers)
                {
                    _SelectingKeyboardActive = true;
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
                if (_NameSelections[_NameSelection].Selected && !_SelectingKeyboardActive)
                {
                    _SelectingKeyboardActive = true;
                    _SelectingFast           = true;
                    _SelectingFastPlayerNr   = 1;
                    _SelectingKeyboardActive = true;
                    _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
                }
            }

            return(true);
        }
Example #15
0
 internal static HandleRef getCPtr(CGame obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Example #16
0
    public void Awake()
    {
        if (!initialised)
        {
            gameInstance = gameObject.GetComponent<CGame>();

            InitialiseHighscores();

            DontDestroyOnLoad(gameInstance.gameObject);
            initialised = true;
        }
        else
        {
            Destroy(gameObject);
        }
    }
Example #17
0
 public static void InstallGame(CGame game) => throw new NotImplementedException();
    override public void update()
    {
        base.update();
        CMouse.update();
        backBtn.update();
        dinoBtn.update();
        kongBtn.update();
        krakenBtn.update();

        if (backClick())
        {
            SoundList.instance.playMenuMusic();
            CGame.inst().setState(new CMenuState());
            return;
        }

        switch (selected)
        {
        case 0:
            if (dinoClick())
            {
                kongBtn.leave();
                krakenBtn.leave();
                selected = 1;
                SoundList.instance.playNewGame2();
                return;
            }
            else
            if (kongClick())
            {
                dinoBtn.leave();
                krakenBtn.leave();
                SoundList.instance.playNewGame2();
                selected = 2;
                return;
            }
            else if (krakenClick())
            {
                kongBtn.leave();
                dinoBtn.leave();
                SoundList.instance.playNewGame2();
                selected = 3;
                return;
            }
            break;

        case 1:
            if (kongBtn.currentState == 1 & krakenBtn.currentState == 1)
            {
                CInfo aux1 = new CInfo(1, 1, 50, 70, CGameConstants.HIGH_SCORE, 0, 0, 0);
                CGame.inst().setState(new CSurvivalState(aux1));
            }
            break;

        case 2:
            if (dinoBtn.currentState == 1 & krakenBtn.currentState == 1)
            {
                CInfo aux1 = new CInfo(2, 1, 50, 70, CGameConstants.HIGH_SCORE, 0, 0, 0);
                CGame.inst().setState(new CSurvivalState(aux1));
            }
            break;

        case 3:
            if (dinoBtn.currentState == 1 & kongBtn.currentState == 1)
            {
                CInfo aux1 = new CInfo(3, 1, 50, 70, CGameConstants.HIGH_SCORE, 0, 0, 0);
                CGame.inst().setState(new CSurvivalState(aux1));
            }
            break;
        }


        CSpriteManager.inst().update();
    }
Example #19
0
    public void Start()
    {
        //    StartCoroutine(Coroutine_StartGame());			// Handled by a coroutine so that our 'OnGui' can run to update the 'Please wait' dialog
        //}
        //public IEnumerator Coroutine_StartGame() {		//####OBS: IEnumerator?? //###NOTE: Game is started by iGUICode_Root once it has completely initialized (so as to present the 'Please Wait...' dialog

        Debug.Log("=== CGame.StartGame() ===");
        INSTANCE = this;
        _nTimeAtStart = Time.time;

        //GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CSoftBody));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CSoftBodyBase));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CB));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CFuckOff));
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CJointDriver));
        //return;

        _oFlexSolver = FindObjectOfType<uFlex.FlexSolver>();        //###F
        GameObject oSceneGO = GameObject.Find("SCENE/SceneColliders");
        //if (oSceneGO != null)
        //    s_aColliders_Scene = oSceneGO.GetComponentsInChildren<CCollider_OBS>();

        _bRunningInEditor = true;       //###HACK ####REVA Application.isEditor
        _DemoVersion = (_bRunningInEditor == false);		//###CHECK? If dev has Unity code they are non-demo

        _oCursor = CCursor.Cursor_Create();             //###DESIGN!!!!!: REVISIT!	###CLEANUP!!!!!
        Cursor.visible = Application.isEditor;      // _bRunningInEditor;

        //=== Set rapid-access members to text widgets so we can rapidly update them ===
        _oTextUL = GameObject.Find("/UI/CanvasScreen/UL/Text-UL").GetComponent<Text>();
        _oTextUC = GameObject.Find("/UI/CanvasScreen/UC/Text-UC").GetComponent<Text>();
        _oTextUR = GameObject.Find("/UI/CanvasScreen/UR/Text-UR").GetComponent<Text>();

        //=== Create user-adjustable top-level game options ===
        _oObj = new CObject(this, 0, typeof(EGamePlay), "Erotic9");		//###TEMP!!! Main game name in this low-importance GUI???
        _oObj.PropGroupBegin("", "", true);		//###CLEANUP
        //_oObj.PropAdd(EGamePlay.Pleasure,			"Pleasure",		30,		-100,	100,	"Amount of pleasure experienced by game characters.  Influences 'Arousal' (NOTE: Temporary game mechanism)");	//###BUG with first setting
        //_oObj.PropAdd(EGamePlay.Arousal,			"Arousal",		0,		0,		100,	"Current state of arousal from game characters.  Currently influence penis size.  (NOTE: Temporary game mechanism)");
        //_oObj.PropAdd(EGamePlay.PoseRootPos,		"Pose Root Position",typeof(EPoseRootPos), 0,	"Base location of pose root.  (e.g. on bed, by bedside, etc)");
        //_oObj.PropAdd(EGamePlay.PenisSize,			"Penis Size",	0,		0,		100,	"", CProp.ReadOnly | CProp.Hide);
        //_oObj.PropAdd(EGamePlay.PenisErectionMax,	"Erection",		0,		0,		100,	"", CProp.ReadOnly | CProp.Hide);
        //_oObj.PropAdd(EGamePlay.FluidConfig,		"Fluid Configuration", 0, "Display the properties of the Erotic9 fluid simulator.  (Advanced)", CProp.AsButton);
        _oObj.FinishInitialization();
        _oHotSpot = CHotSpot.CreateHotspot(this, transform, "Game Options", false, new Vector3(0, 0.0f, 0.0f), 1.0f);

        //if (_GameModeAtStartup == EGameModes.None) {
        //    yield break;
        //}

        float nDelayForGuiCatchup = _bRunningInEditor ? 0.2f : 0.01f;		//###HACK? ###TUNE: Adjustable delay to give iGUI time to update 'Game is Loading' message, with some extra time inserted to make Unity editor appear more responsive during game awake time
        ///yield return new WaitForSeconds(nDelayForGuiCatchup);

        //=== Send async call to authentication so it is ready by the time game has initialized ===
        //		WWW oWWW = null;
        //		if (Application.genuine) {		//###CHECK: Has any value against piracy???
        //			if (Application.internetReachability != NetworkReachability.NotReachable) {		//###CHECK!!!
        //				//####BROKEN?! Why store it if we don't use it? string sMachineID = PlayerPrefs.GetString(G.C_PlayerPref_MachineID);
        //				string sMachineID = CGame.GetMachineID();		//###CHECK Can cause problems if switching adaptors frequently?
        //				oWWW = new WWW("http://www.erotic9.net/cgi-bin/CheckUser.py?Action=Authenticate&MachineID=" + sMachineID);
        //			} else {
        //				Debug.LogError("Warning: Could not authenticate because of Internet unreacheability.");
        //			}
        //		} else {
        //			Debug.LogError("Warning: Could not authenticate because of executable image corruption.");
        //		}

        //=== Try to load our dll to extract helpful error message if it fails, then release it ===
        //Debug.Log("INIT: Attempting to load ErosEngine.dll");         //###BROKEN!  WTF No longer works loading 64 bit dll??
        //int hLoadLibResult = LoadLibraryEx("ErosEngine.dll", 0, 2);
        //if (hLoadLibResult > 32)
        //	FreeLibrary(hLoadLibResult);			// Free our dll so Unity can load it its way.  Based on code sample at http://support.microsoft.com/kb/142814
        //else
        //	CUtility.ThrowException("ERROR: Failure to load ErosEngine.dll.  Error code = " + hLoadLibResult);		// App unusable.  Study return code to find out what is wrong.
        //Debug.Log("INIT: Succeeded in loading ErosEngine.dll");

        //####OBS? GameObject oGuiGO = GameObject.Find("iGUI");			//###TODO!!! Update game load status... ###IMPROVE: Async load so OnGUI gets called???  (Big hassle for that!)
        Debug.Log("0. Game Awake"); ///yield return new WaitForSeconds(nDelayForGuiCatchup);
        int n123 = ErosEngine.Utility_Test_Return123_HACK();			// Dummy call just to see if DLL will load with Unity
        if (n123 != 123)
            CUtility.ThrowException("ERROR: Failure to get 123 from ErosEngine.dll call to Utility_Test_Return123_HACK.");
        Debug.Log("INIT: Succeeded in loading ErosEngine.dll");

        //=== Initialize our gBlender direct-memory buffers ===
        Debug.Log("1. Shared Memory Creation.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        if (ErosEngine.gBL_Init(CGame.GetFolderPathRuntime()) == false)
            CUtility.ThrowException("ERROR: Could not start gBlender library!  Game unusable.");

        //=== Spawn Blender process ===
        Debug.Log("2. Background Server Start.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);	//###CHECK: Cannot wait long!!
        _hWnd_Unity = (IntPtr)GetActiveWindow();			// Just before we start Blender obtain the HWND of our Unity editor / player window.  We will need this to re-activate our window.  (Starting blender causes it to activate and would require user to alt-tab back to game!!)
        _oProcessBlender = CGame.LaunchProcessBlender("Erotic9.blend");
        if (_oProcessBlender == null)
            CUtility.ThrowException("ERROR: Could not start Blender!  Game unusable.");
        //_nWnd_Blender_HACK = (IntPtr)GetActiveWindow();

        //=== Start Blender (and our gBlender scripts).  Game cannot run without them ===
        Debug.Log("3. Client / Server Handshake.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        if (ErosEngine.gBL_HandshakeBlender() == false)
            CUtility.ThrowException("ERROR: Could not handshake with Blender!  Game unusable.");

        SetForegroundWindow(_hWnd_Unity);           // Set our editor / player back into focus (away from just-spawned Blender)

        //=== Set Blender global variables ===
        CGame.gBL_SendCmd("G", "CGlobals.SetFlexParticleSpacing(" + CGame.INSTANCE.particleSpacing.ToString() + ")");         //###TODO: Add others?

        //=== Start PhysX ===
          //      Debug.Log("4. PhysX3 Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //ErosEngine.PhysX3_Create();						// *Must* occur before any call to physics library...  So make sure this object is listed with high priority in Unity's "Script Execution Order"

        //Debug.Log("5. PhysX2 Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //ErosEngine.PhysX2_Create();						//###IMPROVE!!! Return argument ###NOTROBUST

        //Debug.Log("6. OpenCL Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //		if (System.Environment.CommandLine.Contains("-DisableOpenCL") == false)	//###TODO More / better command line processing?		//###SOON ####BROKEN!!!!! OpenCL breaks cloth GPU!
        //			ErosEngine.MCube_Init();		//###IMPROVE: Log message to user!

        SetForegroundWindow(_hWnd_Unity);			//###WEAK: Can get rid of??

        //=== Start misc stuff ===
        Debug.Log("7. CGame globals.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        _oSceneMeshesGO = GameObject.Find("SceneMeshes");			// Remember our scene game object so we can hide/show

        _aGuiMessages = new string[(int)EGameGuiMsg.COUNT];
        _ShowFPS = _ShowSysInfo = _bRunningInEditor;

        //###IMPROVE: Disabled until we need to save CPU cycles...  Create upon user demand to record script!
        //_oScriptRecordUserActions = new CScriptRecord(GetPathScript("RecordedScript"), "Automatically-generated Erotic9 Scene Interation Script");

        _oPoseRoot = GameObject.Find("CPoseRoot").GetComponent<CPoseRoot>();
        _oPoseRoot.OnStart();

        //_oFluid = gameObject.AddComponent<CFluid>();
        //_oFluid.OnAwake();

        Application.targetFrameRate = _TargetFrameRate;			//###BUG!!! Why no effect????
        _DefaultJointSpringOld = _DefaultJointSpring;		//###OBS
        _DefaultJointDampingOld = _DefaultJointDamping;

        _oCamTarget = GameObject.Find("CCamTarget").GetComponent<CCamTarget>();		//###WEAK!!!
        _oCamTarget.OnStart();

        Debug.Log("8. Body Assembly.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);		//###WEAK!!!

        //_oFluid.OnStart();								//###CHECK: Keep interleave

        SetGameModeBasicInteractions(true);

        //=== Find the static scene colliders in 'SceneColliders' node and initialize them ===
        //Debug.Log("CGame.StartGame() Registering Static Colliders: " + s_aColliders_Scene.Length);
          //  if (s_aColliders_Scene != null)
            //foreach (CCollider_OBS oColStatic in s_aColliders_Scene)		// Colliders that are marked as static registered themselves to us in their Awake() so we can start and destroy them
               // oColStatic.OnStart();

        //StartCoroutine(Coroutine_Update100ms());
        StartCoroutine(Coroutine_Update500ms());

        _GameIsRunning = true;
        enabled = true;
        Debug.Log("+++ GameIsRunning ++");

        Debug.Log("7. Scene settling time.");  //###???  new WaitForSeconds(2.0f);		//###DESIGN??  ###TUNE??
        ///_oGui.ShowSceneBlanker(false);
        ///_oGui.ShowPanelGameLoad(false);

        //=== Check result of user authentication ===
        /*
        if (oWWW != null) {
            yield return oWWW;
            string sResultAuth = oWWW.text;
            _DemoVersion = sResultAuth.Contains("Result=OK") == false;		//###IMPROVE: Create parse routine and return server errors
            Debug.Log("Auth Results = " + sResultAuth);
            if (_DemoVersion == false)
                Debug.Log("Starting game in non-demo mode.");
        }*/
        //_DemoVersion = false;
        //if (_DemoVersion)
        //	Debug.Log("Starting game in demo mode.");		//###TODO: Temp caption!

        ///		if (_bRunningInEditor == false)
        ///			CUtility.WndPopup_Create(EWndPopupType.LearnToPlay, null, "Online Help", 50, 50);	// Show the help dialog at start... ###BUG: Does not change the combo box at top!

        SetForegroundWindow(_hWnd_Unity);           //###WEAK: Can get rid of??

        //if (CGame.INSTANCE._GameMode == EGameModes.None)        //####TEMP
        //    return;

        //=== Create the body publicly-editable body definitions that can construct and reconstruct CBody instances ===
        //CGame.INSTANCE._nNumPenisInScene_BROKEN = 0;

        //###NOTE: For simplification in pose files we always have two bodies in the scene with man/shemale being body 0 and woman body 1
        //CreateBody(0);
        //      //CreateBody(1);
        _aBodyBases[0] = new CBodyBase(0, EBodySex.Woman);
        //###BROKEN _aBodyBases[0].SelectBody();

        TemporarilyDisablePhysicsCollision();

        ///SetPenisInVagina(false);		// We initialize the penis in v****a state to false so v****a track colliders don't kick in at scene init

        if (CGame.INSTANCE._GameMode == EGameModes.Play)
            ScenePose_Load("Standing", false);          // Load the default scene pose

        //###TODO ##NOW: Init GUI first!!
        //iGUISmartPrefab_WndPopup.WndPopup_Create(new CObject[] { oObj }, "Game Play", 0, 0);		//###TEMP

        //Time.timeScale = 0.05f;		//###REVA ###TEMP   Gives more time for cloth to settle... but fix it some other way (with far stronger params??)

        ChangeGameMode(_GameModeAtStartup);             // Set the initial game mode as statically requested

        Debug.LogFormat("Time at startup end: {0}", Time.time - _nTimeAtStart);
        //ScenePose_Load("Standing", false);          // Load the default scene pose
    }
    override public void update()
    {
        base.update();
        //CSpriteManager.update();
        CMouse.update();
        if (current_state == STATE_PAUSE)
        {
            if (nextScreenClick())
            {
                screenDim.setImage(null);
                backMenuBttn.setImage(null);
                btnNextScreen.setImage(null);
                current_state = STATE_PLAYING;
            }
            if (backToMenuClick())
            {
                SoundList.instance.stopMusic();
                SoundList.instance.playMenuMusic();
                CGame.inst().setState(new CMenuState());
                return;
            }


            return;
        }
        mBoard.update();
        monster.update();
        building.update();
        screenDim.update();
        mTimer.update();
        optionsBttn.update();
        skills.update();
        backMenuBttn.update();
        tryAgainBttn.update();
        btnNextScreen.update();
        timeLeft.setText("TIME: " + (int)(CurrentStageData.currentTimer.getTimeLeft()));
        timeLeft.update();
        scoreText.setText("SCORE: " + (CurrentStageData.score * 10));
        scoreText.update();
        switch (current_state)
        {
        case STATE_PLAYING:
            if (optionsClick())
            {
                current_state = STATE_PAUSE;
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                btnNextScreen.setImage(Resources.Load <Sprite>("Sprites/Buttons/Button_Continue"));
                btnNextScreen.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 150);
                return;
            }
            if (mBoard.current_state == 0)
            {
                if (CurrentStageData.currentKaiju.scale >= 100)
                {
                    current_state = STATE_WIN;
                    SoundList.instance.stopMusic();
                    monster.setState(4);
                    building.setState(1);
                }
                else
                {
                    screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                    screenDim.setX(0);
                    screenDim.setY(0);

                    current_state = STATE_LOSE;

                    backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                    backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                    tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton"));
                    tryAgainBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 100);
                    monster.setState(2);
                }
            }
            break;

        case STATE_WIN:
            CGameConstants.HIGH_SCORE = CurrentStageData.score;
            //System.IO.File.WriteAllText("score.txt", CurrentStageData.score.ToString());
            tryAgainInfo.TargetScore = CurrentStageData.score;
            if (!building.building.isEnded())
            {
                CurrentStageData.cameraShake();
            }
            else
            {
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton"));
                tryAgainBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 100);

                if (backToMenuClick())
                {
                    CurrentStageData.clearData();
                    SoundList.instance.stopMusic();
                    SoundList.instance.playMenuMusic();
                    CGame.inst().setState(new CMenuState());
                    return;
                }
                if (tryAgainClick())
                {
                    CurrentStageData.clearData();
                    CGame.inst().setState(new CSurvivalState(tryAgainInfo));
                    return;
                }


                if (Camera.main.transform.position.x > 360)
                {
                    Camera.main.transform.Translate(new Vector3(-15, 0, 0));
                }
                if (Camera.main.transform.position.x < 360)
                {
                    Camera.main.transform.Translate(new Vector3(15, 0, 0));
                }
            }
            break;

        case STATE_LOSE:
            if (backToMenuClick())
            {
                CurrentStageData.clearData();
                SoundList.instance.stopMusic();
                SoundList.instance.playMenuMusic();
                CGame.inst().setState(new CMenuState());
                return;
            }
            if (tryAgainClick())
            {
                CurrentStageData.clearData();
                CGame.inst().setState(new CSurvivalState(tryAgainInfo));
                return;
            }
            break;
        }
    }
 public bool Trigger()
 {
     CGame.Restart();
     return(true);
 }
Example #22
0
        private void set_data(int iddiv)
        {
            CPlayer clPlayer;
            CTeam   clTeam;
            CGame   clGame;

            STRecordsPerson data;
            STRecordsPerson?reads;
            string          text;

            STGame   game;
            string   team1, team2;
            DateTime dt;

            CRecordsPerson clRec = new CRecordsPerson(connect);

            try
            {
                /* Очки*/
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 1);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult1.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer1.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam1.Text = clTeam.stTeam.name;

                    labelSeason1.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame1.Text = text;
                }
                else
                {
                    labelResult1.Text = null;
                    labelTeam1.Text   = null;
                    labelPlayer1.Text = null;
                    labelSeason1.Text = null;
                    labelGame1.Text   = null;
                }
                /*__________________________________________________*/

                /* Подборы*/
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 2);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult2.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer2.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam2.Text = clTeam.stTeam.name;

                    labelSeason2.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame2.Text = text;
                }
                else
                {
                    labelResult2.Text = null;
                    labelTeam2.Text   = null;
                    labelPlayer2.Text = null;
                    labelSeason2.Text = null;
                    labelGame2.Text   = null;
                }
                /*__________________________________________________*/

                /* Передачи*/
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 3);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult3.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer3.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam3.Text = clTeam.stTeam.name;

                    labelSeason3.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame3.Text = text;
                }
                else
                {
                    labelResult3.Text = null;
                    labelTeam3.Text   = null;
                    labelPlayer3.Text = null;
                    labelSeason3.Text = null;
                    labelGame3.Text   = null;
                }
                /*__________________________________________________*/

                /* Перехваты */
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 4);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult4.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer4.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam4.Text = clTeam.stTeam.name;

                    labelSeason4.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame4.Text = text;
                }
                else
                {
                    labelResult4.Text = null;
                    labelTeam4.Text   = null;
                    labelPlayer4.Text = null;
                    labelSeason4.Text = null;
                    labelGame4.Text   = null;
                }
                /*__________________________________________________*/

                /* Блок - шоты*/
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 5);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult5.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer5.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam5.Text = clTeam.stTeam.name;

                    labelSeason5.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame5.Text = text;
                }
                else
                {
                    labelResult5.Text = null;
                    labelTeam5.Text   = null;
                    labelPlayer5.Text = null;
                    labelSeason5.Text = null;
                    labelGame5.Text   = null;
                }
                /*__________________________________________________*/

                /* 2-х */
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 6);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult6.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer6.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam6.Text = clTeam.stTeam.name;

                    labelSeason6.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame6.Text = text;
                }
                else
                {
                    labelResult6.Text = null;
                    labelTeam6.Text   = null;
                    labelPlayer6.Text = null;
                    labelSeason6.Text = null;
                    labelGame6.Text   = null;
                }
                /*__________________________________________________*/

                /* 3-х */
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 7);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult7.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer7.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam7.Text = clTeam.stTeam.name;

                    labelSeason7.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame7.Text = text;
                }
                else
                {
                    labelResult7.Text = null;
                    labelTeam7.Text   = null;
                    labelPlayer7.Text = null;
                    labelSeason7.Text = null;
                    labelGame7.Text   = null;
                }
                /*__________________________________________________*/

                /* штраф */
                /*__________________________________________________*/
                reads = clRec.GetRecord(iddiv, 8);

                if (reads != null)
                {
                    data = (STRecordsPerson)reads;

                    labelResult8.Text = data.result.ToString();

                    clPlayer = new CPlayer(connect, data.idplayer);
                    text     = string.Format("{0} {1} {2}", clPlayer.stPlayer.family, clPlayer.stPlayer.name,
                                             clPlayer.stPlayer.payname);
                    labelPlayer8.Text = text;

                    clTeam          = new CTeam(connect, data.idteam);
                    labelTeam8.Text = clTeam.stTeam.name;

                    labelSeason8.Text = data.idseason.ToString();

                    clGame = new CGame(connect);
                    game   = clGame.GetGame(data.idseason, data.idgame);

                    team1 = null;
                    team2 = null;
                    dt    = new DateTime();

                    if (game.idteam1 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam1);
                        team1  = clTeam.stTeam.name;
                    }

                    if (game.idteam2 != null)
                    {
                        clTeam = new CTeam(connect, (int)game.idteam2);
                        team2  = clTeam.stTeam.name;
                    }

                    if (game.datetime != null)
                    {
                        dt = (DateTime)game.datetime;
                    }
                    text = string.Format("{0} - {1} ({2})", team1, team2, dt.ToShortDateString());

                    labelGame8.Text = text;
                }
                else
                {
                    labelResult8.Text = null;
                    labelTeam8.Text   = null;
                    labelPlayer8.Text = null;
                    labelSeason8.Text = null;
                    labelGame8.Text   = null;
                }
                /*__________________________________________________*/
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
Example #23
0
        public bool ReadTXTHeader(string FilePath)
        {
            if (!File.Exists(FilePath))
            {
                return(false);
            }

            this.Folder = Path.GetDirectoryName(FilePath);

            foreach (string folder in CConfig.SongFolder)
            {
                if (this.Folder.Contains(folder))
                {
                    if (this.Folder.Length == folder.Length)
                    {
                        this.FolderName = "Songs";
                    }
                    else
                    {
                        this.FolderName = this.Folder.Substring(folder.Length + 1, this.Folder.Length - folder.Length - 1);

                        string str = this.FolderName;
                        try
                        {
                            str = this.FolderName.Substring(0, this.FolderName.IndexOf("\\"));
                        }
                        catch (Exception)
                        {
                        }
                        this.FolderName = str;
                    }
                }
            }

            this.FileName = Path.GetFileName(FilePath);

            EHeaderFlags HeaderFlags = new EHeaderFlags();
            StreamReader sr;

            try
            {
                sr = new StreamReader(FilePath, Encoding.Default, true);

                string line = sr.ReadLine();
                if (line.Length == 0)
                {
                    return(false);
                }

                int    pos        = -1;
                string Identifier = String.Empty;
                string Value      = String.Empty;

                while ((line.Length == 0) || (line[0].ToString().Equals("#")))
                {
                    pos = line.IndexOf(":");

                    if (pos > 0)
                    {
                        Identifier = line.Substring(1, pos - 1).Trim().ToUpper();
                        Value      = line.Substring(pos + 1, line.Length - pos - 1).Trim();

                        if (Value.Length > 0)
                        {
                            switch (Identifier)
                            {
                            case "ENCODING":
                                this.Encoding = CEncoding.GetEncoding(Value);
                                sr            = new StreamReader(FilePath, this.Encoding);
                                Identifier    = String.Empty;
                                line          = sr.ReadLine();

                                while ((line.Length == 0) || (line[0].ToString().Equals("#")) && (Identifier != "ENCODING"))
                                {
                                    pos = line.IndexOf(":");

                                    if (pos > 0)
                                    {
                                        Identifier = line.Substring(1, pos - 1).Trim().ToUpper();
                                        Value      = line.Substring(pos + 1, line.Length - pos - 1).Trim();
                                    }

                                    if (!sr.EndOfStream)
                                    {
                                        if (Identifier == "ENCODING")
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            line = sr.ReadLine();
                                        }
                                    }
                                    else
                                    {
                                        return(false);
                                    }
                                }
                                break;

                            case "TITLE":
                                if (Value != String.Empty)
                                {
                                    this.Title   = Value;
                                    HeaderFlags |= EHeaderFlags.Title;
                                }
                                break;

                            case "ARTIST":
                                if (Value != String.Empty)
                                {
                                    this.Artist  = Value;
                                    HeaderFlags |= EHeaderFlags.Artist;
                                }
                                break;

                            case "TITLE-ON-SORTING":
                                if (Value != String.Empty)
                                {
                                    this.TitleSorting = Value;
                                }
                                break;

                            case "ARTIST-ON-SORTING":
                                if (Value != String.Empty)
                                {
                                    this.ArtistSorting = Value;
                                }
                                break;

                            case "P1":
                                if (Value != String.Empty)
                                {
                                    this.DuetPart1 = Value;
                                }
                                break;

                            case "P2":
                                if (Value != String.Empty)
                                {
                                    this.DuetPart2 = Value;
                                }
                                break;

                            case "MP3":
                                if (File.Exists(Path.Combine(this.Folder, Value)))
                                {
                                    this.MP3FileName = Value;
                                    HeaderFlags     |= EHeaderFlags.MP3;
                                }
                                else
                                {
                                    CLog.LogError("Can't find audio file: " + Path.Combine(this.Folder, Value));
                                    return(false);
                                }
                                break;

                            case "BPM":
                                if (CHelper.TryParse(Value, out this.BPM))
                                {
                                    this.BPM    *= 4;
                                    HeaderFlags |= EHeaderFlags.BPM;
                                }
                                break;

                            case "EDITION":
                                if (Value.Length > 1)
                                {
                                    this.Edition.Add(Value);
                                }
                                break;

                            case "GENRE":
                                if (Value.Length > 1)
                                {
                                    this.Genre.Add(Value);
                                }
                                break;

                            case "YEAR":
                                int num = 0;
                                if (Value.Length == 4 && int.TryParse(Value, out num))
                                {
                                    this.Year = Value;
                                }
                                break;

                            case "LANGUAGE":
                                if (Value.Length > 1)
                                {
                                    this.Language.Add(Value);
                                }
                                break;

                            case "COMMENT":
                                if (Value.Length > 1)
                                {
                                    this.Comment.Add(Value);
                                }
                                break;

                            case "GAP":
                                if (CHelper.TryParse(Value, out this.Gap))
                                {
                                    this.Gap /= 1000f;
                                }
                                break;

                            case "COVER":
                                if (File.Exists(Path.Combine(this.Folder, Value)))
                                {
                                    this.CoverFileName = Value;
                                }
                                break;

                            case "BACKGROUND":
                                if (File.Exists(Path.Combine(this.Folder, Value)))
                                {
                                    this.BackgroundFileName = Value;
                                }
                                break;

                            case "VIDEO":
                                if (File.Exists(Path.Combine(this.Folder, Value)))
                                {
                                    this.VideoFileName = Value;
                                }
                                else
                                {
                                    CLog.LogError("Can't find video file: " + Path.Combine(this.Folder, Value));
                                }

                                break;

                            case "VIDEOGAP":
                                CHelper.TryParse(Value, out this.VideoGap);
                                break;

                            case "VIDEOASPECT":
                                CHelper.TryParse <EAspect>(Value, out this.VideoAspect, true);
                                break;

                            case "START":
                                CHelper.TryParse(Value, out this.Start);
                                break;

                            case "END":
                                if (CHelper.TryParse(Value, out this.Finish))
                                {
                                    this.Finish /= 1000f;
                                }
                                break;

                            case "PREVIEWSTART":
                                if (CHelper.TryParse(Value, out this.PreviewStart))
                                {
                                    if (this.PreviewStart < 0f)
                                    {
                                        this.PreviewStart = 0f;
                                    }
                                    else
                                    {
                                        HeaderFlags |= EHeaderFlags.PreviewStart;
                                    }
                                }
                                break;

                            case "MEDLEYSTARTBEAT":
                                if (int.TryParse(Value, out this.Medley.StartBeat))
                                {
                                    HeaderFlags |= EHeaderFlags.MedleyStartBeat;
                                }
                                break;

                            case "MEDLEYENDBEAT":
                                if (int.TryParse(Value, out this.Medley.EndBeat))
                                {
                                    HeaderFlags |= EHeaderFlags.MedleyEndBeat;
                                }
                                break;

                            case "CALCMEDLEY":
                                if (Value.ToUpper() == "OFF")
                                {
                                    this.CalculateMedley = false;
                                }
                                break;

                            case "RELATIVE":
                                if (Value.ToUpper() == "YES" && Value.ToUpper() != "NO")
                                {
                                    this.Relative = EOffOn.TR_CONFIG_ON;
                                }
                                break;

                            default:
                                ;
                                break;
                            }
                        }
                    }

                    if (!sr.EndOfStream)
                    {
                        line = sr.ReadLine();
                    }
                    else
                    {
                        return(false);
                    }
                } //end of while

                if ((HeaderFlags & EHeaderFlags.Title) == 0)
                {
                    CLog.LogError("Title tag missing: " + FilePath);
                    return(false);
                }

                if ((HeaderFlags & EHeaderFlags.Artist) == 0)
                {
                    CLog.LogError("Artist tag missing: " + FilePath);
                    return(false);
                }

                if ((HeaderFlags & EHeaderFlags.MP3) == 0)
                {
                    CLog.LogError("MP3 tag missing: " + FilePath);
                    return(false);
                }

                if ((HeaderFlags & EHeaderFlags.BPM) == 0)
                {
                    CLog.LogError("BPM tag missing: " + FilePath);
                    return(false);
                }

                if (this.Relative == EOffOn.TR_CONFIG_ON)
                {
                    CLog.LogError("Relative songs are not supported by Vocaluxe (perhaps later)! (" + FilePath + ")");
                    return(false);
                }

                #region check medley tags
                if ((HeaderFlags & EHeaderFlags.MedleyStartBeat) != 0 && (HeaderFlags & EHeaderFlags.MedleyEndBeat) != 0)
                {
                    if (this.Medley.StartBeat > this.Medley.EndBeat)
                    {
                        CLog.LogError("MedleyStartBeat is bigger than MedleyEndBeat in file: " + FilePath);
                        HeaderFlags = HeaderFlags - EHeaderFlags.MedleyStartBeat - EHeaderFlags.MedleyEndBeat;
                    }
                }

                if ((HeaderFlags & EHeaderFlags.PreviewStart) == 0 || this.PreviewStart == 0f)
                {
                    //PreviewStart is not set or <=0
                    if ((HeaderFlags & EHeaderFlags.MedleyStartBeat) != 0)
                    {
                        //fallback to MedleyStart
                        this.PreviewStart = CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM);
                    }
                    else
                    {
                        //else set to 0, it will be set in FindRefrainStart
                        this.PreviewStart = 0f;
                    }
                }

                if ((HeaderFlags & EHeaderFlags.MedleyStartBeat) != 0 && (HeaderFlags & EHeaderFlags.MedleyEndBeat) != 0)
                {
                    this.Medley.Source      = EMedleySource.Tag;
                    this.Medley.FadeInTime  = CSettings.DefaultMedleyFadeInTime;
                    this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime;
                }
                #endregion check medley tags

                this.Encoding = sr.CurrentEncoding;
            }
            catch (Exception e)
            {
                CLog.LogError("Error reading txt header in file \"" + FilePath + "\": " + e.Message);
                return(false);
            }

            CheckFiles();

            //Before saving this tags to .txt: Check, if ArtistSorting and Artist are equal, then don't save this tag.
            if (this.ArtistSorting == String.Empty)
            {
                this.ArtistSorting = this.Artist;
            }

            if (this.TitleSorting == String.Empty)
            {
                this.TitleSorting = this.Title;
            }

            return(true);
        }
 public CCreditsState()
 {
     CGame.inst().setImage("Sprites/credits");
     CGame.inst().getBakcground().setX(0);
     CGame.inst().getBakcground().setY(0);
 }
Example #25
0
        private static void _Run(string[] args)
        {
            Application.DoEvents();

            try
            {
                // Create data folder
                Directory.CreateDirectory(CSettings.DataFolder);

                // Init Log
                CLog.Init(CSettings.FolderNameLogs,
                          CSettings.FileNameMainLog,
                          CSettings.FileNameSongLog,
                          CSettings.FileNameCrashMarker,
                          CSettings.GetFullVersionText(),
                          CReporter.ShowReporterFunc,
                          ELogLevel.Information);

                if (!CProgrammHelper.CheckRequirements())
                {
                    return;
                }
                CProgrammHelper.Init();

                using (CBenchmark.Time("Init Program"))
                {
                    CMain.Init();
                    Application.DoEvents();

                    // Init Language
                    using (CBenchmark.Time("Init Language"))
                    {
                        if (!CLanguage.Init())
                        {
                            throw new CLoadingException("Language");
                        }
                    }

                    Application.DoEvents();

                    // load config
                    using (CBenchmark.Time("Init Config"))
                    {
                        CConfig.LoadCommandLineParams(args);
                        CConfig.UseCommandLineParamsBefore();
                        CConfig.Init();
                        CConfig.UseCommandLineParamsAfter();
                    }

                    // Create folders
                    CSettings.CreateFolders();

                    _SplashScreen = new CSplashScreen();
                    Application.DoEvents();

                    // Init Draw
                    using (CBenchmark.Time("Init Draw"))
                    {
                        if (!CDraw.Init())
                        {
                            throw new CLoadingException("drawing");
                        }
                    }

                    Application.DoEvents();

                    // Init Playback
                    using (CBenchmark.Time("Init Playback"))
                    {
                        if (!CSound.Init())
                        {
                            throw new CLoadingException("playback");
                        }
                    }

                    Application.DoEvents();

                    // Init Record
                    using (CBenchmark.Time("Init Record"))
                    {
                        if (!CRecord.Init())
                        {
                            throw new CLoadingException("record");
                        }
                    }

                    Application.DoEvents();

                    // Init VideoDecoder
                    using (CBenchmark.Time("Init Videodecoder"))
                    {
                        if (!CVideo.Init())
                        {
                            throw new CLoadingException("video");
                        }
                    }

                    Application.DoEvents();

                    // Init Database
                    using (CBenchmark.Time("Init Database"))
                    {
                        if (!CDataBase.Init())
                        {
                            throw new CLoadingException("database");
                        }
                    }

                    Application.DoEvents();

                    //Init Webcam
                    using (CBenchmark.Time("Init Webcam"))
                    {
                        if (!CWebcam.Init())
                        {
                            throw new CLoadingException("webcam");
                        }
                    }

                    Application.DoEvents();

                    // Init Background Music
                    using (CBenchmark.Time("Init Background Music"))
                    {
                        CBackgroundMusic.Init();
                    }

                    Application.DoEvents();

                    // Init Profiles
                    using (CBenchmark.Time("Init Profiles"))
                    {
                        CProfiles.Init();
                    }

                    Application.DoEvents();

                    // Init Fonts
                    using (CBenchmark.Time("Init Fonts"))
                    {
                        if (!CFonts.Init())
                        {
                            throw new CLoadingException("fonts");
                        }
                    }

                    Application.DoEvents();

                    // Theme System
                    using (CBenchmark.Time("Init Theme"))
                    {
                        if (!CThemes.Init())
                        {
                            throw new CLoadingException("theme");
                        }
                    }

                    using (CBenchmark.Time("Load Theme"))
                    {
                        CThemes.Load();
                    }

                    Application.DoEvents();

                    // Load Cover
                    using (CBenchmark.Time("Init Cover"))
                    {
                        if (!CCover.Init())
                        {
                            throw new CLoadingException("covertheme");
                        }
                    }

                    Application.DoEvents();

                    // Init Screens
                    using (CBenchmark.Time("Init Screens"))
                    {
                        CGraphics.Init();
                    }

                    Application.DoEvents();

                    // Init Server
                    using (CBenchmark.Time("Init Server"))
                    {
                        CVocaluxeServer.Init();
                    }

                    Application.DoEvents();

                    // Init Input
                    using (CBenchmark.Time("Init Input"))
                    {
                        CController.Init();
                        CController.Connect();
                    }

                    Application.DoEvents();

                    // Init Game
                    using (CBenchmark.Time("Init Game"))
                    {
                        CGame.Init();
                        CProfiles.Update();
                        CConfig.UsePlayers();
                    }

                    Application.DoEvents();

                    // Init Party Modes
                    using (CBenchmark.Time("Init Party Modes"))
                    {
                        if (!CParty.Init())
                        {
                            throw new CLoadingException("Party Modes");
                        }
                    }

                    Application.DoEvents();
                    //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
                    //Rely on GC doing its job afterwards and call Dispose methods where appropriate
                    GC.Collect();
                }
            }
            catch (Exception e)
            {
                CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show: true);
                if (_SplashScreen != null)
                {
                    _SplashScreen.Close();
                }
                _CloseProgram();
                return;
            }
            Application.DoEvents();

            // Start Main Loop
            if (_SplashScreen != null)
            {
                _SplashScreen.Close();
            }

            CDraw.MainLoop();
        }
Example #26
0
    /// <summary>
    /// Game startup.
    /// </summary>
    public CGame(CUnityInterface Interface, string CommandLineArgs)
    {
        _cmdArgs = CommandLineArgs.Split(' ');
        string[] parms;

#if !UNITY_EDITOR
        DataDirectory           = Application.dataPath + "/Data/";
        PersistentDataDirectory = Application.persistentDataPath + "/";
#else
        DataDirectory           = "Data/";
        PersistentDataDirectory = "SaveData/";
#endif

        Config = new CConfig(PersistentDataDirectory + "config.txt");
        Config.Load();

#if !UNITY_EDITOR
        DataDirectory           = Application.dataPath + "/Data/";
        PersistentDataDirectory = Application.persistentDataPath + "/";

        if (_CheckArg("dev", out parms))
        {
            Screen.SetResolution(1280, 720, false);
        }
        else
        {
            string resType = Config.GetString("ResolutionType");

            if (resType == "default")
            {
                Resolution r = Screen.resolutions[Screen.resolutions.Length - 1];
                Screen.SetResolution(r.width, r.height, true);
            }
            else if (resType == "fullscreen" || resType == "windowed")
            {
                Resolution r    = Screen.resolutions[Screen.resolutions.Length - 1];
                int        resX = (int)Config.GetFloat("ResolutionWidth");
                int        resY = (int)Config.GetFloat("ResolutionHeight");

                Screen.SetResolution(resX, resY, (resType == "fullscreen"));
            }
        }
#endif

        CUtility.MakeDirectory(PersistentDataDirectory + SAVES_DIRECTORY);
        CUtility.MakeDirectory(PersistentDataDirectory + REPLAYS_DIRECTORY);

        PrimaryResources = Interface.GetComponent <CPrimaryResources>();
        WorldResources   = Interface.GetComponent <CWorldResources>();
        UIResources      = Interface.GetComponent <CUIResources>();
        ToolkitUI        = Interface.GetComponent <CToolkitUI>();
        GameUIStyle      = Interface.GetComponent <CGameUIStyle>();

        Console = new CConsole();

        Debug.Log("Save game directory: " + PersistentDataDirectory);
        Debug.Log("Data directory: " + DataDirectory);

        VarShowGrid        = Console.CreateVar("show_grid", false);
        VarShowVisLines    = Console.CreateVar("show_los", false);
        VarShowDDATest     = Console.CreateVar("show_ddatest", false);
        VarShowArcTest     = Console.CreateVar("show_arctest", false);
        VarShowBounds      = Console.CreateVar("show_bounds", false);
        VarShowDebugStats  = Console.CreateVar("show_debugstats", false);
        VarShowMobility    = Console.CreateVar("show_mobility", 0, 0, CWorld.MAX_PLAYERS);
        VarShowSolidity    = Console.CreateVar("show_solidity", 0, 0, CWorld.MAX_PLAYERS + 1);
        VarShowProfiler    = Console.CreateVar("show_profiler", false);
        VarNoFow           = Console.CreateVar("no_fow", false);
        VarPlaceItemDirect = Console.CreateVar("place_item_direct", false);
        VarShowComfort     = Console.CreateVar("show_comfort", false);
        VarShowEfficiency  = Console.CreateVar("show_efficiency", false);

        VarShowPathing   = Console.CreateVar("pathing", false);
        VarShowFlowField = Console.CreateVar("show_flowfield", false);
        VarShowNavMesh   = Console.CreateVar("show_navmesh", false);
        VarShowNavRect   = Console.CreateVar("show_navrect", 0, 0, CWorld.MAX_PLAYERS);
        VarShowProxies   = Console.CreateVar("show_proxies", 0, 0, CWorld.MAX_PLAYERS);

        VarFreePurchases = Console.CreateVar("freebuy", true);
        Console.CreateCommand("gameui", (Params) => { UIManager.ToggleUIActive(); });
        Console.CreateCommand("quit", (Params) => { ExitApplication(); });
        Console.CreateCommand("exit", (Params) => { ExitApplication(); });
        Console.CreateCommand("set_owed", (Params) => { if (_gameSession == null)
                                                        {
                                                            return;
                                                        }
                                                        _gameSession.SetOwed(1000); });
        Console.CreateCommand("set_stamina", (Params) => { if (_gameSession == null)
                                                           {
                                                               return;
                                                           }
                                                           _gameSession.SetStamina(10.0f); });
        Console.CreateCommand("set_hunger", (Params) => { if (_gameSession == null)
                                                          {
                                                              return;
                                                          }
                                                          _gameSession.SetHunger(80); });
        Console.CreateCommand("rebuild_icons", (Params) => { IconBuilder.RebuildItemIcons(true); });

        Game  = this;
        Steam = new CSteam();
        PrimaryThreadProfiler = new CProfiler();
        SimThreadProfiler     = new CProfiler();
        DebugLevels           = new CDebugLevels();
        UniversalRandom       = new CRandomStream();
        AssetManager          = new CAssetManager();
        Net           = new CNet();
        Resources     = new CResources();
        CameraManager = new CCameraManager();
        UIManager     = new CUIManager(ToolkitUI, GameUIStyle);
        CDebug.StaticInit();
        AssetManager.Init();
        ProfilerManager = new CProfilerManager();
        ProfilerManager.Init();
        IconBuilder = new CIconBuilder();
        IconBuilder.Init();
        _inputState = new CInputState();

        Console.Hide();
        Analytics.SetUserId(Steam.mSteamID.ToString());

        // TODO: Backquote is not ~, investigate.
        // TOOD: Allow the same command to have multiple keys associated with it.
        _inputState.RegisterCommand("console", Config.GetString("KeyConsole"), true);

        _inputState.RegisterCommand("escape", Config.GetString("KeyEscape"));

        _inputState.RegisterCommand("focusOnSpawn", Config.GetString("KeyFocusOnSpawn"));

        _inputState.RegisterCommand("camForward", Config.GetString("KeyCamForward"));
        _inputState.RegisterCommand("camLeft", Config.GetString("KeyCamLeft"));
        _inputState.RegisterCommand("camBackward", Config.GetString("KeyCamBackward"));
        _inputState.RegisterCommand("camRight", Config.GetString("KeyCamRight"));
        _inputState.RegisterCommand("camRotateLeft", KeyCode.Delete);
        _inputState.RegisterCommand("camRotateRight", KeyCode.PageDown);

        _inputState.RegisterCommand("itemPlaceRotate", Config.GetString("KeyPlaceRotate"));
        _inputState.RegisterCommand("itemPlaceRepeat", Config.GetString("KeyPlaceRepeat"));

        _inputState.RegisterCommand("action1", Config.GetString("KeyAction1"));
        _inputState.RegisterCommand("action2", Config.GetString("KeyAction2"));
        _inputState.RegisterCommand("action3", Config.GetString("KeyAction3"));
        _inputState.RegisterCommand("action4", Config.GetString("KeyAction4"));

        _inputState.RegisterCommand("openOptions", Config.GetString("KeyOptionsMenu"));

        _inputState.RegisterCommand("reload", KeyCode.F5);
        _inputState.RegisterCommand("space", KeyCode.Space);

        _inputState.RegisterCommand("editorDelete", Config.GetString("KeyEditorDelete"));
        _inputState.RegisterCommand("editorDuplicate", Config.GetString("KeyEditorDuplicate"));
        _inputState.RegisterCommand("editorUndo", Config.GetString("KeyEditorUndo"));
        _inputState.RegisterCommand("editorRedo", Config.GetString("KeyEditorRedo"));
        _inputState.RegisterCommand("editorSave", Config.GetString("KeyEditorSave"));

        // Apply default settings
        //Application.targetFrameRate = 60;
        //QualitySettings.antiAliasing

        // Volume range: 0.0 - -80.0
        // TODO: Volume in DB is exponential, making 0 to 1 range for config ineffective.
        UIResources.MasterMixer.SetFloat("MasterVolume", CMath.MapRangeClamp(Config.GetFloat("MasterVolume"), 0, 1, -80, -12));
        UIResources.MasterMixer.SetFloat("MusicVolume", CMath.MapRangeClamp(Config.GetFloat("MusicVolume"), 0, 1, -80, 0));
        UIResources.MasterMixer.SetFloat("SoundsVolume", CMath.MapRangeClamp(Config.GetFloat("SoundsVolume"), 0, 1, -80, 0));
        UIResources.MasterMixer.SetFloat("UISoundsVolume", CMath.MapRangeClamp(Config.GetFloat("UISoundsVolume"), 0, 1, -80, 0));

        // NOTE: BE SUPER CAREFUL WITH THIS
        // You can corrupt ALL the item assets if not careful.
        // Saves asset to disk, but asset currently in memory won't reflect new version.
        //_resaveAllItemAssetsToLastestVersion();

        // TODO: This bootstraps all model assets on startup.
        // If the model asset is first loaded by the sim thread, then it will crash as it tries to generate the meshes.
        // Should probably only generate meshes when they are pulled in by the main thread.
        _testItemAssetVersion();

        if (_CheckArg("toolkit", out parms))
        {
            StartAssetToolkit();
        }
        else if (_CheckArg("map", out parms))
        {
            if (parms != null && parms.Length > 0)
            {
                CGameSession.CStartParams startParams = new CGameSession.CStartParams();
                startParams.mPlayType        = CGameSession.EPlayType.SINGLE;
                startParams.mUserPlayerIndex = 0;                 // Will be set by the level when loaded.
                startParams.mLevelName       = parms[0];
                StartGameSession(startParams);
            }
        }
        else
        {
            UIManager.AddInterface(new CMainMenuUI());
        }
    }
Example #27
0
 // return value
 // -1 = not implemented
 // 0 = failure
 // 1 = success
 public static int InstallGame(CGame game)
 {
     //CDock.DeleteCustomImage(game.Title);
     Launch();
     return(-1);
 }
Example #28
0
 public static void StartGame(CGame game)
 {
     //CLogger.LogInfo("Setting up a {0} game...", GOG.NAME_LONG);
     ProcessStartInfo gogProcess    = new();
     string           gogClientPath = game.Launch.Contains(".") ? game.Launch.Substring(0, game.Launch.IndexOf('.') + 4) : game.Launch;
     string           gogArguments  = game.Launch.Contains(".") ? game.Launch[(game.Launch.IndexOf('.') + 4)..] : string.Empty;
Example #29
0
 public CModel(CGame game)
 {
     this.game     = game;
     this.player   = new CPlayer(game);
     this.opponent = new CPlayer(game);
 }
Example #30
0
File: Epic.cs Project: Solaire/GLC
        // return value
        // -1 = not implemented
        // 0 = failure
        // 1 = success
        public static int UninstallGame(CGame game)
        {
            //bool useEGL = (bool)CConfig.GetConfigBool(CConfig.CFG_USEEGL);
            bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
            string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);

            if (string.IsNullOrEmpty(pathLeg))
            {
                useLeg = false;
            }
            if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))             // legendary.exe in current directory
            {
                pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
            }
            if (useLeg && File.Exists(pathLeg))
            {
                //Process ps;
                if (OperatingSystem.IsWindows())
                {
                    CLogger.LogInfo("Launch: cmd.exe /c \"" + pathLeg + "\" -y uninstall " + game.ID);
                    CDock.StartAndRedirect("cmd.exe", "/c \"" + pathLeg + "\" -y uninstall " + game.ID);
                }
                else
                {
                    CLogger.LogInfo("Launch: " + pathLeg + " -y uninstall " + game.ID);
                    Process.Start(pathLeg, "-y uninstall " + game.ID);
                }

                /*
                 * ps.WaitForExit(30000);
                 * if (ps.ExitCode == 0)
                 */
                return(1);
            }

            /*
             * else if (useEGL)
             * {
             *      Launch();
             *      return -1;
             * }
             */
            else if (!string.IsNullOrEmpty(game.Uninstaller))
            {
                // delete Desktop icon
                File.Delete(Path.Combine(GetFolderPath(SpecialFolder.Desktop), game.Title + ".lnk"));
                string[] un = game.Uninstaller.Split(';');

                // delete manifest file
                if (un.Length > 1 && !string.IsNullOrEmpty(un[1]) && un[1].EndsWith(".item"))
                {
                    File.Delete(Path.Combine(GetFolderPath(SpecialFolder.CommonApplicationData), EPIC_ITEMS, un[1]));
                }

                if (un.Length > 0 && !string.IsNullOrEmpty(un[0]) && !un[0].EndsWith(".item"))
                {
                    DirectoryInfo rootDir = new(un[0]);
                    if (rootDir.Exists)
                    {
                        /*
                         * foreach (DirectoryInfo dir in rootDir.EnumerateDirectories())
                         *      dir.Delete(true);
                         * foreach (FileInfo file in rootDir.EnumerateFiles())
                         *      file.Delete();
                         */
                        rootDir.Delete(true);
                        return(1);
                    }
                }
            }
            return(0);
        }
Example #31
0
 public static void InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     Launch();
 }
Example #32
0
File: Epic.cs Project: Solaire/GLC
        public static void StartGame(CGame game)
        {
            bool   useEGL  = (bool)CConfig.GetConfigBool(CConfig.CFG_USEEGL);
            bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
            bool   syncLeg = (bool)CConfig.GetConfigBool(CConfig.CFG_SYNCLEG);
            string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);

            if (string.IsNullOrEmpty(pathLeg))
            {
                useLeg = false;
            }
            if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))             // legendary.exe in current directory
            {
                pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
            }

            if (useLeg && File.Exists(pathLeg))
            {
                if (OperatingSystem.IsWindows())
                {
                    string cmdLine = "\"" + pathLeg + "\" -y launch " + game.ID;
                    CLogger.LogInfo($"Launch: cmd.exe /c " + cmdLine);
                    if (syncLeg)
                    {
                        cmdLine = "\"" + pathLeg + "\" -y sync-saves " + game.ID + " & " + cmdLine + " & \"" + pathLeg + "\" -y sync-saves " + game.ID;
                    }
                    CDock.StartAndRedirect("cmd.exe", "/c '" + cmdLine + " '");
                }
                else
                {
                    CLogger.LogInfo($"Launch: " + pathLeg + " -y launch " + game.ID);
                    if (syncLeg)
                    {
                        Process.Start(pathLeg, "-y sync-saves " + game.ID);
                    }
                    Process.Start(pathLeg, "-y launch " + game.ID);
                    if (syncLeg)
                    {
                        Process.Start(pathLeg, "-y sync-saves " + game.ID);
                    }
                }
            }
            else if (useEGL)
            {
                if (OperatingSystem.IsWindows())
                {
                    CDock.StartShellExecute(START_GAME + game.ID + START_GAME_ARGS);
                }
                else
                {
                    Process.Start(PROTOCOL + START_GAME + game.ID + START_GAME_ARGS);
                }
            }
            else
            {
                if (OperatingSystem.IsWindows())
                {
                    CDock.StartShellExecute(game.Launch);
                }
                else
                {
                    Process.Start(game.Launch);
                }
            }
        }
Example #33
0
 // Use this for initialization
 void Start()
 {
     m_Game      = GameObject.Find("_Game").GetComponent <CGame>();
     m_Animation = new CAnimation(m_material, m_columns, m_rows, m_fFPS);
     m_Game.getLevel().CreateElement <CMachine>(gameObject);
 }
Example #34
0
 public CPlayer(CGame game)
 {
     this.game = game;
 }
Example #35
0
 // Use this for initialization
 void Start()
 {
     m_fAngleY = 0.0f;
     m_fAngleWake = 0.0f;
     m_Fer = gameObject.transform.FindChild("Head").FindChild("Fer").GetComponent<CFerASouder>();
     m_Hand = gameObject.transform.FindChild("Head").FindChild("Hand").GetComponent<CHand>();
     m_fTimerJump = 0.0f;
     m_fTimerWakeUp = 0.0f;
     m_fTimerDie = 0.0f;
     m_eState = Estate.e_Start;
     m_bLaunchMenu = false;
     m_Game = GameObject.Find("_Game").GetComponent<CGame>();
     gameObject.transform.FindChild("Texture").GetComponent<CSpriteSheet>().SetAnim(false);
 }
Example #36
0
 void Start()
 {
     m_Game = GameObject.Find("_Game").GetComponent <CGame>();
 }
Example #37
0
 // Use this for initialization
 void Start()
 {
     m_bLaunchEnd = false;
     m_CGame = GameObject.Find("_Game").GetComponent<CGame>();
     m_fLife = m_CGame.m_fTimerExplosion;
 }
Example #38
0
    public void DestroyGame()
    {
        Debug.Log("--- CGame.DestroyGame() ---");

        _GameIsRunning = false;						// Stop running update loop as we're destroying a lot of stuff

        //=== Destory all the static colliders ===
        //####REVA if (s_aColliders_Scene != null)
        //####REVA     foreach (CCollider oColStatic in s_aColliders_Scene)
        //####REVA         DestroyImmediate(oColStatic.gameObject);		//####CHECK

        //=== Destory the PhysX scenes ===
        //ErosEngine.PhysX3_Destroy();
        //ErosEngine.PhysX2_Destroy();

        //=== Destroy Blender ===
        if (_oProcessBlender != null) {
            try {
                _oProcessBlender.Kill();				//###HACK!!
            } catch (Exception e) {
                Debug.LogException(e);
            }
            _oProcessBlender = null;		//###IMPROVE: Save Blender file before exit!  Tell blender to close itself intead of killing it!!!  Wait for its termination??
        }

        INSTANCE = null;
    }