Exemplo n.º 1
0
    public BaseData GetNextScenario()
    {
        #region 读取json文件
        if (index < fDatas.Count)
        {
            int type = fDatas[index].type;
            switch (type)
            {
            case 0:
                BaseData info1 = new SceneInfo();
                info1 = fDatas[index];
                index++;
                return(info1);

            case 1:
                BaseData info2 = new CharacterItem();
                info2 = fDatas[index];
                index++;
                return(info2);

            case 2:
                BaseData info3 = new SceneInfo();
                info3 = fDatas[index];
                index = 0;
                return(info3);

            default:
                break;
            }
        }
        return(null);

        #endregion
    }
Exemplo n.º 2
0
    /**
     * Adds an item to current user
     *
     * @param int id item id
     * @param int amount item quantity
     *
     * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        bool          success;
        CharacterItem characterItem = Service.getOne <CharacterItem>("FROM inventory WHERE item == ?", id);

        if (characterItem != null)
        {
            characterItem.quantity += amount;
            characterItem.save();
            success = true;
        }
        else
        {
            CharacterItem item = new CharacterItem {
                item     = id,
                quantity = amount
            };
            success = item.create();
        }
        // reload inventory
        if (success)
        {
            try {
                QuestManager.Instance.sendAction(id, Task.ActorType.Item, Task.ActionType.GetItem, amount);
                Inventory.Instance.reload();
            } catch (Exception) { }
        }

        return(success);
    }
        public override void ReceiveDamage(IAttackerEntity attacker, CharacterItem weapon, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts, CharacterBuff debuff, uint hitEffectsId)
        {
            if (!IsServer || IsDead() || !CanReceiveDamageFrom(attacker))
            {
                return;
            }

            base.ReceiveDamage(attacker, weapon, allDamageAmounts, debuff, hitEffectsId);
            var attackerCharacter = attacker as BaseCharacterEntity;

            // If character is not dead, try to attack
            if (!IsDead())
            {
                BaseCharacterEntity targetEntity;
                if (!TryGetTargetEntity(out targetEntity))
                {
                    // If no target enemy, set target enemy as attacker
                    SetAttackTarget(attackerCharacter);
                }
                else if (attackerCharacter != targetEntity && Random.value > 0.5f)
                {
                    // Random 50% to change target when receive damage from anyone
                    SetAttackTarget(attackerCharacter);
                }
            }
        }
Exemplo n.º 4
0
    public static CharacterItem GetRandomedWeapon(this ICharacterData data, out bool isLeftHand)
    {
        isLeftHand = false;
        // Find right hand and left and to set result weapon
        var rightHand       = data.EquipWeapons.rightHand;
        var leftHand        = data.EquipWeapons.leftHand;
        var rightWeaponItem = rightHand.GetWeaponItem();
        var leftWeaponItem  = leftHand.GetWeaponItem();

        if (rightWeaponItem != null && leftWeaponItem != null)
        {
            // Random right hand or left hand weapon
            isLeftHand = Random.Range(0, 1) == 1;
            return(!isLeftHand ? rightHand : leftHand);
        }
        else if (rightWeaponItem != null)
        {
            isLeftHand = false;
            return(rightHand);
        }
        else if (leftWeaponItem != null)
        {
            isLeftHand = true;
            return(leftHand);
        }
        return(CharacterItem.Create(GameInstance.Singleton.DefaultWeaponItem));
    }
Exemplo n.º 5
0
 public void Deserialize(NetDataReader reader)
 {
     // Right hand
     rightHand = (CharacterItem)reader.GetValue(typeof(CharacterItem));
     // Left hand
     leftHand = (CharacterItem)reader.GetValue(typeof(CharacterItem));
 }
Exemplo n.º 6
0
        public override float GetEquipmentBonusRate(CharacterItem characterItem)
        {
            if (characterItem.GetMaxDurability() <= 0)
            {
                return(1);
            }
            var durabilityRate = (float)characterItem.durability / (float)characterItem.GetMaxDurability();

            if (durabilityRate > 0.5f)
            {
                return(1f);
            }
            else if (durabilityRate > 0.3f)
            {
                return(0.75f);
            }
            else if (durabilityRate > 0.15f)
            {
                return(0.5f);
            }
            else if (durabilityRate > 0.05f)
            {
                return(0.25f);
            }
            else
            {
                return(0f);
            }
        }
Exemplo n.º 7
0
    void ReinforceItemSuccess()
    {
        if (ItemDataViewer.DefaultInstance.GetCurrentTargetItem().GetItemType() == Item.E_TYPE.EQUIPMENT)
        {
            EquipmentItem item  = m_Item as EquipmentItem;
            EquipmentItem titem = ItemDataViewer.DefaultInstance.GetCurrentTargetItem() as EquipmentItem;

            if (!item || !titem)
            {
                return;
            }

            titem.IncreaseReinforceCount(item.GetReinforceCount() + 1);
        }
        else if (ItemDataViewer.DefaultInstance.GetCurrentTargetItem().GetItemType() == Item.E_TYPE.CHARACTER)
        {
            CharacterItem item  = m_Item as CharacterItem;
            CharacterItem titem = ItemDataViewer.DefaultInstance.GetCurrentTargetItem() as CharacterItem;

            if (!item || !titem)
            {
                return;
            }

            titem.IncreaseReinforceCount(item.GetReinforceCount() + 1);
        }

        InventoryManager.Instance.DestroyItem(m_Item);
        InventoryViewer.RefreshAllSlots();
        ItemDataViewer.DefaultInstance.Refresh();
        m_LobbyCanvasUI.GetStatusUI().Refresh();
    }
Exemplo n.º 8
0
    internal void CollectedItem(CharacterItem item)
    {
        Vector2    pos = Camera.main.WorldToScreenPoint(item.transform.position);
        GameObject go  = GameObject.Instantiate(_bagChildPrefab, transform);

        go.transform.position = pos;
        Text text = go.GetComponentInChildren <Text>();

        text.text = item.Character.ToString();
        _bagChildItems[_bagChildItems.Count - 1].Show = false;
        foreach (var arrow in _arrows)
        {
            Color color = arrow.color;
            color.a = 0.1f;
            arrow.DOColor(color, 0.25f).OnComplete(() =>
            {
                color.a = 1f;
                arrow.DOColor(color, 0.25f).Play();
            }).Play();
        }
        go.transform.DOMove(RightBox.transform.position, 1f).OnComplete(() =>
        {
            _bagChildItems[_bagChildItems.Count - 1].Show = true;
            GameObject.Destroy(go);
        }).Play();
    }
Exemplo n.º 9
0
        /// <summary>
        /// This will be called on server to use item
        /// </summary>
        /// <param name="dataId"></param>
        protected virtual void NetFuncUseItem(short itemIndex)
        {
            if (!CanUseItem())
            {
                return;
            }

            if (itemIndex >= nonEquipItems.Count)
            {
                return;
            }

            CharacterItem characterItem = nonEquipItems[itemIndex];

            if (characterItem.IsLock())
            {
                return;
            }

            Item potionItem = characterItem.GetPotionItem();

            if (potionItem != null && this.DecreaseItemsByIndex(itemIndex, 1))
            {
                ApplyPotionBuff(potionItem, characterItem.level);
            }
            Item petItem = characterItem.GetPetItem();

            if (petItem != null && this.DecreaseItemsByIndex(itemIndex, 1))
            {
                ApplyItemPetSummon(petItem, characterItem.level, characterItem.exp);
            }
        }
Exemplo n.º 10
0
    IEnumerator Attack()
    {
        UserPiece = GameManager.ci;
        useskil   = true;
        AttackMethod();
        while (GameManager.state == GameState.InterruptPhase)
        {
            yield return(null);
        }
        useskil = false;
        AttackRecalc();
        while (GameManager.state == GameState.AttackReCulc)
        {
            yield return(null);
        }
        GameManager.DiceFix = 0;
        GameManager.DamFix  = 0;
        UserPiece           = null;
        SetTarget           = null;
        SetSkill            = null;

        thdice = 0;
        pname  = "";
        DestroyCheck();
    }
Exemplo n.º 11
0
        protected virtual void NetFuncSwapOrMergeNonEquipItems(short index1, short index2)
        {
            if (!CanDoActions() ||
                index1 >= nonEquipItems.Count ||
                index2 >= nonEquipItems.Count)
            {
                return;
            }

            CharacterItem nonEquipItem1 = nonEquipItems[index1];
            CharacterItem nonEquipItem2 = nonEquipItems[index2];

            if (nonEquipItem1.dataId == nonEquipItem2.dataId &&
                nonEquipItem1.NotEmptySlot() && nonEquipItem2.NotEmptySlot())
            {
                // Merge or swap
                if (nonEquipItem1.IsFull() || nonEquipItem2.IsFull())
                {
                    // Swap
                    NetFuncSwapNonEquipItems(index1, index2);
                }
                else
                {
                    // Merge
                    NetFuncMergeNonEquipItems(index1, index2);
                }
            }
            else
            {
                // Swap
                NetFuncSwapNonEquipItems(index1, index2);
            }
        }
Exemplo n.º 12
0
        protected void NetFuncMergeNonEquipItems(short index1, short index2)
        {
            if (!CanDoActions() ||
                index1 >= nonEquipItems.Count ||
                index2 >= nonEquipItems.Count)
            {
                return;
            }

            CharacterItem nonEquipItem1 = nonEquipItems[index1];
            CharacterItem nonEquipItem2 = nonEquipItems[index2];
            short         maxStack      = nonEquipItem2.GetMaxStack();

            if (nonEquipItem2.amount + nonEquipItem1.amount <= maxStack)
            {
                nonEquipItem2.amount += nonEquipItem1.amount;
                nonEquipItems[index2] = nonEquipItem2;
                nonEquipItems.RemoveAt(index1);
            }
            else
            {
                short mergeAmount = (short)(maxStack - nonEquipItem2.amount);
                nonEquipItem2.amount  = maxStack;
                nonEquipItem1.amount -= mergeAmount;
                nonEquipItems[index1] = nonEquipItem1;
                nonEquipItems[index2] = nonEquipItem2;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// This will be called at server to order character to unequip equipments
        /// </summary>
        /// <param name="fromEquipPosition"></param>
        protected virtual void NetFuncUnEquipItem(byte byteInventoryType, short index)
        {
            if (!CanDoActions())
            {
                return;
            }

            EquipWeapons  tempEquipWeapons = EquipWeapons;
            CharacterItem unEquipItem      = CharacterItem.Empty;

            switch ((InventoryType)byteInventoryType)
            {
            case InventoryType.EquipWeaponRight:
                unEquipItem = tempEquipWeapons.rightHand;
                tempEquipWeapons.rightHand = CharacterItem.Empty;
                EquipWeapons = tempEquipWeapons;
                break;

            case InventoryType.EquipWeaponLeft:
                unEquipItem = tempEquipWeapons.leftHand;
                tempEquipWeapons.leftHand = CharacterItem.Empty;
                EquipWeapons = tempEquipWeapons;
                break;

            case InventoryType.EquipItems:
                unEquipItem = equipItems[index];
                equipItems.RemoveAt(index);
                UpdateEquipItemIndexes();
                break;
            }
            if (unEquipItem.NotEmptySlot())
            {
                nonEquipItems.Add(unEquipItem);
            }
        }
Exemplo n.º 14
0
        private bool ReadCharacterItem(MySQLRowsReader reader, out CharacterItem result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result                     = new CharacterItem();
                result.id                  = reader.GetString("id");
                result.dataId              = reader.GetInt32("dataId");
                result.level               = reader.GetInt16("level");
                result.amount              = reader.GetInt16("amount");
                result.equipSlotIndex      = reader.GetByte("equipSlotIndex");
                result.durability          = reader.GetFloat("durability");
                result.exp                 = reader.GetInt32("exp");
                result.lockRemainsDuration = reader.GetFloat("lockRemainsDuration");
                result.ammo                = reader.GetInt16("ammo");
                result.sockets             = ReadSockets(reader.GetString("sockets"));
                return(true);
            }
            result = CharacterItem.Empty;
            return(false);
        }
Exemplo n.º 15
0
        public async UniTask <bool> IncreaseStorageItems(StorageId storageId, CharacterItem addingItem)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            Storage storge = GetStorage(storageId, out _);
            AsyncResponseData <IncreaseStorageItemsResp> resp = await DbServiceClient.IncreaseStorageItemsAsync(new IncreaseStorageItemsReq()
            {
                StorageType    = storageId.storageType,
                StorageOwnerId = storageId.storageOwnerId,
                WeightLimit    = storge.weightLimit,
                SlotLimit      = storge.slotLimit,
                Item           = addingItem,
            });

            if (!resp.IsSuccess || UITextKeys.NONE != resp.Response.Error)
            {
                // Error ocurring, storage may overwhelming let's it drop items to ground
                return(false);
            }
            SetStorageItems(storageId, resp.Response.StorageCharacterItems);
            NotifyStorageItemsUpdated(storageId.storageType, storageId.storageOwnerId);
            return(true);
#else
            return(false);
#endif
        }
Exemplo n.º 16
0
        public async Task <IActionResult> PutCharacterItem(long id, CharacterItem characterItem)
        {
            if (id != characterItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(characterItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CharacterItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 17
0
        private void SetupList(UIList list, DealingCharacterItems dealingItems, List <UICharacterItem> uiList)
        {
            CacheItemSelectionManager.DeselectSelectedUI();
            List <CharacterItem> filterItems = new List <CharacterItem>();

            foreach (DealingCharacterItem dealingItem in dealingItems)
            {
                CharacterItem characterItem = dealingItem.characterItem;
                filterItems.Add(characterItem);
            }
            uiList.Clear();
            list.Generate(filterItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), null, -1);
                uiCharacterItem.Show();
                uiList.Add(uiCharacterItem);
            });
            CacheItemSelectionManager.Clear();
            foreach (UICharacterItem tempDealingItemUI in tempDealingItemUIs)
            {
                CacheItemSelectionManager.Add(tempDealingItemUI);
            }
            foreach (UICharacterItem tempAnotherDealingItemUI in tempAnotherDealingItemUIs)
            {
                CacheItemSelectionManager.Add(tempAnotherDealingItemUI);
            }
        }
Exemplo n.º 18
0
 public void UseSkillButtonClick()
 {
     UseSkill    = skillList[selectSkill.value];
     TargetPiece = targetList[target.value];
     TypeSpritter();
     panel.SetActive(false);
 }
Exemplo n.º 19
0
        private void SetupList(UIList list, DealingCharacterItems dealingItems, List <UICharacterItem> uiList)
        {
            ItemSelectionManager.DeselectSelectedUI();
            var filterItems = new List <CharacterItem>();

            foreach (var dealingItem in dealingItems)
            {
                var characterItem = new CharacterItem();
                characterItem.dataId     = dealingItem.dataId;
                characterItem.level      = dealingItem.level;
                characterItem.amount     = dealingItem.amount;
                characterItem.durability = dealingItem.durability;
                filterItems.Add(characterItem);
            }
            uiList.Clear();
            list.Generate(filterItems, (index, characterItem, ui) =>
            {
                var uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, string.Empty), null, -1);
                uiCharacterItem.Show();
                uiList.Add(uiCharacterItem);
            });
            ItemSelectionManager.Clear();
            foreach (var tempDealingItemUI in tempDealingItemUIs)
            {
                ItemSelectionManager.Add(tempDealingItemUI);
            }
            foreach (var tempAnotherDealingItemUI in tempAnotherDealingItemUIs)
            {
                ItemSelectionManager.Add(tempAnotherDealingItemUI);
            }
        }
Exemplo n.º 20
0
        public async Task <ActionResult <CharacterItem> > PostCharacterItem(CharacterItem characterItem)
        {
            _context.CharacterItems.Add(characterItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCharacterItem), new { id = characterItem.Id }, characterItem));
        }
Exemplo n.º 21
0
        public static async Task <CharacterItem> DivideResourceAndSaveAsync(MainRepository repo, CharacterItem item, int resourceSize)
        {
            if (item.Resource <= resourceSize)
            {
                return(item);
            }

            item.Resource -= resourceSize;

            var newItem = new CharacterItem
            {
                Type        = item.Type,
                Status      = item.Status,
                CharacterId = item.CharacterId,
                TownId      = item.TownId,
                IntLastStatusChangedGameDate = item.IntLastStatusChangedGameDate,
                Resource = resourceSize,
            };

            await GenerateItemAndSaveAsync(repo, newItem);

            await StatusStreaming.Default.SendAllAsync(ApiData.From(newItem));

            await StatusStreaming.Default.SendAllAsync(ApiData.From(item));

            return(newItem);
        }
        private void ReceivedDamage_PvpGetGold(
            Vector3 fromPosition,
            IGameEntity attacker,
            CombatAmountType combatAmountType,
            int damage,
            CharacterItem weapon,
            BaseSkill skill,
            short skillLevel)
        {
            if (!IsServer)
            {
                return;
            }

            if (attacker == null || attacker.Entity == Entity || !(attacker.Entity is BasePlayerCharacterEntity))
            {
                return;
            }

            if (!this.IsDead())
            {
                return;
            }

            int rewardGold = 100;

            (attacker.Entity as BasePlayerCharacterEntity).RewardCurrencies(new Reward()
            {
                gold = rewardGold
            }, 1f, RewardGivenType.None);
        }
Exemplo n.º 23
0
        protected virtual void NetFuncBuyNpcItem(short itemIndex, short amount)
        {
            if (currentNpcDialog == null)
            {
                return;
            }
            NpcSellItem[] sellItems = currentNpcDialog.sellItems;
            if (sellItems == null || itemIndex >= sellItems.Length)
            {
                return;
            }
            NpcSellItem sellItem = sellItems[itemIndex];

            if (!gameplayRule.CurrenciesEnoughToBuyItem(this, sellItem, amount))
            {
                gameManager.SendServerGameMessage(ConnectionId, GameMessage.Type.NotEnoughGold);
                return;
            }
            int dataId = sellItem.item.DataId;

            if (this.IncreasingItemsWillOverwhelming(dataId, amount))
            {
                gameManager.SendServerGameMessage(ConnectionId, GameMessage.Type.CannotCarryAnymore);
                return;
            }
            gameplayRule.DecreaseCurrenciesWhenBuyItem(this, sellItem, amount);
            this.IncreaseItems(CharacterItem.Create(dataId, 1, amount));
        }
Exemplo n.º 24
0
        private IEnumerator MoveItemFromStorageRoutine(BasePlayerCharacterEntity playerCharacterEntity, StorageId storageId, short storageItemIndex, short amount, short nonEquipIndex)
        {
            List <CharacterItem> storageItemList     = new List <CharacterItem>();
            ReadStorageItemsJob  readStorageItemsJob = new ReadStorageItemsJob(Database, storageId.storageType, storageId.storageOwnerId);

            readStorageItemsJob.Start();
            yield return(StartCoroutine(readStorageItemsJob.WaitFor()));

            if (readStorageItemsJob.result != null)
            {
                // Set storage items
                storageItemList = readStorageItemsJob.result;
            }
            if (storageItemIndex < 0 || storageItemIndex >= storageItemList.Count)
            {
                // Don't do anything, if storage item index is invalid
            }
            else
            {
                // Prepare storage data
                Storage storage     = GetStorage(storageId);
                bool    isLimitSlot = storage.slotLimit > 0;
                short   slotLimit   = storage.slotLimit;
                // Prepare item data
                CharacterItem movingItem = storageItemList[storageItemIndex].Clone();
                movingItem.amount = amount;
                if (nonEquipIndex < 0 ||
                    nonEquipIndex >= playerCharacterEntity.NonEquipItems.Count ||
                    playerCharacterEntity.NonEquipItems[nonEquipIndex].IsEmptySlot() ||
                    playerCharacterEntity.NonEquipItems[nonEquipIndex].dataId == movingItem.dataId)
                {
                    // Add to inventory or merge
                    bool isOverwhelming = playerCharacterEntity.IncreasingItemsWillOverwhelming(movingItem.dataId, movingItem.amount);
                    if (!isOverwhelming && playerCharacterEntity.IncreaseItems(movingItem))
                    {
                        // Remove from storage
                        storageItemList.DecreaseItemsByIndex(storageItemIndex, amount);
                    }
                }
                else
                {
                    // Swapping
                    CharacterItem storageItem  = storageItemList[storageItemIndex];
                    CharacterItem nonEquipItem = playerCharacterEntity.NonEquipItems[nonEquipIndex];

                    storageItemList[storageItemIndex] = nonEquipItem;
                    playerCharacterEntity.NonEquipItems[nonEquipIndex] = storageItem;
                }
                storageItemList.FillEmptySlots(isLimitSlot, slotLimit);
            }
            // Update storage list immediately
            // TODO: Have to test about race condition while running multiple-server
            UpdateStorageItemsJob updateStorageItemsJob = new UpdateStorageItemsJob(Database, storageId.storageType, storageId.storageOwnerId, storageItemList);

            updateStorageItemsJob.Start();
            yield return(StartCoroutine(updateStorageItemsJob.WaitFor()));

            // Update storage items to characters that open the storage
            UpdateStorageItemsToCharacters(usingStorageCharacters[storageId], storageItemList);
        }
Exemplo n.º 25
0
 protected virtual void OnSelectCharacterClass(BaseCharacter baseCharacter)
 {
     eventOnSelectCharacterClass.Invoke(baseCharacter);
     PlayerCharacterByDataId.TryGetValue(baseCharacter.DataId, out selectedPlayerCharacter);
     if (SelectedPlayerCharacter != null)
     {
         // Set creating player character data
         SelectedDataId = baseCharacter.DataId;
         // Prepare equip items
         List <CharacterItem> equipItems = new List <CharacterItem>();
         foreach (Item armorItem in SelectedPlayerCharacter.armorItems)
         {
             if (armorItem == null)
             {
                 continue;
             }
             equipItems.Add(CharacterItem.Create(armorItem));
         }
         // Set model equip items
         SelectedModel.SetEquipItems(equipItems);
         // Prepare equip weapons
         EquipWeapons equipWeapons = new EquipWeapons();
         if (SelectedPlayerCharacter.rightHandEquipItem != null)
         {
             equipWeapons.rightHand = CharacterItem.Create(SelectedPlayerCharacter.rightHandEquipItem);
         }
         if (SelectedPlayerCharacter.leftHandEquipItem != null)
         {
             equipWeapons.leftHand = CharacterItem.Create(SelectedPlayerCharacter.leftHandEquipItem);
         }
         // Set model equip weapons
         SelectedModel.SetEquipWeapons(equipWeapons);
     }
 }
        private void ReceivedDamage_PvpGetGold(
            Vector3 fromPosition,
            IGameEntity attacker,
            CombatAmountType combatAmountType,
            int damage,
            CharacterItem weapon,
            BaseSkill skill,
            short skillLevel)
        {
            if (!IsServer)
            {
                return;
            }

            if (attacker == null || attacker.Entity == Entity || !(attacker.Entity is BasePlayerCharacterEntity))
            {
                return;
            }

            int rewardGold = 100;
            BasePlayerCharacterEntity character = (attacker.Entity as BasePlayerCharacterEntity);

            if (!this.IsDead())
            {
                return;
            }

            character.Gold = character.Gold.Increase(rewardGold);
            GameInstance.ServerGameMessageHandlers.NotifyRewardGold(character.ConnectionId, rewardGold);
        }
    public static CharacterItem GetAvailableWeapon(this ICharacterData data, ref bool isLeftHand)
    {
        CharacterItem rightHand       = data.EquipWeapons.rightHand;
        Item          rightWeaponItem = rightHand.GetWeaponItem();
        CharacterItem leftHand        = data.EquipWeapons.leftHand;
        Item          leftWeaponItem  = leftHand.GetWeaponItem();

        if (!isLeftHand)
        {
            if (rightWeaponItem != null)
            {
                return(rightHand);
            }
            if (rightWeaponItem == null && leftWeaponItem != null)
            {
                isLeftHand = true;
                return(leftHand);
            }
        }
        else
        {
            if (leftWeaponItem != null)
            {
                return(leftHand);
            }
            if (leftWeaponItem == null && rightWeaponItem != null)
            {
                isLeftHand = false;
                return(rightHand);
            }
        }
        isLeftHand = false;
        return(CharacterItem.Create(GameInstance.Singleton.DefaultWeaponItem));
    }
Exemplo n.º 28
0
        protected virtual void NetFuncSellItem(short index, short amount)
        {
            if (IsDead() ||
                index >= nonEquipItems.Count)
            {
                return;
            }

            if (currentNpcDialog == null || currentNpcDialog.type != NpcDialogType.Shop)
            {
                return;
            }

            CharacterItem nonEquipItem = nonEquipItems[index];

            if (!nonEquipItem.NotEmptySlot() || amount > nonEquipItem.amount)
            {
                return;
            }

            Item item = nonEquipItem.GetItem();

            if (this.DecreaseItemsByIndex(index, amount))
            {
                gameplayRule.IncreaseCurrenciesWhenSellItem(this, item, amount);
            }
        }
Exemplo n.º 29
0
        public static async Task SetCharacterPendingAsync(MainRepository repo, CharacterItem item, Character chara)
        {
            if (item.Status == CharacterItemStatus.CharacterHold || item.Status == CharacterItemStatus.CharacterPending)
            {
                if (item.CharacterId == chara.Id)
                {
                    return;
                }

                var oldChara = await repo.Character.GetByIdAsync(item.CharacterId);

                if (oldChara.HasData)
                {
                    await ReleaseCharacterAsync(repo, item, oldChara.Data);
                }
            }

            var system = await repo.System.GetAsync();

            item.Status      = CharacterItemStatus.CharacterPending;
            item.CharacterId = chara.Id;
            item.TownId      = 0;
            item.LastStatusChangedGameDate = system.GameDateTime;

            await CharacterService.StreamCharacterAsync(repo, chara);

            await StatusStreaming.Default.SendAllAsync(ApiData.From(item));
        }
Exemplo n.º 30
0
        protected virtual void NetFuncSetDealingItem(short itemIndex, short amount)
        {
            if (DealingState != DealingState.Dealing)
            {
                gameManager.SendServerGameMessage(ConnectionId, GameMessage.Type.InvalidDealingState);
                return;
            }

            if (itemIndex >= nonEquipItems.Count)
            {
                return;
            }

            DealingCharacterItems dealingItems = DealingItems;

            for (int i = dealingItems.Count - 1; i >= 0; --i)
            {
                if (itemIndex == dealingItems[i].nonEquipIndex)
                {
                    dealingItems.RemoveAt(i);
                    break;
                }
            }
            CharacterItem characterItem = nonEquipItems[itemIndex].Clone();

            characterItem.amount = amount;
            DealingCharacterItem dealingItem = new DealingCharacterItem();

            dealingItem.nonEquipIndex = itemIndex;
            dealingItem.characterItem = characterItem;
            dealingItems.Add(dealingItem);
            // Update to clients
            DealingItems = dealingItems;
        }
Exemplo n.º 31
0
	void Awake()
	{
		_charStatus = GetComponent<CharacterStatus> ();
		_charMotor = GetComponent<CharacterMotor> ();
		_charItem = GetComponent<CharacterItem> ();
		anim = GetComponent<Animator> ();
		_myAgent = GetComponentInChildren<NavMeshAgent> ();
	}
Exemplo n.º 32
0
    public int guardButtonPressed { get; private set; } // CharacterStatus accesses this when recovering from stun so we need it public.

    void Awake()
	{
		_anim = GetComponent<Animator> ();
		_charStatus = GetComponent<CharacterStatus> ();
		_charMotor = GetComponent<CharacterMotor>();
		_charAttacking = GetComponent<CharacterAttacking> ();
		_charItem = GetComponent<CharacterItem> ();
	}
Exemplo n.º 33
0
 public static void insertTestItems()
 {
     CharacterItem item = new CharacterItem ();
     item.id = 1;
     item.item = 1;
     item.character = 1;
     item.quantity = 2;
     item.create();
 }
 public void Initilize(CharacterItem itemToSpawn)
 {
     //Debug.Log("Spawning: " + itemToSpawn.ToString());
     //Load from resources here;
     GameObject characterItemPrefab =
         (GameObject)
         Instantiate(Resources.Load(PREFAB_FOLDER + itemToSpawn), transform.position, transform.rotation);
     Item characterItem = characterItemPrefab.GetComponent<Item>();
     if(!characterItem)
     {
         Debug.LogError("Item Prefab missing Item component in " +itemToSpawn.ToString() );
         return;
     }
     PossibleSpawns.Remove(this);
     characterItem.mAreaSpawn = spawnArea;
     Destroy(gameObject);
 }
    public void SpawnItem(CharacterItem ItemToSpawn)
    {
        //Get random spawn point
        if(ItemToSpawn != null)
        {
            //Debug.Log("Spawning Item: " + ItemToSpawn);
            ItemSpawnPoint point;

            if(ItemSpawnPoint.PossibleSpawns.Count > 1)
            {
                int index = new Random().Next(0, ItemSpawnPoint.PossibleSpawns.Count - 1);
                point = ItemSpawnPoint.PossibleSpawns[index];
                point.Initilize(ItemToSpawn);
            }
        }
    }
Exemplo n.º 36
0
    /**
    * Adds an item to current user
    *
    * @param int id item id
    * @param int amount item quantity
    *
    * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        bool success;
        CharacterItem characterItem = Service.getOne<CharacterItem>("FROM inventory WHERE item == ?", id);

        if (characterItem != null) {
            characterItem.quantity += amount;
            characterItem.save();
            success = true;
        } else {
            CharacterItem item = new CharacterItem {
                item = id,
                quantity = amount
            };
            success = item.create ();
        }
        Debug.Log(success);
        // reload inventory
        if (success) {
            try {
                Inventory.Instance.reload();
            } catch (Exception) {}
        }

        return success;
    }
Exemplo n.º 37
0
    /**
    * Adds an item to current user
    *
    * @param int id item id
    * @param int amount item quantity
    *
    * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        CharacterItem item = new CharacterItem {
            item = id,
            quantity = amount
        };
        bool success = item.create ();

        // reload inventory
        if (success) {
            try {
                Inventory.Instance.reload();
            } catch (Exception) {}
        }

        return success;
    }
Exemplo n.º 38
0
 public void AddBagItem(CharacterItem ci)
 {
     BagItems.Add (ci);
 }
Exemplo n.º 39
0
	public float StrafeDir { get { return _strafeDir; } } // Current amount we are strafing.

	void Awake()
	{
		_charStatus = GetComponent<CharacterStatus> ();
		_charMotor = GetComponent<CharacterMotor> ();
		_charAttacking = GetComponent<CharacterAttacking> ();
		_charItem = GetComponent<CharacterItem> ();
		Agent = GetComponentInChildren<NavMeshAgent> ();
		Agent.stoppingDistance = 0.1f; // default distance to stop from a target that I use.
	}
Exemplo n.º 40
0
 public Item get(CharacterItem cItem)
 {
     Item itm = Service.db.SelectKey<Item> ("item", cItem.item);
     itm.characterItem = cItem;
     return itm;
 }
Exemplo n.º 41
0
 /**
  * Validate if this item can be set on the select equipment position
  *
  */
 public bool isValidEquipmentPosition(CharacterItem.equipmentPosition pos)
 {
     switch (type) {
         case ItemType.Weapon:
                 if (pos == CharacterItem.equipmentPosition.handLeft || pos == CharacterItem.equipmentPosition.handRight) {
                     return true;
                 }
             break;
         case ItemType.Armor:
             switch (subType) {
                 case ItemSubType.Head:
                         if (pos == CharacterItem.equipmentPosition.head) {
                             return true;
                         }
                     break;
                     case ItemSubType.Hands:
                         if (pos == CharacterItem.equipmentPosition.hands) {
                             return true;
                         }
                     break;
             }
             break;
         case ItemType.Consumable:
         case ItemType.Container:
         case ItemType.Useless:
             return false;
     }
     return false;
 }