Exemplo n.º 1
0
        public override void CalculateBehaviourItem(List <BattleBehaviourItem> behaviourItems, float weight)
        {
            var items = damageRecorder.Items(true, true);

            while (items.MoveNext())
            {
                BattleUnitRecordItem recordItem = items.Current;
                //这个家伙已经无法行动了
                if (!recordItem.maker.CanAction)
                {
                    continue;
                }

                var behaviourItem = BattleBehaviourItem.CreateInstance(recordItem.maker, BehaviourType);

                int   distance       = baseData.hostBattleUnit.mapGrid.Distance(recordItem.maker.mapGrid);
                float distanceWeight = behaviourSystem.GetDistanceWeight(distance);
                //判断自己是否当前目标的攻击对象
                float isHisTarget = 0.75f;
                if (recordItem.maker.targetBattleUnit != null)
                {
                    isHisTarget = recordItem.maker.targetBattleUnit.Equals(baseData.hostBattleUnit) ? 0.5f : 1f;
                }

                behaviourItem.point = recordItem.point * weight * distanceWeight * isHisTarget;

                battleBehaviourItems.Add(behaviourItem);
            }

            AddToTargetList(behaviourItems);
        }
Exemplo n.º 2
0
        public static BattleUnitRecordItem CreateInstance(BattleUnit battleUnit)
        {
            if (battleUnit == null)
            {
                return(null);
            }

            BattleUnitRecordItem item = new BattleUnitRecordItem();

            item.maker = battleUnit;
            item.value = 1f;

            return(item);
        }
Exemplo n.º 3
0
        public void Init(List <BattleUnit> battleUnits)
        {
            if (battleUnits == null || battleUnits.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < battleUnits.Count; i++)
            {
                BattleUnitRecordItem recordItem = BattleUnitRecordItem.CreateInstance(battleUnits[i]);
                recordItem.value = 1f;
                recordItems.Add(recordItem);
                recordItemDic.Add(battleUnits[i].ID, recordItem);
            }
            max = recordItems[0];
        }
Exemplo n.º 4
0
        /// <summary>
        /// 刷新点数
        /// </summary>
        /// <param name="sorted">是否排序</param>
        public void RefreshPoint(bool sorted)
        {
            //刷新最大
            max = null;
            for (int i = 0; i < recordItems.Count; ++i)
            {
                if (!recordItems[i].maker.CanAction)
                {
                    continue;
                }

                if (max == null)
                {
                    max = recordItems[i];
                }
                else
                {
                    max = recordItems[i].value > max.value ? recordItems[i] : max;
                }
            }

            for (int i = 0; i < recordItems.Count; ++i)
            {
                //最大的都跪了,或者自己跪了
                if (max == null || !max.maker.CanAction || !recordItems[i].maker.CanAction)
                {
                    recordItems[i].point = 0f;
                }
                else
                {
                    recordItems[i].point = EGameConstL.BattleBehaviourChipMaxPoint * (1f - ((float)max.value - recordItems[i].value) / max.value);
                }
            }

            if (sorted)
            {
                recordItems.Sort(LiteSingleton <BattleUnitRecordItemComparer> .Instance);
            }
        }
Exemplo n.º 5
0
        //记录增加量
        public void RecordAddition(BattleUnit maker, float value)
        {
            if (maker == null)
            {
                return;
            }

            BattleUnitRecordItem recordItem = null;

            if (recordItemDic.ContainsKey(maker.ID))
            {
                recordItem = recordItemDic[maker.ID];
            }
            else
            {
                recordItem       = BattleUnitRecordItem.CreateInstance(maker);
                recordItem.value = 1f;
                recordItems.Add(recordItem);
                recordItemDic.Add(maker.ID, recordItem);
            }

            recordItem.value += value;
        }
Exemplo n.º 6
0
 //重置
 public void Clear()
 {
     recordItems.Clear();
     recordItemDic.Clear();
     max = null;
 }