Пример #1
0
        public ComboCounter(Team team)
        {
            if (team == null)
            {
                throw new ArgumentNullException("team");
            }

            m_team = team;

            String prefix = Misc.GetPrefix(m_team.Side);

            IO.TextFile    textfile     = m_team.Engine.GetSubSystem <IO.FileSystem>().OpenTextFile(@"data/fight.def");
            IO.TextSection combosection = textfile.GetSection("Combo");

            m_displaylocation = (Vector2)combosection.GetAttribute <Point>("pos", new Point(0, 0));

            Single startx = (Single)combosection.GetAttribute <Int32>("start.x", (Int32)m_displaylocation.X);
            Single starty = (Single)combosection.GetAttribute <Int32>("start.y", (Int32)m_displaylocation.Y);

            m_startlocation = new Vector2(startx, starty);

            m_counterelement = m_team.Engine.Elements.Build(prefix + ".combo counter", combosection, "counter");
            m_displayelement = m_team.Engine.Elements.Build(prefix + ".combo text", combosection, "text");

            m_displaytime = combosection.GetAttribute <Int32>("displaytime", 90);

            m_velocity         = new Vector2(5, 5);
            m_state            = State.NotShown;
            m_currentlocation  = m_startlocation;
            m_hitcount         = 0;
            m_displaytimecount = 0;
            m_countertext      = String.Empty;
            m_displaytext      = String.Empty;
            m_hitbonus         = 0;
        }
Пример #2
0
        public RoundInformation(FightEngine engine, IO.TextFile file)
            : base(engine)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            IO.TextSection roundsection    = file.GetSection("Round");
            IO.TextSection powerbarsection = file.GetSection("Powerbar");

            var elements = Engine.Elements;

            elements.Build(roundsection, "round.default");
            elements.Build(roundsection, "round");
            elements.Build(roundsection, "round1");
            elements.Build(roundsection, "round2");
            elements.Build(roundsection, "round3");
            elements.Build(roundsection, "round4");
            elements.Build(roundsection, "round5");
            elements.Build(roundsection, "round6");
            elements.Build(roundsection, "round7");
            elements.Build(roundsection, "round8");
            elements.Build(roundsection, "round9");
            elements.Build(roundsection, "fight");
            elements.Build(roundsection, "KO");
            elements.Build(roundsection, "DKO");
            elements.Build(roundsection, "TO");
            elements.Build(roundsection, "win");
            elements.Build(roundsection, "win2");
            elements.Build(roundsection, "draw");

            elements.Build(powerbarsection, "level1");
            elements.Build(powerbarsection, "level2");
            elements.Build(powerbarsection, "level3");
            elements.Build(powerbarsection, "level4");
            elements.Build(powerbarsection, "level5");
            elements.Build(powerbarsection, "level6");
            elements.Build(powerbarsection, "level7");
            elements.Build(powerbarsection, "level8");
            elements.Build(powerbarsection, "level9");

            m_roundsforwin     = roundsection.GetAttribute <Int32>("match.wins");
            m_maxdrawgames     = roundsection.GetAttribute <Int32>("match.maxdrawgames");
            m_introdelay       = roundsection.GetAttribute <Int32>("start.waittime");
            m_defaultlocation  = (Vector2)roundsection.GetAttribute <Point>("pos");
            m_rounddisplaytime = roundsection.GetAttribute <Int32>("round.time");
            m_controltime      = roundsection.GetAttribute <Int32>("ctrl.time");
            m_koslowtime       = roundsection.GetAttribute <Int32>("slow.time");
            m_overwaittime     = roundsection.GetAttribute <Int32>("over.waittime");
            m_overhittime      = roundsection.GetAttribute <Int32>("over.hittime");
            m_overwintime      = roundsection.GetAttribute <Int32>("over.wintime");
            m_overtime         = roundsection.GetAttribute <Int32>("over.time");
            m_wintime          = roundsection.GetAttribute <Int32>("win.time");

            m_roundnumbers = BuildRoundNumbersSoundMap();
        }
