Example #1
0
        static CreatureTable JsonToZoneTable(string json)
        {
            Console.WriteLine("Deserializing JSON File. Please Wait.");
            CreatureTable tl = JsonConvert.DeserializeObject <CreatureTable>(json);

            Console.WriteLine("Finished deserializing JSON File.");

            return(tl);
        }
Example #2
0
        static string ZoneTableToJson(CreatureTable zt)
        {
            Console.WriteLine("Serializing CreatureTable. Please Wait.");
            string json = JsonConvert.SerializeObject(zt, Formatting.Indented);

            Console.WriteLine("Finished serializing JSON File");

            return(json);
        }
Example #3
0
        // Sort on this column.
        private void CreatureTable_ColumnClick(object sender,
                                               ColumnClickEventArgs e)
        {
            // Get the new sorting column.
            ColumnHeader new_sorting_column = CreatureTable.Columns[e.Column];

            // Figure out the new sorting order.
            System.Windows.Forms.SortOrder sort_order;
            if (SortingColumn == null)
            {
                // New column. Sort ascending.
                sort_order = SortOrder.Ascending;
            }
            else
            {
                // See if this is the same column.
                if (new_sorting_column == SortingColumn)
                {
                    // Same column. Switch the sort order.
                    if (SortingColumn.Text.StartsWith("> "))
                    {
                        sort_order = SortOrder.Descending;
                    }
                    else
                    {
                        sort_order = SortOrder.Ascending;
                    }
                }
                else
                {
                    // New column. Sort ascending.
                    sort_order = SortOrder.Ascending;
                }

                // Remove the old sort indicator.
                SortingColumn.Text = SortingColumn.Text.Substring(2);
            }

            // Display the new sort order.
            SortingColumn = new_sorting_column;
            if (sort_order == SortOrder.Ascending)
            {
                SortingColumn.Text = "> " + SortingColumn.Text;
            }
            else
            {
                SortingColumn.Text = "< " + SortingColumn.Text;
            }

            // Create a comparer.
            CreatureTable.ListViewItemSorter =
                new ListViewComparer(e.Column, sort_order);

            // Sort.
            CreatureTable.Sort();
        }
Example #4
0
        private void PickCreatureFromDb(object sender, EventArgs e)
        {
            var dbId     = uint.Parse(PickCreature_textBox.Text);
            var creature = CreatureTable.GetCreature(dbId);

            if (creature != null)
            {
                ManageCreature_ClassId_TextBox.Text      = creature.ClassId.ToString();
                ManageCreature_Faction_TextBox.Text      = creature.Faction.ToString();
                ManageCreature_Level_TextBox.Text        = creature.Level.ToString();
                ManageCreature_MaxHitPoints_TextBox.Text = creature.Level.ToString();
                ManageCreature_NameId_TextBox.Text       = creature.NameId.ToString();
                ManageCreature_Comment_TextBox.Text      = creature.Comment;
                ManageCreature_ClassName_Label.Text      = Program.LoadedCreatures[creature.ClassId].ClassName;
            }
            else
            {
                MessageBox.Show("There is no creature with that dbId in database!");
            }
        }
Example #5
0
 public void CycleTarget(RagdollHand interactor = null, bool inc = true)
 {
     if (inc)
     {
         currentTarget = (currentTarget >= module.reinforcements.Count - 1) ? 0 : currentTarget + 1;
     }
     else
     {
         currentTarget = (currentTarget <= 0) ? module.reinforcements.Count - 1 : currentTarget - 1;
     }
     reinforcementData = module.reinforcements[currentTarget];
     creatureTable     = Catalog.GetData <CreatureTable>(reinforcementData.creatureTable, true);
     SetGraphic();
     SetColour();
     if (interactor)
     {
         Utils.PlayHaptic(interactor.side == Side.Left, interactor.side == Side.Right, Utils.HapticIntensity.Minor);
     }
     useSound.clip = module.useSoundAsset.PickAudioClip();
     useSound.Play();
 }
