void Start() { animator = GetComponentInChildren <Animator>(); m_foodCollector = GetComponent <FoodCollector>(); m_BoxCollider2D = GetComponent <BoxCollider2D>(); m_RigidBody = GetComponent <Rigidbody2D>(); m_SpriteRenderer = GetComponent <SpriteRenderer>(); m_CatAudio = GetComponent <CatAudio>(); sr = GetComponentInChildren <SpriteRenderer>(); stockController = GetComponent <StockController>(); current_state = PlayerState.FALL; // TODO: In merge, replace variable in prefab, instead of doing this junk m_RigidBody.gravityScale = 2; //Check Cinemachine if (GameObject.Find("CM vcam1") != null) { vcam = GameObject.Find("CM vcam1").GetComponent <CinemachineVirtualCamera>(); } if (GameObject.Find("TargetGroup1") != null) { vgroup = GameObject.Find("TargetGroup1").GetComponent <CinemachineTargetGroup>(); } //StartCoroutine(DoDeath()); }
// void FixedUpdate() // { // velY -= gravity * Time.fixedDeltaTime; // this.m_Rigidbody2D.MovePosition(this.m_Rigidbody2D.position + Vector2.up * velY * Time.fixedDeltaTime); // } void OnCollisionEnter2D(Collision2D other) { // Debug.Log("COLLIDE"); // TODO: Ask next meeting to make a new layer. Im not sure if itll blow everyone's stuff up so yeah. // if (other.collider.tag == "Food") // { // // This is a terrible solution bc extra memory. // // Also they still bounce off each other for a frame. // Physics2D.IgnoreCollision(other.collider, other.otherCollider, true); // return; // } FoodCollector foodCollector = other.collider.GetComponent <FoodCollector>(); if (foodCollector != null) { Hitbox hitbox = GetComponent <Hitbox>(); foodCollector.HandleFood(this.foodValue, hitbox == null ? 0 : hitbox.creatorFatness * transform.localScale.x); if (!dontDestroy) { Object.Destroy(this.gameObject); } else { Physics2D.IgnoreCollision(this.m_CircleCollider, other.collider); } } // Stick to a floor. Dunno if people want this, but why not. // if (other.collider.GetComponent<FoodScript>() == null) // { // my_rigidbody.bodyType = RigidbodyType2D.Kinematic; // } }
public void destroyFoodDestroysFood() { GameObject collectorObject = new GameObject(); FoodCollector foodCollector = collectorObject.AddComponent <FoodCollector>(); GameObject uiContainer = new GameObject(); collectorObject.AddComponent <AudioSource>(); foodCollector.ui = uiContainer.AddComponent <UIscript>(); foodCollector.ui.poopFill = uiContainer.AddComponent <Image>(); GameObject food = new GameObject(); foodCollector.ui.pooAmount = 1; foodCollector.DestroyFood(food); Assert.IsTrue(!food.activeSelf); }
// Start is called before the first frame update void Start() { m_BoxCollider = this.GetComponent <BoxCollider2D>(); m_FoodCollector = this.GetComponent <FoodCollector>(); }
// Start is called before the first frame update void Start() { m_foodCollector = GetComponent <FoodCollector>(); m_CapsuleCollider = GetComponent <CapsuleCollider2D>(); m_RigidBody = GetComponent <Rigidbody2D>(); }