예제 #1
0
 public Background(string file) : base(Kafe.Me)
 {
     Console.WriteLine("Instantiating a Background using definition \"{0}\"...", file);
     json           = Mix.GetJson(file) as JsonObj;
     Sheet          = Mix.GetTexture("locales\\" + json.Path <string>("/base"));
     Layers         = new List <BackgroundLayer>();
     Kafe.Ground    = json.ContainsKey("ground") ? json.Path <int>("/ground") : 240;
     Kafe.LeftStart = Kafe.RightStart = 100;
     if (json.ContainsKey("start"))
     {
         Kafe.LeftStart  = json.Path <int>("/start/0");
         Kafe.RightStart = json.Path <int>("/start/1");
     }
     LeftExtent  = 0;
     RightExtent = 512;
     if (json.ContainsKey("extent"))
     {
         LeftExtent  = json.Path <int>("/extent/0");
         RightExtent = json.Path <int>("/extent/1");
     }
     foreach (var layer in ((List <object>)json["layers"]))
     {
         Layers.Add(new BackgroundLayer((JsonObj)layer, this));
     }
 }
예제 #2
0
 public CharacterSelect(bool versus) : base(Kafe.Me)
 {
     stuff      = Mix.GetTexture("menu.png");
     cursor     = new[] { 1, 0 };
     locked     = new[] { false, false };
     selection  = new[] { Kafe.Characters[1], Kafe.Characters[0] };
     numPlayers = versus ? 2 : 1;
     showTwo    = versus;
 }
예제 #3
0
 protected override void LoadContent()
 {
     batch      = new SpriteBatch(GraphicsDevice);
     background = Mix.GetTexture("menu_back.png");
     //edge = Mix.GetTexture("Console edge");
     width  = GraphicsDevice.PresentationParameters.BackBufferWidth;
     height = GraphicsDevice.PresentationParameters.BackBufferHeight / 2;
     base.LoadContent();
     Console.WriteLine("Console content loaded.");
 }
예제 #4
0
 public TitleScreen(bool skipLogo) : base(Kafe.Me)
 {
     title         = Mix.GetTexture("title_logo.png");
     logo          = Mix.GetTexture("firrhna_logo.png");
     selection     = 0;
     this.skipLogo = skipLogo;
     if (skipLogo)
     {
         anim = 64;
     }
 }
예제 #5
0
        public Character(string jsonFile, int palIndex)
        {
            if (shadow == null)
            {
                shadow = Mix.GetTexture("shadow");
            }
            if (editGreebles == null)
            {
                editGreebles = Mix.GetTexture("editor");
            }
            if (editPixel == null)
            {
                editPixel = new Texture2D(Kafe.GfxDev, 1, 1, false, SurfaceFormat.Color);
                editPixel.SetData(new[] { Color.White });
            }

            boxes    = new List <Rectangle>();
            boxTypes = new List <BoxTypes>();

            Reload(jsonFile, palIndex, false);
            Controls = Input.Controls[0];
        }
예제 #6
0
파일: Text.cs 프로젝트: Kawa-oneechan/Kafe
        private static void LoadFonts()
        {
            var data = Mix.GetJson("fonts") as List <object>;

            fonts = new Font[data.Count];
            var i = 0;

            foreach (var entry in data)
            {
                var font       = (JsonObj)entry;
                var sheet      = Mix.GetTexture(font["sheet"] as string);
                var width      = (int)(double)font["width"];
                var height     = (int)(double)font["height"];
                var lineHeight = (int)(double)font["line"];
                var widths     = (font["widths"] as List <object>);
                var newWidths  = new int[widths.Count];
                for (var j = 0; j < newWidths.Length; j++)
                {
                    newWidths[j] = (int)(double)widths[j];
                }
                fonts[i] = new Font(sheet, width, height, lineHeight, newWidths);
                i++;
            }
        }
