public IEnumerator GameOver() { if (currentscore > highscore) { highscore = currentscore; } PlayerPrefs.SetInt("Highscore", highscore); tileMoveSpeed = 0; player.GetComponentInChildren <Animator>().enabled = false; player.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; player.GetComponent <Rigidbody>().AddForce(Vector3.up * 10f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddForce(-Vector3.right * 5f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddTorque(Vector3.forward * 10f, ForceMode.Impulse); player.GetComponent <Rigidbody>().AddTorque(Vector3.right * 3f, ForceMode.Impulse); //Destroy(player.gameObject, 2); yield return(new WaitForSecondsRealtime(2)); gameOverScreen.SetActive(true); gameOverScreen.GetComponent <UnityEngine.UI.Text>().text = "Your Score: " + currentscore + "\n Highscore: " + highscore; }
// Sheep.BoxCollider의 4변 중 가장 가까운 지점 Search Vector3 FindClosestSide() { Bounds bound = TargetSheep.GetComponent <BoxCollider2D>().bounds; Vector2 closestSide = new Vector2(); // 각 Side 위치 설정 Vector2 middle = (bound.max - bound.min) / 2; Vector3[] sides = new Vector3[4]; sides[0] = new Vector3(bound.min.x + middle.x, bound.max.y); sides[1] = new Vector3(bound.min.x + middle.x, bound.min.y); sides[2] = new Vector3(bound.max.x, bound.min.y + middle.y); sides[3] = new Vector3(bound.min.x, bound.min.y + middle.y); // 가장 가까운 Side 탐색 float shortestDistance = Mathf.Infinity; float distance; for (int i = 0; i < sides.Length; i++) { distance = Vector2.SqrMagnitude(this.transform.position - sides[i]); if (shortestDistance > distance) { shortestDistance = distance; closestSide = sides[i]; } } return(closestSide); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { sheep = animator.GetComponent <Sheep>(); sheep_vars = sheep.GetComponent <Sheep_StateVars>(); time_to_pass = sheep_vars.sheep_floating_time; time_passed = 0; triggered = false; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { sheep = animator.GetComponent <Sheep>(); sheep_vars = sheep.GetComponent <Sheep_StateVars>(); time_to_pass = sheep_vars.sheep_spheric_time; sheep.SwapToSpheric(); }
private bool LionBirthday() { bool sheep = (Sheep.GetComponent <VisitFriend> ().VisitNumber > 0); bool bear = (Bear.GetComponent <VisitFriend> ().VisitNumber > 0); bool lion = (Lion.GetComponent <VisitFriend> ().VisitNumber > 0); bool table = Table.GetComponent <Item> ().haveItem(); bool cake = Table.GetComponent <Item> ().haveItem(); return(sheep && bear && lion && table && cake); }
private void OnMouseDown() { if (Type == IndicatorType.Possible) { if (this.Pos.x != Sheep.Pos.x) { Sheep.GetComponent <SpriteRenderer>().flipX = this.Pos.x < Sheep.Pos.x; } Sheep.Pos = this.Pos; Sheep.JustMoved = true; Globals.ProcessTurn(); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { /* TODO: Busca la oveja más cercana y la establece como objetivo */ sheep = animator.GetComponent <Sheep>(); sheep_vars = sheep.GetComponent <Sheep_StateVars>(); //sheep_vars.rb.freezeRotation time_to_pass = sheep_vars.sheep_fire_time; time_passed = 0; triggered = false; waypoint_set = false; particles = Instantiate(sheep_vars.fire_particles, animator.transform.position, Quaternion.identity, animator.transform); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { sheep = animator.GetComponent <Sheep>(); sheep_vars = sheep.GetComponent <Sheep_StateVars>(); /* Depending on the fruit type, the effect will be different */ sheep_vars.current_chasing_food.Interact(sheep); /* The fruit has been eaten, so it should be removed from the map */ Food food = sheep_vars.current_chasing_food; if (food) { Destroy(sheep_vars.current_chasing_food.gameObject); sheep_vars.current_chasing_food = null; } }