Пример #1
0
        protected override void UpdateUI()
        {
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (owningCharacter != null &&
                Level < GuildSkill.GetMaxLevel() &&
                owningCharacter.gameManager.ClientGuild != null &&
                owningCharacter.gameManager.ClientGuild.IsLeader(owningCharacter) &&
                owningCharacter.gameManager.ClientGuild.skillPoint > 0)
            {
                onAbleToLevelUp.Invoke();
            }
            else
            {
                onUnableToLevelUp.Invoke();
            }

            if (owningCharacter != null &&
                Level > 1 &&
                GuildSkill.skillType == GuildSkillType.Active)
            {
                onAbleToUse.Invoke();
            }
            else
            {
                onUnableToUse.Invoke();
            }
        }
Пример #2
0
        public bool HaveNewQuests(BasePlayerCharacterEntity playerCharacterEntity)
        {
            if (playerCharacterEntity == null)
            {
                return(false);
            }
            var clearedQuests = new List <int>();

            foreach (var characterQuest in playerCharacterEntity.Quests)
            {
                var quest = characterQuest.GetQuest();
                if (quest != null && characterQuest.isComplete)
                {
                    clearedQuests.Add(quest.DataId);
                }
            }
            foreach (var questId in questIds)
            {
                if (!clearedQuests.Contains(questId))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public static void AddCharacterEntities(IEnumerable <BaseCharacterEntity> characterEntities)
        {
            if (characterEntities == null)
            {
                return;
            }
            foreach (BaseCharacterEntity characterEntity in characterEntities)
            {
                if (characterEntity == null || AllCharacterEntities.ContainsKey(characterEntity.Identity.HashAssetId))
                {
                    continue;
                }

                AllCharacterEntities[characterEntity.Identity.HashAssetId] = characterEntity;
                if (characterEntity is BasePlayerCharacterEntity)
                {
                    BasePlayerCharacterEntity playerCharacterEntity = characterEntity as BasePlayerCharacterEntity;
                    PlayerCharacterEntities[characterEntity.Identity.HashAssetId] = playerCharacterEntity;
                }
                else if (characterEntity is BaseMonsterCharacterEntity)
                {
                    BaseMonsterCharacterEntity monsterCharacterEntity = characterEntity as BaseMonsterCharacterEntity;
                    MonsterCharacterEntities[characterEntity.Identity.HashAssetId] = monsterCharacterEntity;
                }
            }
        }
Пример #4
0
        public virtual void LeaveGuild(BasePlayerCharacterEntity playerCharacterEntity)
        {
            int       guildId;
            GuildData guild;

            if (!CanLeaveGuild(playerCharacterEntity, out guildId, out guild))
            {
                return;
            }

            if (guild.IsLeader(playerCharacterEntity))
            {
                foreach (var memberId in guild.GetMemberIds())
                {
                    BasePlayerCharacterEntity memberCharacterEntity;
                    if (playerCharactersById.TryGetValue(memberId, out memberCharacterEntity))
                    {
                        memberCharacterEntity.ClearGuild();
                        SendGuildTerminateToClient(memberCharacterEntity.ConnectionId, guildId);
                    }
                }
                guilds.Remove(guildId);
            }
            else
            {
                playerCharacterEntity.ClearGuild();
                SendGuildTerminateToClient(playerCharacterEntity.ConnectionId, guildId);
                guild.RemoveMember(playerCharacterEntity.Id);
                guilds[guildId] = guild;
                SendRemoveGuildMemberToClients(guild, playerCharacterEntity.Id);
            }
        }
Пример #5
0
        protected override void UpdateUI()
        {
            Profiler.BeginSample("UINpcEntity - Update UI");
            if (Data == null || BasePlayerCharacterController.OwningCharacter == null)
            {
                CacheCanvas.enabled = false;
                return;
            }

            tempOwningCharacter = BasePlayerCharacterController.OwningCharacter;
            NpcEntity targetNpc;

            if (Vector3.Distance(tempOwningCharacter.CacheTransform.position, Data.CacheTransform.position) > visibleDistance)
            {
                CacheCanvas.enabled = false;
            }
            else if (tempOwningCharacter.TryGetTargetEntity(out targetNpc) && targetNpc.ObjectId == Data.ObjectId)
            {
                CacheCanvas.enabled = true;
            }
            else
            {
                CacheCanvas.enabled = false;
            }
            Profiler.EndSample();
        }
        public override void OpenStorage(BasePlayerCharacterEntity playerCharacterEntity)
        {
            if (!CanAccessStorage(playerCharacterEntity, playerCharacterEntity.CurrentStorageId))
            {
                SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.CannotAccessStorage);
                return;
            }
            if (!storageItems.ContainsKey(playerCharacterEntity.CurrentStorageId))
            {
                storageItems[playerCharacterEntity.CurrentStorageId] = new List <CharacterItem>();
            }
            if (!usingStorageCharacters.ContainsKey(playerCharacterEntity.CurrentStorageId))
            {
                usingStorageCharacters[playerCharacterEntity.CurrentStorageId] = new HashSet <uint>();
            }
            usingStorageCharacters[playerCharacterEntity.CurrentStorageId].Add(playerCharacterEntity.ObjectId);
            // Prepare storage data
            Storage storage     = GetStorage(playerCharacterEntity.CurrentStorageId);
            bool    isLimitSlot = storage.slotLimit > 0;
            short   slotLimit   = storage.slotLimit;

            CharacterDataExtension.FillEmptySlots(storageItems[playerCharacterEntity.CurrentStorageId], isLimitSlot, slotLimit);
            // Update storage items
            playerCharacterEntity.StorageItems = storageItems[playerCharacterEntity.CurrentStorageId];
        }
        private void SaveWorld()
        {
            // Save building entities / Tree / Rocks
            BasePlayerCharacterEntity playerCharacterEntity = BasePlayerCharacterController.OwningCharacter;

            worldSaveData.buildings.Clear();
            foreach (BuildingEntity buildingEntity in buildingEntities.Values)
            {
                if (buildingEntity == null)
                {
                    continue;
                }
                worldSaveData.buildings.Add(new BuildingSaveData()
                {
                    Id          = buildingEntity.Id,
                    ParentId    = buildingEntity.ParentId,
                    DataId      = buildingEntity.DataId,
                    Position    = buildingEntity.Position,
                    Rotation    = buildingEntity.Rotation,
                    CurrentHp   = buildingEntity.CurrentHp,
                    CreatorId   = buildingEntity.CreatorId,
                    CreatorName = buildingEntity.CreatorName,
                });
            }
            worldSaveData.SavePersistentData(playerCharacterEntity.Id, playerCharacterEntity.CurrentMapName);
        }
Пример #8
0
 public virtual bool CanSetGuildRole(BasePlayerCharacterEntity playerCharacterEntity, byte guildRole, out int guildId, out GuildData guild)
 {
     guildId = 0;
     guild   = null;
     if (playerCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     guildId = playerCharacterEntity.GuildId;
     if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotJoinedGuild);
         return(false);
     }
     if (!guild.IsLeader(playerCharacterEntity))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotGuildLeader);
         return(false);
     }
     if (!guild.IsRoleAvailable(guildRole))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.GuildRoleNotAvailable);
         return(false);
     }
     return(true);
 }
