示例#1
0
        /// <summary>
        /// Try to grab match object from fill path
        /// </summary>
        /// <param name="completeCallBack"></param>
        internal void FillGrab(Action completeCallBack)
        {
            GameObject mObject = null;
            GridCell   gCell   = null;

            if (spawner)
            {
                MatchObject mo = spawner.Get();
                mObject = (mo) ? mo.gameObject : null;
            }
            else
            {
                if (fillPath != null && fillPath.Count > 0)
                {
                    gCell = fillPath[0];
                }
                else // try to get at top
                {
                    gCell = GColumn.GetTopCell(Row);
                }
                mObject = gCell.DynamicObject;
            }
            if (mObject && gCell && (gCell.PhysStep))
            {
                return;
            }

            GrabDynamicObject(mObject, (MBoard.fillType == FillType.Fast), completeCallBack);
        }
示例#2
0
        /// <summary>
        /// spawn new MO
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public MatchObject Get()
        {
            MatchObjectData mOD   = (SpawnContr) ? SpawnContr.GetObject() : GOSet.GetMainRandomObjects(1)[0];
            MatchObject     match = MatchObject.Create(mOD, transform.position, false, false, MBoard.TargetCollectEventHandler, MBoard.MatchScoreCollectHandler);

            if (match)
            {
                match.transform.localScale = transform.lossyScale;
            }
            return(match);
        }
示例#3
0
        public static void UndoSwap(Action callBack)
        {
            MatchObject dM = Source.Match;
            MatchObject tM = Target.Match;

            Source.GrabDynamicObject(tM.gameObject, false, null);
            Target.GrabDynamicObject(dM.gameObject, false, () =>
            {
                callBack?.Invoke();
            });
        }
示例#4
0
        public List <GridCell> GetMatchIdCells(int id, bool matchable)
        {
            List <GridCell> res = new List <GridCell>();

            foreach (var item in Cells)
            {
                MatchObject m = item.Match;
                if (m && (m.GetID() == id) && (item.IsMatchable == matchable))
                {
                    res.Add(item);
                }
            }
            return(res);
        }
示例#5
0
 public void ForEach(Action <MatchObject> action)
 {
     if (action == null)
     {
         return;
     }
     for (int i = 0; i < Cells.Count; i++)
     {
         MatchObject m = Cells[i].Match;
         if (m)
         {
             action(m);
         }
     }
 }
示例#6
0
 internal void SetMatchObject(MatchObjectData mObjectData)
 {
     if (mObjectData == null || IsDisabled || Blocked)
     {
         return;
     }
     if (DynamicObject)
     {
         GameObject old = DynamicObject;
         DestroyImmediate(old);
     }
     if (StaticBlocker)
     {
         GameObject old = StaticBlocker.gameObject;
         DestroyImmediate(old);
     }
     MatchObject.Create(this, mObjectData, false, true, MBoard.TargetCollectEventHandler, MBoard.MatchScoreCollectHandler);
     Match.SetToFront(false);
 }
示例#7
0
        public static void Swap(GridCell gc1, GridCell gc2)
        {
            Source = gc1;
            Target = gc2;

            if (Source && Source.CanSwap(Target))
            {
                SwapBeginEvent?.Invoke(Target);
                MatchObject dM = Source.Match;
                MatchObject tM = Target.Match;
                dM.SwapTime = Time.time;
                tM.SwapTime = Time.time;
                Source.GrabDynamicObject(tM.gameObject, false, null);
                Target.GrabDynamicObject(dM.gameObject, false, () =>
                {
                    SwapEndEvent?.Invoke(Target);
                });
            }
            else if (Source)
            {
                Touch.ResetDrag(null);
            }
        }