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); }
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)]); }
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); }
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>(); }
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>(); }
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>()); }
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)); }
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>()); }
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)); }
public Chuzzle CreateChuzzle(Cell cell, ChuzzleColor color) { return CreateChuzzle(cell, PrefabOfColor(color)); }
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>(); }
public void ReplaceWithColor(Chuzzle toReplace, ChuzzleColor color) { CreateChuzzle(toReplace.Current, color); toReplace.Destroy(false, false, true); }
public GameObject PrefabOfColor(ChuzzleColor color) { return(ChuzzlePrefabs.FirstOrDefault(x => x.GetComponent <Chuzzle>().Color == color)); }
public Chuzzle CreateChuzzle(Cell cell, ChuzzleColor color) { return(CreateChuzzle(cell, PrefabOfColor(color))); }
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); }
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>(); }
public GameObject PrefabOfColor(ChuzzleColor color) { return ChuzzlePrefabs.FirstOrDefault(x => x.GetComponent<Chuzzle>().Color == color); }