Ejemplo n.º 1
0
    void OnCollisionEnter(Collision col)
    {
        //if blue team colliding with red torch
        if (col.gameObject.name == "Torch_Red" && ourTeam == PunTeams.Team.blue)
        {
            //if red torch is lit
            if (Util.redTorchLit == true)
            {
                //grab it
                if (grabbedObject == null)
                {
                    TryGrabObject(col.gameObject);

                    // Notify players flag has been picked up
                    textManager.AddFlagPickupMessage(PunTeams.Team.blue);
                }
            }
            //red torch not lit
            else
            {
                //if holding lighter
                if (grabbedObject.name == "Lighter")
                {
                    toLight = col.gameObject;
                    //light the torch
                    GetComponent <PhotonView>().RPC("LightTorch", PhotonTargets.AllBuffered, "red");
                    //LightTorch ("red");
                    //col.gameObject.GetComponent<Torchelight> ().IntensityLight = 1;
                    //col.gameObject.GetComponent<Torchelight> ().MaxLightIntensity = 3;
                }
            }
        }
        else if (col.gameObject.name == "Torch_Blue" && ourTeam == PunTeams.Team.red)
        {
            if (Util.blueTorchLit == true)
            {
                if (grabbedObject == null)
                {
                    TryGrabObject(col.gameObject);

                    // Notify players flag has been picked up
                    textManager.AddFlagPickupMessage(PunTeams.Team.red);
                }
            }
            else
            {
                if (grabbedObject.name == "Lighter")
                {
                    toLight = col.gameObject;
                    GetComponent <PhotonView>().RPC("LightTorch", PhotonTargets.AllBuffered, "blue");
                    //LightTorch ("blue");
                    //col.gameObject.GetComponent<Torchelight> ().IntensityLight = 1;
                    //col.gameObject.GetComponent<Torchelight> ().MaxLightIntensity = 3;
                }
            }
        }
        else if ((col.gameObject.name == "Torch_Red" && ourTeam == PunTeams.Team.red) ||
                 (col.gameObject.name == "Torch_Blue" && ourTeam == PunTeams.Team.blue))
        {
            // col.gameObject.transform.position = RedTorchSpawn.transform.position;
            GetComponent <PhotonView>().RPC("ResetFlag", PhotonTargets.AllBuffered, ourTeam);
            // Debug.Log ("Red reclaiming red torch");
        }
        // If we collide with our own flag (red team)
        else if (col.gameObject.name == "Torch_Red" && ourTeam == PunTeams.Team.red)
        {
            // Reset the flag only if its not at the base
            if (col.gameObject.transform.position != Util.defaultRedFlag)
            {
                GetComponent <PhotonView>().RPC("ResetFlag", PhotonTargets.AllBuffered, ourTeam);
            }
        }
        // If we collide with our own flag (blue team)
        else if (col.gameObject.name == "Torch_Blue" && ourTeam == PunTeams.Team.blue)
        {
            // Reset the flag only if its not at the base
            if (col.gameObject.transform.position != Util.defaultBlueFlag)
            {
                GetComponent <PhotonView>().RPC("ResetFlag", PhotonTargets.AllBuffered, ourTeam);
            }
        }
        else if (col.gameObject.name == "Lighter")
        {
            if (grabbedObject == null)
            {
                TryGrabObject(col.gameObject);
            }
        }
    }