Пример #9
0
        public override void Show()
        {
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;
            SocialSystemSetting       systemSetting   = GameInstance.Singleton.SocialSystemSetting;

            if (textRequireGold != null)
            {
                int currentAmount = 0;
                if (owningCharacter != null)
                {
                    currentAmount = owningCharacter.Gold;
                }
                textRequireGold.text = string.Format(
                    LanguageManager.GetText(formatKeyRequireGold),
                    currentAmount,
                    systemSetting.CreateGuildRequiredGold.ToString("N0"));
            }

            if (uiRequireItems != null)
            {
                uiRequireItems.showAsRequirement = true;
                uiRequireItems.Data = systemSetting.CacheCreateGuildRequireItems;
            }

            base.Show();
        }
Пример #10
0
 public virtual bool CanAddGuildMember(BasePlayerCharacterEntity inviteCharacterEntity, BasePlayerCharacterEntity acceptCharacterEntity, out int guildId, out GuildData guild)
 {
     guildId = 0;
     guild   = null;
     if (inviteCharacterEntity == null || acceptCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     if (acceptCharacterEntity.GuildId > 0)
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.JoinedAnotherGuild);
         return(false);
     }
     guildId = inviteCharacterEntity.GuildId;
     if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild))
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.CharacterNotJoinedGuild);
         return(false);
     }
     if (guild.CountMember() >= guild.MaxMember())
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.GuildMemberReachedLimit);
         return(false);
     }
     return(true);
 }
