void Get_Exciting_Object() { // Move the actual character of this gameobject closer to _character gameobject. character.characterEntity.transform.position = Vector2.MoveTowards(transform.position, Current_Exciting_Object.transform.position, Time.deltaTime * True_Speed); if (transform.position == Current_Exciting_Object.transform.position) { Current_Exciting_Object.IsInMouth = true; Current_Held_Object = Current_Exciting_Object; Current_Exciting_Object = null; } }
void Look_Around() { Vector3 start = transform.position; //this isn't stupid, right? int animation_direction = GetComponent <Animator>().GetInteger("Direction"); Vector3 direction; switch (animation_direction) { case 1: direction = Vector3.up; break; case 2: direction = Vector3.left; break; case 3: direction = Vector3.down; break; default: direction = Vector3.right; break; } float distance = 10f; HashSet <RaycastHit2D> objectsInSight = new HashSet <RaycastHit2D>(); for (float i = -45; i <= 45; i += 1) { Vector3 startOffset = Vector3.Scale(Quaternion.AngleAxis(i, Vector3.forward) * direction, new Vector3(0.5f, 0.5f, 0.5f)); Debug.DrawRay(start + startOffset, Quaternion.AngleAxis(i, Vector3.forward) * direction * distance, Color.red); objectsInSight.UnionWith(Physics2D.RaycastAll(start + startOffset, Quaternion.AngleAxis(i, Vector3.forward) * direction, distance)); } foreach (RaycastHit2D obj in objectsInSight) { Exciting_Object exciting_obj = (Exciting_Object)obj.collider.gameObject.GetComponent("Exciting_Object"); if (Current_Exciting_Object == null || (exciting_obj != null && exciting_obj.ExcitementLevel > Current_Exciting_Object.ExcitementLevel)) { Current_Exciting_Object = exciting_obj; } } }
public void Drop_It() { Current_Held_Object.ExcitementLevel = 0; //so she doesn't pick it right back up Current_Held_Object.IsInMouth = false; Current_Held_Object = null; }
public void Pick_Up_Object(Exciting_Object obj) { obj.IsInHand = true; Current_Held_Object = obj; }