예제 #7
0
 public Arena(string file, Character left, Character right) : base(file)
 {
     Console.WriteLine("Instantiating an Arena (regular two-player battle) with {0} against {1}...", left.Name, right.Name);
     bars             = Mix.GetTexture("health_bars");
     left.Position    = new Vector2(Kafe.LeftStart, Kafe.Ground);
     right.Position   = new Vector2(Kafe.ScreenWidth - Kafe.RightStart, Kafe.Ground);
     right.FacingLeft = right.IsRight = true;
     left.Opponent    = right;
     right.Opponent   = left;
     left.Health      = right.Health = 1.0f;
     left.SelectMode  = false;
     right.SelectMode = false;
     left.EditMode    = false;
     right.EditMode   = false;
     left.Controls    = Input.Controls[0];
     right.Controls   = Input.Controls[1];
     left.SwitchTo(StandardAnims.Idle);             //TODO: switch to Intro when both test characters
     right.SwitchTo(StandardAnims.Idle);            //have proper Intro animations.
     left.SetupImage();
     right.SetupImage();
     Characters    = new[] { left, right };
     Kafe.Camera.Y = 0;
     redHealth     = new float[Characters.Length];
 }
예제 #8
0
        public void Reload(string jsonFile, int palIndex, bool refresh)
        {
            Console.WriteLine("Loading Character from \"{0}\"...", jsonFile);
            json = Mix.GetJson("fighters\\" + jsonFile, false) as JsonObj;
            Name = json.Path <string>("/name");
            var baseName = json.Path <string>("/base");

            var keys = new string[json.Keys.Count];

            json.Keys.CopyTo(keys, 0);
            foreach (var key in keys)
            {
                if (json[key] is string && ((string)json[key]).StartsWith("import://"))
                {
                    json[key] = Mix.GetJson("fighters\\" + ((string)json[key]).Substring(9));
                }
            }

            atlas = Atlas.FromJson(json["sprites"]);
            json.Remove("sprites");

            if (sheets.ContainsKey(baseName) && !refresh)
            {
                Console.WriteLine("Reusing spritesheet \"{0}\"...", baseName);
                sheet = sheets[baseName];
                if (palettes.ContainsKey(baseName))
                {
                    palette = palettes[baseName];
                }
                if (icons.ContainsKey(baseName))
                {
                    icon = icons[baseName];
                }
            }
            else
            {
                Console.WriteLine("Loading spritesheet \"{0}\"...", baseName);
                sheet            = Mix.GetTexture("fighters\\" + baseName);
                sheets[baseName] = sheet;

                if (Mix.FileExists("fighters\\" + baseName + "-pal.png"))
                {
                    palette            = Mix.GetTexture("fighters\\" + baseName + "-pal.png");
                    palettes[baseName] = palette;

                    var timer1 = DateTime.Now;
                    Console.WriteLine("Palette start at {0}", timer1.ToLongTimeString());

                    var numPals     = palette.Height;
                    var paletteData = new int[palette.Width * palette.Height];
                    palette.GetData(paletteData);
                    var spriteData = new int[sheet.Width * sheet.Height];
                    sheet.GetData(spriteData);
                    for (var j = 0; j < spriteData.Length; j++)
                    {
                        for (var p = 0; p < palette.Width; p++)
                        {
                            if (spriteData[j] == paletteData[p])
                            {
                                spriteData[j] = 0x10000000 + p;
                            }
                        }
                    }
                    sheet.SetData(spriteData);

                    ColorSwaps = numPals;
                    if (palIndex >= numPals)
                    {
                        palIndex %= numPals;
                    }
                    if (palIndex == 0)
                    {
                        palIndex++;
                    }

                    var timer2 = DateTime.Now;
                    Console.WriteLine("Palette end at {0}", timer2.ToLongTimeString());
                    var timer3 = timer2 - timer1;
                    Console.WriteLine("Palette remapping took {0}", timer3);
                }

                if (Mix.FileExists("fighters\\" + baseName + "-icon.png"))
                {
                    icon            = Mix.GetTexture("fighters\\" + baseName + "-icon.png");
                    icons[baseName] = icon;
                }
            }

            ColorSwap = palIndex;

            animations = json.Path <List <JsonObj> >("/animations");
            if (!refresh)
            {
                animation = animations[0];
            }
            else
            {
                animation = animations[(int)currentAnim];
            }
            Position = new Vector2(160, 160);
            SetupFrames();
            if (!refresh || currentFrame >= totalFrames)
            {
                currentFrame = 0;
            }
            SetupImage();

            MultiplyColor = new Vector4(1);
            AddColor      = new Vector4(0);

            inputSequence = string.Empty;
            Console.WriteLine("Finished loading {0}.", Name);
        }
