Exemplo n.º 1
0
        private void FinalizeWeapon(Loot loot)
        {
            int    weaponTypeRoll = RollDie(8);
            string weaponType     = "simple";

            if (weaponTypeRoll == 8)
            {
                weaponType = "racial";
            }
            else if (weaponTypeRoll == 7)
            {
                weaponType = "exotic";
            }
            else if (weaponTypeRoll > 2)
            {
                weaponType = "martial";
            }

            XmlNodeList candidates = TreasureTable.SelectNodes(string.Format("/treasure/weapons/weapon[@type='{0}']", weaponType));
            XmlNode     weapon     = RollRandomLoot(candidates);

            int enchantLimit = 0, enchantment = 0;

            EnchantmentCalculator(loot.Tier, out enchantLimit, out enchantment);

            string material  = RollMaterial(weapon, loot);
            string enchanted = loot.Enchanted ? "Enchanted " : "";

            loot.FullName = string.Format("+{0} {1}{2}{3}", enchantment, enchanted, material, weapon.InnerText.Trim());
        }
Exemplo n.º 2
0
        private void FinalizeWondrousItem(Loot loot, bool onlySpellcaster)
        {
            string query = string.Format("/treasure/trinkets/trinket[@tier={0}]", loot.Tier > 20 ? 20 : loot.Tier);

            if (onlySpellcaster)
            {
                query = string.Format("/treasure/trinkets/trinket[@tier={0} and @flags='S']", loot.Tier > 20 ? 20 : loot.Tier);
            }

            XmlNodeList candidates   = TreasureTable.SelectNodes(query);
            XmlNode     wondrousItem = RollRandomLoot(candidates);

            if (wondrousItem == null)
            {
                return;
            }

            loot.FullName    = wondrousItem.FirstChild.InnerText.Trim();
            loot.Description = wondrousItem.SelectSingleNode("description").InnerText.Trim();
            loot.Cost        = wondrousItem.Attributes["cost"].Value;
            switch (wondrousItem.Attributes["slot"].Value)
            {
            case "L":
                loot.Slot = "waist";
                break;

            case "B":
                loot.Slot = "feet";
                break;

            case "C":
                loot.Slot = "back";
                break;

            case "A":
                loot.Slot = "torso";
                break;

            case "G":
                loot.Slot = "hands";
                break;

            case "H":
                loot.Slot = "head";
                break;

            case "T":
                loot.Slot = "trinket";
                break;
            }
        }
Exemplo n.º 3
0
        private void FinalizeShield(Loot loot)
        {
            XmlNodeList candidates = TreasureTable.SelectNodes(string.Format("/treasure/shields/shield"));
            XmlNode     shield     = RollRandomLoot(candidates);

            int enchantLimit = 0, enchantment = 0;

            EnchantmentCalculator(loot.Tier, out enchantLimit, out enchantment);

            string material  = RollMaterial(shield, loot);
            string enchanted = loot.Enchanted ? "Enchanted " : "";

            loot.FullName = string.Format("+{0} {1}{2}{3}", enchantment, enchanted, material, shield.InnerText.Trim());
        }
Exemplo n.º 4
0
        //MY Code begins execution here
        public static void begin(Form1 form)
        {
            dbForm     = form;
            party      = new Party();
            npcs       = new List <NPC>();
            magicItems = new List <MagicItem>();
            monsters   = new Dictionary <String, Monster>();

            //Load data from files
            Load.load();
            dbForm.updateInformation();
            SpellTable.initializeSpellTable();
            MagicItemTable.initializeMagicItemTables();
            TreasureTable.initializeTreasureTables();
        }
Exemplo n.º 5
0
        //Handles the generating of treasure
        private void rollTreasureButton_Click(object sender, EventArgs e)
        {
            String CRs = treasureTextBox.Text;

            String[] crSplit = CRs.Split(',');

            bool error    = false;
            int  copper   = 0;
            int  silver   = 0;
            int  gold     = 0;
            int  platinum = 0;

            //Foreach CR in the input
            foreach (String s in crSplit)
            {
                int cr;
                if (Int32.TryParse(s, out int newCR))   //If input can be parsed to an int
                {
                    cr = newCR;
                    int[] treasure = TreasureTable.getLoot(cr); //Retrieve the array of individual loot
                    copper   += treasure[0];
                    silver   += treasure[1];
                    gold     += treasure[2];
                    platinum += treasure[3];
                }
                else
                {
                    error = true;
                }
            }
            if (!error)
            {
                treasureLabel.Text = $"{copper} Copper Pieces, {silver} Silver Pieces, {gold} Gold Pieces, and {platinum} Platinum Pieces";
            }
            else
            {
                notificationBar.Text = "Invalid CR Input provided!";
                System.Media.SystemSounds.Beep.Play();
                return;
            }
        }
