public override void OnStartServer() { base.OnStartServer(); if (!isServer) { return; } tileIDs.Clear(); if (takeFromDebugGrid) { DebugGrid grid = FindObjectOfType <DebugGrid>(); width = grid.xSegments; height = grid.ySegments; spacing.x = grid.width / (float)width; spacing.y = grid.height / (float)height; } for (int i = -5; i < width + 20; i++) { for (int j = -2; j < height + 2; j++) { GameObject go = (GameObject)GameObject.Instantiate(tilePrefab, new Vector2(i * spacing.x + offset * j, j * spacing.y), Quaternion.identity, transform); NetworkServer.Spawn(go); Tile tile = go.GetComponent <Tile>(); if ((height > j && j >= 0) && (width > i && i >= 0)) { tile.posX = i; tile.posY = j; tileIDs.Add(go); } else { Destroy(tile); } if (Random.Range(0, 2) > 0) { GameObject g = GameObject.Instantiate(Resources.Load <GameObject>("NetworkPrefabs/GrassyLand"), go.transform); NetworkServer.Spawn(g); } else { GameObject g = GameObject.Instantiate(Resources.Load <GameObject>("NetworkPrefabs/RockyLand"), go.transform); NetworkServer.Spawn(g); } } } }
private async void LoadItemsClick(object sender, RoutedEventArgs e) { ToggleControls("Load"); items.Clear(); try { // talk to wii u and get mem dump of data var result = await Task.Run(() => LoadItemData()); if (result) { GetNonItemData(); LoadTab(Weapons, 0); LoadTab(Bows, 1); LoadTab(Arrows, 2); LoadTab(Shields, 3); LoadTab(Armor, 4); LoadTab(Materials, 7); LoadTab(Food, 8); LoadTab(KeyItems, 9); Notification.Content = string.Format("Items found: {0}", itemTotal); ToggleControls("DataLoaded"); cbChanged.Clear(); tbChanged.Clear(); ddChanged.Clear(); Save.IsEnabled = HasChanged; DebugGrid.ItemsSource = items; DebugGrid.UpdateLayout(); Debug.UpdateLayout(); } } catch (Exception ex) { LogError(ex, "Load Items"); } }
private async void LoadClick(object sender, RoutedEventArgs e) { this.ToggleControls("Load"); this.items.Clear(); try { // talk to wii u and get mem dump of data var result = await Task.Run(() => this.LoadData()); if (result) { this.GetNonItemData(); this.LoadTab(this.Weapons, 0); this.LoadTab(this.Bows, 1); this.LoadTab(this.Arrows, 2); this.LoadTab(this.Shields, 3); this.LoadTab(this.Armor, 4); this.LoadTab(this.Materials, 7); this.LoadTab(this.Food, 8); this.LoadTab(this.KeyItems, 9); this.Notification.Content = string.Format("Items found: {0}", this.itemsFound); this.ToggleControls("DataLoaded"); this.cbChanged.Clear(); this.tbChanged.Clear(); this.ddChanged.Clear(); this.Save.IsEnabled = this.HasChanged; DebugGrid.ItemsSource = this.items; DebugGrid.UpdateLayout(); Debug.UpdateLayout(); } } catch (Exception ex) { this.LogError(ex, "Load Data"); } }
static void Initialize() { Debug.Log("GilLog - ColorGridWindow::Initialize"); ColorGridWindow window = (ColorGridWindow)CreateInstance <ColorGridWindow>(); IColorGrid colorGridInstance = DebugGrid.AddEditorWindow(window); Debug.Log("GilLog - ColorGridWindow::Initialize - colorGridInstance " + colorGridInstance + " "); if (colorGridInstance == null) { return; } window.title = colorGridInstance.GetWindowTitle(); window.SetupColorGrid(colorGridInstance); window.Show(); }
private void ExportClick(object sender, RoutedEventArgs e) { try { DebugGrid.SelectAllCells(); DebugGrid.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader; ApplicationCommands.Copy.Execute(null, DebugGrid); var result = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue); DebugGrid.UnselectAllCells(); var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var excelFile = new StreamWriter(path + @"\debug.csv"); excelFile.WriteLine(result); excelFile.Close(); MessageBox.Show("File exported to " + path); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Excel Export"); } }
private bool SaveItemData(TabItem tab) { // Clear old errors ErrorLog.Document.Blocks.Clear(); if (!HasChanged) { // Nothing to update return(false); } #region SaveLoad try { // For these we amend the 0x3FCE7FF0 area which requires save/load if (Equals(tab, Weapons) || Equals(tab, Bows) || Equals(tab, Shields) || Equals(tab, Armor)) { var weaponList = items.Where(x => x.Page == 0).ToList(); var bowList = items.Where(x => x.Page == 1).ToList(); var arrowList = items.Where(x => x.Page == 2).ToList(); var shieldList = items.Where(x => x.Page == 3).ToList(); var armorList = items.Where(x => x.Page == 4 || x.Page == 5 || x.Page == 6).ToList(); var y = 0; if (Equals(tab, Weapons)) { foreach (var item in weaponList) { var foundTextBox = (TextBox)FindName("Value_" + item.ValueAddressHex); if (foundTextBox != null) { var offset = (uint)(SaveItemStart + (y * 0x8)); gecko.WriteUInt(offset, Convert.ToUInt32(foundTextBox.Text)); } y++; } } if (Equals(tab, Bows)) { // jump past weapons before we start y += weaponList.Count; foreach (var item in bowList) { var foundTextBox = (TextBox)FindName("Value_" + item.ValueAddressHex); if (foundTextBox != null) { var offset = (uint)(SaveItemStart + (y * 0x8)); gecko.WriteUInt(offset, Convert.ToUInt32(foundTextBox.Text)); } y++; } } if (Equals(tab, Shields)) { // jump past weapons/bows/arrows before we start y += weaponList.Count + bowList.Count + arrowList.Count; foreach (var item in shieldList) { var foundTextBox = (TextBox)FindName("Value_" + item.ValueAddressHex); if (foundTextBox != null) { var offset = (uint)(SaveItemStart + (y * 0x8)); gecko.WriteUInt(offset, Convert.ToUInt32(foundTextBox.Text)); } y++; } } if (Equals(tab, Armor)) { // jump past weapons/bows/arrows/shields before we start y += weaponList.Count + bowList.Count + arrowList.Count + shieldList.Count; foreach (var item in armorList) { var offset = (uint)(SaveItemStart + (y * 0x8)); var foundTextBox = (TextBox)FindName("Value_" + item.ValueAddressHex); if (foundTextBox != null) { gecko.WriteUInt(offset, Convert.ToUInt32(foundTextBox.Text)); } y++; } } } } catch (Exception ex) { LogError(ex, "Attempting to save data in 0x3FCE7FF0 region."); } #endregion #region Modified try { // Only update what has changed to avoid corruption. foreach (var tb in tbChanged) { if (string.IsNullOrEmpty(tb.Text)) { continue; } // These text boxes have been edited var type = tb.Name.Split('_')[0]; var tag = tb.Tag; if (type == "Id") { var newName = Encoding.Default.GetBytes(tb.Text); var address = uint.Parse(tag.ToString(), NumberStyles.HexNumber); var thisItem = items.Single(i => i.NameStart == address); // clear current name var zeros = new byte[36]; for (var i = 0; i < zeros.Length; i++) { zeros[i] = 0x0; } gecko.WriteBytes(address, zeros); uint x = 0x0; foreach (var b in newName) { gecko.WriteBytes(address + x, new[] { b }); x = x + 0x1; } thisItem.Id = tb.Text; // Name var foundTextBox = (TextBox)FindName("JsonName_" + tag); if (foundTextBox != null) { foundTextBox.Text = GetNameFromId(thisItem.Id, thisItem.PageName); } } if (type == "Value") { var address = uint.Parse(tag.ToString(), NumberStyles.HexNumber); int val; bool parsed = int.TryParse(tb.Text, out val); if (parsed) { gecko.WriteUInt(address, Convert.ToUInt32(val)); } } if (type == "Page") { var address = uint.Parse(tag.ToString(), NumberStyles.HexNumber); int val; bool parsed = int.TryParse(tb.Text, out val); if (parsed && val < 10 && val >= 0) { gecko.WriteUInt(address, Convert.ToUInt32(val)); } } if (type == "Mod") { var address = uint.Parse(tag.ToString(), NumberStyles.HexNumber); uint val; bool parsed = uint.TryParse(tb.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out val); if (parsed) { gecko.WriteUInt(address, val); } } } } catch (Exception ex) { LogError(ex, "Attempting to update changed fields"); } #endregion #region Codes try { // For the 'Codes' tab we mimic JGecko and send cheats to codehandler if (Equals(tab, Codes)) { // Disable codehandler before we modify gecko.WriteUInt(CodeHandlerEnabled, 0x00000000); // clear current codes var array = new byte[4864]; Array.Clear(array, 0, array.Length); gecko.WriteBytes(CodeHandlerStart, array); var codelist = codes.CreateCodeList(); // Write our selected codes to mem stream var ms = new MemoryStream(); foreach (var code in codelist) { var b = BitConverter.GetBytes(code); ms.Write(b.Reverse().ToArray(), 0, 4); } var bytes = ms.ToArray(); gecko.WriteBytes(CodeHandlerStart, bytes); // Re-enable codehandler gecko.WriteUInt(CodeHandlerEnabled, 0x00000001); // Save controller choice if (Controller.SelectedValue.ToString() != Settings.Default.Controller) { Settings.Default.Controller = Controller.SelectedValue.ToString(); Settings.Default.Save(); } } DebugGrid.ItemsSource = items; DebugGrid.UpdateLayout(); Debug.UpdateLayout(); // clear changed after save tbChanged.Clear(); cbChanged.Clear(); ddChanged.Clear(); } catch (Exception ex) { LogError(ex); } #endregion return(true); }
public void DisplayGrid() { if (mDebugGridState == DebugGrid.GRID_ENABLED) { mDebugGridState = DebugGrid.GRID_DISABLED; } else if (mDebugGridState == DebugGrid.GRID_DISABLED) { mDebugGridState = DebugGrid.GRID_ENABLED; } }
public void LoadGame() { //Load UserInterface. //Load Debugger. //PopulateLists //gameObject.GetSprite.LoadContent. //gameObject.PostSetSpriteFram(). //Set Starting gamestate // pass gametime. PlayingField = new Rectangle(0, 25, 1380, 775); randomGenerator = new Random(); // EnemyTimeToSpawn = randomGenerator.Next(7000, 15000); mRedTimeElapsed = 0f; mBlueTimeElapsed = 0f; mGreenTimeElapsed = 0f; mYellowTimeElapsed = 0f; mPurpleTimeElapsed = 0f; Graveyard = new JLinkedList(); mInPlayItemDropList = new JLinkedList(); mInPlayObjectList = new JLinkedList(); mInPlayProjectileList = new JLinkedList(); mDebugGridState = DebugGrid.GRID_DISABLED; Debug.EnableGrid = DisplayGrid; Debug.EnableGodModeFunction = EnableGodMode; LoadDebugger(); PopulateLists(); UserInterfaceController.mCastle = mCastle; UserInterfaceController.mHero = mHero; UserInterfaceController.LoadUserInterface(gameTime, content, spriteBatch); InitializeInPlayStructures(ref InPlayStructures); InitializeStructurePool(ref StructurePool); InitializeFriendlyPool(ref FriendlyPool); // Create Castle mCastle.Sprite.LoadContent(); mCastle.PostSetSpriteFrame(); //mCastleHealthBarTexture = content.Load<Texture2D>("Sprites/Castle/HealthBar"); mRedBar = content.Load<Texture2D>("Sprites/PixelTextures/solidred"); source = new Rectangle(1565, 450, 50, 300); mCastleHealthBarRectangle = new Rectangle(1565, 450, 50, 300); // Populate Enemies Menus, and Levels. mHero.Sprite.LoadContent(); // Create HERO mHero.PostSetSpriteFrame(); mHero.PlayingField = PlayingField; // Create Level mDirtLevel = new Level(new Rectangle(0, 0, screenWidth, screenHeight), mLevelTexture, "Audio/Songs/Battle Music", content); WaveController.Castle = mCastle; WaveController.Content = content; WaveController.InitializeWaveController(); PassGameTime(); Notification.LoadNotificationFont(content); Notification.LoadLevelUpRibbon(content); ChangeGameState(GameState.LOAD); }
void Start() { this.grid = new DebugGrid(BoardManager.Instance.levelData.boardSize); }