예제 #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
        private Drawing.FontMap BuildFontMap(IO.TextSection filesection)
        {
            if (filesection == null)
            {
                throw new ArgumentNullException(nameof(filesection));
            }

            var fonts = new Dictionary <int, Drawing.Font>();

            var fontpath1 = filesection.GetAttribute <string>("font1", null);

            if (fontpath1 != null)
            {
                fonts[1] = GetSubSystem <Drawing.SpriteSystem>().LoadFont(fontpath1);
            }

            var fontpath2 = filesection.GetAttribute <string>("font2", null);

            if (fontpath2 != null)
            {
                fonts[2] = GetSubSystem <Drawing.SpriteSystem>().LoadFont(fontpath2);
            }

            var fontpath3 = filesection.GetAttribute <string>("font3", null);

            if (fontpath3 != null)
            {
                fonts[3] = GetSubSystem <Drawing.SpriteSystem>().LoadFont(fontpath3);
            }

            var fontmap = new Drawing.FontMap(fonts);

            return(fontmap);
        }
예제 #3
0
파일: Clock.cs 프로젝트: xubingyue/xnamugen
        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 DataMap(IO.TextSection section, string prefix)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }
            if (prefix == null)
            {
                throw new ArgumentNullException(nameof(prefix));
            }

            m_prefix = prefix;

            m_animationnumber = section.GetAttribute(prefix + ".anim", -1);
            m_spriteid        = section.GetAttribute(prefix + ".spr", SpriteId.Invalid);
            m_fontdata        = section.GetAttribute(prefix + ".font", new Drawing.PrintData());
            m_text            = section.GetAttribute <string>(prefix + ".text", null);
            m_soundid         = section.GetAttribute(prefix + ".snd", SoundId.Invalid);
            m_soundtime       = section.GetAttribute(prefix + ".sndtime", 0);
            m_offset          = (Vector2)section.GetAttribute(prefix + ".offset", new Point(0, 0));
            m_displaytime     = section.GetAttribute(prefix + ".displaytime", 0);

            var hflip = section.GetAttribute(prefix + ".facing", 0);

            m_flip |= hflip >= 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            var vflip = section.GetAttribute(prefix + ".vfacing", 0);

            m_flip |= vflip >= 0 ? SpriteEffects.None : SpriteEffects.FlipVertically;

            m_layernumber = section.GetAttribute(prefix + ".layerno", 0);
            m_scale       = section.GetAttribute(prefix + ".scale", Vector2.One);

            if (AnimationNumber > -1)
            {
                m_type = ElementType.Animation;
            }
            else if (SpriteId != SpriteId.Invalid)
            {
                m_type = ElementType.Static;
            }
            else if (FontData.IsValid)
            {
                m_type = ElementType.Text;
            }
            else
            {
                m_type = ElementType.None;
            }
        }
예제 #5
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();
        }
예제 #6
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");
        }
예제 #7
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);
        }
예제 #8
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);
        }