Пример #11
0
 public virtual bool CanAddGuildSkill(BasePlayerCharacterEntity playerCharacterEntity, int dataId, out int guildId, out GuildData guild)
 {
     guildId = 0;
     guild   = null;
     if (playerCharacterEntity == null || !IsServer || !GameInstance.GuildSkills.ContainsKey(dataId))
     {
         return(false);
     }
     guildId = playerCharacterEntity.GuildId;
     if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild))
     {
         return(false);
     }
     if (!guild.IsLeader(playerCharacterEntity))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotGuildLeader);
         return(false);
     }
     if (guild.IsSkillReachedMaxLevel(dataId))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.GuildSkillReachedMaxLevel);
         return(false);
     }
     if (guild.skillPoint <= 0)
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NoGuildSkillPoint);
         return(false);
     }
     return(true);
 }
        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);
        }
        private bool AddEntity(GameObject other)
        {
            BasePlayerCharacterEntity  player  = null;
            BaseMonsterCharacterEntity monster = null;
            NpcEntity      npc      = null;
            ItemDropEntity itemDrop = null;
            BuildingEntity building = null;

            FindEntity(other, out player, out monster, out npc, out itemDrop, out building);

            if (player != null)
            {
                if (!characters.Contains(player))
                {
                    characters.Add(player);
                }
                if (!players.Contains(player))
                {
                    players.Add(player);
                }
                return(true);
            }
            if (monster != null)
            {
                if (!characters.Contains(monster))
                {
                    characters.Add(monster);
                }
                if (!monsters.Contains(monster))
                {
                    monsters.Add(monster);
                }
                return(true);
            }
            if (npc != null)
            {
                if (!npcs.Contains(npc))
                {
                    npcs.Add(npc);
                }
                return(true);
            }
            if (building != null)
            {
                if (!buildings.Contains(building))
                {
                    buildings.Add(building);
                }
                return(true);
            }
            if (itemDrop != null)
            {
                if (!itemDrops.Contains(itemDrop))
                {
                    itemDrops.Add(itemDrop);
                }
                return(true);
            }
            return(false);
        }
Пример #14
0
 public virtual bool CanChangeGuildLeader(BasePlayerCharacterEntity playerCharacterEntity, string characterId, out int guildId, out GuildData guild)
 {
     guildId = 0;
     guild   = null;
     if (playerCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     guildId = playerCharacterEntity.GuildId;
     if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotJoinedGuild);
         return(false);
     }
     if (!guild.IsLeader(playerCharacterEntity))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotGuildLeader);
         return(false);
     }
     if (!guild.ContainsMemberId(characterId))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.CharacterNotJoinedGuild);
         return(false);
     }
     return(true);
 }
