private void HandleMouseForPlant() { if (selectedPlant) { Vector3 pos = Utility.GetMouseWorldPos(); Vector3 plantPos = pos; plantPos.y -= 0.3f; selectedPlant.transform.position = plantPos; if (StageMap.IsPointInMap(pos)) { StageMap.GetRowAndCol(pos, out row, out col); if (tempPlant.GetComponent <PlantGrow>().CanGrowInmap(row, col)) { tempPlant.transform.position = StageMap.SetPlantPos(row, col); tempPlant.GetComponent <SpriteDisplay>().SetOrderByRow(row); } else { col = row = -1; tempPlant.transform.position = new Vector3(1000, 1000, 0); } } else { col = row = -1; tempPlant.transform.position = new Vector3(1000, 1000, 0); } } }
void HandleMouseDownForPlant() { if (Input.GetMouseButtonDown(0)) { Collider2D collider = Physics2D.OverlapPoint(Utility.GetMouseWorldPos()); if (collider != null) { CancelSelectCard(); if (collider.gameObject.tag == "Card") { collider.gameObject.SendMessage("OnSelect"); AudioManager.GetInstance().PlaySound(seedLift); } } else if (selectedPlant) { if (row != -1) { selectedPlant.transform.position = StageMap.SetPlantPos(row, col); selectedPlant.GetComponent <PlantGrow>().Grow(row, col); AudioManager.GetInstance().PlaySound(plantGrow); selectedPlant = null; Destroy(tempPlant); tempPlant = null; selectedCard.Growed(); selectedCard = null; } else { CancelSelectCard(); } } } if (Input.GetMouseButtonDown(1)) { CancelSelectCard(); } }