void RpcUpdateFlashLightStatus(bool status)
    {
        PlayerFlashLight flashlight = playerGameObject.GetComponent <PlayerFlashLight>();

        if (flashlight != null)
        {
            flashlight.ToggleFlashLight(status);
        }
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     //Start settings
     motor       = GetComponent <PlayerMotor>();
     flashLight  = GetComponent <PlayerFlashLight>();
     attributes  = GetComponent <PlayerAttributes>();
     gameManager = GameObject.FindGameObjectWithTag("GameController");
     DisableCursor();
 }
    public void CmdUpdateFlashLightStatus(bool flashLightStatus)
    {
        Debug.Log("CMD: Update Flash Light Status");
        PlayerFlashLight flashlight = playerGameObject.GetComponent <PlayerFlashLight>();

        if (flashlight != null)
        {
            RpcUpdateFlashLightStatus(flashLightStatus);
        }
    }
示例#4
0
    //Creates current skill id levels
    void Awake()
    {
        gameManager          = GameObject.FindGameObjectWithTag("GameController");
        netUtils             = gameManager.GetComponent <NetworkUtils>();
        skillController      = gameManager.GetComponent <PlayerSkillController>();
        allSkills            = skillController.GetAllSkills();
        currentSkillIDLevels = new int[allSkills.Length];

        flashlight = GetComponent <PlayerFlashLight>();
        attributes = GetComponent <PlayerAttributes>();
        controller = GetComponent <PlayerController>();
    }
    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);
        }
    }
    //Function to update all commands and refresh all clients, useful for when a new player joins
    void Resync()
    {
        CmdUpdateEnvironment();
        CmdChangePlayerName("Player" + Random.Range(1, 100));
        CmdUpdatePlayerSkillPoints();

        PlayerFlashLight flashlight = playerGameObject.GetComponent <PlayerFlashLight>();

        if (flashlight != null)
        {
            CmdUpdateFlashLightStatus(flashlight.flashLightStatus);
            CmdUpdateFlashLightBattery(flashlight.GetFlashLightCharge(), flashlight.GetMaxFlashLightCharge());
        }

        PlayerAttributes attributes = playerGameObject.GetComponent <PlayerAttributes>();

        if (attributes != null)
        {
            CmdUpdatePlayerAttributes(attributes.GetHealth(), attributes.GetMaxHealth(), attributes.GetStamina(), attributes.GetMaxStamina());
        }
    }