Exemple #1
0
        protected void UseSkill(string id, Vector3?aimPosition)
        {
            BaseSkill skill      = null;
            short     skillLevel = 0;

            if (!GameInstance.Skills.TryGetValue(BaseGameData.MakeDataId(id), out skill) || skill == null ||
                !PlayerCharacterEntity.GetCaches().Skills.TryGetValue(skill, out skillLevel))
            {
                return;
            }

            bool isAttackSkill = skill.IsAttack();

            if (!aimPosition.HasValue)
            {
                if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking) && isAttackSkill)
                {
                    // Requested to use attack skill then change attacking hand
                    isLeftHandAttacking = !isLeftHandAttacking;
                }
            }
            else
            {
                if (PlayerCharacterEntity.RequestUseSkill(skill.DataId, isLeftHandAttacking, aimPosition.Value) && isAttackSkill)
                {
                    // Requested to use attack skill then change attacking hand
                    isLeftHandAttacking = !isLeftHandAttacking;
                }
            }
        }
Exemple #2
0
        protected override void UpdateData()
        {
            BaseGameData buffData = null;

            switch (Data.type)
            {
            case BuffType.SkillBuff:
            case BuffType.SkillDebuff:
                buffData = Data.GetSkill();
                break;

            case BuffType.PotionBuff:
                buffData = Data.GetItem();
                break;

            case BuffType.GuildSkillBuff:
                buffData = Data.GetGuildSkill();
                break;
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(
                    LanguageManager.GetText(formatKeyTitle),
                    buffData == null ? LanguageManager.GetUnknowTitle() : buffData.Title);
            }

            if (imageIcon != null)
            {
                Sprite iconSprite = buffData == null ? null : buffData.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiBuff != null)
            {
                if (buffData == null)
                {
                    uiBuff.Hide();
                }
                else
                {
                    Buff buff = Data.GetBuff();
                    uiBuff.Show();
                    uiBuff.Data = new BuffTuple(buff, Data.level);
                }
            }
        }
Exemple #3
0
        protected void UseSkill(string id, AimPosition aimPosition)
        {
            BaseSkill skill;

            if (!GameInstance.Skills.TryGetValue(BaseGameData.MakeDataId(id), out skill) || skill == null ||
                !PlayerCharacterEntity.GetCaches().Skills.TryGetValue(skill, out _))
            {
                return;
            }

            bool isAttackSkill = skill.IsAttack();

            if (PlayerCharacterEntity.UseSkill(skill.DataId, isLeftHandAttacking, SelectedEntityObjectId, aimPosition) && isAttackSkill)
            {
                isLeftHandAttacking = !isLeftHandAttacking;
            }
        }
        protected override void UpdateData()
        {
            BaseGameData summonData = null;

            switch (Data.type)
            {
            case SummonType.Skill:
                onTypeIsSkill.Invoke();
                summonData = Data.GetSkill();
                break;

            case SummonType.Pet:
                onTypeIsPet.Invoke();
                summonData = Data.GetPetItem();
                break;
            }

            if (uiTextTitle != null)
            {
                uiTextTitle.text = string.Format(
                    LanguageManager.GetText(formatKeyTitle),
                    summonData == null ? LanguageManager.GetUnknowTitle() : summonData.Title);
            }

            if (imageIcon != null)
            {
                Sprite iconSprite = summonData == null ? null : summonData.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiCharacter != null)
            {
                if (summonData == null)
                {
                    uiCharacter.Hide();
                }
                else
                {
                    uiCharacter.Show();
                    uiCharacter.Data = Data.CacheEntity;
                }
            }
        }
Exemple #5
0
        protected void UseItem(string id, AimPosition aimPosition)
        {
            int      itemIndex;
            BaseItem item;
            int      dataId = BaseGameData.MakeDataId(id);

            if (GameInstance.Items.ContainsKey(dataId))
            {
                item      = GameInstance.Items[dataId];
                itemIndex = OwningCharacter.IndexOfNonEquipItem(dataId);
            }
            else
            {
                InventoryType inventoryType;
                byte          equipWeaponSet;
                CharacterItem characterItem;
                if (PlayerCharacterEntity.IsEquipped(
                        id,
                        out inventoryType,
                        out itemIndex,
                        out equipWeaponSet,
                        out characterItem))
                {
                    GameInstance.ClientInventoryHandlers.RequestUnEquipItem(
                        inventoryType,
                        (short)itemIndex,
                        equipWeaponSet,
                        -1,
                        ClientInventoryActions.ResponseUnEquipArmor,
                        ClientInventoryActions.ResponseUnEquipWeapon);
                    return;
                }
                item = characterItem.GetItem();
            }

            if (itemIndex < 0)
            {
                return;
            }

            if (item == null)
            {
                return;
            }

            if (item.IsEquipment())
            {
                GameInstance.ClientInventoryHandlers.RequestEquipItem(
                    PlayerCharacterEntity,
                    (short)itemIndex,
                    ClientInventoryActions.ResponseEquipArmor,
                    ClientInventoryActions.ResponseEquipWeapon);
            }
            else if (item.IsSkill())
            {
                bool isAttackSkill = (item as ISkillItem).UsingSkill.IsAttack();
                if (PlayerCharacterEntity.UseSkillItem((short)itemIndex, isLeftHandAttacking, SelectedEntityObjectId, aimPosition) && isAttackSkill)
                {
                    isLeftHandAttacking = !isLeftHandAttacking;
                }
            }
            else if (item.IsBuilding())
            {
                buildingItemIndex = itemIndex;
                ShowConstructBuildingDialog();
            }
            else if (item.IsUsable())
            {
                PlayerCharacterEntity.CallServerUseItem((short)itemIndex);
            }
        }