Ejemplo n.º 1
0
 private void onDropLootTableRolled(LootTable lootTable, Vector3 worldPos, Reward drop)
 {
     if (ConfigMeta.IsRetirementChest(drop.ChestType))
     {
         GameLogic.Binder.GameState.Player.Notifiers.HeroRetirementsInspected = false;
     }
 }
Ejemplo n.º 2
0
    public override IEnumerator Kill()
    {
        phase = 4;
        // Plays anim
        stats.isAlive = false;

        yield return(new WaitForSeconds(2f));

        animControl.PlayDeath();

        LootTable lootTable = GetComponent <LootTable>();

        if (lootTable != null)
        {
            lootTable.SpawnLoot();
        }
        GetComponentInParent <EnemyControl>().enabled = false;

        // The rest of function will continue as deathDuration passes
        yield return(new WaitForSeconds(10f));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

        // Respawns Enemy in its Spawn Point
        if (stats.allowRespawn)
        {
            Respawn();
        }
        // Destroys parent object (the entire Enemy object)
        else
        {
            Destroy(transform.parent.gameObject);
        }
    }
Ejemplo n.º 3
0
 public BlockCobblestone()
 {
     Name    = "Cobblestone";
     Type    = BlockData.Blocks.Cobblestone;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
 }
Ejemplo n.º 4
0
 public BlockGoldOre()
 {
     Name    = "GoldOre";
     Type    = BlockData.Blocks.Gold_Ore;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
 }
        public override ItemsResponse Loot()
        {
            Random       random        = new Random(DateTime.Now.Millisecond);
            double       numberOfRolls = Math.Log10(Level) + 1;
            List <IItem> itemsRolled   = new List <IItem>();

            numberOfRolls--;
            var lootItemsResponse = LootTable.Loot();

            if (lootItemsResponse.SuccessValue)
            {
                itemsRolled.AddRange(lootItemsResponse.Value);
            }

            while (numberOfRolls < 0)
            {
                numberOfRolls--;
                if (random.NextDouble() < numberOfRolls && random.NextDouble() > 0.5)
                {
                    lootItemsResponse = LootTable.Loot();
                    if (lootItemsResponse.SuccessValue)
                    {
                        itemsRolled.AddRange(lootItemsResponse.Value);
                    }
                }
            }

            return(new ItemsResponse(
                       $"A {nameof(Creature)} of class {this.GetType().Name} is getting looted.",
                       $"A {nameof(Creature)} of class {this.GetType().Name} 's Loot method.",
                       itemsRolled));
        }
Ejemplo n.º 6
0
 void Start()
 {
     magicAttack = Resources.Load <MagicAttack>("Items/Weapons/Projectiles/MagicAttack");
     //playerXform = playerGO.transform;
     //transform.LookAt(playerXform);
     // Create new loot table
     LootTable = new LootTable();
     // Create new list of loot
     LootTable.lootDrops = new List <LootDrop>
     {
         // Populate loot list
         new LootDrop("sword", 1),
     };
     for (int i = 0; i < listOfDrops.Length; i++)
     {
         LootTable.lootDrops.Add(new LootDrop(listOfDrops[i], chancesOfDrops[i]));
     }
     ID         = enemyID;
     Experience = experienceForKilling;
     // Assign nav mesh agent
     navMeshAgent   = GetComponent <NavMeshAgent>();
     combatantStats = new CombatantStats(attackLevel, defenceLevel, attackSpeed);
     // Set health to full
     currentHealth = maxHealth;
 }
Ejemplo n.º 7
0
        public void value_is_set()
        {
            const int COUNT = 15;

            ILootTable entry = new LootTable(COUNT);

            Assert.AreEqual(entry, entry.Value);
        }
Ejemplo n.º 8
0
        public void count_is_set()
        {
            const int COUNT = 15;

            ILootTable table = new LootTable(COUNT);

            Assert.AreEqual(COUNT, table.Count);
        }
Ejemplo n.º 9
0
 public BlockJukebox()
 {
     Name    = "Jukebox";
     Type    = BlockData.Blocks.Jukebox;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     BurnEfficiency = 300;
 }