Example #6
0
        protected void Awake()
        {
            item   = GetComponent <Item>();
            module = item.data.GetModule <ItemModuleComlink>();

            item.OnHeldActionEvent += OnHeldAction;
            item.OnGrabEvent       += OnGrabEvent;
            item.OnUngrabEvent     += OnUngrabEvent;
            item.OnSnapEvent       += OnSnapEvent;

            idleSound  = item.GetCustomReference("IdleSound").GetComponent <AudioSource>();
            pingSound  = item.GetCustomReference("PingSound").GetComponent <AudioSource>();
            startSound = item.GetCustomReference("StartSound").GetComponent <AudioSource>();
            stopSound  = item.GetCustomReference("StopSound").GetComponent <AudioSource>();
            useSound   = item.GetCustomReference("UseSound").GetComponent <AudioSource>();

            hologram      = item.GetCustomReference("Hologram").gameObject;
            hologramLight = item.GetCustomReference("HologramLight").GetComponent <MeshRenderer>();
            hologramLogo  = item.GetCustomReference("HologramLogo").GetComponent <MeshRenderer>();
            light         = item.GetCustomReference("Light").GetComponent <Light>();
            text          = item.GetCustomReference("Text").GetComponent <Text>();
            materials     = item.GetCustomReference("Materials").GetComponent <MeshRenderer>().materials;

            hologram.SetActive(false);
            spawnLocations = new List <SpawnLocation>(FindObjectsOfType <SpawnLocation>());

            item.TryGetSavedValue("faction", out string tempFaction);
            item.TryGetSavedValue("target", out string tempTarget);
            int.TryParse(tempFaction, out currentFaction);
            int.TryParse(tempTarget, out currentTarget);

            factionData       = module.factions[currentFaction];
            reinforcementData = module.reinforcements[currentTarget];
            creatureTable     = Catalog.GetData <CreatureTable>(reinforcementData.creatureTable, true);
            SetGraphic();
            SetColour();
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.Title = "CreatureTable file Converter v1.0 - OpenDarkEden";

            //args = new string[] { "C:\\OpenDarkEden\\CreatureTable Converter\\bin\\Debug\\creature.inf" };

            Console.WriteLine("----------------------------------------");
            Console.WriteLine("    CreatureTable file Converter v1.0   ");
            Console.WriteLine("              Open DarkEden             ");
            Console.WriteLine("       Author: Matheus M. Cardoso       ");
            Console.WriteLine("----------------------------------------");

            if (args.Length == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("No valid creaturetable or json was passed as an argument to this program.");
                Console.WriteLine("Drag and drop a valid v6 CreatureTable file (.inf) or a valid JSON file (.js)");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }

            if (!File.Exists(args[0]))
            {
                string   msg  = "File \"{0}\" not found.";
                object[] objs = { args[0] };

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(String.Format(msg, objs));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }

            DirectoryInfo dir = new DirectoryInfo(args[0]);

            if (dir.Extension != ".inf" && dir.Extension != ".js")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Not a .inf or .js file.");
                Console.WriteLine("Drag and drop a valid v6 CreatureTable file (.inf) or a valid JSON file (.js)");
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }

            if (dir.Extension == ".inf")
            {
                FileStream    file = File.Open(args[0], FileMode.Open);
                CreatureTable zt   = new CreatureTable(ref file);

                File.WriteAllText(dir.FullName + ".js", ZoneTableToJson(zt));
            }

            if (dir.Extension == ".js")
            {
                try
                {
                    FileStream file = File.Open(Path.ChangeExtension(dir.FullName, null), FileMode.OpenOrCreate);
                    JsonToZoneTable(File.ReadAllText(args[0])).SaveToFile(ref file);
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;

                    if (e as JsonException != null)
                    {
                        Console.WriteLine("Could not deserialize JSON File. Check the syntax:");
                        Console.WriteLine(e.Message);
                    }
                    else
                    {
                        Console.WriteLine("Something bad happened:");
                        Console.WriteLine(e.Message);
                    }

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine("Press any key to exit.");
                    Console.ReadKey();
                }
            }
        }
Example #8
0
        private void UpdateCreature_Button_OnClick(object sender, EventArgs e)
        {
            var creature = new CreaturesEntry
            {
                DbId = uint.Parse(PickCreature_textBox.Text)
            };

            // check classId
            if (uint.TryParse(ManageCreature_ClassId_TextBox.Text, out var classId))
            {
                if (Program.LoadedCreatures.ContainsKey(classId))
                {
                    creature.ClassId = classId;
                }
                else
                {
                    MessageBox.Show("Given classId is not creature");
                    return;
                }
            }
            else
            {
                MessageBox.Show("classId parameter is empty");
                return;
            }

            // check for faction
            if (uint.TryParse(ManageCreature_Faction_TextBox.Text, out var faction))
            {
                creature.Faction = faction;
            }
            else
            {
                MessageBox.Show("faction parameter is empty");
                return;
            }

            // check for level
            if (uint.TryParse(ManageCreature_Level_TextBox.Text, out var level))
            {
                if (level > 50 || level < 1)
                {
                    MessageBox.Show("invalid level parameter");
                    return;
                }

                creature.Level = level;
            }
            else
            {
                MessageBox.Show("level parameter is empty");
                return;
            }

            // check for maxHitPoints
            if (uint.TryParse(ManageCreature_MaxHitPoints_TextBox.Text, out var maxHitPoints))
            {
                if (maxHitPoints < 1)
                {
                    MessageBox.Show("invalid maxHitPoints parameter");
                    return;
                }

                creature.MaxHitPoints = maxHitPoints;
            }
            else
            {
                MessageBox.Show("maxHitPoints parameter is empty");
                return;
            }

            // check for nameId
            if (uint.TryParse(ManageCreature_NameId_TextBox.Text, out var nameId))
            {
                creature.NameId = nameId;
            }
            else
            {
                MessageBox.Show("nameId parameter is empty");
                return;
            }

            // check for comment
            if (ManageCreature_Comment_TextBox.Text == "" || ManageCreature_Comment_TextBox.Text == "0")
            {
                MessageBox.Show("Please enter some comment about creature");
                return;
            }
            else
            {
                creature.Comment = ManageCreature_Comment_TextBox.Text;
            }

            CreatureTable.UpdateCreature(creature);

            MessageBox.Show($"Update creature with: DbId {creature.DbId}");
        }
