コード例 #1
0
    public void Init(ChuzzleColor color)
    {
        var posibleColors = explosionColors.FirstOrDefault(x => x.color == color).possibleColors;

        //   ps.startColor = posibleColors[Random.Range(0, posibleColors.Length)];
        ps.Play(true);
    }
コード例 #2
0
ファイル: TilesFactory.cs プロジェクト: minthubk/SouffleMatch
    public void ReplaceWithOtherColor(Chuzzle toReplace)
    {
        ChuzzleColor        exceptColor    = toReplace.Color;
        List <ChuzzleColor> possibleColors = ((ChuzzleColor[])Enum.GetValues(typeof(ChuzzleColor))).ToList();

        possibleColors.Remove(exceptColor);

        ReplaceWithColor(toReplace, possibleColors[Random.Range(0, possibleColors.Count)]);
    }
コード例 #3
0
ファイル: ChuzzlePool.cs プロジェクト: minthubk/SouffleMatch
    public void Release(ChuzzleColor color, Type type, GameObject gameObject)
    {
        var holder = holders.FirstOrDefault(x => x.color == color && x.type == type);

        if (holder == null)
        {
            Debug.LogError("Not registered prefab for: " + color + " of " + type);
            return;
        }
        //Debug.Log("release: "+color + " of "+type + " : "+gameObject.name);
        gameObject.SetActive(false);
        freeObjects.FirstOrDefault(x => x.Key.type == type && x.Key.color == color).Value.Add(gameObject);
    }
コード例 #4
0
ファイル: ChuzzlePool.cs プロジェクト: GreatVV/SouffleMatch
        public void RegisterChuzzlePrefab(ChuzzleColor color, Type type, GameObject prefab)
        {
            if (holders.Any(x => x.color == color && x.type == type))
            {
                Debug.LogWarning("Already registered: "+color+" : "+type);
                return;
            }

            var holder = new Holder()
            {
                color = color,
                type = type,
                prefab = prefab
            };
            holders.Add(holder);
            freeObjects[holder] = new List<GameObject>();
        }
コード例 #5
0
ファイル: ChuzzlePool.cs プロジェクト: minthubk/SouffleMatch
    public void RegisterChuzzlePrefab(ChuzzleColor color, Type type, GameObject prefab)
    {
        if (holders.Any(x => x.color == color && x.type == type))
        {
            Debug.LogWarning("Already registered: " + color + " : " + type);
            return;
        }

        var holder = new Holder()
        {
            color  = color,
            type   = type,
            prefab = prefab
        };

        holders.Add(holder);
        freeObjects[holder] = new List <GameObject>();
    }
コード例 #6
0
    public static IEnumerable <Chuzzle> GetVerticalLineChuzzles(int x, ChuzzleColor chuzzleColor,
                                                                List <Chuzzle> chuzzles)
    {
        var firstChuzzle = chuzzles.FirstOrDefault(c => c.Real.x == x && c.Color == chuzzleColor && !(c is InvaderChuzzle));

        //Debug.Log(string.Format("fc:{0} |x: {1} Color: {2}", firstChuzzle, x, chuzzleColor));
        // Debug.Log("Any is lock: "+chuzzles.FirstOrDefault(c=>c is LockChuzzle));
        if (firstChuzzle != null && !chuzzles.Any(c => c is LockChuzzle && c.Current.x == x))
        {
            var secondChuzzle = chuzzles.FirstOrDefault(c => IsSameColor(c, firstChuzzle) && (c.Current == firstChuzzle.Current.Top || c.Current == firstChuzzle.Current.Bottom));
            if (secondChuzzle != null)
            {
                return(new List <Chuzzle> {
                    firstChuzzle, secondChuzzle
                });
            }
            return(new List <Chuzzle> {
                firstChuzzle
            });
        }
        return(new List <Chuzzle>());
    }
