void OnTriggerStay2D(Collider2D other)
    {
        switch (other.gameObject.tag)
        {
            case "EG":
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.floorCmd, 0 );
                break;
            case "Floor1":
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.floorCmd, 1 );
                break;
            case "Floor2":
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.floorCmd, 2 );
                break;
            case "Floor3":
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.floorCmd, 3 );
                break;
            case "Floor4":
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.floorCmd, 4 );
                break;
            default:
            break;
        }

        if (other.gameObject.tag == "Ladder")
        {
            isOnLadder = true;
            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow))
            {
                this.animator.SetInteger("AnimState", 3);
            }
        }
    }
    protected override void Awake()
    {
        base.Awake();

        FilterManager = new OSCFilterManager();

        switch (mode)
        {
        case OSCMode.Send:
            sender = CreateSender(senderId, IPAddress.Parse(targetIp), targetPort);
            break;

        case OSCMode.Receive:
            receiver = CreateReceiver(receiverId, receiverPort, FilterManager.OnReceivedOSC);
            break;

        case OSCMode.SendAndReceive:
            sender   = CreateSender(senderId, IPAddress.Parse(targetIp), targetPort);
            receiver = CreateReceiver(receiverId, receiverPort, FilterManager.OnReceivedOSC);
            break;

        default:
            break;
        }
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        _sender = OSCSender.Create("testClient", 1000, "192.168.11.4");

        _receiver = OSCReceiver.Create("testServer", 1000);
        _receiver.onListenToOSCMessage += OnListenToOSCMessage;
    }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        OSCSender.init();
        oscServer = gameObject.AddComponent <OSCServer>();

        SendGenerateFromScratch();
    }
    // Colliders
    void OnTriggerEnter2D(Collider2D other)
    {
        if (dead) return;

        if (other.gameObject.tag == "Hammer")
        {
            Destroy(other.gameObject);
            //StartCoroutine(hammerTimer());
        }
        if (hammerTime == true && other.gameObject.tag == "Enemy")
        {
            PlayerData.Instance.Score += 100;
            Destroy(other.gameObject);
        }
        else if (hammerTime == false && other.gameObject.tag == "Enemy")
        {
            //dead = true;
            //this.animator.SetTrigger("DeathTrigger");
            OSCSender.SendMessage(OSCSender.PDClient, OSCSender.enemyCollisionCmd, 1.0f );
            gameObject.transform.position = initialPosition;
        }
        if (other.gameObject.tag == "WinLadder" && Input.GetKey(KeyCode.UpArrow))
        {
            //this.animator.SetTrigger("WinTrigger");
        }
    }
    OSCSender CreateSender(string id, IPAddress ip, int port)
    {
        var s = new OSCSender();

        s.Init(id, port, ip);
        return(s);
    }
Beispiel #7
0
 void Start()
 {
     if (networkE)
     {
         transmit = new OSCTransmitter("localhost", 7600);
     }
     s_instance = this;
 }
Beispiel #8
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     Debug.Log("collide and send");
     OSCSender.SendMessage(OSCSender.PDClient, OSCSender.hitCmd + GATE_NUMBER, new List <float>()
     {
         Init.gateNotes[GATE_NUMBER].x, Init.gateNotes[GATE_NUMBER].y
     });
 }
Beispiel #9
0
 // Update is called once per frame
 void Update()
 {
     if (isWheeling)
     {
         int val = (int)((transform.position.y - originalPosition) * 3000);
         OSCSender.SendPitchWheel(val);
     }
 }
Beispiel #10
0
 void Start()
 {
     oscSend  = GetComponent <OSCSender>();
     servoOne = transform.GetChild(0);
     servoTwo = transform.GetChild(1);
     //resetServo();
     counter = 0;
     //BothRotateMax();
 }
