コード例 #1
0
        public void Cell_Click(GridCell cell)
        {
            if (cell.GRow.IsSeviceRow)
            {
                Debug.Log("Click on cell <" + cell.ToString() + "...> - Is Service cell. Don't use it.");
                return;
            }

            Debug.Log("Click on cell <" + cell.ToString() + "...> ");
            LevelConstructSet lcs = GameBoard.Instance.gcSet.GetLevelConstructSet(BubblesPlayer.CurrentLevel);

            if (selectedMainBrushImage.enabled)
            {
                Debug.Log("main brush enabled");
                if (cell.Mainobject && cell.Mainobject.ID == mainBrush.ID)
                {
                    return;
                }
                else
                {
                    if (!cell.Mainobject && mainBrush.ID == 0)
                    {
                        return;
                    }
                    lcs.AddFeaturedCell(new CellData(mainBrush.ID, cell.Row, cell.Column));
                    if (lcs)
                    {
                        Debug.Log("add feat cell, count " + lcs.featuredCells.Count);
                    }
                }
            }
            else if (selectedOverBrushImage.enabled)
            {
                Debug.Log("over brush enabled");
                if (cell.Overlay && cell.Overlay.ID == overBrush.ID)
                {
                    return;
                }
                else
                {
                    if (!cell.Mainobject)
                    {
                        return;
                    }
                    Debug.Log("add overlay");
                    lcs.AddOverlay(new CellData(overBrush.ID, cell.Row, cell.Column));
                }
            }

            CloseOpenedPanels();
            ShowLevelData();
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        public void Cell_Click(GridCell cell)
        {
            if (cell.GRow.IsSeviceRow)
            {
                Debug.Log("Click on cell <" + cell.ToString() + "...> - Is Service cell. Don't use it.");
                return;
            }

            Debug.Log("Click on cell <" + cell.ToString() + "...> ");

            if (selectedMainBrushImage.enabled)
            {
                Debug.Log("main brush enabled");
                if (cell.Mainobject && cell.Mainobject.ID == mainBrush.ID)
                {
                    return;
                }
                else
                {
                    if (!cell.Mainobject && mainBrush.ID == 0)
                    {
                        return;
                    }
                    LCSet.AddFeaturedCell(new CellData(mainBrush.ID, cell.Row, cell.Column));
                }
            }
            else if (selectedOverBrushImage.enabled)
            {
                Debug.Log("over brush enabled");
                if (cell.Overlay && cell.Overlay.ID == overBrush.ID)
                {
                    return;
                }
                else
                {
                    if (!cell.Mainobject)
                    {
                        return;
                    }
                    LCSet.AddOverlay(new CellData(overBrush.ID, cell.Row, cell.Column));
                }
            }

            CloseOpenedPanels();
            ShowLevelData();
        }
コード例 #4
0
ファイル: OverlayObject.cs プロジェクト: dqchess/Tap-Match
        /// <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 OverlayObject Create(GridCell parent, OverlayObjectData oData, Action <int> TargetCollectEvent)
        {
            if (!parent || oData == null)
            {
                return(null);
            }
            GameObject     gO         = null;
            SpriteRenderer sR         = null;
            OverlayObject  gridObject = null;

            sR = Creator.CreateSprite(parent.transform, oData.ObjectImage, parent.transform.position);
            gO = sR.gameObject;

            gridObject = gO.GetOrAddComponent <OverlayObject>();
#if UNITY_EDITOR
            gO.name = "overlay " + parent.ToString();
#endif
            gridObject.SetData(oData);
            gridObject.SRenderer          = sR;
            gridObject.TargetCollectEvent = TargetCollectEvent;
            return(gridObject);
        }
コード例 #5
0
        /// <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 OverlayObject Create(GridCell parent, OverlayObjectData oData)
        {
            if (!parent || oData == null)
            {
                return(null);
            }
            GameObject     gO            = null;
            SpriteRenderer sR            = null;
            OverlayObject  overlayObject = null;

            if (oData.behaviorPrefab)
            {
                Behaviour bH = Instantiate(oData.behaviorPrefab);
                gO = bH.gameObject;
                gO.transform.position   = parent.transform.position;
                gO.transform.localScale = parent.transform.lossyScale;
                gO.transform.parent     = parent.transform;
                sR        = gO.GetOrAddComponent <SpriteRenderer>();
                sR.sprite = oData.ObjectImage;
            }
            else
            {
                sR = Creator.CreateSpriteAtPosition(parent.transform, oData.ObjectImage, parent.transform.position);
                gO = sR.gameObject;
            }


            overlayObject = gO.GetOrAddComponent <OverlayObject>();
#if UNITY_EDITOR
            gO.name = "overlay " + parent.ToString();
#endif
            overlayObject.Init(parent.Row, parent.Column, parent);
            overlayObject.SetData(oData);

            return(overlayObject);
        }
コード例 #6
0
        /// <summary>
        /// Create new MainObject for gridcell
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="mData"></param>
        /// <param name="addCollider"></param>
        /// <param name="radius"></param>
        /// <param name="isTrigger"></param>
        /// <returns></returns>
        public static MainObject Create(GridCell parent, MainObjectData mData, bool addCollider, float radius, bool isTrigger)
        {
            if (!parent || mData == null)
            {
                return(null);
            }
            SpriteRenderer sR         = Creator.CreateSpriteAtPosition(parent.transform, mData.ObjectImage, parent.transform.position);
            GameObject     gO         = sR.gameObject;
            MainObject     Mainobject = gO.AddComponent <MainObject>();

#if UNITY_EDITOR
            gO.name = "main " + parent.ToString();
#endif

            Mainobject.Init(parent.Row, parent.Column, parent);
            if (addCollider)
            {
                CircleCollider2D cC = Mainobject.gameObject.GetOrAddComponent <CircleCollider2D>();
                cC.radius    = radius;
                cC.isTrigger = isTrigger;
            }
            Mainobject.SetData(mData);
            return(Mainobject);
        }