public FollowNav(BoyController boy, NavManage nav) { //this.cat = cat; this.boy = boy; ai = boy.GetComponent <BoyAI>(); this.nav = nav; }
public void SendToPachinko(GameObject geChild) { if (geChild.GetComponent <BoyController>()) { BoyController child = geChild.GetComponent <BoyController>(); int boyId = geChild.GetComponent <BoyController>().BoyID; if (!neededBoyList.Contains(boyId)) { GameController.Instance.audioController.PlayGlobalFX("voice_girl_idontlikeyou"); gameController.GameOver(); return; } var boyVoiceFileId = Random.Range(1, 4); GameController.Instance.audioController.PlayGlobalFX("voice_boy_cry_" + boyVoiceFileId); GameController.Instance.audioController.PlayGlobalFX("game_teleport"); guiController.UpdateChildGUI(boyId, childBall); CreateBall(childBall, boyId); child.gameObject.SetActive(false); } else { Debug.Log("No lo envio al pachinko!!!"); } }
public void ChooseKidToCapture() { var dir = Direction.ToVector2(FaceDirection); var wayleft = (position + dir * stepRange) - new Vector2(transform.position.x, transform.position.y); var normalizedInvertDir = new Vector2(dir.y, -dir.x).normalized; var rayStart = new Vector2(position.x, position.y - stepRange * 0.5f + boxCollider.size.y / 2); Debug.DrawLine(rayStart, rayStart + (4 * dir + normalizedInvertDir * 2f).normalized * 1f, Color.green); Debug.DrawLine(rayStart, rayStart + (4 * dir - normalizedInvertDir * 2f).normalized * 1f, Color.green); var localcollider = FindComponentInColliders <BoyController>(Physics2D.RaycastAll(rayStart, (4 * dir).normalized)); if (selectedBoy == localcollider) { return; } if (localcollider == null) { return; } selectedBoy = localcollider.gameObject.GetComponent <BoyController>(); }
private void Awake() { _goForChocolate = false; _agent = GetComponent <NavMeshAgent>(); _boyController = GetComponent <BoyController>(); _rb = GetComponent <Rigidbody>(); }
private void Awake() { boyInstance = this; characterController2D = GetComponent <CharacterController2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); rigidbody2D = GetComponent <Rigidbody2D>(); collider = GetComponent <CapsuleCollider2D>(); }
void Start() { mainCamera = Camera.main; cameraNoise = Camera.main.gameObject.GetComponent <NoiseEffect>(); timeTakenDuringLerp = captureTime / 2; _count = 0; _clockTransforms = new Queue <Capture>(); boyController = GetComponent <BoyController>(); rigidBody = GetComponent <Rigidbody2D>(); _movedBack = true; _stillLerping = false; bntClicked = false; btnClock.onClick.AddListener(btnClicked); }
// Use this for initialization void Start() { cat = GameManager.Instance.Player; boy = transform.GetComponent <BoyController>(); dangerDct = transform.GetComponent <DangerDetector>(); jmpDct = transform.Find("JumpDetector").GetComponent <JumpDetector>(); followNav = new FollowNav(boy, nav); followDirect = new FollowDirect(boy); GameManager.Instance.AddRoleListener(this); //初始化 mode = FollowMode.FollowTarget; targetTransfrom = cat.transform; }
private void OnCollisionEnter(Collision collision) { if (!collision.collider) { return; } BoyController boy = collision.collider.GetComponentInParent <BoyController>(); if (!boy) { return; } if (!hasBeenBoyed) { GetBoyedOn(); } }
private void OnCollisionEnter(Collision collision) { if (!collision.collider) { return; } BoyController boy = collision.collider.GetComponentInParent <BoyController>(); if (!boy) { return; } if (!boy.HasBeenBeered) { boy.HasBeenBeered = true; boy.GetAColdOne(collision); } }
private void TryToCapture() { IsCapturing = true; if (selectedBoy != null) { if (Vector2.Distance(transform.position, selectedBoy.transform.position) < 2f) { if (selectedBoy.IsWatchedByTeacher) { GameController.Instance.audioController.PlayGlobalFX("game_lose_teacher"); GameController.Instance.GetComponent <GameController>().GameOver(); } else { gameController.LevelController.SendToPachinko(selectedBoy.gameObject); selectedBoy.HandleAbduction(); selectedBoy = null; } } } animator.SetBool("capturing", true); StartCoroutine("CaptureEnd"); }
public FollowDirect(BoyController boy) { //this.cat = cat; this.boy = boy; ai = boy.GetComponent <BoyAI>(); }
// Update is called once per frame void Update() { grounded = Physics2D.OverlapArea((Vector2)transform.position + new Vector2(-0.1f, 0), (Vector2)transform.position + new Vector2(0.1f, -0.1f), StaticStuff.SolidLayers); anim.SetBool("Grounded", grounded); if (isAlive) { switch (state) { case State.Moving: float xMove = Input.GetAxis("Horizontal"); anim.SetFloat("Abs X Move", Mathf.Abs(xMove)); rb.velocity = new Vector2(xMove * movementSpeed, rb.velocity.y); if (xMove != 0) { transform.localScale = new Vector2((xMove > 0) ? 1 : -1, 1); if (stepTimer <= 0 && grounded) { PlaySound(step); stepTimer = 0.5f; } } stepTimer -= Time.deltaTime; textHolder.transform.localScale = transform.localScale; if (Input.GetButtonDown("Jump") && grounded) { rb.velocity = new Vector2(rb.velocity.x, jumpForce); } if (Input.GetButtonDown("Fire1")) { state = State.Attacking; anim.Play("playerAttack"); timeAttacking = 0; hasAttacked = false; } if (Input.GetButtonDown("PickUp")) { PickUp(); } if (Input.GetKeyDown(KeyCode.G)) { state = State.Grooving; anim.Play("playerGroove"); } break; case State.Attacking: //Attack logic timeAttacking += Time.deltaTime; rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y); if (timeAttacking >= attackResolutionTime) { if (!hasAttacked) { Collider2D[] r = new Collider2D[5]; ContactFilter2D cf = new ContactFilter2D(); cf.layerMask = StaticStuff.Destructibles; cf.useLayerMask = true; Physics2D.OverlapCircle(new Vector2(transform.position.x + attackOffset.x * transform.localScale.x, transform.position.y + attackOffset.y), 0.25f, cf, r); for (int i = 0; i < r.Length; i++) { if (r[i] != null && r[i].gameObject != gameObject) { if (r[i].CompareTag("Destructible")) { Destroy(r[i].gameObject); PlaySound(hit); } //EXCEPTIONS try { if (r[i].name == "Mudman") { PlaySound(hit); BoyController boy = GameObject.Find("Boy").GetComponent <BoyController>(); Sprite destroyedMudman = boy.destroyedMudman; r[i].GetComponent <SpriteRenderer>().sprite = destroyedMudman; boy.MudmanDestroyed(); } } catch { //Nothing } } hasAttacked = true; } } if (timeAttacking >= attackRecoveryTime) { state = State.Moving; } } break; case State.Staggered: timeStaggered += Time.deltaTime; rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y); if (timeStaggered > 0.4f) { state = State.Moving; } break; case State.Grooving: rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y); if (Input.GetKeyUp(KeyCode.G)) { state = State.Moving; anim.Play("playerIdle"); } break; case State.Sleeping: rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y); break; default: break; } HandleSpeech(); if (nearbyItems.Count > 0) { nearbyItems.OrderBy(item => (item.transform.position - transform.position).magnitude); nearestItem = nearbyItems[0]; } else { nearestItem = null; } float pttt = timeToLive; timeToLive -= Time.deltaTime; if (pttt > 50 && timeToLive < 50) { voiceLines.Add("I feel a strange, unnerving sensation."); } if (pttt > 5 && timeToLive < 5) { voiceLines.Add("Ow! It hurts at my very core!"); } if (timeToLive <= 0) { Debug.Log("Time ran out, heart attack"); Die(); } } else { timeDead += Time.deltaTime; rb.velocity = new Vector2(rb.velocity.x / Mathf.Pow(10, Time.deltaTime), rb.velocity.y); if (timeDead >= timeDeadMax) { //Reincarnate isAlive = true; transform.position = reincarnationPoint; timeToLive = startTimeToLive; StaticStuff.EndLifeCycle(); anim.Play("playerIdle"); state = State.Moving; } } }
// Use this for initialization void Start() { boy = GetComponent <BoyController>(); overridingSprites = Resources.LoadAll <Sprite>(path + boy.BoyID); }
private void Start() { _boy = GetComponent <BoyController>(); }
// Use this for initialization void Start() { this.boy = GameObject.Find("boy").GetComponent <BoyController>(); this.text = GetComponent <Text>(); }