Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        lootDice = new Dice(new List <string> {
            "GOLD", "ITEM", "ANY\nONE"
        });

        commonRarities.AddElement("Common", 0.9f); commonRarities.AddElement("Rare", 0.1f);
        rareRarities.AddElement("Common", 0.3f); rareRarities.AddElement("Rare", 0.55f); rareRarities.AddElement("Epic", 0.1f); rareRarities.AddElement("Legendary", 0.05f);
    }
Пример #2
0
 public void GeneratePoolItems()
 {
     itemPool = new WeightedBag();
     foreach (string itemName in allItems.Keys)
     {
         if (allItems[itemName].unlocked)
         {
             itemPool.AddElement(itemName, 1f / allItems[itemName].goldValue);
         }
     }
 }
Пример #3
0
    // MOB GENERATION

    public void PrepareLevelPool()
    {
        mobPool.MultiplyWeightAll(0.7f);

        levelConfront++;

        foreach (string name in allMobs.Keys)
        {
            if (allMobs[name].levelAppear == levelConfront && allMobs[name].unlocked)
            {
                mobPool.AddElement(name, allMobs[name].presenceRate);
            }
        }
    }
Пример #4
0
    public void NewGame()
    {
        if (currentScene != null)
        {
            currentScene.SetActive(false);
        }
        deathScene.SetActive(false);
        myLootHandler.followerTab.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text = "";
        sceneProb = new WeightedBag();

        thePlayer = new Player();
        initializePlayer();
        myCombatHandler.thePlayer  = thePlayer; myCombatHandler.levelConfront = 0; myCombatHandler.mobPool = new WeightedBag();
        myUpgradeHandler.thePlayer = thePlayer;
        myLootHandler.thePlayer    = thePlayer;

        sceneProb.AddElement("Heal", 0f); sceneProb.AddElement("Upgrade", 0f);

        //currentScene = upgradeScene;
        //upgradeScene.SetActive(true);
        //myUpgradeHandler.InitUpgradeScene();
        nextScene = "Confront";
        CheckSpecialEvent();
    }
Пример #5
0
    public void ResolveEvent(TriggerContent theEvent, GameObject target)
    {
        for (int i = 0; i < theEvent.effectNames.Count; i++)
        {
            string theText;

            switch (theEvent.effectNames[i])
            {
            // COMMENTARY EVENTS
            case "Pool_commentary":
                aBag = new WeightedBag();
                for (int j = 0; j < theEvent.effectData.Count; j++)
                {
                    aBag.AddElement(theEvent.effectData[j], theEvent.effectValues[j] / 100f);
                }

                theText = aBag.Draw(true);
                if (theText != "nothing")
                {
                    target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theText + "\n"; target.SetActive(true);
                }
                else
                {
                    target.SetActive(false);
                }
                break;

            case "Commentary":
                target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theEvent.effectData[i] + "\n";
                target.SetActive(true);
                break;

            case "Commentary_Variable":
                List <string> copyText = new List <string>(); theEvent.effectData.ForEach(x => copyText.Add(x));
                theText = DecodeString(copyText);
                target.transform.Find("TextBackground").Find("Text").GetComponent <Text>().text += theText + "\n";

                target.SetActive(true);
                break;

            case "Increment_counter":
                myData.allCounters[theEvent.effectData[i]].count += (int)theEvent.effectValues[i];
                myData.StoreCounters();

                ExecuteFromTrigger("Incremented_" + theEvent.effectData[i], target);
                break;

            case "Set_counter":
                myData.allCounters[theEvent.effectData[i]].count = (int)theEvent.effectValues[i];
                myData.StoreCounters();
                break;

            // EVENTS
            case "Special_Event":
                eventData = theEvent.effectData;
                GetComponent <GameHandler>().specialEvent = true;
                break;

            case "Force_encounter":
                CharacterContent encounter = new CharacterContent(myData.allMobs[theEvent.effectData[i]]);

                encounter.myName = theEvent.effectData[i + 1];   // dangerous... an encounter can be force-set without name change
                GetComponent <ConfrontationHandler>().forceEncounter = encounter;
                break;

            case "Force_loot":
                GetComponent <LootHandler>().forceLoot = theEvent.effectData[i];
                break;

            case "Pool_triggerEvent":
                aBag = new WeightedBag();
                for (int j = 0; j < theEvent.effectData.Count; j++)
                {
                    aBag.AddElement(theEvent.effectData[j], theEvent.effectValues[j] / 100f);
                }

                theText = aBag.Draw(true);
                ResolveEvent(myData.allEvents[theText], target);
                break;

            // TOOLS
            case "Activate":
                SetEventActive(theEvent.effectData[i], true);
                break;

            case "Deactivate":
                SetEventActive(theEvent.effectData[i], false);
                break;

            case "Deactivate_quest":
                foreach (string elt in myData.allEvents.Keys.ToList())
                {
                    if (elt.Contains(theEvent.effectData[i]))
                    {
                        SetEventActive(elt, false);
                    }
                }
                break;

            case "Unlock_enemy":
                UnlockEnemy(theEvent.effectData[i]);
                break;

            case "Unlock_item":
                UnlockItem(theEvent.effectData[i]);
                break;
            }
        }
    }