void LocalHandler(GameEvent e) { if (e.GetType() == typeof(Button_GE)) { Button_GE b = (Button_GE)e; if ((sM.C1 == SelectChoice.Ops && ((b.thisPID == PlayerID.p1 && thisSpeaker == Speaker.Ops) || (b.thisPID == PlayerID.p2 && thisSpeaker == Speaker.Doc))) || (sM.C1 == SelectChoice.Doc && ((b.thisPID == PlayerID.p1 && thisSpeaker == Speaker.Doc) || (b.thisPID == PlayerID.p2 && thisSpeaker == Speaker.Ops)))) { if (b.button == Button.Action) { aPressed = b.pressedReleased; } else if (b.button == Button.Dialogue) { yPressed = b.pressedReleased; } else if (b.button == Button.Choice1) { dPadUpPressed = b.pressedReleased; } else if (b.button == Button.Choice2) { dPadDownPressed = b.pressedReleased; } } } else if (e.GetType() == typeof(Stick_GE)) { Stick_GE s = (Stick_GE)e; if ((sM.C1 == SelectChoice.Ops && ((s.thisPID == PlayerID.p1 && thisSpeaker == Speaker.Ops) || (s.thisPID == PlayerID.p2 && thisSpeaker == Speaker.Doc))) || (sM.C1 == SelectChoice.Doc && ((s.thisPID == PlayerID.p1 && thisSpeaker == Speaker.Doc) || (s.thisPID == PlayerID.p2 && thisSpeaker == Speaker.Ops)))) { if (s.stick == Stick.Left) { if (s.leftRight != 0 || s.upDown != 0) { leftStickInputing = true; leftStickAng = Mathf.Atan2(s.upDown, s.leftRight); } else { leftStickInputing = false; } } else { if (s.leftRight != 0 || s.upDown != 0) { rightStickInputting = true; rightStickAng = Mathf.Atan2(s.upDown, s.leftRight); } else { rightStickInputting = false; } } } } }
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); } } } } }
//public void DeathUnload() //{ // EventManager.instance.Fire(new GE_LoadLevelRequest(0)); //} public void LocalHandler(GameEvent e) { if (e.GetType() == typeof(Button_GE)) { Button_GE b = (Button_GE)e; if (b.button == Button.Start && b.pressedReleased) { if (hold != 0 && level == 0) { Debug.Log("hold is " + hold + " and level is " + level); EventManager.instance.Fire(new GE_LoadLevelRequest(hold)); EventManager.instance.Fire(new GE_Danger()); EventManager.instance.Fire(new GameSaveLoadEvent()); } //LoadLevel(hold); } } }
//private void NewTest(GameEvent e) //{ // Test_GE myE = (Test_GE)e; // Debug.Log(myE.myA + " " + myE.myB + " " + myE.myC + " " + myE.myD); //} //private void TestOutput(GameEvent e) //{ // Device_GE thisE = (Device_GE)e; // Debug.Log((float)thisE.thisDev.LeftStickUp); //} private void OutPut(GameEvent e) { if (e.GetType() == typeof(Stick_GE)) { Stick_GE firedSGE = (Stick_GE)e; if ((int)firedSGE.thisPID == charNum) { if (firedSGE.stick == Stick.Left) { LeftStick((float)firedSGE.upDown, (float)firedSGE.leftRight, (int)firedSGE.thisPID); } else if (firedSGE.stick == Stick.Right) { RightStick((float)firedSGE.upDown, (float)firedSGE.leftRight, (int)firedSGE.thisPID); } } } else if (e.GetType() == typeof(Button_GE)) { Button_GE firedBGE = (Button_GE)e; if ((int)firedBGE.thisPID == charNum) { if (firedBGE.button == Button.Action) { AButton(firedBGE.pressedReleased, (int)firedBGE.thisPID); } else if (firedBGE.button == Button.Dialogue) { YButton(firedBGE.pressedReleased, (int)firedBGE.thisPID); } else if (firedBGE.button == Button.Choice1) { LeftBumper(firedBGE.pressedReleased, (int)firedBGE.thisPID); } else if (firedBGE.button == Button.Choice2) { RightBumper(firedBGE.pressedReleased, (int)firedBGE.thisPID); } } } }
void EventFunc(GameEvent e) { if (e.GetType() == typeof(GE_PreLoadLevel)) { //queuedLines.RemoveAll(l => l.GetType() == typeof(GE_Dia_Line)); } else if (e.GetType() == typeof(GE_Dia_Line)) { GE_Dia_Line d = (GE_Dia_Line)e; if (d.priority == DialogueLinePriority.Normal) { queuedLines.Add(d); } else if (d.priority == DialogueLinePriority.Interrupt) { queuedLines.Insert(0, d); if (queuedLines[0].type == DialogueLineType.Standard) { _fsm.TransitionTo <PrintStart>(); } else { _fsm.TransitionTo <ChoiceState>(); } } } else if (e.GetType() == typeof(Button_GE)) { Button_GE b = (Button_GE)e; { if (b.button == Button.Dialogue && b.pressedReleased) { //------------------------------------ // if lines are playing, advance //------------------------------------ if (_fsm.CurrentState.GetType() == typeof(PrintStart)) { EventManager.instance.Fire(new GE_SFX(SFX.Click)); _fsm.TransitionTo <PrintComplete>(); } else if (_fsm.CurrentState.GetType() == typeof(PrintComplete)) { EventManager.instance.Fire(new GE_SFX(SFX.Click)); _fsm.TransitionTo <Standby>(); } //------------------------------------ // if a new event's worth of dialogue is in the queue, start it in the appropriate way //------------------------------------ if (queuedLines.Count > 0 && _fsm.CurrentState.GetType() == typeof(Standby)) { if (queuedLines[0].tag == DialogueLineTag.First || queuedLines[0].tag == DialogueLineTag.FirstAndLast) { if (queuedLines[0].type == DialogueLineType.Standard) { _fsm.TransitionTo <PrintStart>(); } else if (queuedLines[0].type == DialogueLineType.Choice) { _fsm.TransitionTo <ChoiceState>(); } } } } else if (b.button == Button.Choice1 && b.pressedReleased) { if (_fsm.CurrentState.GetType() == typeof(ChoiceState)) { if (((b.thisPID == PlayerID.p1) && ((mySM.C1 == SelectChoice.Doc && queuedLines[0].speaker == Speaker.Doc) || (mySM.C1 == SelectChoice.Ops && queuedLines[0].speaker == Speaker.Ops))) || ((b.thisPID == PlayerID.p2) && ((mySM.C2 == SelectChoice.Doc && queuedLines[0].speaker == Speaker.Doc) || (mySM.C2 == SelectChoice.Ops && queuedLines[0].speaker == Speaker.Ops)))) { activeLine.choice1Event.Fire(); _fsm.TransitionTo <PrintStart>(); EventManager.instance.Fire(new GE_SFX(SFX.Click)); } } } else if (b.button == Button.Choice2 && b.pressedReleased) { if (_fsm.CurrentState.GetType() == typeof(ChoiceState)) { if (((b.thisPID == PlayerID.p1) && ((mySM.C1 == SelectChoice.Doc && queuedLines[0].speaker == Speaker.Doc) || (mySM.C1 == SelectChoice.Ops && queuedLines[0].speaker == Speaker.Ops))) || ((b.thisPID == PlayerID.p2) && ((mySM.C2 == SelectChoice.Doc && queuedLines[0].speaker == Speaker.Doc) || (mySM.C2 == SelectChoice.Ops && queuedLines[0].speaker == Speaker.Ops)))) { activeLine.choice2Event.Fire(); _fsm.TransitionTo <PrintStart>(); EventManager.instance.Fire(new GE_SFX(SFX.Click)); } } } } } }
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); } } } } }