public void Init() { itemEraser = this.gameObject.GetComponent <ItemEraser>(); itemMover = this.gameObject.GetComponent <ItemMover>(); itemEraser.Init(); itemMover.Init(); }
// call by play manager. (self create) public static Block Create(Vector3 pos, int maxHP, ItemType.EType type) { GameObject go = null; Block block = null; switch (type) { case ItemType.EType.BLOCK: go = GPoolManager.Inst.Add("Prefab/Game/Block", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetBlock(maxHP); break; case ItemType.EType.BALL: go = GPoolManager.Inst.Add("Prefab/Game/ItemBall", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetItemBall(); break; case ItemType.EType.TRI: { go = GPoolManager.Inst.Add("Prefab/Game/ItemTri", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetItemOnlyTurn(); ItemTri tri = go.GetComponent <ItemTri> (); // tri.RotateClock90 (UnityEngine.Random.Range (1, 4)); tri.ResetAngle(); } break; case ItemType.EType.ROTATION_TRI: { go = GPoolManager.Inst.Add("Prefab/Game/ItemTriRot", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetItemOnlyTurn(); ItemTriRot triRot = go.GetComponent <ItemTriRot> (); triRot.ResetAngle(); } break; case ItemType.EType.TURRET: go = GPoolManager.Inst.Add("Prefab/Game/ItemTurret", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetItemOnlyTurn(); break; case ItemType.EType.ERASER: go = GPoolManager.Inst.Add("Prefab/Game/ItemEraser", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.SetItemOnlyTurn(); ItemEraser item = go.GetComponent <ItemEraser> (); item.Init(UnityEngine.Random.Range(0, 2) == 0); break; default: go = GPoolManager.Inst.Add("Prefab/Game/Block", GameManager.Inst.tmGameRoot); block = go.GetComponent <Block> (); block.ResetMaxHP(maxHP); block.isBlock = true; break; } block.tm.localPosition = pos; block.type = type; block.dissolve.Reset(); block.fsm.Reset(); block.state = Block.E_STATE.Idle; go.SetActive(true); return(block); }