protected override IEnumerator ActivityDuringDurationTime() { DS = DogState.GO; SkillSoundEffect("SkillEffect_Dog", 2f); return(base.ActivityDuringDurationTime()); }
void Update() { if (findMe.target == null) { state = DogState.DEFAULT; findMe.target = player.transform; } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (state != DogState.DEFAULT) { return; } else { state = DogState.SEARCH; Debug.Log("search"); } } else if (Input.GetKeyDown(KeyCode.Alpha2)) { if (state != DogState.DEFAULT) { return; } else { state = DogState.FETCH; Debug.Log("fetch"); } } }
void StopHere() { //NavMeshAgentを止める agent.isStopped = true; State = DogState.Idle; }
public void SetCurrentState(DogState state) { this.currentState = state; switch (state) { case DogState.barking: isBarking = true; isPatroling = false; isIdle = false; break; case DogState.idle: isBarking = false; isPatroling = false; isIdle = true; break; case DogState.patroling: isBarking = false; isPatroling = true; isIdle = false; break; case DogState.dead: isDead = true; animator.SetTrigger(isDeadParam); break; } animator.SetBool(isPatrolingParam, isPatroling); animator.SetBool(isIdleParam, isIdle); animator.SetBool(isBarkingParam, isBarking); }
private void EnterState(DogState state) { switch (currentState) { case DogState.EYEBROW: ContentManager.GetSound("bow").Play(); currnetTime = 0; break; case DogState.SLIDE_IN_TO_START: dog.SetDrawBoxPos(dog.getDrawBox().X, ContentManager.SCREEN_HEIGHT - dog.getDrawBox().Height - ContentManager.FLOOR_HEIGHT + 10); dog.SetEffect(SpriteEffects.FlipHorizontally); eyebrow.SetEffect(SpriteEffects.FlipHorizontally); EYE_BROW_OFFSET = new Vector2(dog.getDrawBox().Width - 255 - eyebrow.getDrawBox().Width, 43); break; case DogState.POOPING: Pooping(0); break; case DogState.SLIDE_IN: EYE_BROW_OFFSET = new Vector2(255, 43); dog.SetEffect(SpriteEffects.None); eyebrow.SetEffect(SpriteEffects.None); dog.SetDrawBoxPos(ContentManager.SCREEN_WIDTH, ContentManager.SCREEN_HEIGHT - 450); break; } }
public void MovePlayed(DogState move) { if (!movePlayed) // only one move per move! { movePlayed = true; if (move != level.CurrentDogState()) { moveGrade = MoveGrade.Wrong; } else { float timeDifference = Mathf.Abs(Time.time - nextBeatTime); moveGrade = MoveGrade.Perfect; while (timeDifference > thresholdTimes[(int)moveGrade]) { moveGrade++; } } if ((int)moveGrade >= (int)MoveGrade.Miss) { success = false; } gradeText.StartText(moveGrade); } }
// Use this for initialization void Start() { uac = GetComponent <UnityArmatureComponent>(); dogSleep = transform.Find("dog_sleep").gameObject; dogCatch = transform.Find("dog_catch").gameObject; // uac.flipX = true; t = transform.DOMove(new Vector3(2, 0.12f, 1), 6).SetAutoKill(false).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear); Tweener rotate = transform.DORotate(new Vector3(0, 0, 0), 0.01f).SetAutoKill(false); State = DogState.Move; t.onStepComplete += () => { if (rotate.IsBackwards()) { rotate.PlayForward(); } else { rotate.PlayBackwards(); } }; t.PlayForward(); GlobalDispatcher.Instance.AddListener(GlobalEvent.OnDogCatch, OnEventDispach); // MTRunner.Instance.StartRunner(Wait(5)); }
// Update is called once per frame void Update() { time += Time.deltaTime; if (!isCatch) { if (time >= Random.Range(1, 3) * 5) { State = DogState.Sleep; t.Pause(); if (time > Random.Range(1, 3) * 15) { t.PlayForward(); State = DogState.Move; time = 0; } } } else { State = DogState.Catch; t.Pause(); if (time > Random.Range(3, 4)) { isCatch = false; time = 0; } } }
public IEnumerator MoveOutDelay() { yield return(new WaitForSeconds(1f));// guardScript.GoHome(); dogState = DogState.moveOut; }
void Start() { lerp = GetComponent <AILerp>(); findMe = GetComponent <AIDestinationSetter>(); state = DogState.DEFAULT; player = GameObject.FindGameObjectWithTag("Player"); findMe.target = player.transform; }
public void DoFollow() { dogState = DogState.FOLLOW_VISIBLE_VICTIM; runDog.SetActive(true); walkDog.SetActive(false); // alertSound.Play(); }
public Dog() { dog = new Box(ContentManager.SCREEN_WIDTH, ContentManager.SCREEN_HEIGHT - 450, 715, 758, Color.White, "dog"); eyebrow = new Box(0, 0, 44, 25, Color.White, "eyebrow"); EYE_BROW_OFFSET = new Vector2(255, 43); currentState = DogState.IDLE; setNextState(DogState.SLIDE_IN); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); agent = GetComponent <NavMeshAgent>(); state = DogState.Idle; anim = GetComponent <Animator>(); stateNow = state; }
private void OnFollowEnter() { navAgent.isStopped = false; state = DogState.Follow; subState = DogSubState.FollowPath; startLookAtTime = float.MaxValue; animator.PlayWalk(); Repath(followOffset); }
public void ResetGame() { this.locationState = LocationStates.NotStarted; this.dogState = DogState.Ignored; this.capeState = CapeState.Down; this.talkingToGirl = false; this.fallingInLove = 0; SchoolLocation.Instance.Reset(); }
private void LeaveState(DogState state) { switch (currentState) { case DogState.EYEBROW: eye_brow_delta = 0; break; } }
void GotoNextPoint() { State = DogState.Move; //NavMeshAgentのストップの解除 agent.isStopped = false; //CentralPointの位置にPosXとPosZを足す pos = central.position; //NavMeshAgentに目標地点を設定する agent.destination = pos; }
private void OnPatrolEnter() { navAgent.isStopped = false; state = DogState.Patrol; subState = DogSubState.PatrolGotoInteractable; Vector3 targetPos = needsObjects[currentNeedsObjectIndex].transform.position; navAgent.SetDestination(targetPos); animator.PlayWalk(); }
// Start is called before the first frame update void Start() { faceRight = true; isFollow = true; isSit = false; state = DogState.FOLLOW; anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); target = GameObject.FindGameObjectWithTag("Player").transform; }
public void MoveHorizontal(int xPos) { MoveTo(new Vector2(xPos, Position.Y)); if (xPos < Position.X) { CurrentState = DogState.WalkingLeft; } else if(xPos > Position.X) { CurrentState = DogState.WalkingRight; } }
private void OnLeadEnter() { navAgent.isStopped = false; state = DogState.Lead; subState = DogSubState.GoToOwner; startLookAtTime = float.MaxValue; animator.PlayWalk(); Vector3 direction = (needsFilling.transform.position - owner.position).normalized; direction *= goToFarmerDistance; Repath(direction); }
void MoveToTarget() { transform.position = Vector2.MoveTowards(transform.position, new Vector2(target.position.x, transform.position.y), speed * Time.deltaTime); //Debug.Log(Vector2.Distance(transform.position, new Vector2(target.position.x, transform.position.y))); if (Vector2.Distance(transform.position, new Vector2(target.position.x, transform.position.y)) < 0.05f) { Debug.Log(state); isFollow = false; anim.SetBool("Follow", false); state = DogState.STAND; } }
private void SetNextTargetPosition() { float pos = Position.X; while (Math.Abs(pos - Position.X) < 100) { pos = rand.Next(50, 750 - (int)Size.X); } targetPosition = new Vector2(pos, Position.Y); startPosition = Position; stateDuration = (targetPosition - startPosition).Length() / Speed; state = DogState.Moving; }
void Start() { state = DogState.Idle; animator = GetComponent <Animator>(); soundController = GetComponent <DogSoundController>(); stateDuration = 0.4f; // seconds timeAtNewState = 0.0f; StartExtra(); Timer timer = GameObject.Find("MainController").GetComponent <Timer>(); timer.AddSubscriber(this); }
void Update() { // is it time to idle again?! // animator.SetInteger("DogState", (int)state); if (state != DogState.Idle) { if (stateTimeOver()) { state = DogState.Idle; } } }
public void StateButtonPressed(DogState buttonState) { if (!level.IsLeading()) { timeAtNewState = Time.time; state = buttonState; if (state == DogState.Bark) { soundController.Bark(); } verifier.MovePlayed(buttonState); } }
IEnumerator getCoroutineForState(DogState state) { switch (state) { case DogState.Wandering: return(wander()); case DogState.Idle: return(null); default: return(null); } }
void switchToState(DogState state) { if (state != this.currentState) { if (currentStateRoutine != null) { StopCoroutine(currentStateRoutine); } currentStateRoutine = getCoroutineForState(state); if (currentStateRoutine != null) { StartCoroutine(currentStateRoutine); } this.currentState = state; } }
void CalculateWeight() { this.losingWeight = this.hunger <= 25; if (losingWeight) { int curr_state = (int)this.dogState < Enum.GetNames(typeof(DogState)).Length - 1 ? (int)this.dogState + 1 : (int)DogState.Hell; this.dogState = (DogState)curr_state; print("state actual = " + this.dogState.ToString()); } if (this.hunger <= 0) { GameController.current.Ending("dog hunger"); } }
private void GoStraight() { float betangle = Vector3.Angle(Owner.HQ.transform.position, this.transform.position); if (betangle > 90) { DS = DogState.BACK; } if (DS == DogState.GO) { SkillParent.transform.Rotate(new Vector3(-speed * GameTime.FrameRate_60_Time, 0, 0)); } else if (DS == DogState.BACK) { SkillParent.transform.Rotate(new Vector3(speed * GameTime.FrameRate_60_Time, 0, 0)); } }
void CheckPlayerFromRay() { RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, new Vector2(direction, 0), distanceToPlayer, whatIsPlayer); if (hitInfo.collider != null) { isFollow = false; state = DogState.STAND; anim.SetBool("Follow", isFollow); } else { isFollow = true; state = DogState.FOLLOW; anim.SetBool("Follow", isFollow); } }
// Update is called once per frame void Update() { agent.SetDestination(player.transform.position); if (agent.remainingDistance > agent.stoppingDistance) { state = DogState.Walk; } else { state = DogState.Attack; } //如果状态改变 if (stateNow != state) { stateNow = state; ChangeState(); } }
void SetNextState() { switch (state) { case DogState.WaitingToMove: SetNextTargetPosition(); break; case DogState.Moving: state = DogState.WaitingToDrop; stateDuration = DropDelay; break; case DogState.WaitingToDrop: if (DropEgg != null) DropEgg(this, null); state = DogState.WaitingToMove; stateDuration = 0; break; } timeSinceStateChange = 0; }
public void Start() { state = DogState.WaitingToMove; SetNextState(); }
public override void Update(GameTime gameTime) { if (gameTime.TotalGameTime.TotalSeconds >= _bark.TimeFinished && CurrentState.Equals(DogState.Barking)) { CurrentState = DogState.Sitting; } ChangeTexture(); if (HasReachedDestination) { Sit(); } base.Update(gameTime); }
public void Sit() { CurrentState = DogState.Sitting; }
void UpdateState() { Vector3 prevLaneOffset = currentLane.GetOffset(); switch (currentState) { case DogState.CHASE: currentLane = player.currentLane; break; case DogState.LUNGE: // Take care of warning period if (delayTimer < LUNGE_DELAY) { delayTimer += Time.deltaTime; warningSprite.SetActive(true); } else { warningSprite.SetActive(false); lungeTimer++; // If dog has finished lunging, make it go back to chasing if (lungeTimer > MAX_LUNGE_TIMER) { lungeTimer = 0; delayTimer = 0.0f; currentState = DogState.CHASE; } } break; } transform.position = new Vector3 ( transform.position.x, currentLane.GetY() + 0.1f, transform.position.z ) - prevLaneOffset + currentLane.GetOffset(); }
/// <summary> /// Method to let the dog bark /// </summary> public void Bark(GameTime gameTime) { _currentFrame = 0; CurrentState = DogState.Barking; _bark.Play(gameTime); }
public void Stop() { currentState = DogState.EATING; }