void CmdPlayerShootPlayer(string Id, int damage, string sourceName)
    {
        PlayerSetupNetwork player = GameManager.GetPlayer(Id);

        if (player.gameObject != null)
        {
            player.gameObject.GetComponent <CanvasManagerNetwork>().RpcTakeDamage(damage, sourceName);
        }
    }
    public static void RegisterPlayer(string netID, PlayerSetupNetwork player)
    {
        Debug.Log("RegisterPlayer: player" + netID);

        string playerID = PLAYER_ID_PREFIX + netID;

        players.Add(playerID, player);

        player.transform.name = playerID;
    }
示例#3
0
    public override void OnStartClient()
    {
        Debug.Log("OnStartClient");

        base.OnStartClient();

        string netID = GetComponent <NetworkIdentity>().netId.ToString();

        PlayerSetupNetwork player = GetComponent <PlayerSetupNetwork>();

        GameManager.RegisterPlayer(netID, player);
    }
    void CmdPlayerShootPlayer(string Id, int life)
    {
        Debug.Log("CmdPlayerShootPlayer");
        PlayerSetupNetwork player = GameManager.GetPlayer(Id);

        if (player.gameObject != null)
        {
            player.gameObject.GetComponent <CanvasManagerNetwork>().RpcGiveLife(life);
        }

        RpcRespawn();
    }
示例#5
0
    void CmdSetUsername(string playerID, string _username)
    {
        Debug.Log("CmdSetUsername");
        //Get the current player from the GamaManager on the network

        PlayerSetupNetwork player = GameManager.GetPlayer(playerID);

        if (player != null)
        {
            Debug.Log(_username + " has joined!");

            player.username = _username;
        }
    }
示例#6
0
    private void Die(string _sourceID)
    {
        isDead = true;

        PlayerSetupNetwork sourcePlayer = GameManager.GetPlayer(_sourceID);

        if (sourcePlayer != null)
        {
            sourcePlayer.kills++;

            Debug.Log("xx:" + sourcePlayer.username);

            GameManager.instance.onPlayerKilledCallback.Invoke(GetComponent <PlayerSetupNetwork>().username, "Kill", sourcePlayer.username);
        }

        GetComponent <PlayerSetupNetwork>().deaths++;

        //Disable components
        for (int i = 0; i < disableOnDeath.Length; i++)
        {
            disableOnDeath[i].enabled = false;
        }

        //Disable GameObjects
        for (int i = 0; i < disableGameObjectsOnDeath.Length; i++)
        {
            disableGameObjectsOnDeath[i].SetActive(false);
        }

        //SeUIMode
        Onpause();

        //Disable the collider
        Collider _col = GetComponent <Collider>();

        if (_col != null)
        {
            _col.enabled = true;
        }

        Rigidbody rigidbody = GetComponent <Rigidbody>();

        if (rigidbody != null)
        {
            rigidbody.isKinematic = true;
        }


        /* Transform _spawnPoint = NetworkManager.singleton.GetStartPosition();
         * rigidbody.position = _spawnPoint.position;
         * rigidbody.rotation = _spawnPoint.rotation;*/

        //set up position respawn acording to tag
        if (tag == "Cat")
        {
            GetComponent <Rigidbody>().MovePosition(GameObject.Find("Cat").transform.position);
            GetComponent <Rigidbody>().MoveRotation(GameObject.Find("Cat").transform.rotation);
        }
        //set up position respawn acording to tag
        if (tag == "Bear")
        {
            GetComponent <Rigidbody>().MovePosition(GameObject.Find("Bear").transform.position);
            GetComponent <Rigidbody>().MoveRotation(GameObject.Find("Bear").transform.rotation);
        }

        //Spawn a death effect

        /*GameObject _gfxIns = (GameObject)Instantiate(deathEffect, transform.position, Quaternion.identity);
         * Destroy(_gfxIns, 3f);*/

        //Switch cameras

        /*if (isLocalPlayer)
         * {
         *  GameManager.instance.SetSceneCameraActive(true);
         *  GetComponent<PlayerSetup>().playerUIInstance.SetActive(false);
         * }*/

        Debug.Log(transform.name + " is DEAD!");

        StartCoroutine(Respawn());
    }