/// <summary> /// Create new DynamicBlockerObject for gridcell /// </summary> /// <param name="parent"></param> /// <param name="oData"></param> /// <param name="addCollider"></param> /// <param name="radius"></param> /// <param name="isTrigger"></param> /// <returns></returns> public static DynamicBlockerObject Create(GridCell parent, DynamicBlockerData oData, bool addCollider, bool isTrigger, Action <int> TargetCollectEvent) { if (!parent || oData == null) { return(null); } GameObject gO = null; SpriteRenderer sR = null; DynamicBlockerObject gridObject = null; sR = Creator.CreateSprite(parent.transform, oData.ObjectImage, parent.transform.position); gO = sR.gameObject; gridObject = gO.GetOrAddComponent <DynamicBlockerObject>(); if (addCollider) { BoxCollider2D cC = gridObject.gameObject.GetOrAddComponent <BoxCollider2D>(); cC.isTrigger = isTrigger; } #if UNITY_EDITOR gO.name = "dynamic blocker " + parent.ToString(); #endif gridObject.SetData(oData); gridObject.SRenderer = sR; gridObject.TargetCollectEvent = TargetCollectEvent; return(gridObject); }
internal void SetDynamicBlockerObject(DynamicBlockerData mObjectData) { if (mObjectData == null || IsDisabled || Blocked) { return; } // Debug.Log("set dynamic blocker: " + mObjectData.ID); if (DynamicObject) { GameObject old = DynamicObject; DestroyImmediate(old); } if (StaticBlocker) { GameObject old = StaticBlocker.gameObject; DestroyImmediate(old); } DynamicBlockerObject.Create(this, mObjectData, false, true, MBoard.TargetCollectEventHandler); DynamicBlocker.SetToFront(false); }
internal virtual void SetData(DynamicBlockerData mData) { OData = mData; SetToFront(false); }
internal void SetObject(int ID) { IsDisabled = false; MatchObjectData mOD = GOSet.GetMainObject(ID); if (mOD != null) { SetMatchObject(mOD); return; } OverlayObjectData oOD = GOSet.GetOverlayObject(ID); if (oOD != null) { SetOverlay(oOD); return; } UnderlayObjectData uOD = GOSet.GetUnderlayObject(ID); if (uOD != null) { SetUnderlay(uOD); return; } DynamicClickBombObjectData cdOD = GOSet.GetDynamicClickBombObject(ID); if (cdOD != null) { SetDynamicClickBomb(cdOD); return; } if (ID == GOSet.FallingObject.ID) { SetFalling(GOSet.FallingObject); return; } BaseObjectData bOD = GOSet.GetObject(ID); if (bOD != null && GameObjectsSet.IsDisabledObject(bOD.ID)) { SetDisabledObject(bOD); return; } if (bOD != null && GameObjectsSet.IsBlockedObject(bOD.ID)) { SetBlockedObject(bOD); } DynamicBlockerData dbOD = GOSet.GetDynamicBlockerObject(ID); if (dbOD != null) { SetDynamicBlockerObject(dbOD); return; } StaticBlockerData sbOD = GOSet.GetStaticBlockerObject(ID); if (sbOD != null) { SetStaticBlockerObject(sbOD); return; } }