private void OnCollisionEnter2D(Collision2D collision) { SteakMove steak = collision.collider.GetComponent <SteakMove>(); EnemyFollowPlayer pumpkin = collision.gameObject.GetComponent <EnemyFollowPlayer>(); MushroomBehavior mushroom = collision.gameObject.GetComponent <MushroomBehavior>(); if (steak != null || pumpkin != null || mushroom != null) { Hurt(); } if (collision.gameObject.tag == "Ground") { isJumping = false; } }
/* Method is public because it will be accessed within the SQLite script * It takes in the id, positions, age and deathage as arguments and * uses those values in order to set up the mushroom * Those variables will be gathered by reading a table in a database, * storing them and reusing them to call the method and create a mushroom */ public GameObject CreateDBMushroom(int id, float posX, float posY, float posZ, float age, float deathAge) { GameObject mushroom = GameObject.CreatePrimitive(PrimitiveType.Cube); mushroom.transform.position = new Vector3(posX, posY, posZ); Color randomColor = new Color(Random.value, Random.value, Random.value, 1); mushroom.GetComponent <Renderer>().material.color = randomColor; mushroom.name = "mushroom" + id; mushroom.tag = "Mushroom"; mushroom.AddComponent <Rigidbody>(); MushroomBehavior mushBeh = mushroom.AddComponent <MushroomBehavior>(); mushBeh.currentAge = age; mushBeh.deathAge = deathAge; return(mushroom); }