Exemplo n.º 6
0
        private void FinalizeJewelry(Loot loot, bool onlySpellcaster)
        {
            string query = string.Format("/treasure/jewelry/jewel[@tier={0}]", loot.Tier > 20 ? 20 : loot.Tier);

            if (onlySpellcaster)
            {
                query = string.Format("/treasure/jewelry/jewel[@tier={0} and @flags='S']", loot.Tier > 20? 20 : loot.Tier);
            }

            XmlNodeList candidates = TreasureTable.SelectNodes(query);
            XmlNode     jewelry    = RollRandomLoot(candidates);

            if (jewelry == null)
            {
                return;
            }

            loot.FullName    = jewelry.FirstChild.InnerText.Trim();
            loot.Description = jewelry.SelectSingleNode("description").InnerText.Trim();
            loot.Cost        = jewelry.Attributes["cost"].Value;
        }
Exemplo n.º 7
0
    // called by external scripts to select a procedural config for this container
    // TODO - this whole thing is garbage and needs to be rewritten, maybe when i know more about what GameplayManager wants to do
    public void InitializeContainerConfiguration()
    {
        // figure out which objectSpots we're going to use
        List <int> indices = CodeTools.MultipleWeightedRandomSelections(spots_randWeights, numSpotsToFill, false);

        if (indices.Count == 0)
        {
            return;
        }

        int usedByGoalObject = -1;

        if (gameplayManager.readyForInsertion != null)
        {
            usedByGoalObject = GetIndexForGoalObject();
            CodeTools.CopyTransform(objectSpots[usedByGoalObject].transform, gameplayManager.readyForInsertion.transform, true, true, false);
//            Debug.Log(gameplayManager.readyForInsertion + " teleported to newly-emerging alcove.");
            gameplayManager.readyForInsertion = null;
        }

        // spawn treasures at each of those spots
        foreach (int index in indices)
        {
            if (index != usedByGoalObject)  // if a goal object has been placed in this slot, then skip it
            {
                GameObject    spot = objectSpots[index].gameObject;
                TreasureTable tt   = CodeTools.GetComponentFromNearestAncestor <TreasureTable>(spot);
                if (tt == null)
                {
                    Debug.LogError("No TreasureTable found on " + spot + " nor any of its ancestors.");
                }

                // pick a treasure that fits in the chosen spot
                // TODO - this logic should go more like:  there's a method that finds an unused spot this treasure will fit and puts it there.  iterating over treasures, not spots.

                GameObject treasurePrefab = null;
                bool       itFitsHere     = false;
                int        tries          = 0;
                GameObject newTreasure    = null;

                while ((!itFitsHere) && (tries < 20))  // TODO - this is an unacceptable amount of sweeptests for performance
                {
                    tries++;

                    treasurePrefab = tt.GetRandomTreasure();
                    newTreasure    = (GameObject)Instantiate(treasurePrefab) as GameObject;
                    CodeTools.CopyTransform(spot.transform, newTreasure.transform, false, true, false);  // rotate the object to match the spot

                    itFitsHere = CodeTools.TestForCollision(newTreasure, spot.transform.position);

                    if (itFitsHere)
                    {
                        Debug.Log(newTreasure + " fits without collision at " + spot.transform.position);
                        if (spot.transform.position == Vector3.zero)
                        {
                            Debug.Log("Why is it zero?");
                        }
                    }
                    else
                    {
                        Debug.Log(newTreasure + " does not fit at " + spot.transform.position);
                        DestroyImmediate(newTreasure);  // TODO - needless to say this is terrible
                    }
                }

                if (itFitsHere)
                {
                    // now you can teleport it there
                    CodeTools.CopyTransform(spot.transform, newTreasure.transform, true, true, false);
                    newTreasure.transform.parent = (environment.propsFolder != null) ? environment.propsFolder.transform : null;
                }
                else
                {
                    Debug.LogError("Couldn't find any treasures that will fit in spot " + spot.gameObject + " which is at " + spot.transform.position);
                }
            }
        }
    }
Exemplo n.º 8
0
 public void AddTreasureTable(TreasureTable <int> table)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
 public void AddTreasureTable(TreasureTable <int> table)
 {
     // TODO: check if already exists ?
     _treasureTables.Add(table);
 }