예제 #1
0
    private void SetObjectKeyTrigger()
    {
        if (Input.GetKeyDown(keyCodeObject) && playerMirrorController.isPlayer)
        {
            if (prefabObject == null)
            {
                playerController         = this.gameObject.transform.root.GetComponent <PlayerController>();
                playerController.GunKind = GunKind.None;
            }
            else if (prefabObject is WeaponeObjectController)
            {
                WeaponeObjectController weaponeObjectController = (WeaponeObjectController)prefabObject;
                playerController         = this.gameObject.transform.root.GetComponent <PlayerController>();
                playerController.GunKind = GunKind.Rifle;
            }
            else if (prefabObject is HandObjectController)
            {
                HandObjectController handObjectController = (HandObjectController)prefabObject;
                playerController         = this.gameObject.transform.root.GetComponent <PlayerController>();
                playerController.GunKind = GunKind.Object;
            }

            Button buttonSlot = gameObject.transform.Find("Border").GetComponent <Button>();
            buttonSlot.Select();
            buttonSlot.onClick.Invoke();
        }
    }
    public void DropObject(string nameDropObjectScriptable, Vector3 instantiateObjectDrop, float valueDrop)
    {
        //var InstantiateDropObject=Instantiate()
        foreach (var scriptableObject in ((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror.Select(((value, index) => new { value, index })))
        {
            if (scriptableObject.value.name == nameDropObjectScriptable)
            {
                if (((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[scriptableObject.index] is WeaponeObjectController)
                {
                    WeaponeObjectController weaponeObjectController = (WeaponeObjectController)((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[scriptableObject.index];
                    var InstantiateObject = Instantiate(weaponeObjectController.RetrunObjectWeaponeDropPreafabGround(), instantiateObjectDrop, Quaternion.identity);
                    if (NetworkServer.active)
                    {
                        NetworkServer.Spawn(InstantiateObject);
                    }

                    PickUpMaterial pickUpMaterial = InstantiateObject.GetComponent <PickUpMaterial>();
                    if (pickUpMaterial != null)
                    {
                        pickUpMaterial.SetCountObject(valueDrop);
                    }
                    continue;
                }
                else if (((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[scriptableObject.index] is HandObjectController)
                {
                    HandObjectController handObjectController = (HandObjectController)((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[scriptableObject.index];
                    var InstantiateObjectWeapone = Instantiate(handObjectController.RetrunObjectDropPreafabGround(), instantiateObjectDrop, Quaternion.identity);
                    if (NetworkServer.active)
                    {
                        NetworkServer.Spawn(InstantiateObjectWeapone);
                    }
                    PickUpMaterial pickUpMaterial = InstantiateObjectWeapone.GetComponent <PickUpMaterial>();

                    if (pickUpMaterial != null)
                    {
                        pickUpMaterial.SetCountObject(valueDrop);
                    }
                    continue;
                }
            }
        }
    }
    public void SendSlotControllerToObject(int indexSpanObject)
    {
        var objectInstantiate = Instantiate(((NetworkRoomManagerExt)NetworkManager.singleton).objectHand, rightHand.transform);

        if (NetworkServer.active)
        {
            NetworkServer.Spawn(objectInstantiate);
        }
        FightController fightController = objectInstantiate.transform.root.GetComponent <FightController>();



        if (((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[indexSpanObject] is WeaponeObjectController)
        {
            WeaponeObjectController weaponeObjectController = (WeaponeObjectController)((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[indexSpanObject];
            var objectWeaponeInstantiate = Instantiate(weaponeObjectController.ReturnWeaponeHand(), objectInstantiate.transform);
            if (NetworkServer.active)
            {
                NetworkServer.Spawn(objectWeaponeInstantiate);
            }

            //Set Speed Player with gun
            // PlayerController.RestetCalculateVariable();
            PlayerController.SetSpeedGunAimProperties(weaponeObjectController.ReturnSpeedWalikingPlayer(), weaponeObjectController.ReturnSpeedRotationPlayer());
            PlayerController.SetDefaultSpeedToVariableCalculate();

            //Set Properties Weapone
            objectWeaponeInstantiate.transform.localPosition    = weaponeObjectController.ReturnPositionInstantiate(characterSelectPerks);
            objectWeaponeInstantiate.transform.localEulerAngles = weaponeObjectController.ReturnRotationInstantiate(characterSelectPerks);
            objectWeaponeInstantiate.transform.localScale       = weaponeObjectController.ReturnScaleInstantiate(characterSelectPerks);

            //Set ScriptableObject In Script Fight
            fightController.SetHandObjectController(null);
            fightController.SetWeaponeObjectController(weaponeObjectController);

            //Set ObjectHand and ObjectInHandChild
            fightController.SetObjcetHandChild(objectWeaponeInstantiate);
            fightController.SetObjectHand(objectInstantiate);
        }
        else if (((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[indexSpanObject] is HandObjectController)
        {
            HandObjectController handObjectController = (HandObjectController)((NetworkRoomManagerExt)NetworkManager.singleton).scriptableObjectToMirror[indexSpanObject];
            var objectHandInstantiate = Instantiate(handObjectController.ReturnObjectInHandPref(), objectInstantiate.transform);
            if (NetworkServer.active)
            {
                NetworkServer.Spawn(objectHandInstantiate);
            }


            //Set Speed Player With object in hand
            PlayerController.SetSpeedDefProperties(handObjectController.ReturnSpeedWalikingPlayer(), handObjectController.ReturnSpeedRotationPlayer());
            PlayerController.SetDefaultSpeedToVariableCalculate();

            //Set Properties Object
            objectHandInstantiate.transform.localPosition    = handObjectController.ReturnPositionInstantiate(characterSelectPerks);
            objectHandInstantiate.transform.localEulerAngles = handObjectController.ReturnRotationInstantiate(characterSelectPerks);
            objectHandInstantiate.transform.localScale       = handObjectController.ReturnScaleInstantiate(characterSelectPerks);

            //Set ScriptableObject In Script Fight
            fightController.SetWeaponeObjectController(null);
            fightController.SetHandObjectController(handObjectController);

            //Set ObjectHand and ObjectInHandChild
            fightController.SetObjcetHandChild(objectHandInstantiate);
            fightController.SetObjectHand(objectInstantiate);
        }
    }
예제 #4
0
 public void SetHandObjectController(HandObjectController handObjectController)
 {
     this.handObjectController = handObjectController;
 }