// Try-catch clauses to deal with a weird null exception on the FOVscript. Works just as expected otherwise.
    IEnumerator Rotate(FOVScript fov)
    {
        while (true)
        {
            try{
                fov.SetTargetRotation(Vector3.up * 30);
            }   catch (Exception e) {}

            yield return(new WaitForSeconds(2));

            try{
                fov.SetTargetRotation(Vector3.down * 30);
            }   catch (Exception e) {}

            yield return(new WaitForSeconds(2));

            try{
                fov.SetTargetRotation(Vector3.left * 30);
            }   catch (Exception e) {}

            yield return(new WaitForSeconds(2));

            try{
                fov.SetTargetRotation(Vector3.right * 30);
            }   catch (Exception e) {}

            yield return(new WaitForSeconds(2));

            try{
                fov.SetTargetRotation(Vector3.zero);
            }   catch (Exception e) {}

            yield return(new WaitForSeconds(2));
        }
    }
	void Start () {
		STATE = State.IDLE;
		fov = GetComponent<FOVScript> ();
		lastAttack = DateTime.Now;

		// ignore enemies, enemy projectiles, and environment
		mask = ~(6 << 10);
	}
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     // Get mesh components
     mesh = GetComponent <MeshFilter>().mesh;
     fov  = GetComponentInParent <FOVScript>();
     // Change color of mesh material
     GetComponent <MeshRenderer>().material.color   = new Color(255, 250, 0, 0.01f);
     GetComponent <MeshRenderer>().sortingLayerName = "Projectile";
 }
    // Use this for initialization
    void Start()
    {
        headPosition = head.transform.position;

        kinect = this.transform.FindChild("Kinect").gameObject;
        //kinectFOV = this.transform.FindChild("KinectFOV").gameObject;
        //mocapFOV = this.transform.FindChild("MocapFOV").gameObject;
        fovScript = this.GetComponent <FOVScript>();


        audioSource = this.gameObject.AddComponent <AudioSource>();
        audioSource.spatialBlend = 0.0f; // Use 2D sound for sound effects
        audioSource.Play();

        //setup socket
        IPAddress  address         = IPAddress.Parse(ipAddress);
        int        port            = 8888;
        Socket     listeningSocket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        IPEndPoint localEndPoint   = new IPEndPoint(address, port);

        //bind
        //Debug.Log ("binding");
        listeningSocket.Bind(localEndPoint);

        //listen
        //Debug.Log ("listening");
        listeningSocket.Listen(5);

        //accept
        //Debug.Log ("accepting");
        listeningSocket.BeginAccept(new AsyncCallback(AcceptCallback), listeningSocket);

        if (usingMocap)
        {
            //kinect.SetActive(false);

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.Arguments   = mocapIpAddress + " " + ipAddress;
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            startInfo.FileName    = "C:\\rsween\\dev\\ped-sim-mocap\\Release\\EVaRTSDKExample.exe";

            mocapProcess = System.Diagnostics.Process.Start(startInfo);
        }
    }
 private void Awake()
 {
     fov = gameObject.GetComponent <FOVScript>();
 }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        headPosition = head.transform.position;

        kinect = this.transform.FindChild("Kinect").gameObject;
        //kinectFOV = this.transform.FindChild("KinectFOV").gameObject;
        //mocapFOV = this.transform.FindChild("MocapFOV").gameObject;
        fovScript = this.GetComponent<FOVScript>();

        audioSource = this.gameObject.AddComponent<AudioSource>();
        audioSource.spatialBlend = 0.0f; // Use 2D sound for sound effects
        audioSource.Play();

        //setup socket
        IPAddress address = IPAddress.Parse(ipAddress);
        int port = 8888;
        Socket listeningSocket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        IPEndPoint localEndPoint = new IPEndPoint(address, port);

        //bind
        //Debug.Log ("binding");
        listeningSocket.Bind(localEndPoint);

        //listen
        //Debug.Log ("listening");
        listeningSocket.Listen(5);

        //accept
        //Debug.Log ("accepting");
        listeningSocket.BeginAccept(new AsyncCallback(AcceptCallback), listeningSocket);

        if (usingMocap)
        {
            //kinect.SetActive(false);

            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.Arguments = mocapIpAddress;
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
            startInfo.FileName = "C:\\rsween\\dev\\ped-sim-mocap\\Release\\EVaRTSDKExample.exe";

            mocapProcess = System.Diagnostics.Process.Start(startInfo);
        }
    }