void HandleMouseMoveForPlant() { 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.GetPlantPos(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 HandleMouseMoveForShovel() { if (shovel) { Vector3 pos = Utility.GetMouseWorldPos(); Vector3 shovelPos = pos; shovelPos.x += 0.1f; shovelPos.y += 0.1f; shovel.transform.position = shovelPos; if (StageMap.IsPointInMap(pos)) { int row, col; StageMap.GetRowAndCol(pos, out row, out col); GameObject plant = GameModel.GetInstance().map[row, col]; if (selectedPlant != plant) { if (selectedPlant) { selectedPlant.GetComponent <SpriteDisplay>().SetAlpha(1f); } if (plant && plant.tag != "UnableSell") { selectedPlant = plant; selectedPlant.GetComponent <SpriteDisplay>().SetAlpha(0.6f); } else { selectedPlant = null; } } } } }