Ejemplo n.º 10
0
 public BlockWoodenStairs()
 {
     Name    = "WoodenStairs";
     Type    = BlockData.Blocks.Wooden_Stairs;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)BlockData.Blocks.Wood, 1));
     BurnEfficiency = 300;
 }
Ejemplo n.º 11
0
 // Use this for initialization
 public virtual void Start()
 {
     m_pAudioSource                        = (AudioSource)gameObject.GetComponent("AudioSource");
     m_pAudioSource.playOnAwake            = false;
     GetComponent <Rigidbody>().useGravity = false;
     GetComponent <Collider>().isTrigger   = true;
     lootTable = LootTable.CreateLootTable();
 }
Ejemplo n.º 12
0
 public BlockNoteBlock()
 {
     Name    = "NoteBlock";
     Type    = BlockData.Blocks.Note_Block;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     BurnEfficiency = 300;
 }
Ejemplo n.º 13
0
 public BlockLog()
 {
     Name           = "Log";
     Type           = BlockData.Blocks.Log;
     IsSolid        = true;
     BurnEfficiency = 300;
     LootTable.Add(new ItemStack((short)Type, 1));
 }
Ejemplo n.º 14
0
 public void ChangeLootTable(LootTable lootTable, int profit)
 {
     currentEnemyStatisticsSerializable.lootTable = new LootTableSerializable(lootTable);
     this.profit       = profit;
     profitText.text   = "Profit: " + profit;
     lootableName.text = currentEnemyStatisticsSerializable.lootTable.name;
     CanBeSaved();
 }
Ejemplo n.º 15
0
        private void LoottableBtn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            this.Hide();
            LootTable ltbox = new LootTable();

            ltbox.ShowDialog();
            this.Close();
        }
Ejemplo n.º 16
0
 public BlockTNT()
 {
     Name        = "TNT";
     Type        = BlockData.Blocks.TNT;
     IsSingleHit = true;
     IsSolid     = true;
     LootTable.Add(new ItemStack((byte)Type, 1));
 }
Ejemplo n.º 17
0
 public BlockGrass()
 {
     Name      = "Grass";
     Type      = BlockData.Blocks.Grass;
     IsSolid   = true;
     IsFertile = true;
     LootTable.Add(new ItemStack((short)BlockData.Blocks.Dirt, 1));
 }
Ejemplo n.º 18
0
 public ResourceBreakable(LootTable lootTable, float waitTime, ItemData breakTool, Range resourceRange, ItemData itemMain)
 {
     this.lootTable = lootTable;
     this.waitTime  = waitTime;
     this.breakTool = breakTool;
     resourceAmount = (int)Random.Range(resourceRange.min, resourceRange.max);
     this.itemMain  = itemMain;
 }
Ejemplo n.º 19
0
 public BlockDirt()
 {
     Name      = "Dirt";
     Type      = BlockData.Blocks.Dirt;
     IsSolid   = true;
     IsFertile = true;
     LootTable.Add(new ItemStack((short)Type, 1));
 }
Ejemplo n.º 20
0
 public BlockStoneButton()
 {
     Name  = "StoneButton";
     Type  = BlockData.Blocks.Stone_Button;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
 }
Ejemplo n.º 21
0
 public BlockWorkbench()
 {
     Name    = "Workbench";
     Type    = BlockData.Blocks.Workbench;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     BurnEfficiency = 300;
 }
 public void RerollItemsInShop(LootTable TableToGenerateItemsFrom)//rerolls the shop (put a loot table to take items from)
 {
     if (TableToGenerateItemsFrom != null)
     {
         RemoveAllItemsFromShop();
         CreateItemsInTheShop(TableToGenerateItemsFrom);
     }
 }
Ejemplo n.º 23
0
 public BlockSlab()
 {
     Name    = "Slab";
     Type    = BlockData.Blocks.Slab;
     IsSolid = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.5, 1);
 }
