//======================================================================== // Trigger Enter/Stay functions //======================================================================== void OnTriggerEnter(Collider other){ if (other.gameObject.tag == "Health" || other.gameObject.tag == "Life" || other.gameObject.tag == "Key") { return; } if (other.gameObject.tag == "Savepoint" && gameObject.tag == "Hero") { other.enabled = false; return; } if (!touchingObjects.ContainsKey(other)) touchingObjects.Add(other, getRelationToObject(other)); else touchingObjects[other] = getRelationToObject(other); if (touchingObjects [other] == relationToOther.ONTOP) { if (other.tag != "Hero" && other.tag != "Candy") land (other); } if (touchingObjects[other] == relationToOther.ONSLOPE && !onShroom){ onShroom = other.GetComponent<ShroomCube>(); other.GetComponent<ShroomCube>().modifyPosition(gameObject); land(other); } print(touchingObjects[other] + " of " + other.name); switchOnRelation(other); }
void FixedUpdate(){ if (onShroom){ onShroom.modifyPosition(gameObject); if (onShroom.offShroom(gameObject)) { GetComponent<FallingObject>().fall(); onShroom = null; } } if (wall){ if (atWallTop(wall)) landOnWallTop(wall); } }
void land(Collider landing){ // land on the object if (GetComponent<PhysicsObject>() != null) GetComponent<PhysicsObject>().land(); if (GetComponent<FallingObject>() != null) GetComponent<FallingObject>().land(); // if (landing.GetComponent<ShroomCube>()){ // currentShroomLayer = landing.GetComponent<ShroomCube>(); // } else { // currentShroomLayer = null; // } OpenSideObject.openAllSides(); if (GetComponent<SticksToWalls>()) GetComponent<SticksToWalls>().onWall = false; if (!landing.GetComponent<ShroomCube>()) onShroom = null; if (GetComponent<JumpingObject> () != null) { JumpingObject jo = GetComponent<JumpingObject> (); if (infinite_jump) jo.jump (); jo.doubleJump = false; } if (GetComponent<Hero> () != null) { GetComponent<Hero> ().landMiniJump (); } if (infinite_jump) GetComponent<JumpingObject>().jump(); }