예제 #1
0
        /** <summary>
         *      Tasks to be ran when a new item is obtained.
         *  </summary>
         *  <param name="eItemTypeNew">
         *      The player's new item.
         *  </param>
         *  <param name="byPlayerSlot">
         *      The player's slot.
         *  </param>
         *  <param name="byPlayerPosition">
         *      The player's position in the race.
         *  </param>
         */
        private void DoNewItemTasks(MarioKartWii.EItemType eItemTypeNew,byte byPlayerSlot,byte byPlayerPosition)
        {
            WavSoundPlayer wavSoundPlayer = new WavSoundPlayer();

            wavSoundPlayer.PlayItemWarningSound(eItemTypeNew);

            string strItemLog = MarioKartWii.MakeItemLogString(g_raceHeader1Record.timer,
                                                               byPlayerSlot,
                                                               eItemTypeNew,
                                                               byPlayerPosition);

            ConsoleIO.WriteLineColoured(strItemLog,ConsoleColor.Blue);
            FileIO.SaveItemLogToFile(gs_dateTimeLastRaceStart,gs_bySelectedTrackID,strItemLog);
        }
예제 #2
0
        /** <summary>
         *      Saves an item log to a file.
         *  </summary>
         *  <param name="dateTimeLastRaceStart">
         *      The time that the last race started at.
         *  </param>
         *  <param name="bySelectedTrackID">
         *      The id of the selected track.
         *  </param>
         *  <param name="strItemLog">
         *      The item log to save to a file.
         *  </param>
         */
        public static void SaveItemLogToFile(DateTime dateTimeLastRaceStart, byte bySelectedTrackID, string strItemLog)
        {
            const string kLogFolderName = "The Third Eye Item Logs";

            string strExecutingAssemblyDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string strSaveFileName = string.Format("{0:yyyyMMdd-HHmmss}-{1}.log", dateTimeLastRaceStart, MarioKartWii.GetTrackNameByID(bySelectedTrackID));

            // Clean up the file name
            strSaveFileName = Regex.Replace(Path.GetFileName(strSaveFileName), @"[^a-zA-Z0-9\-_.$]", "_");

            string strSaveFilePath = Path.Combine(new string[]
            {
                strExecutingAssemblyDirectory,
                kLogFolderName,
                string.Format("{0:yyyy}", dateTimeLastRaceStart),
                string.Format("{0:MM}", dateTimeLastRaceStart),
                string.Format("{0:dd}", dateTimeLastRaceStart),
                strSaveFileName
            });

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(strSaveFilePath));
                File.AppendAllText(strSaveFilePath, strItemLog + Environment.NewLine);
            }
            catch
            {
                /*
                 * Logging new items to a file is not vital to the execution of the program,
                 * thus, we silently swallow the exception if we fail to do so.
                 */
            }
        }
예제 #3
0
        /** <summary>
         *      Updates the selected track id.
         *  </summary>
         */
        private void UpdateSelectedTrackID()
        {
            byte byPrevSelectedTrackID = gs_bySelectedTrackID;

            if (IsRecordAvailable(RACEPacket.ERecordType.RACEDATA) && g_raceDataRecord.rank != 0) // Wait until the race has started to update the selected track id
            {
                gs_bySelectedTrackID = g_raceHeader1Record.track;
            }

            if (IsRecordAvailable(RACEPacket.ERecordType.SELECT) && g_selectRecord.sel_phase == MarioKartWii.ESelectPhase.WAIT) // Wait until everyone has reached the voting phase to reset the selected track id
            {
                gs_bySelectedTrackID = MarioKartWii.g_kNoTrackSelected;
            }

            if (byPrevSelectedTrackID == MarioKartWii.g_kNoTrackSelected && gs_bySelectedTrackID != MarioKartWii.g_kNoTrackSelected)
            {
                ConsoleIO.WriteLineColoured(string.Format(Environment.NewLine + "----------------------------------------------------------------------------- {0}" + Environment.NewLine,MarioKartWii.GetTrackNameByID(gs_bySelectedTrackID)),ConsoleColor.Cyan);
            }
        }