Esempio n. 1
0
    void Handle(InputDataReceivedEvent e)
    {
        constraint.ForEachGameObject((egoComponent, transform, movement) =>
        {
            if (e.playerID == movement.playerID)
            {
                //Debug.Log(e.data + ", " + e.playerID);
                if (e.data == 1)
                {
                    //Debug.Log(e.playerID + ": Start move right!");
                    movement.canMoveRight = true;
                    movement.canMoveLeft  = false;
                }
                else if (e.data == 2)
                {
                    //Debug.Log(e.playerID + ": Stop move right!");
                    movement.canMoveRight = false;
                }

                if (e.data == 3)
                {
                    movement.canMoveLeft  = true;
                    movement.canMoveRight = false;
                }
                else if (e.data == 4)
                {
                    movement.canMoveLeft = false;
                }
            }
        });
    }
Esempio n. 2
0
    void Handle(InputDataReceivedEvent e)
    {
        constraint.ForEachGameObject((egoComponent, transform, player, animator, jump, movement, onCollisionEnter, sound) => {
            if (e.playerID == player.playerID)
            {
                if (e.data == 1 && animator.GetBool("running") == false)
                {
                }

                if (e.data == 3 && animator.GetBool("running") == false)
                {
                }

                if (e.data == 2 && animator.GetBool("running") == true)
                {
                }

                if (e.data == 4 & animator.GetBool("running2") == true)
                {
                }

                if (jump.jumpstatus == JumpComponent.Jumpstatus.jumping && animator.GetBool("jumping") == false)
                {
                }

                if (jump.jumpstatus == JumpComponent.Jumpstatus.falling && animator.GetBool("jumping") == true)
                {
                    sound.audioSource.clip = sound.jumpSound;
                    sound.audioSource.Play();
                }
            }
        });
    }
Esempio n. 3
0
    void Handle(InputDataReceivedEvent e)
    {
        constraint.ForEachGameObject((ego, ready) => {
            if (e.data == 5 && e.playerID == 1)
            {
                ready.playerOneReady = true;
                EgoEvents <PlayerReadyEvent> .AddEvent(new PlayerReadyEvent(1));
            }
            if (e.data == 6 && e.playerID == 1)
            {
                ready.playerOneReady = false;
                EgoEvents <PlayerNotReadyEvent> .AddEvent(new PlayerNotReadyEvent(1));
            }
            if (e.data == 5 && e.playerID == 2)
            {
                ready.playerTwoReady = true;
                EgoEvents <PlayerReadyEvent> .AddEvent(new PlayerReadyEvent(2));
            }

            if (e.data == 6 && e.playerID == 2)
            {
                ready.playerOneReady = false;
                EgoEvents <PlayerNotReadyEvent> .AddEvent(new PlayerNotReadyEvent(2));
            }
        });
    }
Esempio n. 4
0
    void Handle(InputDataReceivedEvent e)
    {
        constraint.ForEachGameObject((egoComponent, transform, player, animator, jump, movement, onCollisionEnter, spriteRend) => {
            if (e.playerID == player.playerID)
            {
                if (e.data == 1 && animator.GetBool("running") == false)
                {
                    animator.SetBool("running", true);
                    animator.SetBool("running2", true);

                    if (spriteRend.flipX == false)
                    {
                        spriteRend.flipX = true;
                    }
                }

                if (e.data == 3 && animator.GetBool("running") == false)
                {
                    animator.SetBool("running", true);
                    animator.SetBool("running2", true);

                    if (spriteRend.flipX == true)
                    {
                        spriteRend.flipX = false;
                    }
                }

                if (e.data == 2 && animator.GetBool("running") == true)
                {
                    animator.SetBool("running", false);
                }

                if (e.data == 4 & animator.GetBool("running2") == true)
                {
                    animator.SetBool("running2", false);
                }

                if (jump.jumpstatus == JumpComponent.Jumpstatus.jumping && animator.GetBool("jumping") == false)
                {
                    animator.SetBool("jumping", true);
                    animator.SetBool("grounded", false);
                }

                if (jump.jumpstatus == JumpComponent.Jumpstatus.falling && animator.GetBool("jumping") == true)
                {
                    animator.SetBool("jumping", false);
                }
            }
        });
    }
Esempio n. 5
0
 void Handle(InputDataReceivedEvent e)
 {
     constraint.ForEachGameObject((egoComponent, transform, rigbody, jump, player, onCollissionEnter, Animator, AnimationComponent, spriteRend, serialPort) => {
         if (e.playerID == player.playerID)
         {
             //Enable Jumping
             if (e.data == 5)
             {
                 jump.canJump = false;
             }
             //Disable Jumping
             if (e.data == 6)
             {
                 jump.canJump = true;
             }
         }
     });
 }
Esempio n. 6
0
    void ReceiveAdruinoInput(int data, int playerID)
    {
        if (data == 1)
        {
            //Debug.Log("Move right");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }

        if (data == 2)
        {
            //Debug.Log("Stop move right");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }

        if (data == 3)
        {
            //Debug.Log("Move left");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }

        if (data == 4)
        {
            //Debug.Log("Stop move left");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }

        if (data == 5)
        {
            //Debug.Log("GROUNDED");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }

        if (data == 6)
        {
            //Debug.Log("JUMPING");
            var e = new InputDataReceivedEvent(data, playerID);
            EgoEvents <InputDataReceivedEvent> .AddEvent(e);
        }
    }