Human-Farm-Tycoon/Assets/Script/ConstructionBehaviour.cs
2015-08-13 13:29:57 -04:00

36 lines
707 B
C#

using UnityEngine;
using System.Collections;
public class ConstructionBehaviour : MonoBehaviour {
public int ConstructionType;
public GameObject maisonHumain;
public GameObject maisonZombie;
public GameObject champ;
private GameObject SwitchPrefab;
void OnMouseDown()
{
switch (ConstructionType) {
case 1:
SwitchPrefab = maisonHumain;
break;
case 2:
SwitchPrefab = champ;
break;
case 3:
SwitchPrefab = maisonZombie;
break;
default:
SwitchPrefab = maisonHumain;
break;
}
switchPrefab ();
}
void switchPrefab()
{
Instantiate (SwitchPrefab, this.gameObject.transform.position, this.gameObject.transform.rotation);
DestroyObject (this.gameObject);
}
}