Пример #3
0
        public Clock(FightEngine engine)
            : base(engine)
        {
            IO.TextFile    textfile    = Engine.GetSubSystem <IO.FileSystem>().OpenTextFile(@"data/fight.def");
            IO.TextSection timesection = textfile.GetSection("Time");

            m_position       = (Vector2)timesection.GetAttribute <Point>("pos", new Point(0, 0));
            m_bgelement      = Engine.Elements.Build("time bg", timesection, "bg");
            m_counterelement = Engine.Elements.Build("time counter", timesection, "counter");

            m_time = -1;
        }
Пример #4
0
        public FightEngine(SubSystems subsystems)
            : base(subsystems)
        {
            IO.TextFile    textfile    = GetSubSystem <IO.FileSystem>().OpenTextFile(@"data/fight.def");
            IO.TextSection filesection = textfile.GetSection("Files");
            String         basepath    = GetSubSystem <IO.FileSystem>().GetDirectory(textfile.Filepath);

            m_init            = null;
            m_entities        = new EntityCollection(this);
            m_roundnumber     = 0;
            m_stage           = null;
            m_idcounter       = 0;
            m_tickcount       = 0;
            m_pause           = new Pause(this, false);
            m_superpause      = new Pause(this, true);
            m_asserts         = new EngineAssertions();
            m_camera          = new Camera(this);
            m_envcolor        = new EnvironmentColor(this);
            m_envshake        = new EnvironmentShake(this);
            m_speed           = GameSpeed.Normal;
            m_slowspeedbuffer = 0;
            m_fontmap         = BuildFontMap(filesection);
            m_fightsounds     = GetSubSystem <Audio.SoundSystem>().CreateManager(BuildPath(basepath, filesection.GetAttribute <String>("snd")));
            m_commonsounds    = GetSubSystem <Audio.SoundSystem>().CreateManager(BuildPath(basepath, filesection.GetAttribute <String>("common.snd")));
            m_fightsprites    = GetSubSystem <Drawing.SpriteSystem>().CreateManager(BuildPath(basepath, filesection.GetAttribute <String>("sff")));
            m_fxsprites       = GetSubSystem <Drawing.SpriteSystem>().CreateManager(BuildPath(basepath, filesection.GetAttribute <String>("fightfx.sff")));
            m_fightanimations = GetSubSystem <Animations.AnimationSystem>().CreateManager(textfile.Filepath);
            m_fxanimations    = GetSubSystem <Animations.AnimationSystem>().CreateManager(BuildPath(basepath, filesection.GetAttribute <String>("fightfx.air")));
            m_elements        = new Elements.Collection(FightSprites, FightAnimations, FightSounds, Fonts);
            m_roundinfo       = new RoundInformation(this, textfile);
            m_team1           = new Team(this, TeamSide.Left);
            m_team2           = new Team(this, TeamSide.Right);
            m_combatcheck     = new CombatChecker(this);
            m_logic           = new Logic.PreIntro(this);
            m_clock           = new Clock(this);
        }