コード例 #7
0
ファイル: ChuzzlePool.cs プロジェクト: minthubk/SouffleMatch
    public GameObject Get(ChuzzleColor color, Type type)
    {
        var holder = holders.FirstOrDefault(x => x.color == color && x.type == type);

        if (holder == null)
        {
            //  Debug.LogError("Not registered prefab for: " + color + " of " + type);
            return(null);
        }
        //Debug.Log("get: " + color + " of " + type );
        var first = freeObjects.FirstOrDefault(x => x.Key.type == type && x.Key.color == color);

        if (first.Value != null && first.Value.Any())
        {
            var gameObject = first.Value.First();
            gameObject.SetActive(true);
            first.Value.RemoveAt(0);
            //Debug.Log("Gameobject: "+gameObject + " of id "+gameObject.GetInstanceID());
            return(gameObject);
        }

        return((GameObject)Object.Instantiate(holder.prefab));
    }
コード例 #8
0
    public static IEnumerable <Chuzzle> GetHorizontalLineChuzzles(int y, ChuzzleColor chuzzleColor,
                                                                  IEnumerable <Chuzzle> chuzzles)
    {
        var enumerable   = chuzzles as IList <Chuzzle> ?? chuzzles.ToList();
        var firstChuzzle = enumerable.FirstOrDefault(x => x.Real.y == y && x.Color == chuzzleColor && IsOrdinaryDestroyable(x));

        if (firstChuzzle != null && !enumerable.Any(c => c is LockChuzzle && c.Current.y == y))
        {
            var secondChuzzle =
                enumerable.FirstOrDefault(
                    c => IsSameColor(c, firstChuzzle) &&
                    (c.Current == firstChuzzle.Current.Left || c.Current == firstChuzzle.Current.Right));
            if (secondChuzzle != null)
            {
                return(new List <Chuzzle> {
                    firstChuzzle, secondChuzzle
                });
            }
            return(new List <Chuzzle> {
                firstChuzzle
            });
        }
        return(new List <Chuzzle>());
    }
コード例 #9
0
ファイル: ChuzzlePool.cs プロジェクト: GreatVV/SouffleMatch
        public GameObject Get(ChuzzleColor color, Type type)
        {
            RegisterPrefabs();

            var holder = holders.FirstOrDefault(x => x.color == color && x.type == type);
            if (holder == null)
            {
                //Debug.LogError("Not registered prefab for: " + color + " of " + type);
                return null;
            }
            //Debug.Log("get: " + color + " of " + type );
            var freeObjectsOfTypeAndColor = freeObjects.FirstOrDefault(x => x.Key.type == type && x.Key.color == color);

            if (freeObjectsOfTypeAndColor.Value !=null && freeObjectsOfTypeAndColor.Value.Any())
            {
                var gameObject = freeObjectsOfTypeAndColor.Value.First();
                gameObject.SetActive(true);
                freeObjectsOfTypeAndColor.Value.RemoveAt(0);
                //Debug.Log("Gameobject: "+gameObject + " of id "+gameObject.GetInstanceID());
                return gameObject;
            }

            return ((GameObject) Object.Instantiate(holder.prefab));
        }
コード例 #10
0
ファイル: TilesFactory.cs プロジェクト: GreatVV/SouffleMatch
 public Chuzzle CreateChuzzle(Cell cell, ChuzzleColor color)
 {
     return CreateChuzzle(cell, PrefabOfColor(color));
 }
コード例 #11
0
 public static IEnumerable<Chuzzle> GetVerticalLineChuzzles(int x, ChuzzleColor chuzzleColor,
                                                            IEnumerable<Chuzzle> chuzzles)
 {
     var firstChuzzle = chuzzles.FirstOrDefault(c => c.Real.X == x && c.Color == chuzzleColor && !(c is InvaderChuzzle));
     ////Debug.Log(string.Format("fc:{0} |x: {1} Color: {2}", firstChuzzle, x, chuzzleColor));
     // //Debug.Log("Any is lock: "+chuzzles.FirstOrDefault(c=>c is LockChuzzle));
     if (firstChuzzle != null && !chuzzles.Any(c => c is LockChuzzle && c.Current.X == x))
     {
         var secondChuzzle = chuzzles.FirstOrDefault(c => IsSameColor(c, firstChuzzle) && (c.Current == firstChuzzle.Current.Top || c.Current == firstChuzzle.Current.Bottom));
         if (secondChuzzle != null)
         {
             return new List<Chuzzle> {firstChuzzle, secondChuzzle};
         }
         return new List<Chuzzle> {firstChuzzle};
     }
     return new List<Chuzzle>();
 }
