Exemple #1
0
 private void Start()
 {
     rb = GetComponent <Rigidbody>();
     ragdollController = GetComponent <Player_RagdollController>();
     hud    = GetComponent <Player_Hud>();
     config = GetComponent <Player_Config>();
 }
Exemple #2
0
    private void Start()
    {
        config = GetComponent <Player_Config>();
        controllerAnimation = GetComponent <Player_AnimationController>();

        SelectWeaponModel(selectedWeapon);
        config.humanAnimator.SetLayerWeight(1, 0f);
    }
    private void Start()
    {
        rb     = GetComponent <Rigidbody>();
        config = GetComponent <Player_Config>();

        //so we dont get unnessisary force applied, which slams the ragdoll
        foreach (Rigidbody rb in ragdollRigidbodies)
        {
            rb.isKinematic = true;
        }
        foreach (Collider col in ragdollColliders)
        {
            col.enabled = false;
        }
    }
Exemple #4
0
    /// <summary>
    /// SHIFT + Movement makes speed go from 2 to 5, update animation threshold if values change!
    /// </summary>
    /// <param name="config"></param>
    private void RunningControls(Player_Config config)
    {
        //Running speed adjustment
        if (Input.GetKey(KeyCode.LeftShift) && config.canRun)
        {
            controllerWalker.movementSpeed = config.runSpeed;
            config.runStamina -= 8f * Time.deltaTime;
        }
        else
        {
            if (config.runStamina < config.staminaLevel)
            {
                config.runStamina += 8f * Time.deltaTime;
            }
            controllerWalker.movementSpeed = config.walkSpeed;
        }

        //Stamina
        //exhausted? stop running
        if (config.runStamina <= 0)
        {
            config.staminaExhausted = true;
            config.canRun           = false;
        }

        //if not exhausted, we can run
        if (config.runStamina > 0 && !config.staminaExhausted)
        {
            config.canRun = true;
        }
        //if exhausted, we cant run
        else if (config.runStamina > 0 && config.staminaExhausted)
        {
            if (config.runStamina > config.staminaLevelForRecover)
            {
                config.staminaExhausted = false;
            }
        }
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        config = GetComponent <Player_Config>();

        //Local
        if (photonView.IsMine)
        {
            //Remove the body model from FPS view so we dont see clipping
            for (int i = 0; i < removeLocalObjects.Length; i++)
            {
                removeLocalObjects[i].SetActive(false);
            }
            for (int i = 0; i < ragdollCollidersToDisableTillDeath.Length; i++)
            {
                ragdollCollidersToDisableTillDeath[i].enabled = false;
            }
        }
        else //Client
        {
            //Player is Remote, deactivate the scripts and object that should only be enabled for the local player
            for (int i = 0; i < removeScriptsFromOthers.Length; i++)
            {
                removeScriptsFromOthers[i].enabled = false;
            }
            for (int i = 0; i < removeObjectsFromOthers.Length; i++)
            {
                removeObjectsFromOthers[i].SetActive(false);
            }
            for (int i = 0; i < removeLinerendererFromOthers.Length; i++)
            {
                removeLinerendererFromOthers[i].enabled = (false);
            }
            for (int i = 0; i < rigidbodyFromOthersToSetKinematic.Length; i++)
            {
                rigidbodyFromOthersToSetKinematic[i].isKinematic = true;
            }
        }
    }
Exemple #6
0
    private void Start()
    {
        //movement controller
        controllerWalker    = GetComponent <AdvancedWalkerController>();
        controllerAnimation = GetComponent <Player_AnimationController>();
        controllerRagdoll   = GetComponent <Player_RagdollController>();
        config       = GetComponent <Player_Config>();
        hud          = GetComponent <Player_Hud>();
        playerHealth = GetComponent <Player_Health>();

        lineRenderGrab = gameObject.GetComponent <LineRenderer>();
        lineRenderGrab.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero });
        lineRenderGrab.startColor = Color.white;
        lineRenderGrab.endColor   = Color.white;
        lineRenderGrab.startWidth = 0.002f;
        lineRenderGrab.endWidth   = 0.002f;

        //stamina
        config.runStamina = config.staminaLevel;

        //hud
        StartCoroutine("UpdateHUD");
    }
 private void Start()
 {
     config = GetComponent <Player_Config>();
 }
Exemple #8
0
    public void FightingControls(Player_Config config, Player_AnimationController controllerAnimation)
    {
        if (!config.canAttack)
        {
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            //so we can punch and move after animation is done
            if (isFighting)
            {
                return;
            }

            //Make sure no other coroutines are playing
            StopAllCoroutines();

            //Weapon selection
            switch (selectedWeapon)
            {
            case Weapon.Fists:
                hitDistance = 1.7f;
                hitDamage   = 20f;
                StartCoroutine(PunchCooldownTimer(controllerAnimation));
                break;

            case Weapon.Knife:
                hitDistance = 1.7f;
                hitDamage   = 33;
                StartCoroutine(StabCooldownTimer(controllerAnimation));
                break;

            case Weapon.Pistol:
                hitDistance = 22f;
                hitDamage   = 75f;
                StartCoroutine(ShootCooldownTimer(controllerAnimation));
                break;
            }

            //Action
            Ray        ray = Camera.allCameras[0].ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, hitDistance, ~playerCapsuleLayermask))
            {
                if (hit.transform.tag == "PlayerRagdoll")
                {
                    Debug.Log("Punched " + hit.collider.gameObject.name + " On other player!");

                    //damage and kill the player
                    PhotonView pvOther = hit.transform.root.gameObject.GetComponent <PhotonView>();
                    if (pvOther == null)
                    {
                        Debug.LogError("OTHER PLAYER DOESNT HAVE PHOTONVIEW?!");
                    }
                    pvOther.RPC("Damage", RpcTarget.AllBufferedViaServer, pvOther.ViewID, DamageMultiplier(hit.collider.gameObject.name, hitDamage));
                    //pvOther.RPC("KillImmediately", RpcTarget.AllBufferedViaServer, pvOther.ViewID, 15f, hit.point);
                }

                //transfer ownership if available (punching obj)
                PhotonView otherPv = hit.transform.gameObject.GetComponent <PhotonView>();
                if (otherPv != null && !otherPv.IsMine)
                {
                    otherPv.TransferOwnership(PhotonNetwork.LocalPlayer);
                }


                //hit a draggable/door or something, apply force
                StartCoroutine(PunchDelay(0.25f, hit));
            }
        }
    }
    //make item pool
    //when pickup batterys, disable them over pun
    //when drop, enable and teleport them in front of you
    //the pool should only have as many items as there are in a scene

    private void Start()
    {
        config    = GetComponent <Player_Config>();
        hud       = GetComponent <Player_Hud>();
        inventory = GetComponent <Player_Inventory>();
    }
 private void Start()
 {
     //if NOT photonview.ismine
     config = GetComponent <Player_Config>();
 }
Exemple #11
0
 private void Start()
 {
     hud    = GetComponent <Player_Hud>();
     config = GetComponent <Player_Config>();
 }
Exemple #12
0
 private void Start()
 {
     controller      = GetComponent <AdvancedWalkerController>();
     fightController = GetComponent <Player_FightingController>();
     config          = GetComponent <Player_Config>();
 }