Пример #5
0
 public POFile(IO.TextFile textFile, LanguageGetter languageGetter)
 {
     this._dirty = false;
     this._textFile = textFile;
     this._textFile.Saved += this.TextFile_Saved;
     List<IO.TextLine> group = null;
     List<Entry> entries = new List<Entry>();
     Regex rxNoSpaces = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline);
     bool firstGroup = true;
     this._header = null;
     foreach (IO.TextLine line in textFile.Lines)
     {
         if (rxNoSpaces.Replace(line.Value, "").Length > 0)
         {
             if (group == null)
                 group = new List<IO.TextLine>();
             group.Add(line);
         }
         else
         {
             if (group != null)
             {
                 Entry entry = Entry.Parse(firstGroup, this, group);
                 entries.Add(entry);
                 if (entry is HeaderEntry)
                     this._header = (HeaderEntry)entry;
                 firstGroup = false;
                 group = null;
             }
         }
     }
     if (group != null)
     {
         Entry entry = Entry.Parse(firstGroup, this, group);
         entries.Add(entry);
         if (entry is HeaderEntry)
             this._header = (HeaderEntry)entry;
         firstGroup = false;
         group = null;
     }
     this._entries = entries.ToArray();
     this._header = (this._entries.Length > 0) ? (this._entries[0] as HeaderEntry) : null;
     this._language = null;
     if ((this._header != null) && (this.Header.LanguageCode.Length > 0))
     {
         try
         { this._language = new CultureInfo(this.Header.LanguageCode); }
         catch
         { }
     }
     if (this._language == null)
     {
         if (languageGetter != null)
         {
             CultureInfo suggest = null;
             Match match = Regex.Match(Path.GetFileNameWithoutExtension(textFile.FileName), @"(^|\b)(?<code>[a-z]{2})($|[_-](?<code2>[a-z]{2})$)", RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase);
             if (match.Success)
             {
                 if (!string.IsNullOrEmpty(match.Groups["code2"].Value))
                 {
                     try
                     { suggest = new CultureInfo(string.Format("{0}-{1}", match.Groups["code"].Value.ToLowerInvariant(), match.Groups["code2"].Value.ToUpperInvariant())); }
                     catch
                     { }
                     if (suggest == null)
                     {
                         try
                         {
                             suggest = new CultureInfo(match.Groups["code2"].Value.ToLowerInvariant());
                         }
                         catch
                         { }
                     }
                 }
                 if (suggest == null)
                 {
                     try
                     { suggest = new CultureInfo(match.Groups["code"].Value.ToLowerInvariant()); }
                     catch
                     { }
                 }
             }
             this._language = languageGetter(suggest);
             if (this._language == null)
                 throw new OperationCanceledException();
         }
     }
     if (this._language == null)
         throw new Exception("Unable to determine the language.");
     this.TotalDataEntries = 0;
     foreach (Entry entry in this._entries)
         if (entry.Kind == Entry.Kinds.Standard)
             this.TotalDataEntries++;
 }
Пример #6
0
        public POFile(IO.TextFile textFile, LanguageGetter languageGetter)
        {
            this._dirty           = false;
            this._textFile        = textFile;
            this._textFile.Saved += this.TextFile_Saved;
            List <IO.TextLine> group   = null;
            List <Entry>       entries = new List <Entry>();
            Regex rxNoSpaces           = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline);
            bool  firstGroup           = true;

            this._header = null;
            foreach (IO.TextLine line in textFile.Lines)
            {
                if (rxNoSpaces.Replace(line.Value, "").Length > 0)
                {
                    if (group == null)
                    {
                        group = new List <IO.TextLine>();
                    }
                    group.Add(line);
                }
                else
                {
                    if (group != null)
                    {
                        Entry entry = Entry.Parse(firstGroup, this, group);
                        entries.Add(entry);
                        if (entry is HeaderEntry)
                        {
                            this._header = (HeaderEntry)entry;
                        }
                        firstGroup = false;
                        group      = null;
                    }
                }
            }
            if (group != null)
            {
                Entry entry = Entry.Parse(firstGroup, this, group);
                entries.Add(entry);
                if (entry is HeaderEntry)
                {
                    this._header = (HeaderEntry)entry;
                }
                firstGroup = false;
                group      = null;
            }
            this._entries  = entries.ToArray();
            this._header   = (this._entries.Length > 0) ? (this._entries[0] as HeaderEntry) : null;
            this._language = null;
            if ((this._header != null) && (this.Header.LanguageCode.Length > 0))
            {
                try
                { this._language = new CultureInfo(this.Header.LanguageCode); }
                catch
                { }
            }
            if (this._language == null)
            {
                if (languageGetter != null)
                {
                    CultureInfo suggest = null;
                    Match       match   = Regex.Match(Path.GetFileNameWithoutExtension(textFile.FileName), @"(^|\b)(?<code>[a-z]{2})($|[_-](?<code2>[a-z]{2})$)", RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase);
                    if (match.Success)
                    {
                        if (!string.IsNullOrEmpty(match.Groups["code2"].Value))
                        {
                            try
                            { suggest = new CultureInfo(string.Format("{0}-{1}", match.Groups["code"].Value.ToLowerInvariant(), match.Groups["code2"].Value.ToUpperInvariant())); }
                            catch
                            { }
                            if (suggest == null)
                            {
                                try
                                {
                                    suggest = new CultureInfo(match.Groups["code2"].Value.ToLowerInvariant());
                                }
                                catch
                                { }
                            }
                        }
                        if (suggest == null)
                        {
                            try
                            { suggest = new CultureInfo(match.Groups["code"].Value.ToLowerInvariant()); }
                            catch
                            { }
                        }
                    }
                    this._language = languageGetter(suggest);
                    if (this._language == null)
                    {
                        throw new OperationCanceledException();
                    }
                }
            }
            if (this._language == null)
            {
                throw new Exception("Unable to determine the language.");
            }
            this.TotalDataEntries = 0;
            foreach (Entry entry in this._entries)
            {
                if (entry.Kind == Entry.Kinds.Standard)
                {
                    this.TotalDataEntries++;
                }
            }
        }
