コード例 #1
0
        public static Color getRarityColour(RarityObject.Rarity rarity)
        {
            switch (rarity)
            {
            case RarityObject.Rarity.LEGENDARY:
                //orange
                return(new Color(0.941f, 0.553f, 0f));

            case RarityObject.Rarity.VERY_RARE:
                //purple
                return(new Color(0.569f, 0.196f, 0.784f));

            case RarityObject.Rarity.RARE:
                //blue
                return(new Color(0.184f, 0.47f, 1f));

            case RarityObject.Rarity.UNCOMMON:
                //green
                return(new Color(0.235f, 0.816f, 0.0143f));

            case RarityObject.Rarity.COMMON:
            default:
                //grey
                return(new Color(0.314f, 0.314f, 0.314f));
            }
        }
コード例 #2
0
        public static WeaponDefinition getWeapon(string weapon, RarityObject.Rarity rarity)
        {
            //load the weapon definitions into a text asset
            TextAsset weaponDefinitionJson = Resources.Load <TextAsset>(weaponDefinitionPath);

            //deserialize the weapon definitions into an object
            WeaponDefinitions weaponDefinitions = JsonConvert.DeserializeObject <WeaponDefinitions>(weaponDefinitionJson.text);

            return(weaponDefinitions.definitions[weapon][rarity]);
        }
コード例 #3
0
        //temporarily returning weapon list. Need to fix when implementing other drop types
        public WeaponDefinition[] generateLoot(string enemyId)
        {
            //check the enemy id matches a key in the enemy definitions
            if (!enemyDefinitions.definitions.ContainsKey(enemyId))
            {
                throw new System.Exception("Missing enemy id.");
            }

            //retrieve the enemy details
            EnemyDefinition definition = enemyDefinitions.definitions[enemyId];

            //create an array to store the loot drops
            WeaponDefinition[] generatedDefinitions = new WeaponDefinition[definition.lootDrops];

            for (int i = 0; i < definition.lootDrops; i++)
            {
                //randomly select the loot drop type such as weapon, armour, resource etc.
                string dropType = ((WeightedString)WeightedValueSelector.selectValue(definition.lootDropTypes)).value;

                switch (dropType)
                {
                case "WEAPON":
                    //using the selected loot drop type, randomly select the inner group of loot items such as assault_rifles
                    WeaponLootDefinition weaponLootDefinition = ((WeaponLootDefinition)WeightedValueSelector.selectValue(definition.weaponWeights));

                    //randomly select the rarity type of the loot drop
                    RarityObject.Rarity rarity = ((WeightedRarityObject)WeightedValueSelector.selectValue(weaponLootDefinition.rarityWeights)).value;

                    //using the randomly selected information retrieve a weapon definition and add to loot list
                    generatedDefinitions[i] = WeaponUtil.getWeapon(weaponLootDefinition.name, rarity);
                    break;

                case "ARMOUR":
                    break;

                case "INTEL":
                    break;

                case "RESOURCE":
                    break;

                case "NONE":
                    break;
                }
            }

            //return the list of awarded loot types
            return(generatedDefinitions);
        }