private void LocalHandler(GameEvent e)
    {
        if (e.GetType() == typeof(GE_PreLoadLevel))
        {
            UnSub();
        }
        else if (e.GetType() == typeof(GE_PlayerIngressEgress))
        {
            GE_PlayerIngressEgress p = (GE_PlayerIngressEgress)e;
            if ((p.myID == PlayerID.p1 && charNum == 0) || (p.myID == PlayerID.p2 && charNum == 1))
            {
                inOutTimer = 0;

                inOut = p.inTrueOutFalse;
                SetInOut(p.inTrueOutFalse);
            }
        }
        else if (e.GetType() == typeof(Button_GE))
        {
            if (!inOut && inOutReady)
            {
                Button_GE b = (Button_GE)e;
                if ((b.thisPID == PlayerID.p1 && charNum == 0) || (b.thisPID == PlayerID.p2 && charNum == 1))
                {
                    if (b.button == Button.Action && b.pressedReleased)
                    {
                        AButton(b.pressedReleased, charNum);
                    }
                }
            }
        }
        else if (e.GetType() == typeof(Stick_GE))
        {
            if (!inOut)
            {
                Stick_GE s = (Stick_GE)e;
                if ((s.thisPID == PlayerID.p1 && charNum == 0) || (s.thisPID == PlayerID.p2 && charNum == 1))
                {
                    if (s.stick == Stick.Left)
                    {
                        LeftStick(s.upDown, s.leftRight, charNum);
                    }
                    if (s.stick == Stick.Right)
                    {
                        RightStick(s.upDown, s.leftRight, charNum);
                    }
                }
            }
        }
    }
 void LocalHandler(GameEvent e)
 {
     if (e.GetType() == typeof(GE_PlayerIngressEgress))
     {
         GE_PlayerIngressEgress i = (GE_PlayerIngressEgress)e;
         if ((i.myID == PlayerID.p1 && thisSpeaker == Speaker.Ops) || (i.myID == PlayerID.p2 && thisSpeaker == Speaker.Doc))
         {
             if ((i.inTrueOutFalse && myType == IngressEgressIcon.Sub) || (!i.inTrueOutFalse && myType == IngressEgressIcon.Water))
             {
                 mySR.color = litColor;
             }
             else
             {
                 mySR.color = unlitColor;
             }
         }
     }
 }
Exemplo n.º 3
0
    void LocalHandler(GameEvent e)
    {
        if (e.GetType() == typeof(GE_PreLoadLevel))
        {
            Unregister();
        }
        else if (e.GetType() == typeof(GE_SubStatus))
        {
            GE_SubStatus s = (GE_SubStatus)e;
            canMove   = s.Move;
            canGetOut = s.IngEg;
        }
        else if (e.GetType() == typeof(GameSaveEvent))
        {
            EventManager.instance.Fire(new GE_GetSubStatus(canMove, canGetOut));
        }
        else if (e.GetType() == typeof(GE_PlayerIngressEgress))
        {
            //Debug.Log("Reading a ingress/egress event");
            GE_PlayerIngressEgress p = (GE_PlayerIngressEgress)e;
            if (p.myID == PlayerID.p1)
            {
                p1In         = p.inTrueOutFalse;
                p1InOutTimer = 0;
            }
            else
            {
                p2In         = p.inTrueOutFalse;
                p2InOutTimer = 0;
            }
        }
        else if (e.GetType() == typeof(Button_GE))
        {
            if (canGetOut)
            {
                //Debug.Log("Reading a button event from sub");

                Button_GE b = (Button_GE)e;
                if (b.button == Button.Action && b.pressedReleased)
                {
                    //Debug.Log("Sending out");
                    if (p1In && b.thisPID == PlayerID.p1 && p1.GetComponent <PlayerController>().inOutReady)
                    {
                        StartCoroutine("IEInOutP1");
                        //Debug.Log("P1 was in, now is out");
                    }
                    if (p2In && b.thisPID == PlayerID.p2 && p2.GetComponent <PlayerController>().inOutReady)
                    {
                        StartCoroutine("IEInOutP2");
                        //Debug.Log("P2 was in, now is out");
                    }
                }
            }
        }
        else if (e.GetType() == typeof(Stick_GE))
        {
            Stick_GE s = (Stick_GE)e;
            if (p1In && s.thisPID == PlayerID.p1)
            {
                if (s.stick == Stick.Left && canMove)
                {
                    p1MoveVector = new Vector3(s.leftRight, s.upDown, 0) * moveForce;
                }
                if (s.stick == Stick.Right)
                {
                    if (s.upDown == 0 && s.leftRight == 0)
                    {
                        freeze0 = true;
                    }
                    else
                    {
                        //Debug.Log("Right stick inputing player 0");
                        freeze0 = false;

                        float ang = ((Mathf.Atan2(s.upDown, s.leftRight) * Mathf.Rad2Deg) + 360) % 360;
                        if (ang <= 90f)
                        {
                            desiredAngle = 360;
                        }
                        else
                        {
                            desiredAngle = Mathf.Clamp(ang, 180, 360);
                        }
                        //Debug.Log(desiredAngle);
                    }
                }
            }
            else if (p2In && s.thisPID == PlayerID.p2)
            {
                if (s.stick == Stick.Left)
                {
                    p2MoveVector = new Vector3(s.leftRight, s.upDown, 0) * moveForce;
                }
                if (s.stick == Stick.Right)
                {
                    if (s.upDown == 0 && s.leftRight == 0)
                    {
                        freeze1 = true;
                    }
                    else
                    {
                        //Debug.Log("Right stick inputing player 1");
                        freeze1 = false;

                        float ang = ((Mathf.Atan2(s.upDown, s.leftRight) * Mathf.Rad2Deg) + 360) % 360;
                        if (ang <= 90f)
                        {
                            desiredAngle = 360;
                        }
                        else
                        {
                            desiredAngle = Mathf.Clamp(ang, 180, 360);
                        }
                        //Debug.Log(desiredAngle);
                    }
                }
            }
        }
    }