public static MissionBoosterHelper CreateProfileBooster(RectTransform parent, MissionBoosterHelper prefab, Booster b, Action GotoShopHandler) { if (prefab) { prefab.boosterImage.sprite = b.bData.GuiImage; // unity 2019 fix } MissionBoosterHelper missionBooster = Instantiate(prefab); missionBooster.transform.localScale = parent.transform.lossyScale; missionBooster.transform.SetParent(parent); missionBooster.boosterImage.sprite = b.bData.GuiImage; missionBooster.boosterCounter.text = b.Count.ToString(); // add footer click handlers missionBooster.boosterButton.onClick.AddListener(GotoShopHandler.Invoke); missionBooster.shopButton.onClick.AddListener(GotoShopHandler.Invoke); missionBooster.booster = b; missionBooster.InitStart(); return(missionBooster); }
public override bool ActivateApply(Booster b) { MBoard.WinContr.AddMoves(5); MSound.PlayClip(0.2f, b.bData.privateClip); return(true); }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.IsMatchable) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); CellsGroup area = GetArea(gCell); // ScoreCollectHandler?.Invoke(area); //move activeBooster float dist = Vector3.Distance(transform.position, gCell.transform.position); bTS.Add((callBack) => { SimpleTween.Move(gameObject, transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { MSound.PlayClip(0, bData.privateClip); Destroy(b.SceneObject, 0.25f); callBack(); }).SetEase(EaseAnim.EaseInSine); }); //apply effect for each cell parallel float delay = 0.0f; foreach (var c in area.Cells) { delay += 0.15f; float d = delay; par0.Add((callBack) => { delayAction(gameObject, d, () => { Creator.InstantiateAnimPrefab(bData.animPrefab, c.transform, c.transform.position, SortingOrder.Booster + 1, true, callBack); } ); }); } delay = 0.15f; foreach (var c in area.Cells) { delay += 0.15f; float d = delay; par0.Add((callBack) => { c.CollectMatch(d, true, false, true, true, callBack); }); } bTS.Add((callback) => { par0.Start(() => { callback(); }); }); bTS.Add((callback) => { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }
private void CreateBoostersPanel() { MissionBoosterHelper[] ms = BoostersParent.GetComponentsInChildren <MissionBoosterHelper>(); foreach (MissionBoosterHelper item in ms) { DestroyImmediate(item.gameObject); } List <Booster> bList = new List <Booster>(); List <Booster> bListToShop = new List <Booster>(); bool selectFromAll = true; if (!selectFromAll) { foreach (var b in MPlayer.BoostHolder.Boosters) { if (b.Count > 0) { bList.Add(b); } else { bListToShop.Add(b); } } bList.Shuffle(); int bCount = Mathf.Min(bList.Count, boostersCount); for (int i = 0; i < bCount; i++) { Booster b = bList[i]; string id = b.bData.ID.ToString(); string name = b.bData.ObjectImage.name.ToString(); MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id, name); }); } int shopCount = boostersCount - bList.Count; if (shopCount > 0) { shopCount = Mathf.Min(shopCount, bListToShop.Count); bListToShop.Shuffle(); for (int i = 0; i < shopCount; i++) { Booster b = bListToShop[i]; string id = b.bData.ID.ToString(); string name = b.bData.ObjectImage.name.ToString(); MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id, name); }); } } } else { foreach (var b in MPlayer.BoostHolder.Boosters) { bList.Add(b); } bList.Shuffle(); int bCount = Mathf.Min(bList.Count, boostersCount); for (int i = 0; i < bCount; i++) { Booster b = bList[i]; string id = b.bData.ID.ToString(); string name = b.bData.ObjectImage.name.ToString(); MissionBoosterHelper bM = MissionBoosterHelper.CreateMissionBooster(BoostersParent, missionBoosterPrefab, b, () => { MGui.ShowInGameShopBooster(id, name); }); } } }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.Overlay) { if (!gCell.Match && !gCell.StaticBlocker && !gCell.DynamicBlocker) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); //move activeBooster Vector3 pos = transform.position; float dist = Vector3.Distance(transform.position, gCell.transform.position); Vector3 rotPivot = Vector3.zero; float rotRad = 6f; bTS.Add((callBack) => { SetToFront(true); SimpleTween.Move(b.SceneObject, b.SceneObject.transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { rotPivot = transform.position - new Vector3(0, rotRad, 0); callBack(); }).SetEase(EaseAnim.EaseInSine); }); // back move bTS.Add((callBack) => { SimpleTween.Value(gameObject, Mathf.Deg2Rad * 90f, Mathf.Deg2Rad * 180f, 0.25f).SetEase(EaseAnim.EaseInCubic). // SetOnUpdate((float val) => { transform.position = new Vector3(rotRad * Mathf.Cos(val), rotRad * Mathf.Sin(val), 0) + rotPivot; }). AddCompleteCallBack(() => { callBack(); }); }); //forward move bTS.Add((callBack) => { SimpleTween.Value(gameObject, Mathf.Deg2Rad * 180f, Mathf.Deg2Rad * 100f, 0.2f).SetEase(EaseAnim.EaseOutBounce). SetOnUpdate((float val) => { transform.position = new Vector3(rotRad * Mathf.Cos(val), rotRad * Mathf.Sin(val), 0) + rotPivot; }). AddCompleteCallBack(() => { MSound.PlayClip(0, bData.privateClip); Destroy(gameObject, 0.25f); Creator.InstantiateAnimPrefab(bData.animPrefab, gCell.transform, gCell.transform.position, SortingOrder.BoosterToFront + 2, true, callBack); }); }); // if (gCell.IsMatchable) { bTS.Add((callBack) => { GridCell.ExplodeCell(gCell, 0, true, false, true, callBack); // gCell.CollectMatch(0, true, false, true, true, callBack); }); } bTS.Add((callback) => { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.IsMatchable) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); CellsGroup area = GetArea(gCell); //move activeBooster float dist = Vector3.Distance(transform.position, gCell.transform.position); bTS.Add((callBack) => { SetToFront(true); SimpleTween.Move(gameObject, transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { ValuesTween(gameObject, new float[] { 1, 1.3f, 1 }, 0.3f, (val) => { transform.localScale = gCell.transform.lossyScale * val; }, callBack); MSound.PlayClip(0, bData.privateClip); }).SetEase(EaseAnim.EaseInSine); }); bTS.Add((callBack) => // explode wave { MBoard.ExplodeWave(0, transform.position, 5, null); callBack(); }); bTS.Add((callBack) => { GameObject g = Instantiate(explodePrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * 1.0f; callBack(); }); bTS.Add((callBack) => { Destroy(b.SceneObject, 0.1f); callBack(); }); //apply effect for each cell parallel float delay = 0.0f; foreach (var c in area.Cells) { if (!c.IsDisabled && !c.Blocked) { float d = delay; float distance = Vector2.Distance(c.transform.position, gCell.transform.position); d = distance / 15f + delay; par0.Add((callBack) => { delayAction(gameObject, d, () => { Creator.InstantiateAnimPrefab(bData.animPrefab, c.transform, c.transform.position, SortingOrder.BoosterToFront + 2, true, null); callBack(); } ); }); } } delay = 0.15f; foreach (GridCell mc in area.Cells) //parallel explode all cells { float t = 0; float distance = Vector2.Distance(mc.transform.position, gCell.transform.position); t = distance / 15f; par0.Add((callBack) => { GridCell.ExplodeCell(mc, t, false, false, true, callBack); }); } bTS.Add((callback) => { par0.Start(() => { callback(); }); }); bTS.Add((callback) => { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }