void Start() { GameManager.Instance.grid = this; currState = Globals.State.Waiting; prevState = Globals.State.Waiting; Initialize(); CreateGrid(); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { GameObject[] toDestroy = GameObject.FindGameObjectsWithTag("Tile"); for (int xx = 0; xx < toDestroy.Length; xx++) { Destroy(toDestroy [xx]); } allTiles.Clear(); Start(); } if (currState == Globals.State.Waiting || currState == Globals.State.Swap) { if (waitCount > 0) { prevState = currState; currState = Globals.State.Busy; } else { InputDetection(); } } else if (currState == Globals.State.Selected || currState == Globals.State.SwapSelected) { if (waitCount > 0) { prevState = currState; currState = Globals.State.Busy; } else { InputDetection(); } } else if (currState == Globals.State.Busy) { if (waitCount <= 0) { currState = prevState; } } else if (currState == Globals.State.Moving) { if (waitCount <= 0) { GridSweep(); } } }
public void ToggleState(Globals.State newState) { if (state == Globals.State.Waiting) { if (newState == Globals.State.Selected) { ChangeLayers(true); startPos = this.transform.position; floatTimer = 0; state = newState; mouthAnim.SetBool("Active", true); } } else if (state == Globals.State.Moving) { if (newState == Globals.State.Waiting) { ChangeLayers(false); state = newState; mouthAnim.SetBool("Active", false); } } else if (state == Globals.State.Selected) { if (newState == Globals.State.Waiting) { this.transform.position = startPos; ChangeLayers(false); state = newState; mouthAnim.SetBool("Active", false); } if (newState == Globals.State.Moving) { state = newState; } } }
//--------------------------------------------------------------------------------------- void SetUI(Globals.State state) { switch (state) { case Globals.State.NewlyOpen: flowLayoutPanel1.Enabled = true; disconnectButton.Enabled = true; textBoxInfo.Text = global::Kuheylan.Properties.Resources.welcome; break; case Globals.State.InfoGathering: iconDon = true; buttonLoadJson.Enabled = false; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String1; break; case Globals.State.InfoGatheringSuccess: iconDon = false; buttonLoadJson.Enabled = true; progressBar1.Value = 100; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String2; break; case Globals.State.Connecting: iconDon = true; buttonLoadJson.Enabled = true; flowLayoutPanel1.Enabled = false; disconnectButton.Enabled = true; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String5; break; case Globals.State.Connected: iconDon = false; buttonLoadJson.Enabled = true; flowLayoutPanel1.Enabled = true; disconnectButton.Enabled = true; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String9; break; case Globals.State.Disconnecting: iconDon = true; disconnectButton.Enabled = false; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String16; break; case Globals.State.Disconnected: iconDon = false; buttonLoadJson.Enabled = true; flowLayoutPanel1.Enabled = true; disconnectButton.Enabled = false; progressBar1.Value = 0; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String17; break; case Globals.State.ConnError: iconDon = false; flowLayoutPanel1.Enabled = true; disconnectButton.Enabled = false; textBoxInfo.Text = global::Kuheylan.Properties.Resources.String10; //MessageBox.Show("Bağlanılamadı !!!"); break; case Globals.State.Closing: Manager.Close(); iconDon = false; threadIconChange.Abort(); notifyIcon1.Visible = false; notifyIcon1.Dispose(); break; } }
public void ToggleMode(Globals.State theState) { if (currState == Globals.State.Waiting) { if (theState == Globals.State.Selected) { currState = theState; selectedTile.ToggleState(Globals.State.Selected); } if (theState == Globals.State.Swap) { currState = theState; } } else if (currState == Globals.State.Selected) { if (theState == Globals.State.Waiting) { currState = theState; selectedTile.ToggleState(Globals.State.Waiting); selectedTile = null; } } else if (currState == Globals.State.Swap) { if (theState == Globals.State.Waiting) { currState = theState; } else if (theState == Globals.State.SwapSelected) { currState = theState; selectedTile.ToggleState(Globals.State.Selected); } } else if (currState == Globals.State.SwapSelected) { if (theState == Globals.State.Waiting) { currState = theState; selectedTile.ToggleState(Globals.State.Waiting); selectedTile = null; } else if (theState == Globals.State.Swap) { currState = theState; selectedTile.ToggleState(Globals.State.Waiting); selectedTile = null; } } else if (currState == Globals.State.Busy || currState == Globals.State.Moving) { if (theState == Globals.State.Waiting) { currState = theState; if (selectedTile != null) { selectedTile.ToggleState(Globals.State.Waiting); selectedTile = null; } } } ResetGrid(); }
void InputDetection() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Input.mousePosition; mousePos.z = 10.0f; mousePos = Camera.main.ScreenToWorldPoint(mousePos); if (currState == Globals.State.Waiting) { if (Physics2D.OverlapPoint(mousePos, tileLayer)) { selectedTile = Physics2D.OverlapPoint(mousePos, tileLayer).GetComponent <Tile> (); if (currState == Globals.State.Waiting) { ToggleMode(Globals.State.Selected); } } } else if (currState == Globals.State.Selected) { if (Physics2D.OverlapPoint(mousePos, tileLayer)) { //If another tile is clicked, deselect. ToggleMode(Globals.State.Waiting); } else { if (Physics2D.OverlapPoint(mousePos, backgroundLayer)) { currState = Globals.State.Moving; BackgroundTile bgObj = Physics2D.OverlapPoint(mousePos, backgroundLayer).GetComponent <BackgroundTile> (); if (tiles [bgObj.pos.x, bgObj.pos.y] == null) { tiles [selectedTile.pos.x, selectedTile.pos.y] = null; selectedTile.pos.x = bgObj.pos.x; selectedTile.pos.y = bgObj.pos.y; tiles [bgObj.pos.x, bgObj.pos.y] = selectedTile; StartCoroutine(MoveTile(selectedTile, bgObj.transform.position, 0)); } else { ToggleMode(Globals.State.Waiting); } } else { ToggleMode(Globals.State.Waiting); } } } else if (currState == Globals.State.Swap) { if (Physics2D.OverlapPoint(mousePos, tileLayer)) { selectedTile = Physics2D.OverlapPoint(mousePos, tileLayer).GetComponent <Tile> (); ToggleMode(Globals.State.SwapSelected); } } else if (currState == Globals.State.SwapSelected) { if (Physics2D.OverlapPoint(mousePos, tileLayer)) { Tile temp = Physics2D.OverlapPoint(mousePos, tileLayer).GetComponent <Tile> (); if (temp != selectedTile) { currState = Globals.State.Busy; int posX = selectedTile.pos.x; int posY = selectedTile.pos.y; selectedTile.pos.x = temp.pos.x; selectedTile.pos.y = temp.pos.y; temp.pos.x = posX; temp.pos.y = posY; tiles [temp.pos.x, temp.pos.y] = temp; tiles [selectedTile.pos.x, selectedTile.pos.y] = selectedTile; Vector2 posA = selectedTile.transform.position; Vector2 posB = temp.transform.position; selectedTile.ToggleState(Globals.State.Waiting); StartCoroutine(MoveTile(selectedTile, posB, 0)); StartCoroutine(MoveTile(temp, posA, 0)); } else { ToggleMode(Globals.State.Swap); } } else { ToggleMode(Globals.State.Swap); } } } }
/// <summary> /// Initialize /// </summary> private void Initialize() { currentPosition = 0; Shuffle = Globals.State.Off; Repeat = Globals.State.Off; }
/// <summary> /// Changes the state. /// </summary> /// <param name="s">The s.</param> public void ChangeState(Globals.State s) { curState = s; }
/// <summary> /// Toggle repeat On or Off /// </summary> /// <param name="state">State can be "On" / "Off"</param> public void ToggleRepeat(Globals.State state) { playList.Repeat = state; }
/// <summary> /// Initializes a new instance of the <see cref="JudgeStateEventArgs" /> class. /// </summary> /// <param name="s">The s.</param> public JudgeStateEventArgs(Globals.State s) { this.NewState = s; }
/// <summary> /// Handles the Elapse event of the JudgeTimer control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void JudgeTimer_Elapse(object sender, EventArgs e) { if (!_isRunning) return; if (curState != Globals.State.Good) { _procrastinateIteration++; } if (_onTask) { if (curState != Globals.State.Dormant && _currentTimerIteration >= _config.DormantClockIteration) { curState = Globals.State.Dormant; OnJudgeStateChange(this, new JudgeStateEventArgs(curState)); //notify the new dormant state } _currentTimerIteration++; } }
/// <summary> /// Receives a mouse/keyboard activity thus need to reset the dormant timer. /// </summary> public void ResetDormantTimer() { if (_onTask) { _currentTimerIteration = 0; if(curState == Globals.State.Dormant) { curState = Globals.State.Good; OnJudgeStateChange(this, new JudgeStateEventArgs(curState)); //notify the new dormant state CheckProcrastinate(); } } }
/// <summary> /// Checks whether certain window is on primary task or not, here only determines Good and Bad states /// </summary> /// <param name="newWinInfo">The new win information.</param> public void CheckOnTask(WindowInfo newWinInfo) { bool temp = IsProcABrowser(newWinInfo.ProcName) ? CheckKeyWords(newWinInfo.WinTitle) //if it's a browser, disregard handle, title or proc, just look at keywords matching : CheckWindows(newWinInfo); //if it's not a browser, then don't check title, only Check proc and handle normally if (_onTask != temp) //different than before { curState = temp ? Globals.State.Good : Globals.State.Bad; _onTask = temp; OnJudgeStateChange(this, new JudgeStateEventArgs(curState)); //Broadcast new state if (curState == Globals.State.Good) { CheckProcrastinate(); _procrastinateIteration = 0; } } }