public FTankBase CreateTank(GameObject go) { FTankBase tankBase = GameObject.Instantiate(go).GetComponent <FTankBase>(); tankBase.InitTank(4, 200); return(tankBase); }
void Update() { if (Input.GetKeyDown(KeyCode.A)) { int index = Random.Range(0, tankList.Count); FITankFactory tankFactory = null; FTankBase tankBase = null; switch (tankList[index]) { case "TankA": tankFactory = new FTankAFactory(); tankBase = tankFactory.CreateTank(prefab_TankA); break; case "TankB": tankFactory = new FTankBFactory(); tankBase = tankFactory.CreateTank(prefab_TankB); break; case "TankC": tankFactory = new FTankCFactory(); tankBase = tankFactory.CreateTank(prefab_TankC); break; } tankBase.TankMove(); tankBase.TankShoot(); Debug.Log(tankBase.ToString()); } }