Пример #1
0
        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));
                });
            }
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (gameTime.TotalGameTime.Seconds > 2 || skipLogo)
            {
                if (anim < 128)
                {
                    anim++;
                }
            }

            if (anim < 64)
            {
                return;
            }

            if (Input.Controls[0].TrgUp)
            {
                if (selection == 0)
                {
                    selection = captions.Length;
                }
                selection--;
            }
            else if (Input.Controls[0].TrgDown)
            {
                selection++;
                if (selection == captions.Length)
                {
                    selection = 0;
                }
            }
            else if (Input.WasJustReleased(Keys.Escape))
            {
                Input.Flush();
                if (selection < 2)
                {
                    selection = 2;
                }
                else
                {
                    Kafe.AskToQuit();
                }
            }
            else if (Input.WasJustReleased(Keys.Enter) || Input.Controls[0].TrgA)
            {
                Input.Flush();
                switch (selection)
                {
                case 0:                         //Story Mode
                    Kafe.DoTransition(false, () =>
                    {
                        Kafe.Me.Components.Remove(this);
                        LoadingScreen.Start(() =>
                        {
                            var charSelect = new CharacterSelect(false)
                            {
                                Enabled = false
                            };
                            Kafe.Me.Components.Add(charSelect);
                            Kafe.DoTransition(true, () => { charSelect.Enabled = true; });
                        });
                    });
                    break;

                case 1:                         //Versus Mode
                    Kafe.DoTransition(false, () =>
                    {
                        Kafe.Me.Components.Remove(this);
                        LoadingScreen.Start(() =>
                        {
                            var charSelect = new CharacterSelect(true)
                            {
                                Enabled = false
                            };
                            Kafe.Me.Components.Add(charSelect);
                            Kafe.DoTransition(true, () => { charSelect.Enabled = true; });
                        });
                    });
                    break;

                case 2:                         //Quit
                    Kafe.AskToQuit();
                    break;
                }
            }
        }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            for (var i = 0; i < numPlayers; i++)
            {
                if (locked[i])
                {
                    continue;
                }
                var control   = Input.Controls[i];
                var oldCursor = cursor[i];
                if (control.TrgLeft)
                {
                    cursor[i]--;
                    if (cursor[i] < 0)
                    {
                        cursor[i] = Kafe.Characters.Length - 1;
                    }
                }
                else if (control.TrgRight)
                {
                    cursor[i]++;
                    if (cursor[i] >= Kafe.Characters.Length)
                    {
                        cursor[i] = 0;
                    }
                }
                else if (control.TrgUp)
                {
                    cursor[i] -= 5;
                    if (cursor[i] < 0)
                    {
                        cursor[i] = Kafe.Characters.Length - 1;
                    }
                }
                else if (control.TrgDown)
                {
                    cursor[i] += 5;
                    if (cursor[i] >= Kafe.Characters.Length)
                    {
                        cursor[i] = 0;
                    }
                }
                else if (control.TrgA || control.TrgB || control.TrgC || control.TrgD || control.TrgE || control.TrgF)
                {
                    locked[i] = true;
                    if (control.TrgA)
                    {
                        selection[i].ColorSwap = 1;
                    }
                    else if (control.TrgB)
                    {
                        selection[i].ColorSwap = 2;
                    }
                    else if (control.TrgC)
                    {
                        selection[i].ColorSwap = 3;
                    }
                    else if (control.TrgD)
                    {
                        selection[i].ColorSwap = 4;
                    }
                    else if (control.TrgE)
                    {
                        selection[i].ColorSwap = 5;
                    }
                    else if (control.TrgF)
                    {
                        selection[i].ColorSwap = 6;
                    }
                    selection[i].SwitchTo(StandardAnims.Select);

                    //For single-player games, select another character at random for now.
                    if (numPlayers == 1)
                    {
                        var j    = i ^ 1;
                        var rand = new Random();
                        while (cursor[j] == cursor[i])
                        {
                            cursor[j] = rand.Next(Kafe.Characters.Length);
                        }
                        selection[j]           = Kafe.Characters[cursor[j]];
                        selection[j].ColorSwap = 0;
                        selection[j].SwitchTo(StandardAnims.Select);
                        //selection[j].Computer = true;
                        locked[j] = true;
                        showTwo   = true;
                    }
                }
                if (numPlayers > 1 && cursor[i] == cursor[i ^ 1])
                {
                    cursor[i] = oldCursor;
                }
                else
                {
                    selection[i] = Kafe.Characters[cursor[i]];
                }
            }
            if (Input.WasJustReleased(Keys.Escape))
            {
                Kafe.DoTransition(false, () =>
                {
                    Kafe.Me.Components.Remove(this);
                    LoadingScreen.Start(() =>
                    {
                        var title = new TitleScreen(true)
                        {
                            Enabled = false
                        };
                        Kafe.Me.Components.Add(title);
                        Kafe.DoTransition(true, () => { title.Enabled = true; });
                    });
                });
            }
            if (lockTimer == -1)
            {
                if (locked[0] && locked[1])
                {
                    lockTimer = 1000;
                }
            }
            else
            {
                lockTimer -= gameTime.ElapsedGameTime.Milliseconds;
                if (lockTimer <= 0)
                {
                    this.Enabled = false;
                    Kafe.DoTransition(false, () =>
                    {
                        Kafe.Me.Components.Remove(this);
                        for (var i = 0; i < Kafe.Me.Components.Count; i++)
                        {
                            if (Kafe.Me.Components[i] is TitleBackground)
                            {
                                Kafe.Me.Components.RemoveAt(i);
                                break;
                            }
                        }
                        LoadingScreen.Start(() =>
                        {
                            //TODO: base this on the other character.
                            var arena = new Arena("locales\\mci_corridor.bg.json", selection[0], selection[1])
                            {
                                Enabled = false
                            };
                            Kafe.Me.Components.Add(arena);
                            Kafe.DoTransition(true, () => { arena.Enabled = true; });
                        });
                    });
                }
            }
        }