Beispiel #11
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (instance == null)
        {
            instance = this;
        }
        else
        {
            DestroyObject(gameObject);
            return;
        }

        Application.runInBackground = true;
        foreach (var i in GameObject.FindObjectsOfType <BoxCollider2D>())
        {
            i.GetComponent <BoxCollider2D>().sharedMaterial = Metal;
            // i.GetComponent<BoxCollider2D>().isTrigger = true;
            // BoxCollider2D bc = i.gameObject.AddComponent(typeof(BoxCollider2D)) as BoxCollider2D;
            // i.GetComponent<BoxCollider2D>().isTrigger = true;
            i.size = new Vector2(0.18f, 0.1f);
        }


        if (sendOSC)
        {
            OSCSender sender = new OSCSender(address, port);
        }

        if (receiveOSC)
        {
            if (mReceiver == null)
            {
                Debug.Log("create server");
                mReceiver = new OSCReceiver("dkserver", serverPort);
            }
        }

        if (muteMario)
        {
        }

        notePosition = FindObjectOfType <NotePositions>();
        //receivedParams = new List<float>();
        servers = new Dictionary <string, ServerLog>();
        clients = new Dictionary <string, ClientLog> ();

        gateNotes = new Vector2[3];
    }
Beispiel #12
0
 void OnPostRender()
 {
     if (screenChanged)
     {
         counter--;
         if (counter < 0)
         {
             screenChanged = false;
             //StartCoroutine("Send");
             counter = 8;
             OSCSender.SendEmptyMessage("/readyCheck");
         }
     }
 }
Beispiel #13
0
    // Start is called before the first frame update
    void Start()
    {
        goalIndex         = 0;
        sleeptime         = 100;
        positionThreshold = 3;
        osc     = transform.GetComponent <OSCSender>();
        goalPos = new int[servoNum] {
            maxPos, minPos
        };
        servoId = new int[servoNum] {
            servoID_1, servoID_2
        };

        initialSetting();
    }
Beispiel #14
0
 public void SendGenerateFromScratch()
 {
     OSCSender.SendGenerateFromScratch();
 }
    void Update()
    {
        if (dead) return;

        // Restart
        if ( Input.GetKeyUp( KeyCode.R ) ) {
            gameObject.transform.position = initialPosition;
            hammerTime = false;

        } else if ( Input.GetKeyUp( KeyCode.H ) ) { // Hammer Time
            hammerTime = !hammerTime;
            if (hammerTime) {
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.hammerTimeCmd, 1 );
            } else {
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.hammerTimeCmd, 0 );
            }
        }

        CheckGround();

        var forceX = 0f;
        var forceY = 0f;

        var absVelX = Mathf.Abs(rb2d.velocity.x);
        var absVelY = Mathf.Abs(rb2d.velocity.y);

        if (absVelY < .2f)
        {
            standing = true;
        }
        else
        {
            standing = false;
        }

        // Moving Left or Right
        if (controller.moving.x != 0)
        {
            if (absVelX < maxVelocity.x)
            {
                forceX = standing ? speed * controller.moving.x : (speed * controller.moving.x);
                transform.localScale = new Vector3(forceX > 0 ? -3 : 3, 3, 0);
                OSCSender.SendMessage(OSCSender.PDClient, OSCSender.movingCmd, forceX > 0 ? -1.0f : 1.0f );
            }
        }
        // Standing
        else if (controller.moving.x == 0)
        {
            if (!hammerTime) this.animator.SetInteger("AnimState", 0);

            else if (hammerTime)
            {
                this.animator.SetInteger("AnimState", 5);
            }
            OSCSender.SendMessage(OSCSender.PDClient, OSCSender.movingCmd, 0.0f );
        }
        // Moving Up or Down, Only if Mario is on a ladder trigger
        if (controller.moving.y > 0 && isOnLadder == true)
        {
            if (absVelY < maxVelocity.y)
            {
                forceY = controller.moving.y * climbSpeed;
                this.animator.SetInteger("AnimState", 4);
            } else {
                this.animator.SetInteger("AnimState", 3);
            }
        }
        else if (absVelY > 0 && isOnGround == true)
        {
            this.animator.SetInteger("AnimState", 0);
        }
        // Jumping only if Mario is on the ground
        if (isOnGround == true && Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Space");
            rb2d.AddForce(Vector2.up * jumpForce);
            this.animator.SetInteger("AnimState", 2);
            OSCSender.SendMessage(OSCSender.PDClient, OSCSender.jumpCmd, 1.0f );
            if (!hammerTime){
                PlaySound(this.jumpClip);
            }
        }
        // Play sound clip once
        if (isOnGround == true && (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow)))
        {
            if (!hammerTime)
            {
                PlaySound(this.walkingClip);
                this.animator.SetInteger("AnimState", 1);
            }
            else if (hammerTime)
            {
                this.animator.SetInteger("AnimState", 6);
            }
        }

        rb2d.AddForce(new Vector2(forceX, forceY));

        // Lower left is 0 0 (6.5, 5.0)

        // float[] xy = {rb2d.transform.position.x, rb2d.transform.position.y};
        List<float> xy = new List<float>();
        xy.Add((rb2d.transform.position.x + width/2)/width);
        xy.Add(1.0f - ((rb2d.transform.position.y + height/2)/height));
        xy.Add(rb2d.velocity.x);
        xy.Add(rb2d.velocity.y);

        OSCSender.SendMessage(OSCSender.PDClient, OSCSender.positionCmd, xy);
    }