Ejemplo n.º 24
0
 public BlockLever()
 {
     Name  = "Lever";
     Type  = BlockData.Blocks.Lever;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
 }
Ejemplo n.º 25
0
    public virtual void Start()
    {
        mySprite = GetComponent <SpriteRenderer>();

        health       = GetComponentInChildren <GenericHealth>();
        currentState = EnemyState.idle;
        thisLoot     = enemyStatistics.lootTable;
    }
Ejemplo n.º 26
0
 public BlockBed()
 {
     Name           = "Bed";
     Type           = BlockData.Blocks.Bed;
     BurnEfficiency = 300;
     LootTable.Add(new ItemStack((short)BlockData.Items.Bed, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.5625, 1);
 }
Ejemplo n.º 27
0
 public BlockStonePressurePlate()
 {
     Name  = "StonePressurePlate";
     Type  = BlockData.Blocks.Stone_Pressure_Plate;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity = 0x0;
 }
Ejemplo n.º 28
0
        public FishingZone(FishingZoneDepletedDelegate callback, int id, float x, float y, float z, float rotX, float rotY, float rotZ, float scale, FishingZoneType type, Loot[] loot)
        {
            this.fishingZoneDepletedMethod = callback;
            this.id = id;
            FishingSpot fishingSpot = new FishingSpot(x, y, z, rotX, rotY, rotZ, scale, type, loot);

            this.fishingSpot = fishingSpot;
            lootTable        = new LootTable(fishingSpot.loots);
        }
Ejemplo n.º 29
0
 public BlockWoodenPressurePlate()
 {
     Name  = "WoodenPressurePlate";
     Type  = BlockData.Blocks.Wooden_Pressure_Plate;
     IsAir = true;
     LootTable.Add(new ItemStack((short)Type, 1));
     Opacity           = 0x0;
     BlockBoundsOffset = new BoundingBox(0.0625, 0, 0.0625, 0.9375, 0.0625, 0.9375);
 }
Ejemplo n.º 30
0
 public BlockPoweredRail()
 {
     Name    = "PoweredRail";
     Type    = BlockData.Blocks.PoweredRail;
     IsAir   = true;
     Opacity = 0x0;
     LootTable.Add(new ItemStack((short)Type, 1));
     BlockBoundsOffset = new BoundingBox(0, 0, 0, 1, 0.125, 1);
 }
Ejemplo n.º 31
0
        public LootController()
        {
            var weightings = new List<ItemWeighting>
            {
                new ItemWeighting(new Item("Sword"), 10),
                new ItemWeighting(new Item("Shield"), 10),
                new ItemWeighting(new Item("Health Potion"), 30),
                new ItemWeighting(new Item("Resurrection Phial"), 30),
                new ItemWeighting(new Item("Scroll of wisdom"), 20)
            }; //TODO: Get these from a real place

            _lootTable = new LootTable(weightings, new RandomGenerator(), new DebugLogger()); //TODO: Dependency injection
        }
Ejemplo n.º 32
0
    // Use this for initialization
    public ServerLootTables()
    {
        functionName = "Loot Tables";
        // Database tables name
        tableName = "loot_tables";
        functionTitle =  "Loot Table Configuration";
        loadButtonLabel =  "Load Loot Tables";
        notLoadedText =  "No Loot Table loaded.";
        // Init
        dataRegister = new Dictionary<int, LootTable> ();

        editingDisplay = new LootTable ();
        originalDisplay = new LootTable ();
    }
Ejemplo n.º 33
0
    public static List<EnemyToLootTable> parseLootTables(string content)
    {
        List<EnemyToLootTable> enemyToLootTables = new List<EnemyToLootTable> ();
        XmlDocument xmlDoc = new XmlDocument ();

        xmlDoc.LoadXml (content);
        XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/allTables/lootTable");
        foreach (XmlNode node in nodeList) {
            string enemy = node.SelectSingleNode("enemy").InnerText;
            LootTable lootTable = new LootTable();
            foreach (XmlNode lootNode in node.SelectSingleNode("loots").ChildNodes) {
                lootTable.loots.Add (new Loot(
                    lootNode.SelectSingleNode("id").InnerText,
                    float.Parse(lootNode.SelectSingleNode("dropRate").InnerText),
                    int.Parse (lootNode.SelectSingleNode("amount").InnerText),
                    _stringToLootType(lootNode.SelectSingleNode("type").InnerText)
                    ));
            }
            enemyToLootTables.Add (new EnemyToLootTable(lootTable, enemy));
        }
        return enemyToLootTables;
    }
Ejemplo n.º 34
0
    // Draw the loaded list
    public override void DrawLoaded(Rect box)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        if (dataRegister.Count <= 0) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawLabel (pos.x, pos.y, "You must create a Loot Table before edit it.");
            return;
        }

        // Draw the content database info
        ImagePack.DrawLabel (pos.x, pos.y, "Loot Table Configuration");

        if (newItemCreated) {
            newItemCreated = false;
            LoadSelectList();
            newSelectedDisplay = displayKeys.Count - 1;
        }

        // Draw data Editor
        if (newSelectedDisplay != selectedDisplay) {
        selectedDisplay = newSelectedDisplay;
        int displayKey = displayKeys [selectedDisplay];
        editingDisplay = dataRegister [displayKey];
            originalDisplay = editingDisplay.Clone();
        }

        //if (!displayList.showList) {
            pos.y += ImagePack.fieldHeight;
            pos.x -= ImagePack.innerMargin;
            pos.y -= ImagePack.innerMargin;
            pos.width += ImagePack.innerMargin;
            DrawEditor (pos, false);
            pos.y -= ImagePack.fieldHeight;
            //pos.x += ImagePack.innerMargin;
            pos.y += ImagePack.innerMargin;
            pos.width -= ImagePack.innerMargin;
        //}

        if (state != State.Loaded) {
        // Draw combobox
        pos.width /= 2;
        pos.x += pos.width;
        newSelectedDisplay = ImagePack.DrawCombobox (pos, "", selectedDisplay, displayList);
        pos.x -= pos.width;
        pos.width *= 2;
        }
    }