Пример #15
0
        public bool HaveInProgressQuests(BasePlayerCharacterEntity playerCharacterEntity)
        {
            if (playerCharacterEntity == null)
            {
                return(false);
            }
            List <int> inProgressQuests = new List <int>();

            foreach (CharacterQuest characterQuest in playerCharacterEntity.Quests)
            {
                Quest quest = characterQuest.GetQuest();
                if (quest != null && !characterQuest.isComplete)
                {
                    inProgressQuests.Add(quest.DataId);
                }
            }
            foreach (int questId in questIds)
            {
                if (inProgressQuests.Contains(questId))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #16
0
 public virtual bool CanAddPartyMember(BasePlayerCharacterEntity inviteCharacterEntity, BasePlayerCharacterEntity acceptCharacterEntity, out int partyId, out PartyData party)
 {
     partyId = 0;
     party   = null;
     if (inviteCharacterEntity == null || acceptCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     if (acceptCharacterEntity.PartyId > 0)
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.JoinedAnotherParty);
         return(false);
     }
     partyId = inviteCharacterEntity.PartyId;
     if (partyId <= 0 || !parties.TryGetValue(partyId, out party))
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.CharacterNotJoinedParty);
         return(false);
     }
     if (party.CountMember() >= party.MaxMember())
     {
         SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.PartyMemberReachedLimit);
         return(false);
     }
     return(true);
 }
        public override void OnEndDrag(PointerEventData eventData)
        {
            base.OnEndDrag(eventData);
            if (isDropped || !CanDrag)
            {
                return;
            }
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (owningCharacter == null)
            {
                return;
            }
            if (sourceLocation == SourceLocation.NonEquipItems && !EventSystem.current.IsPointerOverGameObject())
            {
                uiCharacterItem.OnClickDrop();
            }
            if (sourceLocation == SourceLocation.EquipItems && EventSystem.current.IsPointerOverGameObject())
            {
                uiCharacterItem.OnClickUnEquip();
            }
            if (sourceLocation == SourceLocation.StorageItems)
            {
                uiCharacterItem.OnClickMoveFromStorage();
            }
            if (sourceLocation == SourceLocation.Hotkey)
            {
                owningCharacter.RequestAssignHotkey(uiCharacterHotkey.hotkeyId, HotkeyType.None, 0);
            }
        }
Пример #18
0
        public virtual void LeaveParty(BasePlayerCharacterEntity playerCharacterEntity)
        {
            int       partyId;
            PartyData party;

            if (!CanLeaveParty(playerCharacterEntity, out partyId, out party))
            {
                return;
            }

            if (party.IsLeader(playerCharacterEntity))
            {
                foreach (var memberId in party.GetMemberIds())
                {
                    BasePlayerCharacterEntity memberCharacterEntity;
                    if (playerCharactersById.TryGetValue(memberId, out memberCharacterEntity))
                    {
                        memberCharacterEntity.ClearParty();
                        SendPartyTerminateToClient(memberCharacterEntity.ConnectionId, partyId);
                    }
                }
                parties.Remove(partyId);
            }
            else
            {
                playerCharacterEntity.ClearParty();
                SendPartyTerminateToClient(playerCharacterEntity.ConnectionId, partyId);
                party.RemoveMember(playerCharacterEntity.Id);
                parties[partyId] = party;
                SendRemovePartyMemberToClients(party, playerCharacterEntity.Id);
            }
        }
        void AddCharacter(GameObject gameObject)
        {
            if (!BaseGameNetworkManager.Singleton.IsServer)
            {
                return;
            }

            tempPlayerCharacterEntity = gameObject.GetComponent <BasePlayerCharacterEntity>();
            if (tempPlayerCharacterEntity != null &&
                !characterObjectIds.Contains(tempPlayerCharacterEntity.ObjectId))
            {
                int indexOfQuest = tempPlayerCharacterEntity.IndexOfQuest(quest.DataId);
                if (indexOfQuest >= 0 &&
                    !tempPlayerCharacterEntity.Quests[indexOfQuest].isComplete &&
                    !tempPlayerCharacterEntity.Quests[indexOfQuest].IsAllTasksDone(tempPlayerCharacterEntity))
                {
                    // Add characters which has quest, and quest is not complete yet
                    characterObjectIds.Add(tempPlayerCharacterEntity.ObjectId);
                    if (monsterEntities.Count == 0)
                    {
                        // Will spawn all monsters when there is no monsters, and character is only 1 character in list
                        SpawnAll();
                    }
                }
            }
        }
        private bool RemoveEntity(GameObject other)
        {
            BasePlayerCharacterEntity  player  = null;
            BaseMonsterCharacterEntity monster = null;
            NpcEntity      npc      = null;
            ItemDropEntity itemDrop = null;
            BuildingEntity building = null;

            FindEntity(other, out player, out monster, out npc, out itemDrop, out building, false);

            if (player != null)
            {
                return(characters.Remove(player) && players.Remove(player));
            }
            if (monster != null)
            {
                return(characters.Remove(monster) && monsters.Remove(monster));
            }
            if (npc != null)
            {
                return(npcs.Remove(npc));
            }
            if (itemDrop != null)
            {
                return(itemDrops.Remove(itemDrop));
            }
            if (building != null)
            {
                return(buildings.Remove(building));
            }
            return(false);
        }
