Esempio n. 1
0
        /// <summary>
        /// 检测目标层和箱子层重合结果
        /// </summary>
        /// <param name="targetMap">目标层</param>
        /// <param name="boxMap">箱子层</param>
        /// <returns>重合结果</returns>
        private MatchResult CheckResult(BoxMap targetMap, BoxMap boxMap)
        {
            MatchResult result = new MatchResult();

            foreach (Point targetPoint in targetMap.Keys)
            {
                result.TargetCount++;
            }
            foreach (Point boxPoint in boxMap.Keys)
            {
                result.BoxCount++;
                if (targetMap.ContainsKey(boxPoint))
                {
                    result.MatchedCount++;
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 箱子层添加箱子事件(移动则为先移除再添加)
        /// </summary>
        /// <param name="boxLayerMap"></param>
        void Value_ItemAdd(BoxMap boxLayerMap)
        {
            if (StageCompleteEventHandler == null)
            {
                return;
            }
            uint targetLayer = (uint)LayerOptions.Target;//目标层

            if (!this.layerMapDict.ContainsKey(targetLayer))
            {
                return;
            }
            //检测箱子层和目标点层
            MatchResult result = CheckResult(this.layerMapDict[targetLayer], boxLayerMap);

            //通关则触发通关事件
            if (result.IsComplete)
            {
                StageCompleteEventHandler(result);
            }
        }