Esempio n. 1
0
    //=====================================================

    public static ChestReward GetChestReward(eChestType type,
                                             eTradingCardClassification cardClassification,
                                             eTradingCardRarity cardRarity,
                                             eTradingCardCondition cardCondition)
    {
        var reward = new ChestReward();

        var rewardCard = (type == eChestType.LARGE &&
                          cardClassification != eTradingCardClassification.NULL &&
                          cardRarity != eTradingCardRarity.NULL);

        // 50% chance of awarding a card or gem
        if (rewardCard == false && Random.Range(0, 99) % 2 == 0)
        {
            rewardCard = true;
        }

        if (rewardCard == true)
        {
            reward.Card          = TradingCardItemsManager.GetCard(type, cardClassification, cardRarity, cardCondition);
            reward.CardCondition = cardCondition;
            //Debug.Log( "SceneManager: Reward card" );
        }
        else
        {
            // Small, medium or large number of gems
            var maxGems = Convert.ToInt32(SettingsManager.GetSettingsItem("AWARD_GEMS_CHEST_" + type, -1));

            reward.Gems = Random.Range(maxGems / 2, maxGems);
            //Debug.Log( "SceneManager: Reward gems" );
        }

        return(reward);
    }
Esempio n. 2
0
    //=====================================================

    public static Object GetModel(eChestType type, int index)
    {
        Init();

        var path = GetModelPath(type, index);

        if (string.IsNullOrEmpty(path) == false)
        {
            var model = Resources.Load(path);

            if (model != null)
            {
                return(model);
            }
        }

        Debug.Log("Chest not found in resources: " + type + " [" + index + "]");
        return(null);
    }
Esempio n. 3
0
    //=====================================================

    private static string GetModelPath(eChestType type, int index)
    {
        var path = new StringBuilder();

        path.Append("Prefabs/Chests/");

        switch (type)
        {
        case eChestType.SMALL:
            SetModelPathLocation(ref path, _smallChests, "Small", index);
            break;

        case eChestType.MEDIUM:
            SetModelPathLocation(ref path, _mediumChests, "Medium", index);
            break;

        case eChestType.LARGE:
            SetModelPathLocation(ref path, _largeChests, "Large", index);
            break;
        }

        return(string.IsNullOrEmpty(path.ToString()) == false ? path.ToString() : string.Empty);
    }
Esempio n. 4
0
    //==================================================================

    public static TradingCardSpreadsheetItem GetCard(eChestType type, eTradingCardClassification cardClassification, eTradingCardRarity cardRarity, eTradingCardCondition cardCondition)
    {
        TradingCardSpreadsheetItem card = new TradingCardSpreadsheetItem();

        //if( _forceRareCardReward )
        //	type = eChestType.LARGE;

        if ((cardClassification != eTradingCardClassification.NULL) || (cardRarity != eTradingCardRarity.NULL))
        {
            // Use a specific classification/type rather than a random one
            eNPC UnlockedNPC = eNPC.NULL;
            card = GetSpecificCardType(cardClassification, cardRarity, cardCondition, ref UnlockedNPC);
            return(card);
        }

        switch (type)
        {
        case eChestType.SMALL:
            // Return common card
            //card = TradingCardItemsManager.GetRandomCard( eTradingCardRarity.COMMON , 30.0f , eTradingCardRarity.VERYCOMMON , 70.0f );
            card = GetRandomCard(eTradingCardRarity.COMMON, 30.0f, eTradingCardRarity.COMMON, 70.0f);
            break;

        case eChestType.MEDIUM:
            // Return common or uncommon card
            card = GetRandomCard(eTradingCardRarity.RARE, 100.0f, eTradingCardRarity.NULL, 0.0f);
            break;

        case eChestType.LARGE:
            // Return uncmmon or rare card
            //card = TradingCardItemsManager.GetRandomCard( eTradingCardRarity.VERYRARE , 80.0f , eTradingCardRarity.UNIQUE , 20.0f );
            card = GetRandomCard(eTradingCardRarity.VERYRARE, 80.0f, eTradingCardRarity.VERYRARE, 20.0f);
            break;
        }

        return(card);
    }
Esempio n. 5
0
    //=====================================================

    private static void AddChestOfType(eChestType type)
    {
        var pfb = ResourcesChests.GetPrefab();
        var mdl = ResourcesChests.GetModel(type, 0);

        if (pfb == null)
        {
            return;
        }

        // Create containers for chests if they don't already exist
        var container = GameObject.Find("Chests");
        var small     = GameObject.Find("Small");
        var medium    = GameObject.Find("Mediun");
        var large     = GameObject.Find("Large");

        if (container == null)
        {
            container = CreateContainer("Chests");

            if (small == null)
            {
                small = CreateContainer("Small", container);
            }

            if (medium == null)
            {
                medium = CreateContainer("Mediun", container);
            }

            if (large == null)
            {
                large = CreateContainer("Large", container);
            }
        }

        var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject;

        if (prefab == null)
        {
            return;
        }

        var script = prefab.GetComponent <Chest>();

        switch (type)
        {
        case eChestType.SMALL:
            prefab.name             = "SmallChest";
            prefab.transform.parent = small.transform;
            break;

        case eChestType.MEDIUM:
            prefab.name             = "MediumChest";
            prefab.transform.parent = medium.transform;
            break;

        case eChestType.LARGE:
            prefab.name             = "LargeChest";
            prefab.transform.parent = large.transform;
            break;
        }

        if (script != null)
        {
            script.Type = type;

            if (mdl != null)
            {
                var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject;

                script.Init(model);
            }
        }

        PositionObjectAndSelect(prefab);
    }