/// <summary> /// Create new OverlayObject 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 StaticBlockerObject Create(GridCell parent, StaticBlockerData oData, bool addCollider, bool isTrigger, Action <int> TargetCollectEvent) { if (!parent || oData == null) { return(null); } GameObject gO = null; SpriteRenderer sR = null; StaticBlockerObject gridObject = null; sR = Creator.CreateSprite(parent.transform, oData.ObjectImage, parent.transform.position); gO = sR.gameObject; gridObject = gO.GetOrAddComponent <StaticBlockerObject>(); if (addCollider) { BoxCollider2D cC = gridObject.gameObject.GetOrAddComponent <BoxCollider2D>(); cC.isTrigger = isTrigger; } #if UNITY_EDITOR gO.name = "static blocker " + parent.ToString(); #endif gridObject.SetData(oData); gridObject.SRenderer = sR; gridObject.TargetCollectEvent = TargetCollectEvent; return(gridObject); }
internal void SetStaticBlockerObject(StaticBlockerData mObjectData) { if (mObjectData == null || IsDisabled || Blocked) { return; } // Debug.Log("set static blocker: " + mObjectData.ID); if (DynamicObject) { GameObject old = DynamicObject; DestroyImmediate(old); } if (StaticBlocker) { GameObject old = StaticBlocker.gameObject; DestroyImmediate(old); } StaticBlockerObject.Create(this, mObjectData, false, true, MBoard.TargetCollectEventHandler); StaticBlocker.SetToFront(false); }
internal virtual void SetData(StaticBlockerData 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; } }