Пример #1
0
 public void OnTransformJewel(IRuntimeJewel jewel, JewelID transformType)
 {
     //Debug.Log("OnTransformJewel");
     //Debug.Log(UIRuntimeData);
     //Debug.Log(jewel);
     if (UIRuntimeData.RuntimeData != null && UIRuntimeData.RuntimeData.JewelID == jewel.JewelID)
     {
         JewelData     data = JewelDatabase.Instance.Get(transformType);
         IRuntimeJewel jwl  = UIRuntimeData.RuntimeData;
         jwl.TransformJewel(data);
         UIRuntimeData.OnSetData?.Invoke(jwl);
     }
 }
Пример #2
0
        public void OnTransformJewel(IRuntimeJewel jewel, JewelID transformType)
        {
            JewelData data = JewelDatabase.Instance.Get(transformType);

            jewel.TransformJewel(data);
        }
Пример #3
0
        List<JewelData> findMatch(int x,int y,MoveDirection direction)
        {
            List<JewelData> match = new List<JewelData>();
            JewelKind current = GetJewel(x, y);
            int matchNum = 0;
            bool _findMatch = true;
            switch (direction)
            {
                case MoveDirection.Left:


                    while (_findMatch)
                    {
                        int target = x - matchNum;
                        matchNum++;
                        if (target >=0)
                        {
                            if (current == GetJewel(target, y))
                            {
                                JewelData currentJewel = new JewelData(target, y);
                                match.Add(currentJewel);

                            }
                            else {
                                _findMatch = false;
                            }
                        }
                        else
                        {
                            _findMatch = false;
                        }
                    }
                    
                    return match;
                case MoveDirection.Right:

                    while (_findMatch)
                    {
                        int target = x + matchNum;
                        matchNum++;
                        
                        if (target <= width-1)
                        {
                            if (current == GetJewel(target, y))
                            {
                                JewelData currentJewel = new JewelData(target, y);
                                match.Add(currentJewel);

                            }
                            else {
                                _findMatch = false;
                            }
                        }
                        else
                        {
                            _findMatch = false;
                        }
                    }
                    return match;
                case MoveDirection.Up:

                    while (_findMatch)
                    {
                        int target = y + matchNum;
                        matchNum++;
                        if (target <=height-1)
                        {
                            if (current == GetJewel(x, target))
                            {
                                JewelData currentJewel = new JewelData(x, target);
                                match.Add(currentJewel);

                            }
                            else {
                                _findMatch = false;
                            }
                        }
                        else
                        {
                            _findMatch = false;
                        }
                    }
                    
                    return match;
                case MoveDirection.Down:

                    while (_findMatch)
                    {
                        int target = y - matchNum;
                        matchNum++;
                        if (target >=0)
                        {
                            if (current == GetJewel(x, target))
                            {
                                JewelData currentJewel = new JewelData(x, target);
                                match.Add(currentJewel);

                            }
                            else {
                                _findMatch = false;
                            }
                        }
                        else
                        {
                            _findMatch = false;
                        }
                    }

                    return match;
                default:
                    return match;

            }
        }
Пример #4
0
 bool addUnique(JewelData value,List<JewelData> list)
 {
     foreach(JewelData data in list)
     {
         if (data.x == value.x && data.y == value.y)
         {
             return true;
         }
     }
     list.Add(value);
     return false;
 }