예제 #9
0
        private Texture2D sheet;         //, backdrop;
        //private int lineAnim, backdropAnim;

        //private static int gridStart = 49;

        public TitleBackground() : base(Kafe.Me)
        {
            sheet = Mix.GetTexture("menu.png");
            //backdrop = Mix.GetTexture("menu_back.png");
            Kafe.RetrowaveEffect.Parameters["iResolution"].SetValue(new Vector2(Kafe.ScreenWidth, Kafe.ScreenHeight));
        }
예제 #10
0
파일: Game.cs 프로젝트: Kawa-oneechan/Kafe
        protected override void LoadContent()
        {
            Console.WriteLine("Loading game content...");
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            rawScreen   = new RenderTarget2D(GraphicsDevice, ScreenWidth, ScreenHeight);

            ClutEffect       = GetEffect("clut");
            TransitionEffect = GetEffect("transition");
            transitionImage  = Mix.GetTexture("transition");
            RetrowaveEffect  = GetEffect("shaderwave");

            Console.WriteLine("Enumerating characters and locations...");
            var fighterFiles = Mix.GetFilesWithPattern("fighters\\*.char.json");
            var fighters     = new List <string>();

            foreach (var f in fighterFiles)
            {
                fighters.Add(f.Substring(f.IndexOf('\\') + 1));
            }
            var arenaFiles = Mix.GetFilesWithPattern("locales\\*.bg.json");
            var arenas     = new List <string>();

            foreach (var a in arenaFiles)
            {
                arenas.Add(a.Substring(a.IndexOf('\\') + 1));
            }

            if (Args.Length >= 3 && Args[0] == "/edit")
            {
                Console.WriteLine("|c3|Edit mode requested.");
                LoadingScreen.Start(() =>
                {
                    Components.Add(new Editor("locales\\" + Args[1] + ".bg.json", Args[2] + ".char.json"));
                });
            }
            else if (Args.Length > 0 && Args[0] == "/quick")
            {
                Console.WriteLine("|c3|Quick battle requested.");
                var names  = new string[2];
                var colors = new int[2];
                var rand   = new Random();
                for (var i = 0; i < 2; i++)
                {
                    names[i] = fighters[rand.Next(fighters.Count)];
                }
                var numNames = (Args.Length > 2) ? 2 : 1;
                for (var i = 0; i < numNames; i++)
                {
                    names[i]  = Args[i + 1].ToLowerInvariant();
                    colors[i] = 1;
                    if (names[i].Contains(","))
                    {
                        colors[i] = int.Parse(names[i].Substring(names[i].IndexOf(',') + 1));
                        names[i]  = names[i].Remove(names[i].IndexOf(','));
                    }
                    if (!names[i].EndsWith(".char.json"))
                    {
                        names[i] += ".char.json";
                    }
                }
                //Ensure mirror matches have distinct colors
                if (names[0] == names[1] && colors[0] == colors[1])
                {
                    colors[1]++;
                }
                var arena = "locales\\" + ((Args.Length > 3) ? Args[3] + ".bg.json" : arenas[rand.Next(arenas.Count)]);
                LoadingScreen.Start(() =>
                {
                    var left  = new Character(names[0], colors[0]);
                    var right = new Character(names[1], colors[1]);
                    Components.Add(new Arena(arena, left, right));
                });
            }
            else
            {
                Console.WriteLine("|c3|Regular gameplay requested.");
                LoadingScreen.Start(() =>
                {
                    var fighterList = new List <Character>();
                    foreach (var f in fighters)
                    {
                        fighterList.Add(new Character(f, 0));
                    }
                    Kafe.Characters = fighterList.ToArray();
                    Components.Add(new TitleBackground());
                    Components.Add(new TitleScreen(false));
                });
            }
        }
예제 #11
0
파일: Game.cs 프로젝트: Kawa-oneechan/Kafe
 protected override void LoadContent()
 {
     bits = Mix.GetTexture("confirm.png");
     base.LoadContent();
 }