Example #9
0
        private void CreateCreatureButton_Click(object sender, EventArgs e)
        {
            var creature = new CreaturesEntry();

            // check classId
            if (uint.TryParse(ClassId_textBox.Text, out var classId))
            {
                if (Program.LoadedCreatures.ContainsKey(classId))
                {
                    creature.ClassId = classId;
                }
                else
                {
                    MessageBox.Show("Given classId is not creature");
                    return;
                }
            }
            else
            {
                MessageBox.Show("classId parameter is empty");
                return;
            }

            // check for faction
            if (uint.TryParse(Faction_textBox.Text, out var faction))
            {
                creature.Faction = faction;
            }
            else
            {
                MessageBox.Show("faction parameter is empty");
                return;
            }

            // check for level
            if (uint.TryParse(Level_ComboBox.Text, out var level))
            {
                if (level > 50 || level < 1)
                {
                    MessageBox.Show("invalid level parameter");
                    return;
                }

                creature.Level = level;
            }
            else
            {
                MessageBox.Show("level parameter is empty");
                return;
            }

            // check for maxHitPoints
            if (uint.TryParse(MaxHitPoints_textBox.Text, out var maxHitPoints))
            {
                if (maxHitPoints < 1)
                {
                    MessageBox.Show("invalid maxHitPoints parameter");
                    return;
                }

                creature.MaxHitPoints = maxHitPoints;
            }
            else
            {
                MessageBox.Show("maxHitPoints parameter is empty");
                return;
            }

            // check for nameId
            if (uint.TryParse(NameId_textBox.Text, out var nameId))
            {
                creature.NameId = nameId;
            }
            else
            {
                MessageBox.Show("nameId parameter is empty");
                return;
            }

            // check for comment
            if (Comment_textBox.Text == "" || Comment_textBox.Text == "0")
            {
                MessageBox.Show("Please enter some comment about creature");
                return;
            }
            else
            {
                creature.Comment = Comment_textBox.Text;
            }

            if (!CreatureTable.AddCreature(creature))
            {
                MessageBox.Show("TechnicalDifficulty");
                return;
            }

            if (CC_SetAppearence_CheckButton.Checked == true)
            {
                if (CC_Helmet_ComboBox.SelectedItem is ComboBoxItem helmet)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 1, helmet.Value, new Color(CC_Helmet_Panel.BackColor).Hue);
                }
                if (CC_Shoes_ComboBox.SelectedItem is ComboBoxItem shoes)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 2, shoes.Value, new Color(CC_Shoes_Panel.BackColor).Hue);
                }
                if (CC_Gloves_ComboBox.SelectedItem is ComboBoxItem gloves)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 3, gloves.Value, new Color(CC_Helmet_Panel.BackColor).Hue);
                }
                if (CC_Weapon_ComboBox.SelectedItem is ComboBoxItem weapon)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 13, weapon.Value, 0);   // weapons don't need color
                }
                if (CC_Hair_ComboBox.SelectedItem is ComboBoxItem hair)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 14, hair.Value, new Color(CC_Hair_Panel.BackColor).Hue);
                }
                if (CC_Torso_ComboBox.SelectedItem is ComboBoxItem torso)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 15, torso.Value, new Color(CC_Torso_Panel.BackColor).Hue);
                }
                if (CC_Legs_ComboBox.SelectedItem is ComboBoxItem legs)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 16, legs.Value, new Color(CC_Legs_Panel.BackColor).Hue);
                }
                if (CC_Face_ComboBox.SelectedItem is ComboBoxItem face)
                {
                    CreatureAppearanceTable.SetCreatureAppearance(creature.DbId, 17, face.Value, new Color(CC_Face_Panel.BackColor).Hue);
                }
            }

            MessageBox.Show($"Created Creature {creature.DbId}");
        }