Exemplo n.º 1
0
    //Function to apply player skills
    void ApplySkills()
    {
        //Apply flashlight skills
        if (flashlight != null)
        {
            float newFlash = GetAppliedSkillPercentValue(PlayerSkill.FlashlightEfficiency, flashlight.GetBaseFlashLightCharge(), 0.05f);
            flashlight.SetMaxFlashLightCharge(newFlash);
            flashlight.SetFlashLightCharge(newFlash);
        }
        //Apply attribute skills
        if (attributes != null)
        {
            //Health
            float newHealth = GetAppliedSkillPercentValue(PlayerSkill.IncreasedHealth, attributes.GetBaseHealth(), 0.05f);
            attributes.SetMaxHealth(newHealth);
            attributes.SetHealth(newHealth);
            //Stamina
            float newStamina = GetAppliedSkillPercentValue(PlayerSkill.IncreasedStamina, attributes.GetBaseStamina(), 0.05f);
            attributes.SetMaxStamina(newStamina);
            attributes.SetStamina(newStamina);
        }
        if (controller != null)
        {
            //MovementSpeed
            //Speed
            float newSpeed = GetAppliedSkillPercentValue(PlayerSkill.FasterMovement, controller.GetBaseSpeed(), 0.02f);
            controller.SetSpeed(newSpeed);

            //Sprint speed
            float newSprintSpeed = GetAppliedSkillPercentValue(PlayerSkill.FasterMovement, controller.GetBaseSprintSpeed(), 0.02f);
            controller.SetSprintSpeed(newSprintSpeed);
        }
    }
    public void CmdUpdateFlashLightBattery(float flashLightBattery, float flashLightMaxBattery)
    {
        Debug.Log("CMD: Update Flash Light Battery");
        PlayerFlashLight flashlight = playerGameObject.GetComponent <PlayerFlashLight>();

        if (flashlight != null)
        {
            RpcUpdateFlashLightBattery(flashLightBattery, flashLightMaxBattery);

            flashlight.SetFlashLightCharge(flashLightBattery);
            flashlight.SetMaxFlashLightCharge(flashLightMaxBattery);
        }
    }
    void RpcUpdateFlashLightBattery(float flashLightBattery, float flashLightMaxBattery)
    {
        PlayerFlashLight flashlight = playerGameObject.GetComponent <PlayerFlashLight>();

        if (flashlight != null)
        {
            //Only sync for local player, prevents incorrect data being synced, fixes issue #5 on GitHub
            if (hasAuthority)
            {
                return;
            }

            flashlight.SetFlashLightCharge(flashLightBattery);
            flashlight.SetMaxFlashLightCharge(flashLightMaxBattery);
        }
    }