public Human(HumanState state, int missionID, Point location, List <Item> expectedItems = null) { Location = location; this.MissionID = missionID; this.State = state; this.expectedItems = expectedItems; }
public void Die(bool sound) { if (sound) { GetComponent <AudioSource>().PlayOneShot(GameController.instance.deathSound); } if (buildingInside != null) { LeaveHouse(); } else if (resourceBeingGathered != null) { LeaveResource(); } GameController.instance.gameManager.humanManager.RemoveHuman(human); if (PlayerController.instance.previousSelection.go = gameObject) { PlayerController.instance.previousSelection.selected = null; Destroy(PlayerController.instance.currentGroundMarker); } Destroy(button); if (human._ageZone == Human.AgeZone.Elder && human._age.agingTimer > 1) { EventHandler.instance.AddAchievement(Achievement.hospice); } humanState = HumanState.dead; }
public void LeaveResource() { resourceBeingGathered.RemoveHuman(human); if (resourceBeingGathered._age._go.GetComponent <ResourceController>().whirlwind.activeInHierarchy) { resourceBeingGathered._age._go.GetComponent <ResourceController>().whirlwind.SetActive(false); } resourceBeingGathered = null; human._performingTask = false; if (axe.activeInHierarchy) { axe.SetActive(false); } if (farmingTool.activeInHierarchy) { farmingTool.SetActive(false); } human._age._taskTime = null; if (humanState != HumanState.movie && PlayerController.instance.previousSelection.go == gameObject) { humanState = HumanState.beingHeld; } else if (humanState != HumanState.movie) { humanState = HumanState.idle; Select(false); } }
public void CreateHuman(Human father, Human mother) { gm = GameController.instance.gameManager; human = gm.humanManager.AddHuman(this.gameObject, father, mother); gm.humanManager.RepopulateArray(); if (eyes != null) { eyes.GetComponent <MeshRenderer>().material = Instantiate(human._humanGenetics.GetEyeColour()); } if (model != null) { model.GetComponent <SkinnedMeshRenderer>().material = Instantiate(human._humanGenetics.GetSkinColour()); } hair = human._humanGenetics._hair; if (hair != null) { hair.GetComponent <MeshRenderer>().material = Instantiate(human._humanGenetics.GetHairColour()); } humanState = HumanState.idle; SpeechBubbleCanvas.gameObject.SetActive(true); button = Instantiate(GameController.instance.button) as GameObject; popBut = button.GetComponent <PopulationButtonList>(); button.SetActive(true); button.transform.SetParent(OrderChildren.oc.transform, false); popBut.human = human; feetTrail = Instantiate(feetTrailPrefab, transform, false); EventHandler.instance.AddHiddenEvent(EventHandler.EventType.childBorn); }
protected override void OnBeginHumanState(HumanState state) { if (state == HumanState.Dying) { TrashWorld.Instance.DecrementWasters(); ThrowItem(); StopAllCoroutines(); CachedAnimator.enabled = false; CachedRigidbody2D.fixedAngle = false; HitEffect h = GameObject.Instantiate(deathEffect) as HitEffect; h.SetEffect(CachedTransform.position, 0f, deathColor, AnnouncementType.Kill); //TrashUIManager.Instance.MakeAnnouncement (announcementBind, AnnouncementType.Kill, 0f); TemporarilyEnableRagdoll(); } else if (state == HumanState.Idle) { BeginIdle(); } }
void FixedUpdate() { if (Variables.screenState != ScreenState.Game) { return; } switch (state) { case HumanState.Idle: break; case HumanState.Run: // if (isTop) // { vel.z = speed; vel.y = rb.velocity.y; rb.velocity = vel; // } break; case HumanState.Jumping: var groundTfm = GetGround(); if (groundTfm) { state = HumanState.Run; animator.SetTrigger("JumpEnd"); } break; default: break; } }
public Human(HairSaloon saloon, int index) { HumanThread = new Thread(new ThreadStart(Run)); State = HumanState.Outside; Saloon = saloon; _index = index; }
void ChangeState(HumanState newState) { switch (newState) { case HumanState.Walking: seenItem = null; seenPlayer = null; targetSpeed = walkSpeed; look.LooseFocus(); emotion.Hide(); MoveTo(currentWaypoint); break; case HumanState.Thinking: targetSpeed = 0; SoundPlayer.PlayAtPosition("si_concerned_human", transform.position, 0.1f, true); break; case HumanState.Chasing: emotion.Show("Suprised"); targetSpeed = chaseSpeed; SoundPlayer.PlayAtPosition("si_raccoon_spotted", transform.position, 0.1f, false); break; case HumanState.Collecting: seenPlayer = null; break; } state = newState; }
private IEnumerator Resting() { float currentTimeSpentResting = 0; float timeToSpendDuringThisRest = Random.Range( SpawnManager.Instance.AverageHumanRestTime - SpawnManager.Instance.RangeFromAverageHumanRestTime, SpawnManager.Instance.AverageHumanRestTime + SpawnManager.Instance.RangeFromAverageHumanRestTime); while (currentTimeSpentResting < timeToSpendDuringThisRest) { currentTimeSpentResting += Time.deltaTime; yield return(null); } // Chance to rest more int restAgainRN = Random.Range(0, 2); if (restAgainRN == 0) { StartCoroutine(Resting()); yield break; } else { currentPathNode++; targetPosition.transform.position = PathFromExit[currentPathNode].position; humanState = HumanState.AutoPathing; UpdateStateText(); yield break; } }
void OnCollisionEnter2D(Collision2D other) { if (!started && other.gameObject.CompareTag("ground")) { started = true; final_distance = Random.Range(3f, 5f); final_position = new Vector3(transform.position.x + final_distance, transform.position.y, transform.position.z); } else if (other.gameObject.CompareTag("object")) { speed = 7; ObjectObstacle obj = other.gameObject.GetComponent <ObjectObstacle>(); if (obj != null) { current_state = obj.effect_on_human; animator.SetTrigger("Flip"); if (current_state.current_state == ObjectType.MOVE) { float displacement = current_state.distance; if (fallen == true) { displacement += 1; } displacement *= 2; final_position = new Vector3(transform.position.x + displacement, transform.position.y, transform.position.z); } } } }
public void ReleaseLatch() { humanState = HumanState.ReleaseLatch; GetComponent <StartupExperienceGeometry>().ReleaseDoor(); syncCamera = true; offset = cameraController.transform.position - human.transform.position; }
public void StartMovement(MovementDirection movementDirection, HumanState movementType) { if (IsJumping()) { if (movementDirection == currentMovementDirection) { return; } ChangeDirection(movementDirection); jumpMoving = true; return; } if (IsMoving()) { CachedRigidbody2D.velocity = Vector2.zero; EndMovement(); } ChangeDirection(movementDirection); SetState(movementType); }
public void EnableRun() { state = HumanState.Run; col.isTrigger = false; rb.constraints = RigidbodyConstraints.FreezeRotation; animator.SetTrigger("Run"); }
private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player" && State != HumanState.Idle) { State = HumanState.Idle; } }
void OnCollisionEnter(Collision coll) { if (coll.gameObject.tag == "rabbit" && humanstate == HumanState.GoToTarget && coll.gameObject == GameObject.Find("HumanSense").GetComponent <HumanSense>().target) { destination = p[Random.Range(0, 4)]; nvAgent.destination = destination.position; humanstate = HumanState.Wander; Destroy(coll.gameObject); Hungry += 100; } else if (coll.gameObject.tag == "tree" && humanstate == HumanState.GoToTarget && coll.gameObject == GameObject.Find("HumanSense").GetComponent <HumanSense>().target) { destination = p[Random.Range(0, 4)]; nvAgent.destination = destination.position; humanstate = HumanState.Wander; Destroy(coll.gameObject); Hungry += 50; } else if (coll.gameObject.tag == "flint" && humanstate == HumanState.GoToTarget && coll.gameObject == GameObject.Find("HumanSense").GetComponent <HumanSense>().target) { destination = p[Random.Range(0, 4)]; nvAgent.destination = destination.position; humanstate = HumanState.Wander; Destroy(coll.gameObject); Flints++; // 부싯돌 개수 증가 } }
void CheckHumanState() //FSM 상태간의 전환 { if (humanstate == HumanState.GoToEnd) { return; } if (humanstate == HumanState.SendSOS) { return; } if (humanstate == HumanState.GoToTop && MountTop.GetComponent <Transform>().position.x == GetComponent <Transform>().position.x && MountTop.GetComponent <Transform>().position.z == GetComponent <Transform>().position.z) { FindShip = false; humanstate = HumanState.SendSOS; return; } if (FindShip) { humanstate = HumanState.GoToTop; return; } if (humanstate == HumanState.Wander && Helth == 0) { humanstate = HumanState.GoToBed; return; } if (humanstate == HumanState.GoToBed && Home.GetComponent <Transform>().position.x == GetComponent <Transform>().position.x && Home.GetComponent <Transform>().position.z == GetComponent <Transform>().position.z) { humanstate = HumanState.Sleep; return; } if (humanstate == HumanState.Sleep) { return; } if (humanstate == HumanState.Wander && Hungry < 50) { humanstate = HumanState.LookForFood; return; } if (humanstate == HumanState.Wander && FoundTarget) { humanstate = HumanState.GoToTarget; return; } if (humanstate == HumanState.LookForFood && FoundTarget) { humanstate = HumanState.GoToTarget; return; } }
void Awake() { rb = GetComponent <Rigidbody>(); col = GetComponent <Collider>(); bulletManager = GetComponent <BulletManager>(); pullController = GetComponent <PullController>(); state = HumanState.Idle; }
//Add by Guanchen Liu //This condition will show the script is activated or not // Start is called before the first frame update void Start() { randomSpot = Random.Range(0, moveSpots.Length); currentState = HumanState.NORMAL; waitTime = startWaitTime; anim = GetComponent <Animator>(); anim.Play("walk"); }
// Use this for initialization void Start() { _myAnimator = GetComponent<Animator> (); _myRigid = GetComponent<Rigidbody> (); _myParticle = GetComponent<ParticleSystem> (); _state = HumanState.Human_Safe; }
protected void SetNextState(HumanState state) { if (currState != state && currState != HumanState.SCARED && currState != HumanState.HARDSTUNNED) { currState = state; } }
void OnMouseExit() { if (this.state != HumanState.Selected) { this.state = HumanState.Unselected; } GameManager.current.hideText(); }
void OnMouseEnter() { if (this.state != HumanState.Selected) { this.state = HumanState.Hover; } GameManager.current.showText(this.gameObject.name, human.age, this.description); }
private void Update() { if (human == null) { return; } Vector3 position = human.transform.position; HumanState state = human.state; bool onGround = human.onGround; if (oldState != HumanState.Walk && state == HumanState.Walk) { walkStartPos = position; } if (oldState == HumanState.Walk) { float magnitude = (position - walkStartPos).ZeroY().magnitude; if (state != HumanState.Walk) { if (magnitude > 0.5f) { StatsAndAchievements.AddTravel(human, magnitude); } } else if (magnitude > 10f) { StatsAndAchievements.AddTravel(human, magnitude); walkStartPos = position; } } if (oldState == HumanState.Climb && (state == HumanState.Jump || state == HumanState.Idle || state == HumanState.Walk)) { float num = position.y - climbStartPos.y; if (num > 0f) { StatsAndAchievements.AddClimb(human, num); } } if (state == HumanState.Climb && oldState != HumanState.Jump && oldState != HumanState.Climb) { climbStartPos = oldPos; } else if (state == HumanState.Jump && oldState != HumanState.Jump) { climbStartPos = oldPos; } else if (state == HumanState.Climb && position.y - climbStartPos.y < 0f) { climbStartPos = oldPos; } if (state == HumanState.Jump && oldState != HumanState.Jump) { StatsAndAchievements.IncreaseJumpCount(human); } oldState = state; oldPos = position; }
private IEnumerator Train(Training t) { this.State = HumanState.Typing; yield return new RadicalWaitForSeconds(t.Strength * 2); if(t.Skill.ID == 1) this.Programming += t.Strength; if (t.Skill.ID == 2) this.Art += t.Strength; this.State = HumanState.Idle; }
public void OnEnterRoom(RoomProperties enteredRoom) { if (!RunningAway) { if (EmotionalState == HumanState.SCARED) { EmotionalState = HumanState.WORRIED; } } }
public bool IsDead() { HumanState humanState = this.humanState.GetState(); if (humanState == HumanState.Dying || humanState == HumanState.Dead) { return(true); } return(false); }
public void NodeReached(NodeOnPath.PathNodeType pathNodeType) { if (PathFromExit.Length - 1 == currentPathNode) { // Exit node reached SpawnManager.Instance.humanCount--; Destroy(gameObject); } else if (PathFromExit.Length - 2 == currentPathNode) { // 25% chance to go around again if (Random.Range(0, 2) == 0) { currentPathNode = 0; targetPosition.transform.position = PathFromExit[currentPathNode].position; } else { // Send to exit currentPathNode++; targetPosition.transform.position = PathFromExit[currentPathNode].position; } } else if (!(currentPathNode == 0 && pathNodeType == NodeOnPath.PathNodeType.EnterExit)) { if (PathFromExit[currentPathNode + 1].GetComponent <NodeOnPath>().NodeType == NodeOnPath.PathNodeType.Rest) { // 50% chance to move towards rest node and rest there, 50% chance to pass int restRN = Random.Range(0, 2); currentPathNode = restRN == 1 ? currentPathNode + 1 : currentPathNode + 2; if (restRN == 1) { humanState = HumanState.Resting; UpdateStateText(); } targetPosition.transform.position = PathFromExit[currentPathNode].position; } else if (PathFromExit[currentPathNode].GetComponent <NodeOnPath>().NodeType == NodeOnPath.PathNodeType.Rest && humanState == HumanState.Resting) { // Run resting co-routine to take a rest and to have a 50% chance after each rest to take an additional resting period StartCoroutine(Resting()); } else { // Go to next node on path if this isn't the first node and they're colliding with the initial Enter/Exit node // The next node is a path node, by default currentPathNode++; targetPosition.transform.position = PathFromExit[currentPathNode].position; } } // Down here on initial spawn }
public bool IsMoving() { HumanState humanState = this.humanState.GetState(); if (humanState == HumanState.Running || humanState == HumanState.Walking) { return(true); } return(false); }
public void Jump() { if (state != HumanState.Run) { return; } vel.y = 12; rb.velocity = vel; animator.SetTrigger("JumpStart"); state = HumanState.Jumping; }
private void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Player") { if (State != HumanState.Flail) { m_target = other.gameObject; State = HumanState.Flail; } } }
void OnTrashAnimStateEnds(int stateHash) { HumanState state = GetStateForHash(stateHash); if (state != HumanState.None) { HandleAnimStateEnds(state); } HandleTrashAnimStateEnds(stateHash); }
public Human(GeneticCode code) { this.code = code; type = HumanType.Child; firstUpdate = true; secondsUntilMaturity = 5f + (Random.value * 10f); state = HumanState.Idle; setFuel(200); addBehaviours(); updateWeights(); World.world.updateHumanState(getID()); }
// Update is called once per frame void Update() { // Check the distance float distance = Vector3.Distance (gameObject.transform.position, _enemy.transform.position); if (distance <= 25) { _state = HumanState.Human_Danger; } else if (distance <= 30) { _state = HumanState.Human_Alert; } else if (distance > 30) { _state = HumanState.Human_Safe; } Vector3 velocity = new Vector3(); // State Switch switch (_state) { case HumanState.Human_Safe: { _myAnimator.SetTrigger ("Safe"); rotation = Mathf.Deg2Rad * GetComponent<Transform> ().rotation.eulerAngles; velocity.x = Constant.WalkSpeed * Mathf.Sin (rotation.y); velocity.y = _myRigid.velocity.y; velocity.z = Constant.WalkSpeed * Mathf.Cos (rotation.y); _myRigid.velocity = velocity; break; } case HumanState.Human_Alert: { _myAnimator.SetTrigger ("Alert"); _myRigid.velocity = Vector3.zero; Vector3 pos = _enemy.transform.position; pos.y = gameObject.transform.position.y; gameObject.transform.LookAt (pos); break; } case HumanState.Human_Danger: { _myAnimator.SetTrigger ("Danger"); Vector3 pos = _enemy.transform.position; pos.y = gameObject.transform.position.y; gameObject.transform.LookAt (pos); rotation = GetComponent<Transform> ().eulerAngles; rotation.y = rotation.y - 180; gameObject.transform.eulerAngles = rotation; velocity.x = Constant.RunSpeed * Mathf.Sin (Mathf.Deg2Rad * rotation.y); velocity.y = _myRigid.velocity.y; velocity.z = Constant.RunSpeed * Mathf.Cos (Mathf.Deg2Rad * rotation.y); _myRigid.velocity = velocity; break; } default: break; } }