Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("aaaaaaa2");
        if (other.gameObject.layer == 9)
        {
            Debug.Log("aaaaaaa1");
            if (athoritySet == false)
            {
                playerWithAthority = other.gameObject.transform.root.gameObject;
                Debug.Log("aaaaaaa");
                if (ovrGrab.isGrabbed == true)
                {
                    floatColider.GetComponent <CapsuleCollider>().gameObject.SetActive(false);

                    Debug.Log("aaaaaaa3");
                    objRoot = playerWithAthority.transform.root;
                    player  = objRoot.gameObject.GetComponent <OculusRemote>();
                    player.ShootList.Add(gameObject);
                    gameObject.GetComponent <NetworkIdentity>().AssignClientAuthority(playerWithAthority.GetComponent <NetworkIdentity>().connectionToClient);
                    gameObject.GetComponent <NetworkIdentity>().RemoveClientAuthority(gameObject.GetComponent <NetworkIdentity>().connectionToClient);
                    gameObject.GetComponent <NetworkIdentity>().AssignClientAuthority(playerWithAthority.GetComponent <NetworkIdentity>().connectionToClient);

                    CmdSetAthority();
                    athoritySet = true;
                }
            }
        }
    }
    public void OnTriggerEnter(Collider other)
    {
        //Debug.Log(6);


        GameObject   hit          = other.gameObject;
        OculusRemote oculusRemote = hit.GetComponent <OculusRemote>();

        if (setParent == true)
        {
            //Debug.Log(7);
            if (oculusRemote != null)
            {
                //if object is in player list dont trigger
                Debug.Log(8);
                //keep teleprt spell from hitting self
                if (oculusRemote.ShootList.Contains(gameObject))
                {
                    Debug.Log(9);
                    return;
                }

                else
                {//teleport local player
                    Debug.Log(10);
                    CmdTeleport();
                    // set the players new position on the cliant side
                    fireMage.GetComponent <CharacterController>().enabled = false;
                    fireMage.transform.position = new Vector3(transform.position.x,
                                                              transform.position.y + 1,
                                                              transform.position.z);
                    //this.enabled = false;
                    //NetworkServer.Destroy(gameObject);
                    fireMage.GetComponent <CharacterController>().enabled = true;
                }
            }
            // keep teleprt spell from hitting  other spells
            else if ((oculusRemote == null && other.gameObject.layer == 9) || (oculusRemote == null && other.gameObject.layer == 10))
            {
                Debug.Log(11);
                return;
            }
            else
            {//teleport local player
                Debug.Log(12);
                CmdTeleport();
                fireMage.GetComponent <CharacterController>().enabled = false;

                fireMage.transform.position = new Vector3(transform.position.x,
                                                          transform.position.y + 1,
                                                          transform.position.z);
                //this.enabled = false;
                //NetworkServer.Destroy(gameObject);
                fireMage.GetComponent <CharacterController>().enabled = true;
            }
        }
    }
Exemple #3
0
 void CmdSetAthority()
 {
     floatColider.GetComponent <CapsuleCollider>().gameObject.SetActive(false);
     Debug.Log("qweqweqw");
     objRoot = playerWithAthority.transform.root;
     player  = objRoot.gameObject.GetComponent <OculusRemote>();
     player.ShootList.Add(gameObject);
     gameObject.GetComponent <NetworkIdentity>().AssignClientAuthority(playerWithAthority.GetComponent <NetworkIdentity>().connectionToClient);
     gameObject.GetComponent <NetworkIdentity>().RemoveClientAuthority(gameObject.GetComponent <NetworkIdentity>().connectionToClient);
     gameObject.GetComponent <NetworkIdentity>().AssignClientAuthority(playerWithAthority.GetComponent <NetworkIdentity>().connectionToClient);
     athoritySet = true;
 }
Exemple #4
0
    public void OnTriggerEnter(Collider other)
    {
        //Debug.Log(other.gameObject);
        //Debug.Log("Server" + gameObject.GetComponent<NetworkBehaviour>().isServer);
        //Debug.Log("Client" + gameObject.GetComponent<NetworkBehaviour>().isClient);
        //Debug.Log("Authority" + gameObject.GetComponent<NetworkBehaviour>().hasAuthority);
        //Debug.Log("layer" + other.gameObject.layer);

        // set hit to object hit so if hit = player it will not go off if on players list
        GameObject   hit          = other.gameObject.transform.root.gameObject;
        OculusRemote oculusRemote = hit.GetComponent <OculusRemote>();

        if (oculusRemote != null)
        {
            if (oculusRemote.ShootList.Contains(gameObject))
            {
                return;
            }

            else
            {
                //networkIdentity.localPlayerAuthority = false;

                // run exploshon if hits player without spell on list
                CmdExploshon();
            }
        }
        else if ((oculusRemote == null && other.gameObject.layer == 9) || (oculusRemote == null && other.gameObject.layer == 10))
        {
            return;
        }

        else
        {
            //networkIdentity.localPlayerAuthority = false;\

            // play exploshen if coliding with anything that is not player that casts the spell
            CmdExploshon();
        }
    }
    void CmdTeleport()
    {
        // teleport player over the network and create a smokescreen effect
        Debug.Log(15);
        //foreach (var fireMage in goList)
        {
            OculusRemote oculusRemote = fireMage.GetComponent <OculusRemote>();
            if (this.enabled)

            {
                Debug.Log(16);
                GameObject smokeScreen = Instantiate(smoke, fireMage.transform.position, Quaternion.identity) as GameObject;
                //smokeScreen.GetComponent<Transform>().localScale = gameObject.GetComponent<Transform>().localScale;
                NetworkServer.Spawn(smokeScreen);
                if (fireMage.GetComponent <OculusRemote>().ShootList.Contains(gameObject))
                {
                    Debug.Log(17);
                    fireMage.GetComponent <CharacterController>().enabled = false;

                    fireMage.transform.position = new Vector3(transform.position.x,
                                                              transform.position.y + 1,
                                                              transform.position.z);
                    this.enabled = false;
                    NetworkServer.Destroy(gameObject);
                    Destroy(gameObject);

                    fireMage.GetComponent <CharacterController>().enabled = false;
                }

                else
                {
                    Debug.Log(18);
                    return;
                }
                Destroy(smokeScreen, efectTime);
            }
        }
    }