Пример #21
0
        public virtual bool CanSendPartyInvitation(BasePlayerCharacterEntity inviteCharacterEntity, uint objectId, out BasePlayerCharacterEntity targetCharacterEntity)
        {
            targetCharacterEntity = null;
            var       partyId = inviteCharacterEntity.PartyId;
            PartyData party;

            if (partyId <= 0 || !parties.TryGetValue(partyId, out party))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.NotJoinedParty);
                return(false);
            }
            if (!party.CanInvite(inviteCharacterEntity.Id))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CannotSendPartyInvitation);
                return(false);
            }
            if (!inviteCharacterEntity.TryGetEntityByObjectId(objectId, out targetCharacterEntity))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.NotFoundCharacter);
                return(false);
            }
            if (targetCharacterEntity.CoCharacter != null)
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CharacterIsInAnotherDeal);
                return(false);
            }
            if (targetCharacterEntity.PartyId > 0)
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CharacterJoinedAnotherParty);
                return(false);
            }
            return(true);
        }
Пример #22
0
        public virtual bool CanSendGuildInvitation(BasePlayerCharacterEntity inviteCharacterEntity, uint objectId, out BasePlayerCharacterEntity targetCharacterEntity)
        {
            targetCharacterEntity = null;
            var       guildId = inviteCharacterEntity.GuildId;
            GuildData guild;

            if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.NotJoinedGuild);
                return(false);
            }
            if (!guild.CanInvite(inviteCharacterEntity.Id))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CannotSendGuildInvitation);
                return(false);
            }
            if (!inviteCharacterEntity.TryGetEntityByObjectId(objectId, out targetCharacterEntity))
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.NotFoundCharacter);
                return(false);
            }
            if (targetCharacterEntity.CoCharacter != null)
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CharacterIsInAnotherDeal);
                return(false);
            }
            if (targetCharacterEntity.GuildId > 0)
            {
                SendServerGameMessage(inviteCharacterEntity.ConnectionId, GameMessage.Type.CharacterJoinedAnotherGuild);
                return(false);
            }
            return(true);
        }
 public void OnDrop(PointerEventData eventData)
 {
     if (RectTransformUtility.RectangleContainsScreenPoint(DropRect, Input.mousePosition))
     {
         UIDragHandler dragHandler = eventData.pointerDrag.GetComponent <UIDragHandler>();
         if (dragHandler != null && !dragHandler.isDropped)
         {
             dragHandler.isDropped = true;
             // Get owing character
             BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;
             if (owningCharacter == null)
             {
                 return;
             }
             UICharacterItemDragHandler draggedItemUI = dragHandler as UICharacterItemDragHandler;
             if (draggedItemUI != null)
             {
                 switch (draggedItemUI.sourceLocation)
                 {
                 case UICharacterItemDragHandler.SourceLocation.NonEquipItems:
                 case UICharacterItemDragHandler.SourceLocation.EquipItems:
                     draggedItemUI.uiCharacterItem.OnClickSetRefineItem();
                     break;
                 }
             }
         }
     }
 }
Пример #24
0
 public virtual bool CanChangePartyLeader(BasePlayerCharacterEntity playerCharacterEntity, string characterId, out int partyId, out PartyData party)
 {
     partyId = 0;
     party   = null;
     if (playerCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     partyId = playerCharacterEntity.PartyId;
     if (partyId <= 0 || !parties.TryGetValue(partyId, out party))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotJoinedParty);
         return(false);
     }
     if (!party.IsLeader(playerCharacterEntity))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.NotPartyLeader);
         return(false);
     }
     if (!party.ContainsMemberId(characterId))
     {
         SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.CharacterNotJoinedParty);
         return(false);
     }
     return(true);
 }
Пример #25
0
        public bool TryGetPlayerCharacterByName(string characterName, out BasePlayerCharacterEntity result)
        {
            result = null;
            long connectionId;

            return(connectionIdsByCharacterName.TryGetValue(characterName, out connectionId) && playerCharacters.TryGetValue(connectionId, out result));
        }
