private async Task BuildIndexAsync(bool skipItemTypesReload = false) { SetStatusbarText("Loading characters and items..."); IndexSummary result; var newIndex = new Index(); result = await newIndex.BuildAsync(GrimDawnDirectory, GrimDawnSavesDirectory, _loadedSettings.KeepExtractedDBFiles, false, (msg) => SetStatusbarText(msg)).ConfigureAwait(false); _index = newIndex; if (!skipItemTypesReload) { Dispatcher.Invoke((Action)(() => { var itemQualities = new ObservableCollection <MultiselectComboItem>(); itemQualities.AddRange(result.ItemRarities.Select(x => new MultiselectComboItem() { Selected = (x != "Common" && x != "Rare" && x != "Magical"), Value = x, DisplayText = x })); ItemQualities = itemQualities; ItemTypes.Clear(); ItemTypes.AddRange(result.ItemTypes.Select(x => new MultiselectComboItem() { Selected = true, Value = x, DisplayText = ItemHelper.GetItemTypeDisplayName(x) })); AllCharacters.Clear(); AllCharacters.Add("(select character)"); AllCharacters.AddRange(result.Characters); })); } }
private void CreateCharacterJson() { string[] pics = Directory.GetFiles(WorkDirEtcPic); int count = pics.Length; ObservableCollection <Character> c = new ObservableCollection <Character>(); foreach (string pic in pics) { string nameWithScore = Path.GetFileName(pic); nameWithScore = nameWithScore.Replace(".png", ""); Character character = new Character(nameWithScore); try { AllCharacters.Add(character); } catch // catch fires when the program starts { c.Add(character); AllCharacters = c; } count--; } new CharacterJson(WorkDirEtc, AllCharacters); }
void OnDestroy() { if (AllCharacters != null) { AllCharacters.Remove(this); } OnChDestroy(); }
public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content) { if (Interviewees.Count == MaxInterviewees) { GState = LocationState.ConfirmedReturn; } else { GState = LocationState.Normal; } content.Unload(); MainCharacter = mainCharacter; Content = content; IsTransitioning = false; Point WindowSize = Game1.GetWindowSize(); // Load Characters String CharPath = Path.Combine(Content.RootDirectory, "characters.txt"); String CharJSON = File.ReadAllText(CharPath); CharList = JsonSerializer.Deserialize <AllCharacters>(CharJSON); // Load Case Info String CasePath = Path.Combine(Content.RootDirectory, "case" + MainCharacter.CurrentCase + ".txt"); String CaseJSON = File.ReadAllText(CasePath); Case Case = JsonSerializer.Deserialize <Case>(CaseJSON); // Visual Elements Background = new Background(content, BGImagePath); CharPics = new Dictionary <string, ClickableTexture>(); Greetings = new Dictionary <string, string>(); Notebook = Content.Load <Texture2D>("notebook_icon"); NotebookRect = new Rectangle(WindowSize.X - 100, 20, 70, 70); MapIcon = Content.Load <Texture2D>("map-icon"); MapIconRect = new Rectangle(WindowSize.X - 200, 20, 70, 70); Arial = content.Load <SpriteFont>("Fonts/Arial"); SpeechMenu = null; int NumSuspects = Case.Suspects.Count; Vector2 CharPos = new Vector2(WindowSize.X / 6, WindowSize.Y / 3); // may want to customize position at a given location later foreach (string Suspect in Case.Suspects) { Greetings[Suspect] = CharList.AllChars[Suspect].Greetings[0]; Texture2D CharTexture = Content.Load <Texture2D>(CharList.AllChars[Suspect].ImagePath); CharPics[Suspect] = new ClickableTexture(CharTexture, CharPos); CharPos.X += 0.75f * WindowSize.X / NumSuspects; } IntervieweeListRect = new Rectangle(WindowSize.X / 4, 2 * WindowSize.Y / 3, WindowSize.X / 2, WindowSize.Y / 4); TextOffset = new Vector2(0, Arial.MeasureString("A").Y); MouseState = Mouse.GetState(); PrevMouseState = MouseState; }
void GetCharacterInfo() { allCharacters = Resources.Load("CharacterSO/Characters") as AllCharacters; ChosedCharacter = allCharacters.Characters[CharacterID]; characterName = ChosedCharacter.CharacterName; hp = int.Parse(ChosedCharacter.Hp); atkPower = float.Parse(ChosedCharacter.AtkPower); occupation = ChosedCharacter.Occupation; }
/// <summary> /// Sets the singleton for this class. Ensures only one copy of this script is instantiated. /// </summary> private void OnEnable() { if (Singleton != null && this != Singleton) { Destroy(this); } else { Singleton = this; } }
void Awake() { if (AllCharacters == null) { AllCharacters = new List <Character>(); } AllCharacters.Add(this); GetAnimation(); GetMotionMachine(); GetMotionCommander(); GetMotionCrossfader(); OnChAwake(); }
private void LoadCharacters() { foreach (Character c in CharacterJson.GetCharactersFromJson()) { try { AllCharacters.Add(c); } catch // catch fires when the program starts { ObservableCollection <Character> characters = new ObservableCollection <Character>(); characters.Add(c); AllCharacters = characters; } } }
public static void DoCombat(AllCharacters attacker, AllCharacters defender, bool isFleeing = false) { int block = defender.GetBlock(); var attack = attacker.GetHitAndDamage(); if (!isFleeing && block >= attack.Hit) { Console.WriteLine("The attack was blocked!\n"); } else { defender.Character.Life -= attack.Damage; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"{attacker.Character.Name} hits {defender.Character.Name} for {attack.Damage}"); Console.ResetColor(); } }
/// <summary> /// Checks to see if a target position is occupied by a character. May choose whether to include checking /// for dead characters. /// </summary> /// <param name="position">The position to check.</param> /// <param name="includeDeadCharacters">Whether or not to count dead characters as occupying this position.</param> /// <returns>If true, this position is occupied.</returns> public bool IsPositionOccupied(int position, bool includeDeadCharacters = true) { Character target; if (includeDeadCharacters) { target = AllCharacters.FirstOrDefault(character => character.Position == position); } else { target = GetAllLivingCharacters().FirstOrDefault(character => character.Position == position); } if (target == null) { return(false); } else { return(true); } }
public XElement Save() { return(new XElement("characters", AllCharacters.Select(c => c.Save()))); }
private void CreateBoard(int size, string data) { //check to see if the Board list is already created, if it is, we just overwrite its values if (Board == null || Board.Length != size) { Board = new IMapNode[size][]; for (var index = 0; index < Board.Length; index++) { Board[index] = new IMapNode[size]; } } var x = 0; var y = 0; var charData = data.ToCharArray(); for (var i = 0; i < charData.Length; i += 2) { switch (charData[i]) { case '#': Board[x][y] = new MapNode(Tile.IMPASSABLE_WOOD, x, y) { Id = i, Passable = false }; break; case ' ': Board[x][y] = new MapNode(Tile.FREE, x, y) { Id = i, Passable = true, Type = Tile.FREE }; break; case '@': switch (charData[i + 1]) { case '1': Board[x][y] = AllCharacters.First(h => h.Type == Tile.HERO_1); break; case '2': Board[x][y] = AllCharacters.First(h => h.Type == Tile.HERO_2); break; case '3': Board[x][y] = AllCharacters.First(h => h.Type == Tile.HERO_3); break; case '4': Board[x][y] = AllCharacters.First(h => h.Type == Tile.HERO_4); break; } break; case '[': Board[x][y] = new MapNode(Tile.TAVERN, x, y); break; case '$': switch (charData[i + 1]) { case '-': Board[x][y] = new MapNode(Tile.GOLD_MINE_NEUTRAL, x, y); break; case '1': Board[x][y] = new MapNode(Tile.GOLD_MINE_1, x, y); break; case '2': Board[x][y] = new MapNode(Tile.GOLD_MINE_2, x, y); break; case '3': Board[x][y] = new MapNode(Tile.GOLD_MINE_3, x, y); break; case '4': Board[x][y] = new MapNode(Tile.GOLD_MINE_4, x, y); break; } break; } //time to increment X and Y x++; if (x == size) { x = 0; y++; } } }
public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content) { // Commmon to all Modes MainCharacter = mainCharacter; Content = content; Background = new Background(content, NotebookPath); MouseState = Mouse.GetState(); PrevMouseState = MouseState; GState = NotebookState.Stats; Arial = content.Load <SpriteFont>("Fonts/Arial"); JustBreathe = content.Load <SpriteFont>("Fonts/JustBreathe20"); JustBreathe25 = content.Load <SpriteFont>("Fonts/JustBreathe25"); // Load Characters (convert to method) String path = Path.Combine(Content.RootDirectory, "characters.txt"); String CharJSON = File.ReadAllText(path); AllChars = JsonSerializer.Deserialize <AllCharacters>(CharJSON); // Load Case (convert to method) String CasePath = Path.Combine(Content.RootDirectory, "case" + MainCharacter.CurrentCase + ".txt"); String CaseJSON = File.ReadAllText(CasePath); Case = JsonSerializer.Deserialize <Case>(CaseJSON); // Load Testimonies (convert to method) path = Path.Combine(Content.RootDirectory, "testimonies.txt"); String TestimonyJSON = File.ReadAllText(path); TestimonyList = JsonSerializer.Deserialize <TestimonyList>(TestimonyJSON); // Always start by viewing stats. Point WindowSize = Game1.GetWindowSize(); // Fixed Visual Elements ReturnIcon = Content.Load <Texture2D>("return-icon"); ReturnIconRect = new Rectangle(WindowSize.X - 100, 20, 70, 70); int TabOffset = WindowSize.X / 10 - 8; PeopleTab = new ClickableTexture(Content.Load <Texture2D>("tab_people"), new Vector2(TabOffset, TabOffset)); StatsTab = new ClickableTexture(Content.Load <Texture2D>("tab_stats"), new Vector2(TabOffset, PeopleTab.Rect.Y + PeopleTab.Rect.Height)); TestimonyTab = new ClickableTexture(Content.Load <Texture2D>("tab_testimony"), new Vector2(TabOffset, StatsTab.Rect.Y + StatsTab.Rect.Height)); OptionsTab = new ClickableTexture(Content.Load <Texture2D>("tab_options"), new Vector2(TabOffset, TestimonyTab.Rect.Y + TestimonyTab.Rect.Height)); // Variable Visual Elements MainOptionsList = null; TopicOptionsList = null; QuitButton = null; SaveButton = null; // Text Spacing TextOffset = new Vector2(0.0f, JustBreathe.MeasureString("A").Y + 0.5f); Indent = new Vector2(Arial.MeasureString("A").X, 0.0f); // Represents bounds of open notebook OpenNotebookRect = new Rectangle((int)(0.12f * WindowSize.X), (int)(0.15f * WindowSize.Y + TextOffset.Y), (int)(0.75f * WindowSize.X), (int)(0.71f * WindowSize.Y)); }
public CharacterAdventurePhysicsPair(AllCharacters character, AdventurePhysics physics) { Character = character; Physics = physics; }