示例#1
0
文件: Item.cs 项目: brudi07/lc_unity
    public static Item SpawnItem(Player player, World world)
    {
        //Debug.Log("Spawn item");
        Item     item = null;
        Modifier mod  = new Modifier();

        // Rng weapon or armor
        int type = UnityEngine.Random.Range(0, 2);

        // Create weapon
        if (type == 0)
        {
            Weapon        weapon = new Weapon();
            List <Weapon> wl     = new List <Weapon>();
            // Rarity weighting
            int rarityRng = UnityEngine.Random.Range(0, 100);
            //Debug.Log("Weapon rarity: " + rarityRng);
            if (rarityRng > 95)
            {
                wl = weapon.GetListByRarity(world.weaponList, Item.Rarity.Set);
            }
            else if (rarityRng > 90)
            {
                wl = weapon.GetListByRarity(world.weaponList, Item.Rarity.Legendary);
            }
            else if (rarityRng > 65)
            {
                wl = weapon.GetListByRarity(world.weaponList, Item.Rarity.Uncommon);
            }
            else
            {
                wl = weapon.GetListByRarity(world.weaponList, Item.Rarity.Common);
            }
            int listCount = wl.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = wl[rng].itemId;
            item = weapon.GetWeaponById(weapon.WeaponList(), id);
        }
        // Create armor
        else if (type == 1)
        {
            Armor        armor = new Armor();
            List <Armor> al    = world.armorList;
            // Rarity weighting
            int rarityRng = UnityEngine.Random.Range(0, 100);
            //Debug.Log("Armor rarity: " + rarityRng);
            if (rarityRng > 95)
            {
                al = armor.GetListByRarity(world.armorList, Item.Rarity.Set);
            }
            else if (rarityRng > 90)
            {
                al = armor.GetListByRarity(world.armorList, Item.Rarity.Legendary);
            }
            else
            {
                al = armor.GetListByRarity(world.armorList, Item.Rarity.Uncommon);
            }
            // Armor does not contain common rarities
            int listCount = al.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = al[rng].itemId;
            item = armor.GetArmorById(armor.ArmorList(), id);
        }

        // Check to add prefix
        if (UnityEngine.Random.Range(0, 100) < player.magicFind)
        {
            int listCount = world.prefixList.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = world.prefixList[rng].modId;
            item.AddModifier(mod.GetModifierById(mod.PrefixList(), id));
        }
        // Check to add suffix
        if (UnityEngine.Random.Range(0, 100) < player.magicFind)
        {
            int listCount = world.suffixList.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = world.suffixList[rng].modId;
            item.AddModifier(mod.GetModifierById(mod.SuffixList(), id));
        }
        return(item);
    }
示例#2
0
    // Spawn an item and rng check to add magical properties
    public void SpawnItem()
    {
        //Debug.Log("Spawn item");
        Item     item = null;
        Modifier mod  = new Modifier();
        int      type = UnityEngine.Random.Range(0, 2);

        // Create weapon
        if (type == 0)
        {
            Weapon weapon    = new Weapon();
            int    listCount = world.weaponList.Count;
            int    rng       = UnityEngine.Random.Range(0, listCount);
            int    id        = world.weaponList[rng].itemId;
            item = weapon.GetWeaponById(weapon.WeaponList(), id);
        }
        // Create armor
        else if (type == 1)
        {
            Armor armor     = new Armor();
            int   listCount = world.armorList.Count;
            int   rng       = UnityEngine.Random.Range(0, listCount);
            int   id        = world.armorList[rng].itemId;
            item = armor.GetArmorById(armor.ArmorList(), id);
        }

        // Check to add prefix
        if (UnityEngine.Random.Range(0, 100) < player.magicFind)
        {
            int listCount = world.prefixList.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = world.prefixList[rng].modId;
            item.AddModifier(mod.GetModifierById(mod.PrefixList(), id));
        }

        // Check to add suffix
        if (UnityEngine.Random.Range(0, 100) < player.magicFind)
        {
            int listCount = world.suffixList.Count;
            int rng       = UnityEngine.Random.Range(0, listCount);
            int id        = world.suffixList[rng].modId;
            item.AddModifier(mod.GetModifierById(mod.SuffixList(), id));
        }

        // Add item to inventory
        if (player.inventory.Count < 15)
        {
            player.inventory.Add(item);
        }
        else
        {
            SoundManager.sm.PlaySoundFX(Resources.Load <AudioClip>("Sfx/dropsfx"));
        }

        // Update Inventory (Set item border color to match rarity)
        for (int i = 0; i < player.inventory.Count; i++)
        {
            GameObject.Find("Item" + i).GetComponent <ItemPanel>().item                     = player.inventory[i];
            GameObject.Find("Item" + i).GetComponentInChildren <Image>().sprite             = Resources.Load <Sprite>(player.inventory[i].spritePath);
            GameObject.Find("ItemPanel" + i).GetComponentInChildren <Outline>().effectColor = player.inventory[i].GetRarityColor();
        }
    }
