IEnumerator TexCtrler() { faceState fState_crnt = faceState.idle; mouseState mState_crnt = mouseState.idle; while (true) { yield return(new WaitForSeconds(0.03f)); // 얼굴 변경시 얼굴 코루틴 실행 if (fState == faceState.idle && fState_crnt != fState) { fState_crnt = fState; IEnumerator fCorout = idleFaceCtrler(); StartCoroutine(fCorout); } else if (fState == faceState.bling && fState_crnt != fState) { fState_crnt = fState; IEnumerator fCorout = blingFaceCtrler(); StartCoroutine(fCorout); } else if (fState == faceState.smile && fState_crnt != fState) { fState_crnt = fState; IEnumerator fCorout = smileFaceCtrler(); StartCoroutine(fCorout); } else if (fState == faceState.close && fState_crnt != fState) { fState_crnt = fState; IEnumerator fCorout = closeFaceCtrler(); StartCoroutine(fCorout); } // 입 변경시 입 코루틴 실행 if (mState == mouseState.idle && mState_crnt != mState) { mState_crnt = mState; IEnumerator mCorout = idleMouseCtrler(); StartCoroutine(mCorout); } else if (mState == mouseState.talking && mState_crnt != mState) { mState_crnt = mState; IEnumerator mCorout = talkingMouseCtrler(); StartCoroutine(mCorout); } else if (mState == mouseState.close && mState_crnt != mState) { mState_crnt = mState; IEnumerator mCorout = closeMouseCtrler(); StartCoroutine(mCorout); } } }
private void OnMouseDown() { if (Grid.state != Grid.gameState.playing) { return; } state = mouseState.downClick; //Debug.Log("OnMouseDown() for Cell [" + x + ", " + y + "]"); }
private void OnMouseDrag() { if (state == mouseState.downClick) { mouseDragStartPosition = Input.mousePosition; state = mouseState.drag; } if (state == mouseState.drag) { if (Vector3.Distance(mouseDragStartPosition, Input.mousePosition) > 3) { state = mouseState.cancelledClick; } } }
// Use this for initialization void Start() { state = mouseState.clear; transform.position = new Vector3(x, y, 0); Debug.Log("transform init'd to " + x + ", " + y); BoxCollider2D collider = gameObject.AddComponent <BoxCollider2D>(); SpriteRenderer spriteCellBG = gameObject.AddComponent <SpriteRenderer>(); spriteCellBG.sprite = Resources.Load <Sprite>("cell_bg"); cellLayer1 = new GameObject("Sprite Layer for Cell [" + x + ", " + y + "]"); cellLayer1.transform.position = transform.position; cellSprite = cellLayer1.AddComponent <SpriteRenderer>(); cellSprite.sortingOrder = 1; }
private void timer1_Tick(object sender, EventArgs e) { distanceFromCat = Vector2.Distance(cursorPos, mousePos); if (cursorPos.X != lastCursorPos.X && cursorPos.Y != lastCursorPos.Y) { lastCursorPos = cursorPos; if (distanceFromCat > saveDistanceFromCat) { mouseState = mouseState.Chilling; timer2.Stop(); } else { mouseState = mouseState.Evading; timer2.Start(); } } Invalidate(); }
private void btnRefresh_Click(object sender, EventArgs e) { mousePos.X = Width / 2; mousePos.Y = Height / 2; mouseState = mouseState.Chilling; }
private void OnMouseUp(bool sim) { //Debug.Log("OnMouseUp() " + sim + ", Cell [" + x + ", " + y + "]"); if (Grid.state != Grid.gameState.playing) { return; } if ((Time.time - touchTime) > Grid.longPressTime) { OnMouseUpRight(); touchTime = 0f; return; } else if (state == mouseState.cancelledClick) { state = mouseState.clear; return; } if (!clicked && !flagged) { clicked = true; if (!hasMine) { //todo: Debug, replace with sprites var theText = new GameObject("TextMesh for Cell [" + x + ", " + y + "]"); var textMesh = theText.AddComponent <TextMesh>(); textMesh.characterSize = 0.01f; textMesh.fontSize = 512; textMesh.text = neighborMines.Count.ToString(); textMesh.offsetZ = -1; if (neighborMines.Count == 1) { textMesh.color = Color.blue; } else if (neighborMines.Count == 2) { textMesh.color = Color.green; } else if (neighborMines.Count == 3) { textMesh.color = Color.red; } else if (neighborMines.Count == 4) { textMesh.color = Color.magenta; } else if (neighborMines.Count == 5) { textMesh.color = Color.cyan; } else { textMesh.color = Color.black; } textMesh.transform.position = transform.position + new Vector3(-0.15f, 0.275f, 0f); //end triggerNeighborCells(); } else { cellSprite.sprite = Resources.Load <Sprite>("mine"); } } }
void Pre() { this.mousePosition = Input.mousePosition; this.objectPosition = Camera.main.ScreenToWorldPoint (mousePosition); this.pointText.text = points.ToString (); if (tooltip != null) tooltip.transform.position = new Vector2(mousePosition.x + tooltip.GetComponent<RectTransform>().rect.width/2 + 10, mousePosition.y - tooltip.GetComponent<RectTransform>().rect.height/2 - 10); print (objectPosition.y); switch (this.state) { case mouseState.NONE: Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); break; case mouseState.PUSHER: if (objectPosition.x > -3 && objectPosition.x < 4.5f && objectPosition.y > -3.52f) { Cursor.SetCursor (cursorTexture [0], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { Instantiate (robo [0], new Vector3 (objectPosition.x, objectPosition.y, 0), Quaternion.identity); points -= 15; this.state = mouseState.NONE; } } else { Cursor.SetCursor (cursorTexture [3], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { this.state = mouseState.NONE; } } break; case mouseState.SLOW: if (objectPosition.x > -3 && objectPosition.x < 4.5f && objectPosition.y > -3.52f) { Cursor.SetCursor (cursorTexture [1], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { Instantiate (robo [1], new Vector3 (objectPosition.x, objectPosition.y, 0), Quaternion.identity); points -= 10; this.state = mouseState.NONE; } } else { Cursor.SetCursor (cursorTexture [4], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { this.state = mouseState.NONE; } } break; case mouseState.STUN: if (objectPosition.x > -3 && objectPosition.x < 4.5f && objectPosition.y > -3.52f) { Cursor.SetCursor (cursorTexture [2], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { Instantiate (robo [2], new Vector3 (objectPosition.x, objectPosition.y, 0), Quaternion.identity); points -= 20; this.state = mouseState.NONE; } } else { Cursor.SetCursor (cursorTexture [5], Vector2.zero, CursorMode.Auto); if (Input.GetMouseButtonDown (0)) { this.state = mouseState.NONE; } } break; } }
public void setStun() { if (points >= 20) this.state = mouseState.STUN; }
public void setSlow() { if (points >= 10) this.state = mouseState.SLOW; }
public void setPusher() { if (points >= 15) this.state = mouseState.PUSHER; }
// Update : clip 확인하고 state 수정 // IEnumerator TexCtrler : 0.03초마다 state 확인하고 코루틴 실행 // IEnumerator ~Ctrler : 각 얼굴/입 표정 담당 // Update is called once per frame void Update() { // check current animationclip clipInfo = mascot_animator.GetCurrentAnimatorClipInfo(0); clipName = clipInfo[0].clip.name; Fcount++; // 애니메이션클립이 바뀌었을때 한번만 실행 if (clipName == "m_starthi") { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.smile; mState = mouseState.talking; parti_flower.gameObject.SetActive(true); parti_flower.Play(); parti_spark.gameObject.SetActive(false); } } else if (clipName == "m_startwait") { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.idle; mState = mouseState.close; parti_flower.gameObject.SetActive(false); parti_spark.gameObject.SetActive(false); } } else if (clipName == "m_idlecute") { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.bling; mState = mouseState.idle; parti_flower.gameObject.SetActive(false); parti_spark.gameObject.SetActive(true); parti_spark.Play(); } } else if (clipName == "m_run") { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.smile; mState = mouseState.idle; parti_flower.gameObject.SetActive(false); parti_spark.gameObject.SetActive(false); } } else if (clipName == "m_talk") { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.close; mState = mouseState.talking; parti_flower.gameObject.SetActive(false); parti_spark.gameObject.SetActive(false); } } else { if (clipName_crnt != clipName) { clipName_crnt = clipName; fState = faceState.idle; mState = mouseState.idle; parti_flower.gameObject.SetActive(false); parti_spark.gameObject.SetActive(false); } } }