// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { GameObject unitRef = IsMouseOnUnit(Input.mousePosition); Debug.Log("Mouse Was clicked, unit ref" + (unitRef == null ? "NULL" : "NOT NULL")); if (unitRef != null) { Debug.Log("Mouse is over a unit"); if (PreviousUnit != null) { animalController previousController = PreviousUnit.GetComponent <animalController>(); previousController.UnselectUnit(); } CurrentUnit = unitRef; animalController controller = CurrentUnit.GetComponent <animalController>(); controller.SelectUnit(); PreviousUnit = CurrentUnit; } } }
public void startFish(GameObject go) { this.spawner = go; this.controlScript = go.GetComponent <animalController>(); }
private void setController(GameObject go) { this.spawnGo = go; this.controller = go.GetComponent <animalController>(); }
public static void AddAnimal(animalController a) { Animals.Add(a); Debug.Log("ADDED to Aniaml List"); }
public void InstantiateAnimal(int switchNumber) { homeSpawn = mpGenertaor.GetTileAt(HomeSpawnCol, HomeSpawnRow).transform.position; enemySpawn = mpGenertaor.GetTileAt(EnemySpawnCol, EnemySpawnRow).transform.position; switch (switchNumber) { case 1: Debug.Log("You chose Wolf"); GameObject newWolf = Instantiate(Wolf); newWolf.transform.position = enemySpawn; animalController Script = newWolf.GetComponent <animalController>(); Script.AnimalColumn = EnemySpawnCol; Script.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script); ResourceObject.GetComponent <Resources>().PayMoneyWild(25); break; case 2: Debug.Log("You chose Deer"); GameObject newDeer = Instantiate(Deer, enemySpawn, Quaternion.identity); animalController Script1 = newDeer.GetComponent <animalController>(); Script1.AnimalColumn = EnemySpawnCol; Script1.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script1); ResourceObject.GetComponent <Resources>().PayMoneyWild(15); break; case 3: Debug.Log("You chose Moose"); GameObject newMoose = Instantiate(Moose, enemySpawn, Quaternion.identity); animalController Script2 = newMoose.GetComponent <animalController>(); Script2.AnimalColumn = EnemySpawnCol; Script2.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script2); ResourceObject.GetComponent <Resources>().PayMoneyWild(26); break; case 4: Debug.Log("You choose Bear"); GameObject newBear = Instantiate(Bear, enemySpawn, Quaternion.identity); animalController Script3 = newBear.GetComponent <animalController>(); Script3.AnimalColumn = EnemySpawnCol; Script3.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script3); ResourceObject.GetComponent <Resources>().PayMoneyWild(28); break; case 5: Debug.Log("You Chose Fox"); GameObject newFox = Instantiate(Fox, enemySpawn, Quaternion.identity); animalController Script4 = newFox.GetComponent <animalController>(); Script4.AnimalColumn = EnemySpawnCol; Script4.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script4); ResourceObject.GetComponent <Resources>().PayMoneyWild(18); break; case 6: Debug.Log("You chose Boar"); GameObject newBoar = Instantiate(Boar, enemySpawn, Quaternion.identity); animalController Script5 = newBoar.GetComponent <animalController>(); Script5.AnimalColumn = EnemySpawnCol; Script5.AnimalRow = EnemySpawnRow; AnimalList.AddAnimal(Script5); ResourceObject.GetComponent <Resources>().PayMoneyWild(20); break; ////////////////////////// case 7: Debug.Log("You chose Dog"); GameObject newDog = Instantiate(Dog, homeSpawn, Quaternion.identity); animalController eScript = newDog.GetComponent <animalController>(); eScript.AnimalColumn = HomeSpawnCol; eScript.AnimalRow = HomeSpawnRow; AnimalList.AddAnimal(eScript); ResourceObject.GetComponent <Resources>().PayMoneyTame(27); break; case 8: Debug.Log("You chose Cat"); GameObject newCat = Instantiate(Cat, homeSpawn, Quaternion.identity); animalController eScript1 = newCat.GetComponent <animalController>(); eScript1.AnimalColumn = HomeSpawnCol; eScript1.AnimalRow = HomeSpawnRow; AnimalList.AddAnimal(eScript1); ResourceObject.GetComponent <Resources>().PayMoneyTame(20); break; case 9: Debug.Log("You chose Bull"); GameObject newBull = Instantiate(Bull, homeSpawn, Quaternion.identity); animalController eScript2 = newBull.GetComponent <animalController>(); AnimalList.AddAnimal(eScript2); eScript2.AnimalColumn = HomeSpawnCol; eScript2.AnimalRow = HomeSpawnRow; ResourceObject.GetComponent <Resources>().PayMoneyTame(29); break; case 10: Debug.Log("You choose Rooster"); GameObject newRooster = Instantiate(Rooster, homeSpawn, Quaternion.identity); animalController eScript3 = newRooster.GetComponent <animalController>(); eScript3.AnimalColumn = HomeSpawnCol; eScript3.AnimalRow = HomeSpawnRow; AnimalList.AddAnimal(eScript3); ResourceObject.GetComponent <Resources>().PayMoneyTame(19); break; case 11: Debug.Log("You Chose Rabbit"); GameObject newRabbit = Instantiate(Rabbit, homeSpawn, Quaternion.identity); animalController eScript4 = newRabbit.GetComponent <animalController>(); eScript4.AnimalColumn = HomeSpawnCol; eScript4.AnimalRow = HomeSpawnRow; AnimalList.AddAnimal(eScript4); ResourceObject.GetComponent <Resources>().PayMoneyTame(18); break; case 12: Debug.Log("You chose Pig"); GameObject newPig = Instantiate(Pig, homeSpawn, Quaternion.identity); animalController eScript5 = newPig.GetComponent <animalController>(); eScript5.AnimalColumn = HomeSpawnCol; eScript5.AnimalRow = HomeSpawnRow; AnimalList.AddAnimal(eScript5); ResourceObject.GetComponent <Resources>().PayMoneyTame(20); break; default: Debug.Log("Not an animal"); break; } }