Пример #26
0
        private void TriggerExit(GameObject other)
        {
            // Improve performance by tags
            if (!other.CompareTag(GameInstance.Singleton.playerTag))
            {
                return;
            }

            BasePlayerCharacterEntity playerCharacterEntity = other.GetComponent <BasePlayerCharacterEntity>();

            if (playerCharacterEntity == null)
            {
                return;
            }

            if (playerCharacterEntity == BasePlayerCharacterController.OwningCharacter)
            {
                playerCharacterEntity.warpingPortal = null;

                foreach (GameObject warpSignal in warpSignals)
                {
                    if (warpSignal != null)
                    {
                        warpSignal.SetActive(false);
                    }
                }
            }
        }
Пример #27
0
        protected virtual void UpdateOnlineCharacter(long connectionId, BasePlayerCharacterEntity playerCharacterEntity, float time)
        {
            PartyData tempParty;
            GuildData tempGuild;

            if (playerCharacterEntity.PartyId > 0 && parties.TryGetValue(playerCharacterEntity.PartyId, out tempParty))
            {
                tempParty.UpdateMember(playerCharacterEntity);
                tempParty.NotifyOnlineMember(playerCharacterEntity.Id);
                if (!updatingPartyMembers.ContainsKey(connectionId))
                {
                    updatingPartyMembers.Add(connectionId, tempParty);
                }
            }

            if (playerCharacterEntity.GuildId > 0 && guilds.TryGetValue(playerCharacterEntity.GuildId, out tempGuild))
            {
                tempGuild.UpdateMember(playerCharacterEntity);
                tempGuild.NotifyOnlineMember(playerCharacterEntity.Id);
                if (!updatingGuildMembers.ContainsKey(connectionId))
                {
                    updatingGuildMembers.Add(connectionId, tempGuild);
                }
            }
        }
Пример #28
0
 public virtual bool CanWarpCharacter(BasePlayerCharacterEntity playerCharacterEntity)
 {
     if (playerCharacterEntity == null || !IsServer)
     {
         return(false);
     }
     return(true);
 }
 public override void CloseStorage(BasePlayerCharacterEntity playerCharacterEntity)
 {
     if (usingStorageCharacters.ContainsKey(playerCharacterEntity.CurrentStorageId))
     {
         usingStorageCharacters[playerCharacterEntity.CurrentStorageId].Remove(playerCharacterEntity.ObjectId);
     }
     playerCharacterEntity.StorageItems.Clear();
 }
Пример #30
0
        protected override void UpdateData()
        {
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCraftingItem != null)
            {
                if (CraftingItem == null)
                {
                    // Hide if crafting item is null
                    uiCraftingItem.Hide();
                }
                else
                {
                    uiCraftingItem.Show();
                    uiCraftingItem.Data = new CharacterItemTuple(CharacterItem.Create(CraftingItem), 1, InventoryType.NonEquipItems);
                }
            }

            if (uiRequireItemAmounts != null)
            {
                if (CraftingItem == null)
                {
                    // Hide if crafting item is null
                    uiRequireItemAmounts.Hide();
                }
                else
                {
                    uiRequireItemAmounts.showAsRequirement = true;
                    uiRequireItemAmounts.Show();
                    uiRequireItemAmounts.Data = ItemCraft.CacheCraftRequirements;
                }
            }

            if (uiTextRequireGold != null)
            {
                if (CraftingItem == null)
                {
                    uiTextRequireGold.text = string.Format(
                        LanguageManager.GetText(formatKeyRequireGold),
                        "0",
                        "0");
                }
                else
                {
                    int currentAmount = 0;
                    if (owningCharacter != null)
                    {
                        currentAmount = owningCharacter.Gold;
                    }
                    uiTextRequireGold.text = string.Format(
                        currentAmount >= ItemCraft.RequireGold ?
                        LanguageManager.GetText(formatKeyRequireGold) :
                        LanguageManager.GetText(formatKeyRequireGoldNotEnough),
                        currentAmount.ToString("N0"),
                        ItemCraft.RequireGold.ToString("N0"));
                }
            }
        }