void Creature_onArrive(SteerableBehavior obj) { ((CreatureCtrl)obj).SetBool("isWalking", false); ((CreatureCtrl)obj).SetTrigger("reset"); obj.onMoveEnd = null; ((CreatureCtrl)obj).transform.localScale = new Vector3(1, 1, 1); }
private SteerableBehavior SpawnEgg(Vector3 inPosition, Quaternion inRotation) { GameObject egg = (GameObject)Instantiate(EggAwardPrefab, inPosition, inRotation); SteerableBehavior steering = egg.AddComponent <SteerableBehavior>(); steering.speed = 2.0f; egg.transform.SetParent(Counter.transform.parent, false); egg.transform.SetSiblingIndex(Counter.transform.GetSiblingIndex() + 1); egg.GetComponent <RectTransform>().anchoredPosition = inPosition; return(steering); }
void Creature_onFellToGround(SteerableBehavior obj) { // calculate which way to run // move off screen PrepWalkAnims(!isReturningToSeat); this.SetTrigger("plop"); this.StartMove(this.transform.position, true, ChickenSettings.instance.plopWait, false); this.onMoveEnd = Creature_onPlopped; UpdateQueuedSeatbelt(); }
void Creature_onPlopped(SteerableBehavior obj) { if (isReturningToSeat) { this.StartMove(prevLocalPosition, false, ChickenSettings.instance.snapBackSpeed, true); this.onMoveEnd = Creature_onSnappedBack; } else { float xPos = (this.transform.position.x > 0f) ? 10f : -10f; Vector3 pos = new Vector3(xPos, this.transform.position.y, this.transform.position.z); this.StartMove(pos, true, ChickenSettings.instance.leaveSpeed); this.onMoveEnd = Creature_onLeaveScreen; } UpdateQueuedSeatbelt(); }
void Creature_onFellToGround(SteerableBehavior obj) { ((CreatureCtrl)obj).SetBool("dragged", false); ((CreatureCtrl)obj).SetBool("isWalking", true); ((CreatureCtrl)obj).SetTrigger("plop"); if (((CreatureCtrl)obj).transform.localPosition.x - ((CreatureCtrl)obj).prevLocalPosition.x < 0) { ((CreatureCtrl)obj).transform.localScale = new Vector3(-1, 1, 1); } else { ((CreatureCtrl)obj).transform.localScale = new Vector3(1, 1, 1); } obj.StartMove(obj.transform.position, true, ChickenSettings.instance.plopWait, false); obj.onMoveEnd = Creature_onPlopped; }
void Creature_onSnappedBack(SteerableBehavior obj) { this.SetBool("isWalking", false); this.SetTrigger("reset"); this.transform.localScale = (value == 1) ? new Vector3(1f, 1f, 1f) : new Vector3(1.28f, 1.28f, 1f); //TODO: set local position //TODO: set local position (when picked up each time) //obj.transform.localPosition = obj.prevLocalPosition; this.onMoveEnd = null; this.transform.localPosition = this.prevLocalPosition; //TODO: should we set local (or global) to be SteerableBehavior.targetPosition instead? if (isSeatbelted) { seatbelt.GetComponent <Animator>().SetTrigger("dragFeedback"); this.SetTrigger("plop"); } UpdateQueuedSeatbelt(); }
void Creature_onPlopped(SteerableBehavior obj) { obj.StartMove(((CreatureCtrl)obj).prevLocalPosition, false, ChickenSettings.instance.toSubZoneSpeed, true); obj.onMoveEnd = Creature_onArrive; }
void Creature_onLeaveScreen(SteerableBehavior obj) { // destroy creature this.onMoveEnd = null; Destroy(this.gameObject); }