Beispiel #16
0
 public void toggleWheeling()
 {
     isWheeling = !isWheeling;
     // Reset pitch wheel
     OSCSender.SendPitchWheel(0);
 }
Beispiel #17
0
    // Function: Init
    // 		Call this when you're ready to start daemon-based communications.
    // 		*(Actually, this can probably be moved into the MonoBehaviour's Start method, so devs just need to call <SendGameInit> when they're ready.)*
    public void Init()
    {
        DebugExtras.Log("GhopperDaemon.Init");
        detailedDebug = _detailedDebug;

        if (!didInit) {

            GhopperEnv attachedEventReceiver = gameObject.GetComponent<GhopperEnv>();
            if (gameEventReceiver == null) {
                if (attachedEventReceiver != null) {
                gameEventReceiver = attachedEventReceiver;
                } else {
                    DebugExtras.LogError("Please attach your GhopperEnv subclass to the same prefab as the GhopperDaemon, or assign it manually to GhopperDaemon.gameEventReceiver before init.");
                }
            }

        //			usingTouchReader = (touchReader != null);

            // recognized (daemon) message address setup
            SetDaemonMessageReceiver(PLAYER_API_ADDRESS, OnReceivePlayerEvent);
            SetDaemonMessageReceiver(GAME_API_ADDRESS, OnReceiveGameEvent);
            SetDaemonMessageReceiver(BEZEL_API_ADDRESS, OnReceiveBezelEvent);

            // udp/osc setup -- PENDING UPDATE -- will need to transition to reactivision + mindstorm OSC
        //			udp.init(hostIP, remotePort, localPort);
        //			osc.init(udp);
        //
        //			osc.SetAllMessageHandler(OnReceiveOsc);

            // osc (&tuio) setup
            TuioConfiguration receiverConfig = new TuioConfiguration();

            oscReceiver = new OSCReceiver();
            oscSender = new OSCSender();
            tuioTracker = new TuioTracking();

            oscSender.Start();

            receiverConfig.Port = GetLaunchOption("-daemonspeak", listenPort);
            oscReceiver.ConfigureFramework( receiverConfig );
            oscReceiver.SetAllMessageHandler( OnReceiveOsc );
            TuioTrackingComponent.StartTracking(oscReceiver, tuioTracker);

            oscReceiver.Start();

            didInit = true;
        }
    }