public void Setup(CharacterOfPlr character, Inventory inventory, Equipment equipment, bool isLocalPlayer)
        {
            _character = character;
            _inventory = inventory;
            _equipment = equipment;
            _character.PlayerScriptsConnectorr = this;
            _inventory.PlayerScriptsConnectorr = this;
            _equipment.PlayerScriptsConnectorr = this;
            _statsManager        = GetComponent <StatsManager>();
            _progress            = GetComponent <CharacterProgress>();
            _statsManager.Player = this;

            if (isLocalPlayer)
            {
                InventoryUI.Instance.SetInventory(_inventory);
                EquipmentUI.Instance.SetEquipment(_equipment);
                StatsUI.Instance.SetManager(_statsManager);
            }

            if (GetComponent <NetworkIdentity>().isServer)
            {
                _character.Stats.Manager = _statsManager;
                _progress.Manager        = _statsManager;
            }
        }
        public void CmdCreatePlayer()
        {
            CharacterOfPlr character = CreateCharacter();
            //_controller.SetCharacter(unit.GetComponent<CharacterOfPlr>(), false);
            Inventory inventory = GetComponent <Inventory>();
            Equipment equipment = GetComponent <Equipment>();

            _scriptsConnectorr.Setup(character, inventory, equipment, false);
            _controller.SetCharacter(character, true);
        }
예제 #3
0
        protected override void DamageWithCombat(GameObject luser)
        {
            base.DamageWithCombat(luser);
            CharacterOfPlr character = luser.GetComponent <CharacterOfPlr>();

            if (character != null && !_enemies.Contains(character))
            {
                _enemies.Add(character);
            }
        }
 public void SetCharacter(CharacterOfPlr characterOfPlr, bool isLocalPlayer)
 {
     _characterOfPlr = characterOfPlr;
     if (isLocalPlayer)
     {
         CameraController cameraController = _camera.GetComponent <CameraController>();
         if (cameraController)
         {
             cameraController.Target = characterOfPlr.transform;
         }
     }
 }
 private void HookUnitIdentity(NetworkIdentity unit)
 {
     if (isLocalPlayer)
     {
         _unitIdentity = unit;
         CharacterOfPlr character = unit.GetComponent <CharacterOfPlr>();
         Equipment      equipment = GetComponent <Equipment>();
         Inventory      inventory = GetComponent <Inventory>();
         _scriptsConnectorr.Setup(character, inventory, equipment, true);
         _controller.SetCharacter(character, true);
         //character.SetInventory(_inventory);
         //InventoryUI.Instance.SetInventory(_inventory);
     }
 }
        public bool PickUp(GameObject luser)
        {
            Debug.Log("ItemPickUp::PickUp: pick up " + ItemScriptableObject.Name);
            CharacterOfPlr character = luser.GetComponent <CharacterOfPlr>();

            if (character != null)
            {
                if (character.AddToInventory(ItemScriptableObject))
                {
                    Destroy(gameObject);
                    //return true;
                }
            }

            return(false);
        }
        //public override void OnStartServer()
        //{
        //    GameObject unit = Instantiate(_unitPrefab, transform.position, Quaternion.identity);
        //    NetworkServer.SpawnWithClientAuthority(unit, gameObject);
        //}

        public override void OnStartAuthority()
        {
            //base.OnStartAuthority();
            if (isServer)
            {
                CharacterOfPlr character = CreateCharacter();
                //_controller.SetCharacter(character, true);
                //character.SetInventory(_inventory);
                //InventoryUI.Instance.SetInventory(_inventory);
                Inventory inventory = GetComponent <Inventory>();
                Equipment equipment = GetComponent <Equipment>();
                _scriptsConnectorr.Setup(character, inventory, equipment, true);
                _controller.SetCharacter(character, true);
            }
            else
            {
                CmdCreatePlayer();
            }
        }