Пример #1
0
    public void RpcTakeDamage(string _PlayerID, float amount)
    {
        TankHealth tankHealth = GameManager_Net.Getplayer(_PlayerID).GetComponent <TankHealth>();

        // Adjust the tank's current health, update the UI based on the new health and check whether or not the tank is dead.

        tankHealth.TakeDamage(amount);


        Debug.Log("hit recieved from client side");
    }
Пример #2
0
    void CmdFire()
    {
        //RpcFire();

        // Set the fired flag so only Fire is only called once.
        m_Fired = true;

        // Create an instance of the shell and store a reference to it's rigidbody.
        GameObject shellInstance =
            Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation);



        // Set the shell's velocity to the launch force in the fire position's forward direction.
        shellInstance.GetComponent <Rigidbody>().velocity = m_CurrentLaunchForce * m_FireTransform.forward;


        foreach (var instance in GameManager_Net.players)
        {
            if (GameManager_Net.Getplayer(instance.Key).GetComponent <NetworkIdentity>().hasAuthority)
            {
                authority = GameManager_Net.Getplayer(instance.Key);
            }
        }


        // Spawn the shell on the clients
        NetworkServer.SpawnWithClientAuthority(shellInstance, authority);


        // NetworkServer.Spawn(shellInstance);


        // Change the clip to the firing clip and play it.
        m_ShootingAudio.clip = m_FireClip;
        m_ShootingAudio.Play();

        // Reset the launch force.  This is a precaution in case of missing button events.
        m_CurrentLaunchForce = m_MinLaunchForce;
    }