public override void FulfillTarget <T>(T[] _items) { if (_items.Length > 0 && _items[0].GetType().BaseType != typeof(Item)) { return; } var items = _items as Item[]; foreach (var item in subTargetContainers) { foreach (var obj in items) { if (obj == null) { continue; } var color = obj.GetComponent <IColorableComponent>().color; if (item.color == color && item.preCount > 0) { amount--; item.preCount--; var pos = TargetGUI.GetTargetGUIPosition(color); var itemAnim = new GameObject(); var animComp = itemAnim.AddComponent <AnimateItems>(); animComp.InitAnimation(obj.gameObject, pos, obj.transform.localScale, () => { item.changeCount(-1); }); } } } }
public override void CheckTargetItemsAfterDestroy() { if (fulledCountPerLevel.Length == 0) { fulledCountPerLevel = new int[LevelManager.THIS.fieldBoards.Count]; } var sqList = LevelManager.THIS.field.GetBottomRow(); foreach (var item in subTargetContainers) { foreach (var hItem in sqList) { if (hItem.Item == null) { continue; } var obj = hItem.Item; var ingredientName = obj.sprRenderer.FirstOrDefault().sprite.name; if (item.extraObject.name == ingredientName && item.preCount > 0) { var v = LevelManager.THIS.fieldBoards.FindIndex(x => x == LevelManager.THIS.field); fulledCountPerLevel[v]++; amount--; item.preCount--; var pos = TargetGUI.GetTargetGUIPosition(ingredientName); var itemAnim = new GameObject(); var animComp = itemAnim.AddComponent <AnimateItems>(); animComp.InitAnimation(obj.gameObject, pos, obj.transform.localScale, () => { item.changeCount(-1); // obj.DestroyBehaviour(); }); obj.DestroyBehaviour(); } } } }
public override void FulfillTarget <T>(T[] _items) { if (_items[0]?.GetType() != typeof(Square)) { return; } var items = _items as Square[]; var sugarList = items?.Where(i => i.type.ToString() == GetType().ToString()); var pos = TargetGUI.GetTargetGUIPosition(LevelData.THIS.target.name); foreach (var sugarBlock in sugarList) { Vector2 scale = sugarBlock.subSquares[0].transform.localScale; var targetContainer = subTargetContainers.Where(i => sugarBlock.type.ToString().Contains(i.targetPrefab.name)).FirstOrDefault(); amount++; var itemAnim = new GameObject(); var animComp = itemAnim.AddComponent <AnimateItems>(); animComp.InitAnimation(sugarBlock.gameObject, pos, scale, () => { targetContainer.changeCount(-1); }, sugarBlock.GetSubSquare().GetComponentInChildren <SpriteRenderer>().sprite); // square.DestroyBlock(); } }