Exemple #1
0
 public void SetPlayerChat(PlayerChat chat)
 {
     playerChat = chat;
     RefreshChanels();
     playerChat.onChangeChannels += RefreshChanels;
     playerChat.onReciveMessage  += ReciveChatMessage;
 }
 public override void OnStartClient()
 {
     if (instance != null)
     {
         Debug.LogError("More than one instance of PlayerChat found!");
         return;
     }
     instance = this;
 }
Exemple #3
0
        public void Setup(Character character, Inventory inventory, Equipment equipment, bool isLocalPlayer)
        {
            Debug.Log("setup");
            _statsManager        = GetComponent <StatsManager>();
            _progress            = GetComponent <PlayerProgress>();
            _character           = character;
            _inventory           = inventory;
            _equipment           = equipment;
            _character.Player    = this;
            _inventory.Player    = this;
            _equipment.Player    = this;
            _statsManager.Player = this;

            if (GetComponent <NetworkIdentity>().isServer)
            {
                UserAccount account = AccountManager.GetAccount(GetComponent <NetworkIdentity>().connectionToClient);
                _character.Stats.Load(account.data);
                _character.unitSkills.Load(account.data);
                _progress.Load(account.data);
                _inventory.Load(account.data);
                _equipment.Load(account.data);

                _character.Stats.Manager = _statsManager;
                _progress.Manager        = _statsManager;
            }

            if (isLocalPlayer)
            {
                Debug.Log("local");
                InventoryUI.Instance.SetInventory(_inventory);
                EquipmentUI.Instance.SetEquipment(_equipment);
                StatsUI.instance.SetManager(_statsManager);
                SkillsPanel.instance.SetSkills(character.unitSkills);
                SkillTree.instance.SetCharacter(character);
                SkillTree.instance.SetManager(_statsManager);

                PlayerChat playerChat = GetComponent <PlayerChat>();
                if (playerChat != null)
                {
                    if (GlobalChatChannel.instance != null)
                    {
                        playerChat.RegisterChannel(GlobalChatChannel.instance);
                    }
                    ChatChannel localChannel = _character.GetComponent <ChatChannel>();
                    if (localChannel != null)
                    {
                        playerChat.RegisterChannel(localChannel);
                    }
                    ChatUI.instance.SetPlayerChat(playerChat);
                }
            }
        }