示例#3
0
文件: World.cs 项目: brudi07/lc_unity
    // List of all worlds
    public List <World> WorldList()
    {
        List <World> worldList = new List <World>();
        // Instantiate
        Enemy    enemy  = new Enemy();
        Weapon   weapon = new Weapon();
        Armor    armor  = new Armor();
        Modifier mod    = new Modifier();
        // Shortcut lists
        List <Enemy>    el = enemy.EnemyList();
        List <Weapon>   wl = weapon.WeaponList();
        List <Armor>    al = armor.ArmorList();
        List <Modifier> pl = mod.PrefixList();
        List <Modifier> sl = mod.SuffixList();

        World world;

        // Create Plains
        world = new World
        {
            worldName      = "Plains",
            enemyScaling   = 0.8,
            backgroundPath = "Background/plains",
            soundPath      = "Music/plains",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 152), enemy.GetEnemyById(el, 153), enemy.GetEnemyById(el, 154), enemy.GetEnemyById(el, 155), enemy.GetEnemyById(el, 156),
                enemy.GetEnemyById(el, 157), enemy.GetEnemyById(el, 158), enemy.GetEnemyById(el, 159), enemy.GetEnemyById(el, 160), enemy.GetEnemyById(el, 161)
            },
            miniBoss   = enemy.GetEnemyById(el, 162),
            boss       = enemy.GetEnemyById(el, 163),
            weaponList = weapon.GetListByTier(wl, 01),
            armorList  = armor.GetListByTier(al, 1),
            prefixList = mod.GetListByTier(pl, 1),
            suffixList = mod.GetListByTier(sl, 1)
        };
        worldList.Add(world);

        // Create Forest
        world = new World
        {
            worldName      = "Forest",
            enemyScaling   = 2.1,
            backgroundPath = "Background/forest1",
            soundPath      = "Music/forestmusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 164), enemy.GetEnemyById(el, 165), enemy.GetEnemyById(el, 166), enemy.GetEnemyById(el, 167),
                enemy.GetEnemyById(el, 168), enemy.GetEnemyById(el, 169), enemy.GetEnemyById(el, 170), enemy.GetEnemyById(el, 171), enemy.GetEnemyById(el, 172), enemy.GetEnemyById(el, 173)
            },
            miniBoss   = enemy.GetEnemyById(el, 174),
            boss       = enemy.GetEnemyById(el, 175),
            weaponList = weapon.GetListByTier(wl, 02),
            armorList  = armor.GetListByTier(al, 2),
            prefixList = mod.GetListByTier(pl, 2),
            suffixList = mod.GetListByTier(sl, 2)
        };
        worldList.Add(world);

        // Create Cave
        world = new World
        {
            worldName      = "Cave",
            enemyScaling   = 3.3,
            backgroundPath = "Background/cave1",
            soundPath      = "Music/cavemusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 176), enemy.GetEnemyById(el, 177), enemy.GetEnemyById(el, 178), enemy.GetEnemyById(el, 179),
                enemy.GetEnemyById(el, 180), enemy.GetEnemyById(el, 181), enemy.GetEnemyById(el, 182), enemy.GetEnemyById(el, 183), enemy.GetEnemyById(el, 184),
                enemy.GetEnemyById(el, 184), enemy.GetEnemyById(el, 185)
            },
            miniBoss   = enemy.GetEnemyById(el, 186),
            boss       = enemy.GetEnemyById(el, 187),
            weaponList = weapon.GetListByTier(wl, 03),
            armorList  = armor.GetListByTier(al, 3),
            prefixList = mod.GetListByTier(pl, 3),
            suffixList = mod.GetListByTier(sl, 3)
        };
        worldList.Add(world);

        // Create River
        world = new World
        {
            worldName      = "River",
            enemyScaling   = 4.7,
            backgroundPath = "Background/river",
            soundPath      = "Music/rivermusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 188), enemy.GetEnemyById(el, 189), enemy.GetEnemyById(el, 190), enemy.GetEnemyById(el, 191),
                enemy.GetEnemyById(el, 192), enemy.GetEnemyById(el, 193), enemy.GetEnemyById(el, 194), enemy.GetEnemyById(el, 195),
                enemy.GetEnemyById(el, 196), enemy.GetEnemyById(el, 197)
            },
            miniBoss   = enemy.GetEnemyById(el, 198),
            boss       = enemy.GetEnemyById(el, 199),
            weaponList = weapon.GetListByTier(wl, 04),
            armorList  = armor.GetListByTier(al, 4),
            prefixList = mod.GetListByTier(pl, 4),
            suffixList = mod.GetListByTier(sl, 4)
        };
        worldList.Add(world);

        // Create Swamp
        world = new World
        {
            worldName      = "Swamp",
            enemyScaling   = 6.2,
            backgroundPath = "Background/forest2",
            soundPath      = "Music/swampmusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 200), enemy.GetEnemyById(el, 201), enemy.GetEnemyById(el, 202), enemy.GetEnemyById(el, 203),
                enemy.GetEnemyById(el, 204), enemy.GetEnemyById(el, 205), enemy.GetEnemyById(el, 206),
                enemy.GetEnemyById(el, 207), enemy.GetEnemyById(el, 208), enemy.GetEnemyById(el, 209)
            },
            miniBoss   = enemy.GetEnemyById(el, 210),
            boss       = enemy.GetEnemyById(el, 211),
            weaponList = weapon.GetListByTier(wl, 05),
            armorList  = armor.GetListByTier(al, 5),
            prefixList = mod.GetListByTier(pl, 5),
            suffixList = mod.GetListByTier(sl, 5)
        };
        worldList.Add(world);

        // Create Desert
        world = new World
        {
            worldName      = "Desert",
            enemyScaling   = 7.8,
            backgroundPath = "Background/desert",
            soundPath      = "Music/desertmusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 212), enemy.GetEnemyById(el, 213), enemy.GetEnemyById(el, 214), enemy.GetEnemyById(el, 215),
                enemy.GetEnemyById(el, 216), enemy.GetEnemyById(el, 217), enemy.GetEnemyById(el, 218),
                enemy.GetEnemyById(el, 219), enemy.GetEnemyById(el, 220), enemy.GetEnemyById(el, 221)
            },
            miniBoss   = enemy.GetEnemyById(el, 222),
            boss       = enemy.GetEnemyById(el, 223),
            weaponList = weapon.GetListByTier(wl, 06),
            armorList  = armor.GetListByTier(al, 6),
            prefixList = mod.GetListByTier(pl, 6),
            suffixList = mod.GetListByTier(sl, 6)
        };
        worldList.Add(world);

        return(worldList);
    }