Пример #7
0
 public POFile(IO.TextFile textFile)
     : this(textFile, null)
 {
 }
Пример #8
0
        public TeamDisplay(Team team)
        {
            if (team == null)
            {
                throw new ArgumentNullException("team");
            }

            m_team         = team;
            m_combocounter = new ComboCounter(team);

            IO.TextFile    textfile = m_team.Engine.GetSubSystem <IO.FileSystem>().OpenTextFile(@"data/fight.def");
            IO.TextSection lifebar  = textfile.GetSection("Lifebar");
            IO.TextSection powerbar = textfile.GetSection("Powerbar");
            IO.TextSection face     = textfile.GetSection("Face");
            IO.TextSection name     = textfile.GetSection("Name");
            IO.TextSection winicon  = textfile.GetSection("WinIcon");

            String prefix   = Misc.GetPrefix(m_team.Side);
            var    elements = m_team.Engine.Elements;

            m_lifebg0   = elements.Build(prefix + "lifebar.bg0", lifebar, prefix + ".bg0");
            m_lifebg1   = elements.Build(prefix + "lifebar.bg1", lifebar, prefix + ".bg1");
            m_lifebg2   = elements.Build(prefix + "lifebar.bg2", lifebar, prefix + ".bg2");
            m_lifemid   = elements.Build(prefix + "lifebar.mid", lifebar, prefix + ".mid");
            m_lifefront = elements.Build(prefix + "lifebar.front", lifebar, prefix + ".front");

            m_powerbg0     = elements.Build(prefix + "powerbar.bg0", powerbar, prefix + ".bg0");
            m_powerbg1     = elements.Build(prefix + "powerbar.bg1", powerbar, prefix + ".bg1");
            m_powerbg2     = elements.Build(prefix + "powerbar.bg2", powerbar, prefix + ".bg2");
            m_powermid     = elements.Build(prefix + "powerbar.mid", powerbar, prefix + ".mid");
            m_powerfront   = elements.Build(prefix + "powerbar.front", powerbar, prefix + ".front");
            m_powercounter = elements.Build(prefix + "powerbar.counter", powerbar, prefix + ".counter");

            m_facebg    = elements.Build(prefix + "face.bg", face, prefix + ".bg");
            m_faceimage = elements.Build(prefix + "face.face", face, prefix + ".face");

            m_namelement = elements.Build(prefix + "name.name", name, prefix + ".name");

            m_winiconnormal   = elements.Build(prefix + "winicon.normal", winicon, prefix + ".n");
            m_winiconspecial  = elements.Build(prefix + "winicon.special", winicon, prefix + ".s");
            m_winiconhyper    = elements.Build(prefix + "winicon.hyper", winicon, prefix + ".h");
            m_winiconthrow    = elements.Build(prefix + "winicon.normalthrow", winicon, prefix + ".throw");
            m_winiconcheese   = elements.Build(prefix + "winicon.cheese", winicon, prefix + ".c");
            m_winicontime     = elements.Build(prefix + "winicon.timeout", winicon, prefix + ".t");
            m_winiconsuicide  = elements.Build(prefix + "winicon.suicide", winicon, prefix + ".suicide");
            m_winiconteammate = elements.Build(prefix + "winicon.teammate", winicon, prefix + ".teammate");
            m_winiconperfect  = elements.Build(prefix + "winicon.perfect", winicon, prefix + ".perfect");

            m_lifebarposition = (Vector2)lifebar.GetAttribute <Point>(prefix + ".pos");
            m_lifebarrange    = lifebar.GetAttribute <Point>(prefix + ".range.x");

            m_powerbarposition = (Vector2)powerbar.GetAttribute <Point>(prefix + ".pos");
            m_powerbarrange    = powerbar.GetAttribute <Point>(prefix + ".range.x");

            m_faceposition = (Vector2)face.GetAttribute <Point>(prefix + ".pos");

            m_nameposition = (Vector2)name.GetAttribute <Point>(prefix + ".pos");

            m_winiconposition = (Vector2)winicon.GetAttribute <Point>(prefix + ".pos");
            m_winiconoffset   = (Vector2)winicon.GetAttribute <Point>(prefix + ".iconoffset");
        }