Ejemplo n.º 35
0
    // Load Database Data
    public override void Load()
    {
        if (!dataLoaded) {
            // Clean old data
            dataRegister.Clear ();
            displayKeys.Clear ();

            // Read all entries from the table
            string query = "SELECT * FROM " + tableName;

            // If there is a row, clear it.
            if (rows != null)
                rows.Clear ();

            // Load data
            rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
            //Debug.Log("#Rows:"+rows.Count);
            // Read all the data
            if ((rows!=null) && (rows.Count > 0)) {
                foreach (Dictionary<string,string> data in rows) {
                    //foreach(string key in data.Keys)
                    //	Debug.Log("Name[" + key + "]:" + data[key]);
                    //return;
                    LootTable display = new LootTable ();
                    display.id = int.Parse (data ["id"]);
                    display.name = data ["name"];
                    for (int i = 1; i <= display.maxEntries; i++) {
                        int itemId = int.Parse (data ["item" + i]);
                        if (itemId != -1) {
                            int chance = int.Parse (data ["item" + i + "chance"]);
                            int count = int.Parse (data ["item" + i + "count"]);
                            LootTableEntry entry = new LootTableEntry(itemId, chance, count);
                            display.entries.Add(entry);
                        }
                    }

                    display.isLoaded = true;
                    //Debug.Log("Name:" + display.name  + "=[" +  display.id  + "]");
                    dataRegister.Add (display.id, display);
                    displayKeys.Add (display.id);
                }
                LoadSelectList();
            }
            dataLoaded = true;
        }
    }
Ejemplo n.º 36
0
 public override void CreateNewData()
 {
     editingDisplay = new LootTable ();
         originalDisplay = new LootTable ();
     selectedDisplay = -1;
 }