示例#4
0
    // Warrior select
    public void CreateWarrior(InputField inputName)
    {
        Debug.Log("Warrior selected");
        // Create warrior player
        string name = inputName.text;

        if (name == "")
        {
            name = "Hero";
        }
        // Base character
        player.playerName    = name;
        player.playerClass   = "Warrior";
        player.strength      = 10;
        player.dexterity     = 1;
        player.intelligence  = 1;
        player.critChance    = 10;
        player.critDamage    = 150;
        player.bonusPhysical = 100;
        player.bonusMagical  = 100;
        player.itemFind      = 10;
        player.magicFind     = 10;
        player.bonusGold     = 100;
        player.bonusExp      = 100;
        // Equip weapons
        player.weapon1        = (Weapon)player.Equip(weapon.GetWeaponById(weapon.WeaponList(), 00101));
        player.weapon2        = (Weapon)player.Equip(new Weapon());
        player.weapon3        = (Weapon)player.Equip(new Weapon());
        player.equippedWeapon = player.weapon1;
        // Equip armor
        player.head   = (Armor)player.Equip(armor.GetArmorById(armor.ArmorList(), 0001));
        player.chest  = (Armor)player.Equip(armor.GetArmorById(armor.ArmorList(), 0002));
        player.gloves = (Armor)player.Equip(armor.GetArmorById(armor.ArmorList(), 0003));
        player.legs   = (Armor)player.Equip(armor.GetArmorById(armor.ArmorList(), 0004));
        player.boots  = (Armor)player.Equip(armor.GetArmorById(armor.ArmorList(), 0005));
        // Inventory
        //Modifier mod = new Modifier();
        //player.inventory.Add(weapon.GetWeaponById(weapon.WeaponList(), 00101).AddModifier(mod.GetModifierById(mod.PrefixList(), 1102)));
        //player.inventory.Add(weapon.GetWeaponById(weapon.WeaponList(), 19303));
        player.inventory.Add(weapon.GetWeaponById(weapon.WeaponList(), 5));

        // Load Main scene
        GameManager.gm.LoadScene("Town");
    }
