Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            EditorGUILayout.Space();

            if (GUILayout.Button("Test Drop"))
            {
                if (m_LootTable == null)
                {
                    return;
                }

                m_Result = string.Empty;

                var itemDrops = m_LootTable.GetDrops();
                foreach (var itemDrop in itemDrops)
                {
                    m_Result += itemDrop.ToString() + '\n';
                }

                m_Result = m_Result.TrimEnd('\n');

                if (m_Result == string.Empty)
                {
                    m_Result = "No Drops";
                }
            }

            if (m_Result != null)
            {
                EditorGUILayout.TextArea(m_Result);
            }
        }
Exemplo n.º 2
0
        public void PerformGoal(ref NPCBase.NPCState state)
        {
            state.JobIsDone = true;

            if (!Foraging)
            {
                Foraging = true;
                var nextTime = Pipliz.Random.Next(ForagingTimeMinSec, ForagingTimeMaxSec);
                ForageEndTime = ServerTimeStamp.Now.Add(nextTime * 1000);
                state.SetCooldown(1, 2);
                state.SetIndicator(new Shared.IndicatorState(Pipliz.Random.NextFloat(1, 2), LootTable.LootPoolList.GetRandomItem().Item));
            }
            else if (ForageEndTime.IsPassed)
            {
                var items = LootTable.GetDrops(LuckMod);

                foreach (var item in items)
                {
                    Job.NPC.Inventory.Add(item.Key, item.Value);
                }

                state.SetCooldown(1);

                Foraging = false;
                PandaJobFactory.SetActiveGoal(Job, new PutItemsInCrateGoal(Job, JobPos, this, Job.NPC.Inventory.Inventory, this), ref state);
                Job.NPC.Inventory.Inventory.Clear();
            }
            else
            {
                RandomizePos();
                var nextTime = Pipliz.Random.Next(5, 7);
                state.SetCooldown(nextTime);
                state.SetIndicator(new Shared.IndicatorState(nextTime, LootTable.LootPoolList.GetRandomItem().Item));
            }
        }
Exemplo n.º 3
0
    public void DropLoot()
    {
        var drops = lootTable.GetDrops();

        if (drops == null)
        {
            return;
        }
        foreach (var item in drops)
        {
            items.Add(item.name);
            var itemObject    = Instantiate(itemPrefab, transform.position, transform.rotation);
            var itemBehaviour = itemObject.GetComponent <ItemBehaviour>();
            itemBehaviour.item_config = item;
            itemBehaviour.Initialize(item);

            itemObject.GetComponent <Rigidbody2D>().AddForce(Vector2.up * 10f, ForceMode2D.Impulse);
            GetComponent <SpriteRenderer>().enabled = false;
            Destroy(gameObject);
        }
    }