コード例 #1
0
ファイル: TimeSlice.cs プロジェクト: conan513/RealmPlayers
        public Dictionary <int, UnitData> GetDeltaUnitDatas(TimeSlice _ReferenceTimeSlice, bool _OnlyChangedForThisTimeSlice = false)
        {
            Dictionary <int, UnitData> deltaUnitDatas = new Dictionary <int, UnitData>();

            if (_OnlyChangedForThisTimeSlice == false)
            {
                foreach (var unit in UnitDatas)
                {
                    if (_ReferenceTimeSlice.UnitDatas.ContainsKey(unit.Key))
                    {
                        deltaUnitDatas.Add(unit.Key, UnitData.CreateDifference(_ReferenceTimeSlice.UnitDatas[unit.Key], unit.Value));
                    }
                    else
                    {
                        deltaUnitDatas.Add(unit.Key, unit.Value);
                    }
                }
            }
            else
            {
                foreach (var unitKey in ChangedUnitDatas)
                {
                    if (UnitDatas.ContainsKey(unitKey) == true) //Remove later when old site data is removed
                    {
                        var unit = UnitDatas[unitKey];
                        if (_ReferenceTimeSlice.UnitDatas.ContainsKey(unitKey))
                        {
                            deltaUnitDatas.Add(unitKey, UnitData.CreateDifference(_ReferenceTimeSlice.UnitDatas[unitKey], unit));
                        }
                    }
                    else
                    {
                        //ERROR
                    }
                }
            }
            return(deltaUnitDatas);
        }
コード例 #2
0
ファイル: FightData.cs プロジェクト: conan513/RealmPlayers
        public List <Tuple <string, UnitData> > GenerateUnitsDataList(List <string> _InterestingUnits, Dictionary <int, string> _UnitIDToNames, int _StartTime = -1, int _EndTime = -1)
        {
            if (_StartTime > _EndTime)
            {
                _EndTime = -1;
            }

            int firstTimeSliceTime = 0;

            if (_StartTime != -1 || _EndTime != -1)
            {
                firstTimeSliceTime = TimeSlices.First().Time;
            }

            if (_EndTime == -1)
            {
                _EndTime = int.MaxValue;
            }
            List <Tuple <string, UnitData> > unitsData = new List <Tuple <string, UnitData> >();

            foreach (string unitName in _InterestingUnits)
            {
                try
                {
                    int      unitID        = _UnitIDToNames.First((_Value) => { return(_Value.Value == unitName); }).Key;
                    UnitData startUnitData = null;
                    foreach (var timeSlice in TimeSlices)
                    {
                        if ((timeSlice.Time - firstTimeSliceTime) >= _StartTime && timeSlice.UnitDatas.ContainsKey(unitID) == true)
                        {
                            startUnitData = timeSlice.UnitDatas[unitID];
                            break;
                        }
                    }
                    //var petIDs = _UnitIDToNames.Where((_Value) => {
                    //    if(_Value.Value.StartsWith("VF_PET_"))
                    //    {
                    //        if (_Value.Value.Split('_').Last() == unitName)
                    //            return true;
                    //        else
                    //            return false;
                    //    }
                    //    return false;
                    //});
                    if (startUnitData != null)
                    {
                        UnitData endUnitData = null;
                        for (int i = TimeSlices.Count - 1; i >= 0; --i)
                        {
                            var timeSlice = TimeSlices[i];
                            if ((timeSlice.Time - firstTimeSliceTime) <= _EndTime && timeSlice.UnitDatas.ContainsKey(unitID) == true)
                            {
                                endUnitData = timeSlice.UnitDatas[unitID];
                                break;
                            }
                        }
                        int deadTimeSliceIndex = TimeSlices.FindIndex((_TimeSlice) => { return(_TimeSlice.Event == "Dead " + FightName || _TimeSlice.Event == "Wipe " + FightName); });

                        int highestThreat = 0;
                        if (deadTimeSliceIndex >= 0)
                        {
                            int deadTimeSliceTime = TimeSlices[deadTimeSliceIndex].Time;
                            for (int i = deadTimeSliceIndex; i >= 0; --i)
                            {
                                if ((TimeSlices[i].Time - firstTimeSliceTime) > _EndTime)
                                {
                                    deadTimeSliceTime = TimeSlices[i].Time;
                                    continue;
                                }
                                if (Math.Abs(deadTimeSliceTime - TimeSlices[i].Time) > 15)
                                {
                                    break;
                                }
                                if (TimeSlices[i].UnitDatas.ContainsKey(unitID) == true)
                                {
                                    if (TimeSlices[i].UnitDatas[unitID].I.ThreatValue > highestThreat)
                                    {
                                        highestThreat = TimeSlices[i].UnitDatas[unitID].I.ThreatValue;
                                    }
                                }
                            }
                        }
                        if (endUnitData != null)
                        {
                            try
                            {
                                UnitData totalUnitData = UnitData.CreateDifference(startUnitData, endUnitData);
                                if (highestThreat > 0)
                                {
                                    totalUnitData.I.SetThreatValue(highestThreat);
                                }
                                //string unitName = m_DataSession.UnitIDToNames[unitID];
                                unitsData.Add(new Tuple <string, UnitData>(unitName, totalUnitData));
                            }
                            catch (Exception)
                            { }
                        }
                    }
                }
                catch (Exception)
                {}
            }
            return(unitsData);
        }