public void TryMerge(Bubble bubble) { merged.Clear(); CheckBubblePower(null, bubble, merged); if (merged.Count > 0) { var x = bubble.X; var y = bubble.Y; var power = Mathf.Clamp(bubble.Power + merged.Count, minPower, maxPower); merged.Add(bubble); CheckAutomatic(power, ref x, ref y); CheckMergedFall(); OnMerge?.Invoke(new MergeInfo() { x = x, y = y, power = power, involvedCount = merged.Count }); for (int i = merged.Count - 1; i >= 0; i--) { ReleaseBubble(merged[i]); } var newBubble = SpawnBubble(x, y, power); if (newBubble.X != -1 && newBubble.Y != -1) { CheckFall(newBubble, out bool attached); if (attached) { GetAllLinks(newBubble, notFalling); for (int i = 0; i < notFalling.Count; i++) { var notFallingBubble = notFalling[i]; if (falling.Contains(notFallingBubble)) { falling.Remove(notFallingBubble); } } notFalling.Clear(); if (power == maxPower) { Explode(newBubble); } } } } CheckToClear(); }
private void QueMergeAnimation() { mAnimationDelayTicker.QueAction(() => { foreach (var item in mLastMergeBoxList) { int gridIndex = GetMapedInex(item.x, item.y); int value = GetGridValueByPoint(mGridPoints[item.x, item.y]); //Debug.Log ("merged value " + value + " at " + item + " for " + gridIndex); mGridBoxList[gridIndex].AnimateValue(value); OnMerge?.Invoke(item.x, item.y); OnScore?.Invoke(mGridPoints[item.x, item.y]); } mLastMergeBoxList.Clear(); }); mAnimationDelayTicker.Start(); }
/// <summary> /// 当缓存过期时的委托 /// </summary> /// <param name="key">缓存的Key</param> /// <param name="value">缓存的值</param> /// <param name="reason">移除原因</param> void WriteBack(string key, object value, CacheItemRemovedReason reason) { if (destoryed) { return; } //如果是因为外部修改了文件 if (reason == CacheItemRemovedReason.DependencyChanged && !inWriteBack) { //则将当前内存中的对象与磁盘上的对象合并 var oldObj = mItem; ReadObject(); OnMerge?.Invoke(this, new CachedObjectOnMergeEventArgs <T>(oldObj, mItem)); // LogHelper.SysLog("缓存文件被覆盖", "json缓存文件:更新").ModuleName = typeof(T).Name; } else { //Save(); } AddCache(); }