private void SpawnMushroom(GameObject mushroomPrefab, int x, int y, MushroomBehaviour mushroomBehaviour, MushroomColor color) { GameObject mushroom = Instantiate(mushroomPrefab, mPots[x][y].transform); MushroomControlerDeVerdad mushCon = mushroom.GetComponent <MushroomControlerDeVerdad>(); mushCon.mBoardController = this; mushCon.mPos = new Vector2Int(x, y); mushCon.mMushroomBehaviour = Instantiate <MushroomBehaviour>(mushroomBehaviour); mushCon.mMushroomBehaviour.mMushroomColor = color; }
internal void LittleHappyUpdate(MushroomControlerDeVerdad mushroom) { bool isHappy = IsHappy(mushroom.mBoardController, mushroom.mPos); if (isHappy && (!mWasHappy || firtUpdate)) { mushroom.GetComponent <Animator>().runtimeAnimatorController = mMushroomColor.mHappyAnimator; } else if (!isHappy && (mWasHappy || firtUpdate)) { mushroom.GetComponent <Animator>().runtimeAnimatorController = mMushroomColor.mSadAnimator; } mWasHappy = isHappy; firtUpdate = false; }
void Update() { if (Input.GetMouseButtonUp(0)) { if (potSelected != null && potOvered != null) { MushroomControlerDeVerdad mushroomSelected = potSelected.GetComponentInChildren <MushroomControlerDeVerdad>(); MushroomControlerDeVerdad mushroomTarget = potOvered.GetComponentInChildren <MushroomControlerDeVerdad>(); if (mushroomSelected != null) { mushroomSelected.transform.parent = potOvered.transform; mushroomSelected.transform.localPosition = Vector3.zero; mushroomSelected.mPos = potOvered.GetComponent <PotScript>().mPos; } if (mushroomTarget != null) { mushroomTarget.transform.parent = potSelected.transform; mushroomTarget.transform.localPosition = Vector3.zero; mushroomTarget.mPos = potSelected.GetComponent <PotScript>().mPos; } } else { if (potSelected != null) { MushroomControlerDeVerdad mushroomSelected = potSelected.GetComponentInChildren <MushroomControlerDeVerdad>(); if (mushroomSelected != null) { mushroomSelected.transform.localPosition = Vector3.zero; } } } potSelected = null; potOvered = null; } }