예제 #1
0
        static void Drop(string code, Vector3 pos, int itemLevel, QualityFactors qualityFactors)
        {
            var treasureClass = TreasureClass.Find(code);

            if (treasureClass == null)
            {
                var item = Item.Create(code);
                if (item == null)
                {
                    Debug.LogWarning("Item wasn't spawned: " + code);
                    return;
                }
                item.level = itemLevel;
                SelectItemQuality(item, qualityFactors, mf: 1000);
                if (item.quality != Item.Quality.HiQuality &&
                    item.quality != Item.Quality.Normal &&
                    item.quality != Item.Quality.LowQuality)
                {
                    item.identified = false;
                }
                GenerateItemProperties(item);
                GenerateItemQuantity(item);
                Loot.Create(pos, item);
            }
            else
            {
                Drop(treasureClass, pos, itemLevel, qualityFactors);
            }
        }
예제 #2
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (_player.HandsItem != null && !CanEquip(_player.HandsItem))
            {
                string charClass = _player.charStatInfo.classNameLower;
                AudioManager.instance.Play(charClass + "_impossible_1");
                return;
            }

            Item[] unequipped = _player.equip.Equip(_player.HandsItem, bodyLoc);

            if (_player.HandsItem != null)
            {
                AudioManager.instance.Play(_player.HandsItem.useSound);
            }
            else if (unequipped[0] != null)
            {
                AudioManager.instance.Play(SoundInfo.itemPickup);
            }

            _player.HandsItem = unequipped[0];
            if (unequipped[1] != null)
            {
                if (!_player.inventory.Put(unequipped[1]))
                {
                    Loot.Create(_player.transform.position, unequipped[1]);
                }
            }
        }
예제 #3
0
        public static void Drop(SetItem setItem, Vector3 pos)
        {
            var item = Item.Create(setItem.itemCode);

            item.quality    = Item.Quality.Set;
            item.level      = setItem.level;
            item.identified = false;
            GenerateSetItem(item, setItem);
            Loot.Create(pos, item);
        }
예제 #4
0
        public static void Drop(UniqueItem uniqueItem, Vector3 pos)
        {
            var item = Item.Create(uniqueItem.code);

            item.quality    = Item.Quality.Unique;
            item.level      = uniqueItem.level;
            item.identified = false;
            GenerateUnique(item, uniqueItem);
            Loot.Create(pos, item);
        }
예제 #5
0
 public void OnGoldButton()
 {
     if (_player.inventory.gold > 0)
     {
         var item = Item.Create("gld");
         item.quantity = _player.inventory.gold;
         Loot.Create(_player.transform.position, item);
         _player.inventory.gold = 0;
     }
 }
예제 #6
0
        void Execute(string input)
        {
            if (input == "")
            {
                return;
            }

            if (history.Count == 0 || history[history.Count - 1] != input)
            {
                history.Add(input);
            }

            string[] parts = input.Split(' ');
            if (parts.Length >= 2 && parts[0] == "/spawn")
            {
                var pos = Iso.MapToWorld(IsoInput.mouseTile);
                if (parts[1] == "flippy")
                {
                    string flippyFile = @"data\global\items\flp" + parts[2] + ".dc6";
                    Loot.Create(pos, flippyFile, flippyFile);
                    return;
                }

                if (parts[1] == "item")
                {
                    string subname    = parts[2].ToLower();
                    var    uniqueItem = UniqueItem.sheet.Find(s => s.nameStr.ToLower().Contains(subname));
                    if (uniqueItem != null)
                    {
                        ItemDrop.Drop(uniqueItem, pos);
                    }
                    else
                    {
                        string code = parts[2];
                        ItemDrop.Drop(code, pos, 100);
                    }

                    return;
                }

                if (parts[1] == "itemset")
                {
                    string subname = parts[2].ToLower();
                    var    set     = ItemSet.sheet.Find(s => s.id.ToLower().Contains(subname));
                    if (set != null)
                    {
                        foreach (var setItem in set.items)
                        {
                            ItemDrop.Drop(setItem, pos);
                        }
                    }
                    return;
                }

                var id = parts[1];

                var objectInfo = ObjectInfo.Find(id);
                if (objectInfo != null)
                {
                    var obj = WorldBuilder.SpawnObject(objectInfo, pos, fit: true);
                    if (obj != null && parts.Length > 2)
                    {
                        obj.modeName = parts[2];
                    }
                }
                else
                {
                    int monsterCount = parts.Length > 2 ? int.Parse(parts[2]) : 1;
                    for (int i = 0; i < monsterCount; ++i)
                    {
                        WorldBuilder.SpawnMonster(id, pos);
                    }
                }
            }
            else if (parts.Length == 2 && parts[0] == "/act")
            {
                if (int.TryParse(parts[1], out int actNumber))
                {
                    WorldBuilder.LoadAct(actNumber);
                }
            }
            else if (parts.Length == 2 && parts[0] == "/addstate")
            {
                string stateCode = parts[1];
                var    stateInfo = StateInfo.FindByCode(stateCode);
                if (stateInfo != null)
                {
                    var player = WorldState.instance.Player.gameObject;
                    Overlay.Create(player, stateInfo.castoverlay, loop: false);
                    Overlay.Create(player, stateInfo.overlay1, loop: true);
                    Overlay.Create(player, stateInfo.overlay2, loop: true);
                    Overlay.Create(player, stateInfo.overlay3, loop: true);
                    Overlay.Create(player, stateInfo.overlay4, loop: true);
                }
            }
            else
            {
                Debug.LogWarning(input);
            }
        }
예제 #7
0
        void ControlPlayerUnit()
        {
            if (player == null)
            {
                return;
            }

            DrawDebugPath();

            if (player.HandsItem != null)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Loot.Create(player.transform.position, player.HandsItem);
                    FlushInput();
                    player.HandsItem = null;
                }
                return;
            }

            usingSkills = false;
            for (int i = 0; i < hotSkills.Count; ++i)
            {
                SkillInfo skill = hotSkills[i];
                KeyCode   key   = hotSkillsBindings[i];
                if (skill == null || !Input.GetKey(key))
                {
                    continue;
                }

                usingSkills = true;
                if (MouseSelection.instance.HotEntity != null)
                {
                    var targetUnit = MouseSelection.instance.HotEntity.GetComponent <Unit>();
                    if (targetUnit != null)
                    {
                        player.unit.UseSkill(skill, targetUnit);
                    }
                    else
                    {
                        player.unit.UseSkill(skill, Iso.MapToIso(MouseSelection.instance.HotEntity.transform.position));
                    }
                }
                else
                {
                    player.unit.UseSkill(skill, IsoInput.mousePosition);
                }
            }

            if (!usingSkills)
            {
                if (Input.GetMouseButton(1) || (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButton(0)))
                {
                    player.unit.UseSkill(rightSkill, IsoInput.mousePosition);
                }
                else if (Input.GetMouseButton(0))
                {
                    if (MouseSelection.instance.HotEntity != null)
                    {
                        var targetUnit = MouseSelection.instance.HotEntity.GetComponent <Unit>();
                        if (targetUnit != null)
                        {
                            if (targetUnit.monStat != null && targetUnit.monStat.npc)
                            {
                                player.unit.Use(MouseSelection.instance.HotEntity);
                            }
                            else
                            {
                                player.unit.UseSkill(leftSkill, targetUnit);
                            }
                        }
                        else
                        {
                            player.unit.Use(MouseSelection.instance.HotEntity);
                        }
                    }
                    else
                    {
                        player.unit.GoTo(IsoInput.mousePosition);
                    }
                }
            }

            player.unit.run = run;
        }