private void btClear_Click(object sender, EventArgs e) { if (mPhase == ePhase.ePWDWAIT) { mPhase = ePhase.ePWDOWR; } }
private void btStop_Click(object sender, EventArgs e) { if (mPhase != ePhase.eIDLE) { mPhase = ePhase.eRST; } mProcAsw(0, ""); }
private void btRead_Click(object sender, EventArgs e) { if (mPhase != ePhase.eIDLE) { return; } mPhase = ePhase.eREAD; btStop.Enabled = true; }
private void btWrite_Click(object sender, EventArgs e) { if (mPhase != ePhase.eIDLE) { return; } SyncData(); mPhase = ePhase.eWRITE; btStop.Enabled = true; }
public void CardClicked(Card card) { if (card.state == eCardState.onplace || card.state == eCardState.select) { return; } // TODO: По возможности переделать в switch if (phase == ePhase.idle) { if (VoidName == "") { float Vx = card.transform.localPosition.x; float Vy = card.transform.localPosition.y; VoidName = FindSuit(Vy) + FindRank(Vx); VoidPlace = new Vector2(Vx, Vy); print("выбрана " + VoidName + " позиция"); } card.transform.localPosition = SelectPlace; phase = ePhase.select; SelectCard = card; SelectCard.state = eCardState.select; score++; } else { if (card.state == eCardState.well) { if (SelectCard.rank == 7 || SelectCard.name == VoidName) { deck.RemoveWell(card); card.transform.localPosition = SelectPlace; CardGoToVoid(SelectCard.name); card.state = eCardState.select; SelectCard = card; score++; } return; } if (CheckPlace(card)) { ChangeCards(card); score++; print("Позиции совпадают"); } else { print("Позиции разные"); } } }
/// <summary> /// Called from string function to actually change the phase /// </summary> /// <param name="phase">Phase changing to</param> protected void ChangePhase(ePhase phase) { m_phase = phase; switch (phase) { case ePhase.Build: Build(); break; case ePhase.Play: BeginWave(); break; } Debug.LogFormat("Changing to {0} mode", m_phase); }
// Update is called once per frame void Update() { if (phase == ePhase.FadeIn || phase == ePhase.FadeOut) { Color colorOut = Color.black; Color colorIn = Color.black; Color color = Color.black; colorIn.a = 0.0f; switch (phase) { case ePhase.FadeIn: m_timer -= Time.deltaTime; if (m_timer <= 0.0f) { color.a = 0.0f; phase = ePhase.In; } else { color = Color.Lerp(colorIn, colorOut, m_timer / m_fadeTime); } Debug.Log(color.a); m_image.color = color; break; case ePhase.FadeOut: m_timer -= Time.deltaTime; if (m_timer <= 0.0f) { color.a = 1.0f; phase = ePhase.Out; } else { color = Color.Lerp(colorOut, colorIn, m_timer / m_fadeTime); } m_image.color = color; break; } } }
//Vector3 bar = default(Vector3) public void SetPhase(MySuffererController.ePhase _newPhase, Vector3 v3Destination, int opt) { if (_newPhase == ePhase.eRoom2Pre) { wayPointPos = myWayPointRoom2SE[0].transform.position; totalWayPointCnt = myWayPointsRoom2.Length; //iMyBedNumber = ( opt != -1) ? opt : 0; iMyBedNumber = opt; } else if (_newPhase == ePhase.eRoom2) { wayPointPos = v3Destination; } else if (_newPhase == ePhase.eExit) { wayPointPos = myWayPointRoom2SE[1].transform.position; } nowWayPointIdx = 0; phase = _newPhase; }
//--------------------------------------------------------------- public void thrRun() { string s; int i, n; while (!mbStop) { try { switch (mPhase) { case ePhase.eRST: mProcAsw(1, ""); mCom.Close(); mPhase = ePhase.eIDLE; mStatusTicks = Environment.TickCount; continue; case ePhase.eIDLE: Thread.Sleep(100); i = Environment.TickCount - mStatusTicks; if (i > 5000) { mProcAsw(0, ""); mStatusTicks = Environment.TickCount; } continue; case ePhase.eREAD: if (thrFindCom() <= 0) { break; } mProcAsw(0, "#G" + mCom.PortName + ": #B" + ResPw.sPwLogin); s = UsbPktTx('P', 1, mPasswUD, 15); if (s.Substring(0, 2) != "pA") { mProcAsw(0, "#G" + mCom.PortName + ": #R" + ResPw.sPwBad); break; } mCom.Write("\n"); s = UsbPktRx(1); s = UsbPktTx('R', 2, "0", 10); if (s.Substring(0, 2) != "rB") { mProcAsw(0, "#G" + mCom.PortName + ": #R" + ResPw.sPwReadFail); break; } mProcAsw(0, "#G" + mCom.PortName + ": #B" + ResPw.sPwReadOk); mProcAsw(3, s); break; case ePhase.eWRITE: if (thrFindCom() <= 0) { break; } mProcAsw(0, "#G" + mCom.PortName + ": #B" + ResPw.sPwLogin); mCom.Write("\n"); s = UsbPktRx(1); s = UsbPktTx('P', 3, mPasswUD, 15); if (s.Substring(0, 2) != "pC") { mPhase = ePhase.ePWDWAIT; mProcAsw(2, ""); // Unblock btCLEAR continue; } thrWrData(); break; case ePhase.ePWDWAIT: mProcAsw(0, ""); Thread.Sleep(100); mProcAsw(0, "#G" + mCom.PortName + ": #R" + ResPw.sPwNew); Thread.Sleep(200); continue; case ePhase.ePWDOWR: mProcAsw(0, "#G" + mCom.PortName + ": #B" + ResPw.sPwNewDo); mCom.Write("\n"); s = UsbPktRx(1); s = UsbPktTx('S', 4, mPasswUD, 15); if (s.Substring(0, 2) != "sD") { break; } thrWrData(); break; } } catch (Exception e) { mProcAsw(0, "#ROperation failed! " + e.Message); } mPhase = ePhase.eRST; } }
// Update is called once per frame void Update() { if (fHP > 80.0f) { //renderer.color = new Color(0, 0, 0, 1f); // black renderer.color = new Color(0, 1f, 0, 1f); // green } else if (fHP > 50.0f) { renderer.color = new Color(120 / 255, 1f, 120 / 255, 1f); } else if (fHP > 30.0f) { renderer.color = new Color(1f, 0.92f, 0.016f, 1f); // yellow } else if (fHP > 15.0f) { renderer.color = new Color(0.2f, 0.3f, 0.4F); // orange } else { renderer.color = new Color(1f, 0f, 0f, 1f); // red } if (currentState == eMoveState.Idle) { timeSpan += Time.deltaTime; if (timeSpan > checkTime) { currentState = eMoveState.Move; timeSpan = 0; // TEMP checkTime = Random.Range(2.0f, 6.0f); } // TEMP if (phase == ePhase.eRoom2) { fHP += 0.1f; if (fHP >= 100.0f) { phase = ePhase.eExit; wayPointPos = myWayPointRoom2SE[1].transform.position; GameObject findManager = GameObject.Find("SimulationManager"); findManager.GetComponent <SimulationManager>().SetEmptyBedStatus(iMyBedNumber, false); } } } if (currentState == eMoveState.Move) { currentPos = transform.position; float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(currentPos, wayPointPos, step); if (Vector3.Distance(wayPointPos, currentPos) == 0f) { currentState = eMoveState.Idle; if (phase == ePhase.eNone) { phase = ePhase.eRoom1; wayPointPos = myWayPointsRoom1[0].transform.position; } else if (phase == ePhase.eRoom1) { wayPointPos = myWayPointsRoom1[nowWayPointIdx].transform.position; //nowWayPointIdx++; nowWayPointIdx = Random.Range(0, totalWayPointCnt); nowWayPointIdx = (totalWayPointCnt > nowWayPointIdx) ? nowWayPointIdx : 0; } else if (phase == ePhase.eRoom2Pre) { if (iMyBedNumber != -1) { phase = ePhase.eRoom2; wayPointPos = myWayPointsRoom2[iMyBedNumber].transform.position; } } else if (phase == ePhase.eRoom2) { //wayPointPos = myWayPointsRoom1[iMyBedNumber].transform.position; //nowWayPointIdx++; //nowWayPointIdx = (totalWayPointCnt > nowWayPointIdx) ? nowWayPointIdx : 0; if (fHP >= 100.0f) { phase = ePhase.eExit; wayPointPos = myWayPointRoom2SE[1].transform.position; GameObject findManager = GameObject.Find("SimulationManager"); findManager.GetComponent <SimulationManager>().SetEmptyBedStatus(iMyBedNumber, false); } } else if (phase == ePhase.eExit) { GameObject findManager = GameObject.Find("SpawnManager"); findManager.GetComponent <SpawnManager>().PatientGoingOut(); Object.Destroy(this.gameObject); } } } }
public bool Import(out ePhase Phase, string Text, int oLine) { var c = new Cursor(Text); Phase = ePhase.None; if (c.SkipSpace() >= 2) { c.Commit(); switch ((int)mPhase) { case (int)ePhase.Number: { int Number = 0; if (c.IsMark('@') > 0) { c.Commit(); if (c.GetDecimal(ref Number, true) && Number >= 1 && Number <= 255) { c.Commit(); if (c.IsMark(':') > 0) { c.Commit(); if (c.IsMark('{') > 0) { c.Commit(); if (c.IsTerm) { mTimbre.Number = Number; Phase = mPhase; mPhase = ePhase.FB; return(true); } } } } else { Console.WriteLine($"!! Error !! : Illegal parameter"); Console.WriteLine($"Line {oLine+1} : Column {c.Preview+1}"); return(false); } } break; } case (int)ePhase.FB: { int FB = 0; if (c.GetValue(ref FB, true) && FB >= 0 && FB <= 7) { c.Commit(); if (c.IsTerm) { mTimbre.FB = (byte)FB; Phase = mPhase; mPhase = ePhase.OP1; return(true); } } else { Console.WriteLine($"!! Error !! : Illegal parameter"); Console.WriteLine($"Line {oLine+1} : Column {c.Preview+1}"); return(false); } break; } case (int)ePhase.OP1: { int AR = 0; int DR = 0; int SR = 0; int RR = 0; int SL = 0; int TL = 0; int KS = 0; int SE = 0; if (c.GetValue(ref AR, false) && AR >= 0 && AR <= 31) { c.Commit(); if (c.GetValue(ref DR, false) && DR >= 0 && DR <= 31) { c.Commit(); if (c.GetValue(ref SR, false) && SR >= 0 && SR <= 31) { c.Commit(); if (c.GetValue(ref RR, false) && RR >= 0 && RR <= 15) { c.Commit(); if (c.GetValue(ref SL, false) && SL >= 0 && SL <= 15) { c.Commit(); if (c.GetValue(ref TL, false) && TL >= 0 && TL <= 127) { c.Commit(); if (c.GetValue(ref KS, false) && KS >= 0 && KS <= 3) { c.Commit(); if (c.GetValue(ref SE, true) && SE >= 0 && SE <= 15) { c.Commit(); if (c.IsTerm) { mTimbre.OP1.AR = (byte)AR; mTimbre.OP1.DR = (byte)DR; mTimbre.OP1.SR = (byte)SR; mTimbre.OP1.RR = (byte)RR; mTimbre.OP1.SL = (byte)SL; mTimbre.OP1.TL = (byte)TL; mTimbre.OP1.KS = (byte)KS; mTimbre.OP1.SE = (byte)SE; Phase = mPhase; mPhase = ePhase.OP2; return(true); } break; } } } } } } } } Console.WriteLine($"!! Error !! : Illegal parameter"); Console.WriteLine($"Line {oLine+1} : Column {c.Preview+1}"); return(false); } case (int)ePhase.OP2: { int AR = 0; int DR = 0; int SR = 0; int RR = 0; int SL = 0; int TL = 0; int KS = 0; int SE = 0; string Name = ""; if (c.GetValue(ref AR, false) && AR >= 0 && AR <= 31) { c.Commit(); if (c.GetValue(ref DR, false) && DR >= 0 && DR <= 31) { c.Commit(); if (c.GetValue(ref SR, false) && SR >= 0 && SR <= 31) { c.Commit(); if (c.GetValue(ref RR, false) && RR >= 0 && RR <= 15) { c.Commit(); if (c.GetValue(ref SL, false) && SL >= 0 && SL <= 15) { c.Commit(); if (c.GetValue(ref TL, false) && TL >= 0 && TL <= 127) { c.Commit(); if (c.GetValue(ref KS, false) && KS >= 0 && KS <= 3) { c.Commit(); if (c.GetValue(ref SE, false) && SE >= 0 && SE <= 15) { c.Commit(); if (c.GetString(ref Name)) { c.Commit(); if (c.IsMark('}') > 0) { c.Commit(); if (c.IsTerm) { mTimbre.OP2.AR = (byte)AR; mTimbre.OP2.DR = (byte)DR; mTimbre.OP2.SR = (byte)SR; mTimbre.OP2.RR = (byte)RR; mTimbre.OP2.SL = (byte)SL; mTimbre.OP2.TL = (byte)TL; mTimbre.OP2.KS = (byte)KS; mTimbre.OP2.SE = (byte)SE; mTimbre.Name = Name; Phase = mPhase; mPhase = ePhase.Number; return(true); } } break; } } } } } } } } } Console.WriteLine($"!! Error !! : Illegal parameter"); Console.WriteLine($"Line {oLine+1} : Column {c.Preview+1}"); return(false); } } } Console.WriteLine($"!! Error !! : Syntax error"); Console.WriteLine($"Line {oLine+1} : Column {c.Preview+1}"); return(false); }