void Core_LoadScreen() { try { byte[] tileset = Core.ReadData(Core.GetPointer("Battle Screen Tileset"), 0); byte[] palettes = Core.ReadData(Core.GetPointer("Battle Screen Palettes"), 4 * Palette.LENGTH); TSA_Array tsa = Core.ReadTSA(Core.GetPointer("Battle Screen TSA"), 16, 32, false, false); CurrentScreen = new BattleScreen( palettes, tileset, BattleScreen.GetReadibleTSA(tsa), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen L Name"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen L Weapon"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen R Name"), 0)), new Tileset(Core.ReadData(Core.GetPointer("Battle Screen R Weapon"), 0))); Screen_GridBox.Load(CurrentScreen); Screen_PaletteBox.Load(new Palette(palettes, 4 * Palette.MAX)); } catch (Exception ex) { Program.ShowError("Could not load the battle platform image.", ex); Screen_GridBox.Reset(); Screen_PaletteBox.Reset(); } }
private void Start() { fighter1 = GameObject.Find("Fighter1").transform; fighter2 = GameObject.Find("Fighter2").transform; fighter1Properties = fighter1.GetComponent <Properties>(); fighter2Properties = fighter2.GetComponent <Properties>(); _cardDatabase = GameObject.Find("CardDatabase").GetComponent <CardDatabase>(); _cardEffects = GameObject.Find("CardDatabase").GetComponent <CardEffects>(); _battleScreen = GetComponent <BattleScreen>(); _cardDatabase.LoadCardDatabase(); fighter1Properties.fighterName = GameObject.Find("Client").GetComponent <Client>().clientName; fighter1.Find("FighterName").GetComponent <Text>().text = fighter1Properties.fighterName; fighter2Properties.fighterName = GameObject.Find("Client").GetComponent <Client>().opponentName; fighter2.Find("FighterName").GetComponent <Text>().text = fighter2Properties.fighterName; fighter1Properties.oldHP = fighter1Properties.maxHP; fighter2Properties.oldHP = fighter2Properties.maxHP; fighter1Properties.currentHP = fighter1Properties.maxHP; fighter2Properties.currentHP = fighter2Properties.maxHP; fighter1.Find("HPBar").transform.Find("Text").GetComponent <Text>().text = fighter1Properties.maxHP.ToString(); fighter2.Find("HPBar").transform.Find("Text").GetComponent <Text>().text = fighter2Properties.maxHP.ToString(); Init(); }
public override void Effect(ref Mokepon caster, ref Mokepon target, BattleScreen screen) { Damage damage = GameManager.Instance.CalculateDamage(caster, target, this); screen.Dialogues.AddText(caster.Name + " absorbed " + target.Name + "'s health points"); caster.Heal((int)Math.Ceiling(damage.DamageValue / 2.0)); }
public void OnPass(NetworkMessage msg) { BattleScreen screen = (game.GetOpenScreen() as BattleScreen); Battle b = screen.battle; b.log.Add(b.GetCurrentPawn().GetName() + " passes..."); }
public override void Effect(ref Mokepon caster, ref Mokepon target, BattleScreen screen) { int prevHP = caster.HP; caster.Heal(25); screen.Dialogues.AddText(caster.Name + " restored " + (caster.HP - prevHP).ToString() + " health points!"); }
void ActOnClick() { // activate map view Debug.Log("Exit"); BattleScreen battleScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <BattleScreen>(); switch (exitOption) { case ExitOption.DestroyPlayer: battleScreen.DestroyPlayer(); break; case ExitOption.DestroyEnemy: battleScreen.DestroyEnemy(); break; case ExitOption.FleePlayer: battleScreen.FleePlayer(); break; case ExitOption.FleeEnemy: battleScreen.FleeEnemy(); break; case ExitOption.EnterCity: battleScreen.CaptureAndEnterCity(); break; default: Debug.LogError("Unknown exit option."); break; } }
public void Select() { BattleScreen btlscr = (BattleScreen)StateManager.GetState(StateID.BattleScreen); if (btlscr != null) { btlscr.LowerHUD.AddBreadcrumb(new UI_BattleBreadcrumbIconPanel(this)); } }
public SpellButton(BattleScreen screen, Battle battle, Spell spell, Vector2i pos, bool blocked) { SetSpell(spell); this.screen = screen; this.battle = battle; size = new Vector2i(92, 28); SetPosition(pos); this.blocked = blocked; }
void Proceed() { // get battle screen, structure: BattleScreen-CtrlPnlFight-This BattleScreen battleScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <BattleScreen>(); // set unit has moved flag battleScreen.ActiveUnitUI.LPartyUnit.HasMoved = true; // activate next unit battleScreen.ActivateNextUnit(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { world = new World(); battleScreen = new BattleScreen(); battleScreen.Initialize(); world.Initialize(); screen = battleScreen; base.Initialize(); }
void Core_WriteBattleScreenTSA(TSA_Array tsa) { bool[,] selection = Screen_GridBox.Selection; Core.WriteData(this, Core.GetPointer("Battle Screen TSA"), BattleScreen.GetInsertableTSA(CurrentScreen.Tiling).ToBytes(false, false), BattleScreenEntry + "TSA changed"); Screen_GridBox.Selection = selection; }
public void Unselect() { collapsed = false; BattleScreen btlscr = (BattleScreen)StateManager.GetState(StateID.BattleScreen); if (btlscr.LowerHUD.PeekBreadcrumb()._originalPanel == this) { btlscr.LowerHUD.RemoveBreadcrumb(); } }
public void ActOnClick() { Debug.Log("Wait"); // get battle screen, structure: BattleScreen-CtrlPnlFight-This BattleScreen battleScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <BattleScreen>(); // set unit is waiting status battleScreen.ActiveUnitUI.LPartyUnit.UnitStatus = UnitStatus.Waiting; // execute wait animation //battleScreen.Queue.Run(Wait()); CoroutineQueueManager.Run(Wait()); // activate next unit battleScreen.ActivateNextUnit(); }
public void OnCastSpell(NetworkMessage msg) { BattleScreen screen = (game.GetOpenScreen() as BattleScreen); Battle b = screen.battle; Pawn caster = b.GetCurrentPawn(); GameMsg.MsgCastSpell actualMsg = msg.ReadMessage <GameMsg.MsgCastSpell>(); Pawn target = null; if (actualMsg.targetId >= 0) { target = b.GetPawn(actualMsg.targetId); } EventBus.CastSpellPre.Invoke(b, caster, target, actualMsg.spellId); }
public void OnRoll(NetworkMessage msg) { BattleScreen screen = (game.GetOpenScreen() as BattleScreen); Battle b = screen.battle; int[] rollIds = msg.ReadMessage <GameMsg.MsgIntegerArray>().array; Element[] rolls = new Element[rollIds.Length]; for (int i = 0; i < rollIds.Length; i++) { rolls[i] = Element.All[rollIds[i]]; } b.rollsLeft -= 1; b.rolls = rolls; //RB.SoundPlay(Game.AUDIO_ROLL, Game.volume); screen.UpdateContext(); }
public void OnNextTurn(NetworkMessage msg) { int turn = msg.ReadMessage <IntegerMessage>().value; battle.currentTurn = turn; for (int i = 0; i < battle.rolls.Length; i++) { battle.rolls[i] = Element.None; battle.locks[i] = false; } BattleScreen screen = game.GetOpenScreen() as BattleScreen; if (battle.currentTurn < battle.allies.Length) { screen.ViewSpellTab(battle.currentTurn); } screen.UpdateContext(); }
void Core_Screen_InsertData(string filepath) { BattleScreen screen; try { string path = Path.GetDirectoryName(filepath) + '\\'; string file = Path.GetFileNameWithoutExtension(filepath); if (!File.Exists(path + file + ".chr")) { throw new Exception("Could not find Tileset file:\n" + path + file + ".chr"); } if (!File.Exists(path + file + ".pal")) { throw new Exception("Could not find Palette file:\n" + path + file + ".pal"); } if (!File.Exists(path + file + ".tsa")) { throw new Exception("Could not find TSA file:\n" + path + file + ".tsa"); } byte[] tileset = File.ReadAllBytes(path + file + ".chr"); byte[] palette = File.ReadAllBytes(path + file + ".pal"); TSA_Array tsa = new TSA_Array( BattleScreen.WIDTH, BattleScreen.HEIGHT, File.ReadAllBytes(path + file + ".tsa")); screen = new BattleScreen( palette, tileset, tsa, new Tileset(File.ReadAllBytes(path + file + " L name.chr")), new Tileset(File.ReadAllBytes(path + file + " L weapon.chr")), new Tileset(File.ReadAllBytes(path + file + " R name.chr")), new Tileset(File.ReadAllBytes(path + file + " R weapon.chr"))); } catch (Exception ex) { Program.ShowError("Could not load the image data.", ex); return; } Core_Insert(screen); }
void Core_Screen_InsertImage(string filepath) { BattleScreen screen; try { GBA.Bitmap image = new GBA.Bitmap(filepath); GBA.Palette palettes = new Palette( filepath.Substring(0, filepath.Length - 4) + " palette.png", 4 * Palette.MAX); screen = new BattleScreen(image, Palette.Split(palettes, 4)); } catch (Exception ex) { Program.ShowError("Could not load the image.", ex); return; } Core_Insert(screen); }
/* The PokemonEngine() constructor initializes all of the important parts of the engine, including managers and screens. */ public PokemonEngine() { /* The GraphicsDeviceManager is initialized, and the PreferredBackBuffer properties are set to the constants screenWidth and screenHeight. * This means that the engine window will have these dimensions, if possible. * The ScreenRectangle is also initialized with a position of zero and the screen width and height. */ graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; ScreenRectangle = new Rectangle(0, 0, screenWidth, screenHeight); /* The two vital components of the engine, the InputHandler and the GameStateManager, are initialized and added to the engine's master component list. * Whenever base.Update() and base.Draw() are called from this class, everything on the component list is updated and drawn. * Since these classes contain all code for handling input and for drawing the game states, everything will now be updated and drawn properly. */ Components.Add(new InputHandler(this)); stateManager = new GameStateManager(this); Components.Add(stateManager); /* Every screen is initialized. Each has a reference to the engine and the state manager passed in. */ SplashScreen = new SplashScreen(this, stateManager); StartScreen = new StartScreen(this, stateManager); WorldScreen = new WorldScreen(this, stateManager); CharacterSelectScreen = new CharacterSelectScreen(this, stateManager); LoadGameScreen = new LoadGameScreen(this, stateManager); StarterSelectScreen = new StarterSelectScreen(this, stateManager); InventoryScreen = new InventoryScreen(this, stateManager); BattleScreen = new BattleScreen(this, stateManager); SwitchScreen = new SwitchScreen(this, stateManager); /* The state stack is reset and the SplashScreen is pushed on. This means the first thing to appear when the engine is run will be the SplashScreen. */ stateManager.ChangeState(SplashScreen); /* The content root directory is set to the "/Content/" folder, meaning every filename string passed to Content.Load<T>() will start in this folder. */ Content.RootDirectory = "Content"; /* Type matchups are initialized in the PkmnUtils class, which creates the type advantage lookup table. */ PkmnUtils.InitTypeMatchups(); /* These two settings make the game run as many times per second as it can. * They could be changed later depending on how well the engine performs. */ IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false; }
public UI_BattleSelectorPanel(UITheme.UITheme_Structure color, string text = "", Sprite sprite = null) { this.text = text; panelColor = color; panelIcon.SetSprite(sprite); panelIcon.SetParent(this); panelIcon.alignHorizontal = 1.0f; panelIcon.alignVertical = 0.5f; panelIcon.Left = iconLeftPad; panelIcon.Width = panelIcon.Height = 25; SetSprite(panelColor.Panel_Flat); Width = 95; PaddingAll = 6; PaddingRight += 2; OnMouseEnter = () => { hovering = true; Main.instance.Content.Load <SoundEffect>("Audio/rollover2").Play(); return(true); }; OnMouseLeave = () => { hovering = false; return(true); }; OnMouseHover = () => { BattleScreen btlscr = (BattleScreen)StateManager.GetState(StateID.BattleScreen); if (btlscr != null) { btlscr.LowerHUD.LeftPanel.hoveredPanel = this; } return(true); }; OnMouseClick = () => { if (collapsed) { Unselect(); } else { Select(); } Main.instance.Content.Load <SoundEffect>("Audio/click1").Play(); return(true); }; Recalculate(); }
// Load GameScreen witth a Streamreader public static BattleScreen LoadBattleScreen(StreamReader reader) { BattleScreen screen = new BattleScreen(); string line; while ((line = GetLine(reader)) != "---") { switch (line) { case "Player": screen.GameObjects.Add(LoadPlayerBattle(reader, screen)); break; default: LoadScreenInformation(screen, reader, line); break; } } return(screen); }
/// <summary> /// Initlialise the game! /// </summary> public Game1() { Content.RootDirectory = "Content"; IsMouseVisible = true; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = WIDTH; graphics.PreferredBackBufferHeight = HEIGHT; ScreenRectangle = new Rectangle(0, 0, WIDTH, HEIGHT); Components.Add(new Input(this)); stateManager = new GameStateManager(this); Components.Add(stateManager); // default starting screen TitleScreen = new TitleScreen(this, stateManager); BattleScreen = new BattleScreen(this, stateManager); stateManager.ChangeState(TitleScreen); }
public override void Effect(ref Mokepon caster, ref Mokepon target, BattleScreen screen) { if (screen.enemy.Name.Length > 0) { screen.Dialogues.AddText("How dare you try to catch someone's Mokepon?!"); return; } int rand = Managers.GameManager.Instance.random.Next(256); int treshold = (target.HP * 255 * target.LVL) / (target.MaxHP * 4); if (rand < treshold) { screen.Dialogues.AddText(target.Name + " broke free!"); return; } else { screen.EnemyMokeponCaught = true; return; } }
void CheckFights() { if (Steps == 0) { bs = new BattleScreen(); bs.Run(); if (Mcharacter.ActualLife == 0) { if (CanFight) { go = new GameOverScreen(); go.Run(); finished = true; } else { Steps = RandomSteps(); } } Steps = RandomSteps(); } }
public bool ApplySetBattleState(BattleScreen previousState, BattleScreen nextState) { if (this.battleScreenDetails.ContainsKey(previousState)) { this.battleScreenDetails[previousState].PreviousState(); } if (this.battleScreenDetails.ContainsKey(nextState)) { this.battleScreenDetails[nextState].NextState(); } bool flag = this.battleScreenDetails.ContainsKey(nextState) && this.battleScreenDetails[nextState].isAlwaysScreen; if (this.ui.battleAlwaysUi != null && flag != this.ui.battleAlwaysUi.gameObject.activeInHierarchy) { NGUITools.SetActiveSelf(this.ui.battleAlwaysUi.gameObject, flag); } if (this.ui.rootPanel != null) { this.ui.rootPanel.Refresh(); } return(flag); }
private static IEnumerator DoAttacks(Offensive[] offensives) { if (GameSettings.DoBattleAnimation) { yield return(instance.StartCoroutine(BattleScreen.Open(offensives[0].Attacker, offensives[0].Defender))); } foreach (Offensive o in offensives) { if (o != null && o.Attacker != null && o.Defender != null && !o.Attacker.Dead() && !o.Defender.Dead()) { Current = o; yield return(_Attack(o)); } } if (GameSettings.DoBattleAnimation) { yield return(instance.StartCoroutine(BattleScreen.Close())); } IsBattling = false; }
public override void Update(GameTime gameTime) { base.Update(gameTime); BattleScreen screen = ((BattleScreen)StateManager.GetState(StateID.BattleScreen)); if (KeybindHandler.CancelButton.Down) { screen?.LowerHUD.LeftPanel.hoveredPanel?.Select(); } else if (KeybindHandler.ConfirmButton.Down) { screen?.LowerHUD.LeftPanel.hoveredPanel?.Unselect(); } /*if (KeybindHandler.DownButton.Pressed) { Main.playerMapEntity.MoveDown(); } * else if (KeybindHandler.UpButton.Pressed) { Main.playerMapEntity.MoveUp(); } * else if (KeybindHandler.LeftButton.Pressed) { Main.playerMapEntity.MoveLeft(); } * else if (KeybindHandler.RightButton.Pressed) { Main.playerMapEntity.MoveRight(); } */ if (StateManager.currentState is BattleScreen) { } }
static public void Initialize(GraphicsDeviceManager g, ContentManager c, SpriteFont f, PokeBattle inBattle, BattleScreen battleScreen) { graphics = g; content = c; font = f; isVisible = true; optionChoice = 0; battle = inBattle; pokemon = battle.Positions[0].pokemon; player = (Player)battle.Positions[0].trainer; fightChoice = 0; pokeChoice = 0; itemOptions = new int[player.inventory.Count]; itemChoice = 0; Textures.fightMenu = SaveLoad.LoadTexture2D(@"Content\Textures\Battle\fightMenu.png", g.GraphicsDevice); Textures.pokeMenu = SaveLoad.LoadTexture2D(@"Content\Textures\Battle\pokeMenu.png", g.GraphicsDevice); Textures.itemMenu = SaveLoad.LoadTexture2D(@"Content\Textures\Battle\itemMenu.png", g.GraphicsDevice); Textures.runMenu = SaveLoad.LoadTexture2D(@"Content\Textures\Battle\runMenu.png", g.GraphicsDevice); Textures.moveButton = SaveLoad.LoadTexture2D(@"Content\Textures\Battle\moveButton.png", g.GraphicsDevice); Rectangles.menuRect = new Rectangle( graphics.PreferredBackBufferWidth / 2 - Textures.fightMenu.Width / 2, graphics.PreferredBackBufferHeight - Textures.fightMenu.Height, Textures.fightMenu.Width, Textures.fightMenu.Height); Rectangles.moveRect[0] = new Rectangle( Rectangles.menuRect.X + 40, Rectangles.menuRect.Y + 40, Textures.moveButton.Width, Textures.moveButton.Height); Rectangles.moveRect[1] = new Rectangle( Rectangles.moveRect[0].X + Textures.moveButton.Width + 10, Rectangles.moveRect[0].Y, Textures.moveButton.Width, Textures.moveButton.Height); Rectangles.moveRect[2] = new Rectangle( Rectangles.moveRect[0].X, Rectangles.moveRect[0].Y + Textures.moveButton.Height + 10, Textures.moveButton.Width, Textures.moveButton.Height); Rectangles.moveRect[3] = new Rectangle( Rectangles.moveRect[0].X + Textures.moveButton.Width + 10, Rectangles.moveRect[0].Y + Textures.moveButton.Height + 10, Textures.moveButton.Width, Textures.moveButton.Height); }
public static void HandleInput(GamePadState gamePadState, KeyboardState keyState, MouseState mouseState, BattleScreen battleScreen) { if (battleScreen.state == State.Input) { if (!inMenu) //if selecting an option { //go in the menu if (Input.InputHandler.WasKeyPressed(keyState, Keys.Z, 10) || Input.InputHandler.WasKeyPressed(keyState, Keys.Down, 10)) { inMenu = true; } //go right if (Input.InputHandler.WasKeyPressed(keyState, Keys.Right, 10)) { optionChoice = (byte)(optionChoice < (byte)3 ? optionChoice + 1 : 0); } //go left if (Input.InputHandler.WasKeyPressed(keyState, Keys.Left, 10)) { optionChoice = (byte)(optionChoice > (byte)0 ? optionChoice - 1 : 3); } } else //else if currently in an option { //go out of the menu to select an option if (Input.InputHandler.WasKeyPressed(keyState, Keys.X, 10) || Input.InputHandler.WasKeyPressed(keyState, Keys.Up, 10)) { inMenu = false; } lock (battle.lockObject) { switch (optionChoice) { //FIGHT case 0: //use move if (Input.InputHandler.WasKeyPressed(keyState, Keys.Z)) { if (pokemon.pokemon.move[fightChoice] != null) { battle.Positions[battle.waitingIndex].choice = BattleChoice.UseMove(battle.Positions[battle.waitingIndex].pokemon.move[fightChoice], battle.Positions[1]); battle.waitingForPlayerInput = false; Monitor.Pulse(battle.lockObject); } } //go right if (Input.InputHandler.WasKeyPressed(keyState, Keys.Right, 10)) { fightChoice = (byte)(fightChoice < (byte)3 ? fightChoice + 1 : 0); } //go left if (Input.InputHandler.WasKeyPressed(keyState, Keys.Left, 10)) { fightChoice = (byte)(fightChoice > (byte)0 ? fightChoice - 1 : 3); } break; //POKE case 1: //switch pokemon if (Input.InputHandler.WasKeyPressed(keyState, Keys.Z)) { if (player.currentPokemon[pokeChoice] != null) { battle.Positions[0].SwitchPokemon(player.currentPokemon[pokeChoice]); battle.waitingForPlayerInput = false; Monitor.Pulse(battle.lockObject); } } //go right if (Input.InputHandler.WasKeyPressed(keyState, Keys.Right, 10)) { pokeChoice = (byte)(pokeChoice < (byte)5 ? pokeChoice + 1 : 0); } //go left if (Input.InputHandler.WasKeyPressed(keyState, Keys.Left, 10)) { pokeChoice = (byte)(pokeChoice > (byte)0 ? pokeChoice - 1 : 5); } break; //ITEM case 2: //use item if (Input.InputHandler.WasKeyPressed(keyState, Keys.Z)) { if (player.inventory[itemChoice] != null) { battle.Positions[battle.waitingIndex].choice = BattleChoice.UseItem(Item.getItem(battle.Positions[battle.waitingIndex].trainer.inventory[itemChoice].itemID), battle.Positions[1]); battle.waitingForPlayerInput = false; Monitor.Pulse(battle.lockObject); } } //go right if (Input.InputHandler.WasKeyPressed(keyState, Keys.Right, 10)) { itemChoice = (itemChoice < itemOptions.Length - 1 ? itemChoice + 1 : 0); } //go left if (Input.InputHandler.WasKeyPressed(keyState, Keys.Left, 10)) { itemChoice = (itemChoice > 0 ? itemChoice - 1 : itemOptions.Length - 1); } break; //RUN case 3: //get the f**k out of there (or try to atleast) if (Input.InputHandler.WasKeyPressed(keyState, Keys.Z)) { battle.Positions[battle.waitingIndex].choice = BattleChoice.RunFromBattle(); battle.waitingForPlayerInput = false; Monitor.Pulse(battle.lockObject); } break; } } } } }
public override void Effect(ref Mokepon caster, ref Mokepon target, BattleScreen screen) { screen.Dialogues.AddText(target.Name + "\'s attack fell!"); target.AddBuff(-3, 0, 0, 0, 0, 0); }
void Awake() { S = this; }