Пример #9
0
        public Font LoadFont(String filepath)
        {
            if (filepath == null)
            {
                throw new ArgumentNullException("filepath");
            }

            if (m_fontcache.Contains(filepath) == true)
            {
                return(m_fontcache[filepath]);
            }

            Point     size    = new Point(0, 0);
            Texture2D pixels  = null;
            Texture2D palette = null;

            IO.TextFile textfile = null;

            using (IO.File file = GetSubSystem <IO.FileSystem>().OpenFile(filepath))
            {
                IO.FileHeaders.FontFileHeader header = new IO.FileHeaders.FontFileHeader(file);

                file.SeekFromBeginning(header.ImageOffset);
                LoadImage(file, header.ImageSize, out size, out pixels, out palette);

                file.SeekFromBeginning(header.ImageOffset + header.ImageSize);
                textfile = GetSubSystem <IO.FileSystem>().BuildTextFile(file);
            }

            Sprite sprite = new Sprite(size, new Point(0, 0), true, pixels, true, palette, false);

            IO.TextSection data    = textfile.GetSection("Def");
            IO.TextSection textmap = textfile.GetSection("Map");

            Int32 colors          = data.GetAttribute <Int32>("colors");
            Point defaultcharsize = data.GetAttribute <Point>("size");

            Int32 numchars = 0;
            Dictionary <Char, Rectangle> sizemap = new Dictionary <Char, Rectangle>();

            foreach (String line in textmap.Lines)
            {
                Match m = m_fontlinemapregex.Match(line);
                if (m.Success == false)
                {
                    continue;
                }

                Char  c        = GetChar(m.Groups[1].Value);
                Point offset   = (m.Groups[2].Value == "") ? new Point(defaultcharsize.X * numchars, 0) : new Point(Int32.Parse(m.Groups[2].Value), 0);
                Point charsize = (m.Groups[3].Value == "") ? defaultcharsize : new Point(Int32.Parse(m.Groups[3].Value), sprite.Size.Y);

                if (sizemap.ContainsKey(c) == false)
                {
                    Rectangle r = new Rectangle(offset.X, offset.Y, charsize.X, charsize.Y);
                    sizemap.Add(c, r);
                }

                ++numchars;
            }

            Font font = new Font(this, filepath, sprite, new ReadOnlyDictionary <Char, Rectangle>(sizemap), defaultcharsize, colors);

            m_fontcache.Add(font);

            return(font);
        }