public void SetThiefAnimator(ThiefState _state) { thievRenderer.SetActive(true); thiev.SetBool("Speed", false); thiev.SetBool("Normal", false); thiev.SetBool("Barrier", false); switch (_state) { case ThiefState.None: thievRenderer.SetActive(false); break; case ThiefState.Speed: thiev.SetBool("Speed", true); break; case ThiefState.Normal: thiev.SetBool("Normal", true); break; case ThiefState.Barrier: thiev.SetBool("Barrier", true); break; default: break; } thievTimer += waitToChangeAnim; }
private void changeState(ThiefState newState) { if (state == newState) { return; } state = newState; switch(state) { case ThiefState.LOCATE_CIDER: break; case ThiefState.IDLE_WHEN_NO_CIDER: { // Only change anchor if too far away from previous target. if ((idleAnchorPosition - transform.position).sqrMagnitude > idleRandomRadius * idleRandomRadius) { idleAnchorPosition = transform.position; } targetPosition = idleAnchorPosition + (Vector3) G.RandCircle(idleRandomRadius); } break; case ThiefState.MOVE_TO_CIDER: break; case ThiefState.GRAB_CIDER: break; case ThiefState.RUN_AWAY: { // TODO Make this smarter by running away from players? targetPosition = G.RandCircle(G.SAFE_SPAWN_RADIUS); } break; case ThiefState.DEAD: break; } }
public void GotStunned(float time) { stunnedTime = time; thiefState = Thief.ThiefState.STUN; anim.SetThiefAnimation(ThiefAnimator.Stun); //StartCoroutine(Stunned(time)); }
private void Update() { policeTimer -= Time.deltaTime; if (policeTimer <= 0) { if (currentPoliceState == PoliceState.Normal) { SetPoliceAnimator(PoliceState.Speed); currentPoliceState = PoliceState.Speed; } else { SetPoliceAnimator(PoliceState.Normal); currentPoliceState = PoliceState.Normal; } } thievTimer -= Time.deltaTime; if (thievTimer <= 0) { if (currentThievState == ThiefState.Normal) { currentThievState = ThiefState.Speed; SetThiefAnimator(ThiefState.Speed); } else { currentThievState = ThiefState.Normal; SetThiefAnimator(ThiefState.Normal); } } }
void stunnedUpdate() { stunnedTime -= Time.fixedDeltaTime; if (stunnedTime <= 0f) { anim.SetThiefAnimation(ThiefAnimator.Run); //アニメーション設定 thiefState = ThiefState.ESCAPE; } }
IEnumerator Stunned(float sec) { ThiefState tempState = thiefState; thiefState = Thief.ThiefState.STUN; anim.SetThiefAnimation(ThiefAnimator.Stun); yield return(new WaitForSeconds(sec)); thiefState = tempState; anim.SetThiefAnimation(ThiefAnimator.Run); }
//void StartSecondaryCounter() // //{ // //Debug.Log("start2ndCounter"); // escapeTimer2 += Time.deltaTime; // if (escapeTimer2 > headTreasureTimer) // { // if (!mIsTakenTreasure) // { // unit.HeadToTreasure(); // escapeTimer2 = 0f; // thiefState = ThiefState.HEAD_TREASURE; // anim.setRunAnimation(); // } // else // { // unit.HeadToExit(); // escapeTimer2 = 0f; // thiefState = ThiefState.HEAD_EXIT; // anim.setRunAnimation(); // } // } //} void OnTriggerEnter(Collider other) { if (thiefState == ThiefState.STUN) { return; } if (other.tag == "PlayerCollider" && thiefState != ThiefState.ARRESTED && mIsAllowFind == true) { mIsAllowFind = false; Debug.Log("detected Player"); mIsPlayerExitedState = false; thiefState = ThiefState.ESCAPE; //playerCollider.SetActive(true);// activates the collider of player, thus not pasing that route unit.HeadToEscapePoint(); //mIsTouched = true; //unit.RefindPath(); //unit.FollowPriority(); //StartCounter(); } else if (other.tag == "Ghost" && thiefState != ThiefState.ARRESTED && mIsAllowFind == true) { mIsAllowFind = false; Debug.Log("detected Ghost"); mIsPlayerExitedState = false; thiefState = ThiefState.ESCAPE; //if(ghostCollider!=null)ghostCollider.SetActive(true);// activates the collider of player, thus not pasing that route unit.HeadToEscapePoint(); //unit.RefindPath(); //unit.FollowPriority(); } //else if (other.tag == "Treasure") //{ // Debug.Log("inTreasure"); // thiefState = ThiefState.IN_TREASURE; // anim.setWaitAnimation(); //} else if (other.tag == "Alarm") { Debug.Log("sensed alarm"); } //else if (other.tag == "Exit" && thiefState == ThiefState.HEAD_EXIT) //{ // Debug.Log("exited"); // thiefState = ThiefState.END; // anim.setWaitAnimation(); //} else if (other.tag == "Exit" && !mIsTakenTreasure) { thiefState = ThiefState.EXITED; } }
void InTreasureUpdate() { treasureTimer += Time.deltaTime; if (treasureTimer > TimeToTakeTreasure)//time needed to collect treasure ** hardcode { mIsTakenTreasure = true; unit.HeadToExit(); thiefState = ThiefState.HEAD_EXIT; anim.SetThiefAnimation(ThiefAnimator.Run); treasureTimer = 0f; } if (unit.currTarget != unit.treasure) { TakingTreasureInterrupted(); } }
/// <summary> /// 終点チェック /// </summary> public void reachEscapePoint() { if (thiefState == Thief.ThiefState.GAMEOVER || thiefState == Thief.ThiefState.ARRESTED || thiefState == Thief.ThiefState.KILLED) { return; } //mIsAllowFind = false; //mIsPlayerExitedState = false; Debug.Log("ReachTarget"); if (mIsTakenTreasure) { if (unit.currTarget == unit.exit && thiefState == ThiefState.HEAD_EXIT && GameManager.Instance.getXZDistance(unit.exit.gameObject, unit.gameObject) <= 2f) //逃げる成功 { Debug.Log("exit_success"); thiefState = ThiefState.GAMEOVER; anim.SetThiefAnimation(ThiefAnimator.Wait); } else { thiefState = ThiefState.HEAD_EXIT; unit.HeadToExit(); anim.SetThiefAnimation(ThiefAnimator.Run); } } else { if (unit.currTarget == unit.treasure && GameManager.Instance.getXZDistance(unit.treasure.gameObject, unit.gameObject) <= 2f) //宝に接触 { if (thiefState != ThiefState.IN_TREASURE) { Debug.Log("inTreasure"); thiefState = ThiefState.IN_TREASURE; anim.SetThiefAnimation(ThiefAnimator.Steal); } } else { thiefState = ThiefState.HEAD_TREASURE; unit.HeadToTreasure(); anim.SetThiefAnimation(ThiefAnimator.Run); } } setGhostCollider(); //if(ghostCollider!=null)ghostCollider.SetActive(true);// activates the collider of player, thus not pasing that route }
void StartCounter() { //Debug.Log("startCounter"); escapeTimer += Time.deltaTime; if (escapeTimer > headTreasureTimer) { if (!mIsTakenTreasure) { unit.HeadToTreasure(); escapeTimer = 0f; thiefState = ThiefState.HEAD_TREASURE; anim.SetThiefAnimation(ThiefAnimator.Run); } else { unit.HeadToExit(); escapeTimer = 0f; thiefState = ThiefState.HEAD_EXIT; anim.SetThiefAnimation(ThiefAnimator.Run); } } }
// Use this for initialization void Start () { state = ThiefState.LOCATE_CIDER; ciderSource = null; carryOverheadBehaviour = gameObject.GetComponent<CarryOverheadBehaviour>(); }
private void MoveToTarget(Vector3 targetPosition, ThiefState onReachState) { Vector2 toDestination = targetPosition - this.transform.position; float distance = toDestination.sqrMagnitude; if (distance < 0.001f) { changeState(onReachState); } // actual movement is done in updateMove() }
void TakingTreasureInterrupted() { thiefState = ThiefState.ESCAPE; anim.SetThiefAnimation(ThiefAnimator.Run); treasureTimer = 0f; }