private void OnTriggerEnter2D(Collider2D collision) { if (isAttached) { return; } RotateCenter center = collision.GetComponent <RotateCenter>(); if (center != null) { isAttached = true; isCellActive = false; transform.position = center.transform.position + Vector3.down * CELL_SIZE; transform.SetParent(_center.transform); this.RunAction(GetScale()); SetLocalCoord(); LevelMgr.Current.DelayCheckMerge(); SoundMgr.Current.PlayImpactSound(); return; } Cell anotherCell = collision.GetComponent <Cell>(); if (anotherCell != null) { isAttached = true; isCellActive = false; if (anotherCell.pow != this.pow) { transform.position = anotherCell.transform.position + Vector3.down * 0.426f; transform.SetParent(_center.transform); this.RunAction(GetScale()); SetLocalCoord(); SoundMgr.Current.PlayImpactSound(); if (anotherCell._cellType == CellType.Bomb) { anotherCell.BombTrigger(); } } else { MergeTo(anotherCell); } LevelMgr.Current.DelayCheckMerge(); } }
public void Init() { InitGrid(); //Physics.gravity = new Vector3(0, -30.0F, 0); _uiMgr = FindObjectOfType <UIMgr>(); _settingMgr = SettingMgr.Instance; _settingMgr.LoadFile(); _uiMgr.UpdateUI(); RotateCircle = GameObject.FindObjectOfType <RotateCenter>(); _fsm = StateMachine <PlayState> .Initialize(this, PlayState.Ready); _indicator = GetComponentInChildren <Indicator>(); _indicator.gameObject.SetActive(false); AdMgr.RegisterAllAd(); AdMgr.ShowAdmobBanner(); }
private void OnTriggerEnter2D(Collider2D collision) { if (isAttached) { return; } RotateCenter circle = collision.GetComponent <RotateCenter>(); if (circle != null) { isFire = false; Hitted(); transform.SetParent(circle.transform); return; } Number num = collision.GetComponent <Number>(); if (num != null) { isFire = false; Hitted(); if (_num == num.GetNum()) { num.Increase(); Destroy(gameObject); } else if (num.isAttached) { transform.SetParent(num.transform); } return; } }
private void Start() { _center = LevelMgr.Current.RotateCircle; }