public void initCannon() { if (curCannon) { Destroy(curCannon); } curCannonSpec = SpecController.getItemById(PlayerData.getCurrentCannon()) as CannonItemSpec; CannonLevelMax = curCannonSpec.maxLevel; curCannon = (GameObject)Instantiate(GameController.GetInstance().getPrefab(curCannonSpec.name), new Vector3(0, 0, 0), Quaternion.identity, cannonCanvas.transform); curCannon.name = "MyCannon"; curCannon.GetComponent <MyCannon> ().init(curCannonSpec); Vector3 v2 = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, 0, 0)); v2.z = GameController.fishCannon_z; curCannon.transform.position = v2; }
public void init(CannonItemSpec spec) { itemSpec = spec; getAnimator().Play(itemSpec.name); }