コード例 #12
0
ファイル: TilesFactory.cs プロジェクト: minthubk/SouffleMatch
 public void ReplaceWithColor(Chuzzle toReplace, ChuzzleColor color)
 {
     CreateChuzzle(toReplace.Current, color);
     toReplace.Destroy(false, false, true);
 }
コード例 #13
0
ファイル: TilesFactory.cs プロジェクト: minthubk/SouffleMatch
 public GameObject PrefabOfColor(ChuzzleColor color)
 {
     return(ChuzzlePrefabs.FirstOrDefault(x => x.GetComponent <Chuzzle>().Color == color));
 }
コード例 #14
0
ファイル: TilesFactory.cs プロジェクト: minthubk/SouffleMatch
 public Chuzzle CreateChuzzle(Cell cell, ChuzzleColor color)
 {
     return(CreateChuzzle(cell, PrefabOfColor(color)));
 }
コード例 #15
0
 public void Init(ChuzzleColor color)
 {
     //var posibleColors = explosionColors.FirstOrDefault(x => x.color == color).possibleColors;
     //   ps.startColor = posibleColors[Random.Range(0, posibleColors.Length)];
     ps.Play(true);
 }
コード例 #16
0
ファイル: ChuzzlePool.cs プロジェクト: GreatVV/SouffleMatch
 public void Release(ChuzzleColor color, Type type, GameObject gameObject)
 {
     var holder = holders.FirstOrDefault(x => x.color == color && x.type == type);
     if (holder == null)
     {
         Debug.LogError("Not registered prefab for: " + color + " of " + type);
         return;
     }
     //Debug.Log("release: "+color + " of "+type + " : "+gameObject.name);
     gameObject.SetActive(false);
     freeObjects.FirstOrDefault(x => x.Key.type == type && x.Key.color == color).Value.Add(gameObject);
 }
コード例 #17
0
 public static IEnumerable<Chuzzle> GetHorizontalLineChuzzles(int y, ChuzzleColor chuzzleColor,
                                                              IEnumerable<Chuzzle> chuzzles)
 {
     var enumerable = chuzzles as IList<Chuzzle> ?? chuzzles.ToList();
     var firstChuzzle = enumerable.FirstOrDefault(x => x.Real.Y == y && x.Color == chuzzleColor && IsOrdinaryDestroyable(x));
     if (firstChuzzle != null && !enumerable.Any(c => c is LockChuzzle && c.Current.Y == y))
     {
         var secondChuzzle =
             enumerable.FirstOrDefault(
                                       c => IsSameColor(c, firstChuzzle) &&
                                            (c.Current == firstChuzzle.Current.Left || c.Current == firstChuzzle.Current.Right));
         if (secondChuzzle != null)
         {
             return new List<Chuzzle> {firstChuzzle, secondChuzzle};
         }
         return new List<Chuzzle> {firstChuzzle};
     }
     return new List<Chuzzle>();
 }
コード例 #18
0
ファイル: TilesFactory.cs プロジェクト: GreatVV/SouffleMatch
 public void ReplaceWithColor(Chuzzle toReplace, ChuzzleColor color)
 {
     CreateChuzzle(toReplace.Current, color);
     toReplace.Destroy(false, false, true);
 }
コード例 #19
0
ファイル: TilesFactory.cs プロジェクト: GreatVV/SouffleMatch
 public GameObject PrefabOfColor(ChuzzleColor color)
 {
     return ChuzzlePrefabs.FirstOrDefault(x => x.GetComponent<Chuzzle>().Color == color);
 }