Ejemplo n.º 1
0
        protected StateController(StateSystem statesystem, String label, TextSection textsection)
        {
            if (statesystem == null) throw new ArgumentNullException("statesystem");
            if (label == null) throw new ArgumentNullException("label");
            if (textsection == null) throw new ArgumentNullException("textsection");

            m_statesystem = statesystem;
            m_textsection = textsection;
            m_persistence = textsection.GetAttribute<Int32>("persistent", 1);
            m_ignorehitpause = textsection.GetAttribute<Boolean>("ignorehitpause", false);
            m_triggers = BuildTriggers(textsection);
            m_label = label;
        }
Ejemplo n.º 2
0
        public DataMap(IO.TextSection section, String prefix)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }

            m_prefix = prefix;

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

            Int32 hflip = section.GetAttribute <Int32>(prefix + ".facing", 0);

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

            Int32 vflip = section.GetAttribute <Int32>(prefix + ".vfacing", 0);

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

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

            if (AnimationNumber > -1)
            {
                m_type = ElementType.Animation;
            }
            else if (SpriteId != SpriteId.Invalid)
            {
                m_type = ElementType.Static;
            }
            else if (FontData.IsValid == true)
            {
                m_type = ElementType.Text;
            }
            else
            {
                m_type = ElementType.None;
            }
        }
Ejemplo n.º 3
0
        public Base Build(String name, IO.TextSection section, String prefix)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }

            DataMap datamap = new DataMap(section, prefix);

            Base element = null;

            switch (datamap.Type)
            {
            case ElementType.Animation:
                element = new AnimatedImage(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            case ElementType.Static:
                element = new StaticImage(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            case ElementType.Text:
                element = new Text(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            case ElementType.None:
            default:
                element = new Base(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;
            }

            m_elements.Add(element);
            return(element);
        }
Ejemplo n.º 4
0
        public Base Build(string name, IO.TextSection section, string prefix)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }
            if (prefix == null)
            {
                throw new ArgumentNullException(nameof(prefix));
            }

            var datamap = new DataMap(section, prefix);

            Base element;

            switch (datamap.Type)
            {
            case ElementType.Animation:
                element = new AnimatedImage(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            case ElementType.Static:
                element = new StaticImage(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            case ElementType.Text:
                element = new Text(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;

            default:
                element = new Base(this, name, datamap, SpriteManager, AnimationManager, SoundManager);
                break;
            }

            m_elements[element.Name] = element;
            return(element);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 7
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);
        }