Ejemplo n.º 37
0
    // Edit or Create
    public override void DrawEditor(Rect box, bool newItem)
    {
        if (!linkedTablesLoaded) {
            // Load items
            LoadItemList();
            linkedTablesLoaded = true;
        }
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        // Draw the content database info
        if (newItem) {
            ImagePack.DrawLabel (pos.x, pos.y, "Create a new loot table");
            pos.y += ImagePack.fieldHeight;
        }

        editingDisplay.name = ImagePack.DrawField (pos, "Name:", editingDisplay.name, 0.5f);
        pos.y += ImagePack.fieldHeight;

        if (editingDisplay.entries.Count == 0) {
            editingDisplay.entries.Add(new LootTableEntry(-1, 100, 1));
        }
        for (int i = 0; i < editingDisplay.maxEntries; i++) {
            if (editingDisplay.entries.Count > i) {
                pos.width = pos.width / 2;
                int selectedItem = GetPositionOfItem(editingDisplay.entries[i].itemId);
                selectedItem = ImagePack.DrawSelector (pos, "Item " + (i+1) + ":", selectedItem, itemsList);
                editingDisplay.entries[i].itemId = itemIds[selectedItem];
                pos.x += pos.width;
                editingDisplay.entries[i].count = ImagePack.DrawField (pos, "Count:", editingDisplay.entries[i].count);
                pos.x -= pos.width;
                pos.y += ImagePack.fieldHeight;
                editingDisplay.entries[i].chance = ImagePack.DrawField (pos, "Chance:", editingDisplay.entries[i].chance);
                pos.x += pos.width;
                if (ImagePack.DrawButton (pos.x, pos.y, "Remove Item")) {
                    editingDisplay.entries.RemoveAt(i);
                }
                pos.x -= pos.width;
                pos.y += ImagePack.fieldHeight;
                pos.width = pos.width * 2;
            }
        }
        if (editingDisplay.entries.Count < editingDisplay.maxEntries) {
            if (ImagePack.DrawButton (pos.x, pos.y, "Add Item")) {
                LootTableEntry lootTableEntry = new LootTableEntry(-1, 0, 1);
                editingDisplay.entries.Add(lootTableEntry);
            }
        }
        //pos.width = pos.width * 2;

        // Save data
        pos.x -= ImagePack.innerMargin;
        pos.y += 1.4f * ImagePack.fieldHeight;
        pos.width /=3;
        if (ImagePack.DrawButton (pos.x, pos.y, "Save Data")) {
            if (newItem)
                InsertEntry ();
            else
                UpdateEntry ();

            state = State.Loaded;
        }

        // Delete data
        if (!newItem) {
            pos.x += pos.width;
            if (ImagePack.DrawButton (pos.x, pos.y, "Delete Data")) {
                DeleteEntry ();
                newSelectedDisplay = 0;
                state = State.Loaded;
            }
        }

        // Cancel editing
        pos.x += pos.width;
        if (ImagePack.DrawButton (pos.x, pos.y, "Cancel")) {
            editingDisplay = originalDisplay.Clone();
            if (newItem)
                state = State.New;
            else
                state = State.Loaded;
        }

        if (resultTimeout != -1 && resultTimeout > Time.realtimeSinceStartup) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawText(pos, result);
        }
    }
Ejemplo n.º 38
0
    public void SetLootTable(LootTable lt)
    {
        LootTableArgs args = new LootTableArgs();
        args.TableID = lt.TableID;
        args.BaseDropChance = lt.BaseDropChance;
        args.MarkerBonus = lt.MarkerBonus;

        List<LootTableArgs.Range> ranges = new List<LootTableArgs.Range>();
        foreach (LootRange lr in lt.Ranges)
        {
            LootTableArgs.Range range = new LootTableArgs.Range();
            range.Percentage = lr.Percentage;
            range.Templates = new int[lr.Templates.Length];

            int index = 0;
            foreach( ItemTemplate it in lr.Templates )
                range.Templates[index++] = it.TemplateID;
            ranges.Add(range);
        }
        args.Ranges = ranges.ToArray();

        _ffc.SetLootTable(args);
    }
Ejemplo n.º 39
0
 public EnemyToLootTable(LootTable loots, string enemy)
 {
     this.loots = loots;
     this.enemy = enemy;
 }