示例#5
0
    // List of all worlds
    public List <World> WorldList()
    {
        List <World> worldList = new List <World>();
        // Instantiate
        Enemy    enemy  = new Enemy();
        Weapon   weapon = new Weapon();
        Armor    armor  = new Armor();
        Modifier mod    = new Modifier();
        // Shortcut lists
        List <Enemy>    el = enemy.EnemyList();
        List <Weapon>   wl = weapon.WeaponList();
        List <Armor>    al = armor.ArmorList();
        List <Modifier> pl = mod.PrefixList();
        List <Modifier> sl = mod.SuffixList();

        World world;

        // Create Forest
        world = new World
        {
            worldName      = "Forest",
            backgroundPath = "Background/forest1",
            soundPath      = "Music/forestmusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 001), enemy.GetEnemyById(el, 010), enemy.GetEnemyById(el, 011), enemy.GetEnemyById(el, 012),
                enemy.GetEnemyById(el, 013), enemy.GetEnemyById(el, 014), enemy.GetEnemyById(el, 016), enemy.GetEnemyById(el, 017)
            },
            miniBoss   = enemy.GetEnemyById(el, 002),
            boss       = enemy.GetEnemyById(el, 003),
            weaponList = weapon.GetListByTier(wl, 1),
            armorList  = al,
            prefixList = pl,
            suffixList = sl
        };
        worldList.Add(world);

        // Create Cave
        world = new World
        {
            worldName      = "Cave",
            backgroundPath = "Background/cave1",
            soundPath      = "Music/cavemusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 004), enemy.GetEnemyById(el, 050), enemy.GetEnemyById(el, 051), enemy.GetEnemyById(el, 041),
                enemy.GetEnemyById(el, 042), enemy.GetEnemyById(el, 027), enemy.GetEnemyById(el, 028)
            },
            miniBoss   = enemy.GetEnemyById(el, 005),
            boss       = enemy.GetEnemyById(el, 006),
            weaponList = weapon.GetListByTier(wl, 1),
            armorList  = armor.ArmorList(),
            prefixList = mod.PrefixList(),
            suffixList = mod.SuffixList()
        };
        worldList.Add(world);

        // Create River
        world = new World
        {
            worldName      = "River",
            backgroundPath = "Background/river",
            soundPath      = "Music/rivermusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 007), enemy.GetEnemyById(el, 019), enemy.GetEnemyById(el, 020), enemy.GetEnemyById(el, 021),
                enemy.GetEnemyById(el, 022), enemy.GetEnemyById(el, 014), enemy.GetEnemyById(el, 025), enemy.GetEnemyById(el, 026)
            },
            miniBoss   = enemy.GetEnemyById(el, 008),
            boss       = enemy.GetEnemyById(el, 009),
            weaponList = weapon.GetListByTier(wl, 2),
            armorList  = armor.ArmorList(),
            prefixList = mod.PrefixList(),
            suffixList = mod.SuffixList()
        };
        worldList.Add(world);

        // Create Swamp
        world = new World
        {
            worldName      = "Swamp",
            backgroundPath = "Background/forest2",
            soundPath      = "Music/swampmusic",
            enemyList      = new List <Enemy> {
                enemy.GetEnemyById(el, 043), enemy.GetEnemyById(el, 046), enemy.GetEnemyById(el, 047), enemy.GetEnemyById(el, 048),
                enemy.GetEnemyById(el, 049), enemy.GetEnemyById(el, 023), enemy.GetEnemyById(el, 024)
            },
            miniBoss   = enemy.GetEnemyById(el, 044),
            boss       = enemy.GetEnemyById(el, 045),
            weaponList = weapon.GetListByTier(wl, 2),
            armorList  = armor.ArmorList(),
            prefixList = mod.PrefixList(),
            suffixList = mod.SuffixList()
        };
        worldList.Add(world);

        return(worldList);
    }