Esempio n. 1
0
        public static EntityTurnTimelineCalculationData build()
        {
            EntityTurnTimelineCalculationData l_instance = new EntityTurnTimelineCalculationData();

            l_instance.CurrentTimelinePosition = 0.0f;
            return(l_instance);
        }
Esempio n. 2
0
 public static void addEntityToTimeline(TurnTimeline p_turnTimeline, Entity p_entity)
 {
     if (!p_turnTimeline.TimelineOrderingDatas.ContainsKey(p_entity))
     {
         EntityTurnTimelineCalculationData l_initialEntityTurnTimelineCalculationdata = EntityTurnTimelineCalculationData.build();
         l_initialEntityTurnTimelineCalculationdata.CurrentTimelinePosition = EntityTurnTimelineCalculationData.calculateReferenceTurnTimelineScore(p_entity);
         p_turnTimeline.TimelineOrderingDatas.Add(p_entity, l_initialEntityTurnTimelineCalculationdata);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Calculates the next <see cref="Entity"/> to play from the <see cref="TurnTimeline"/>.
        /// The next <see cref="Entity"/> to play is the one that have the lowest <see cref="EntityTurnTimelineCalculationData.CurrentTimelinePosition"/>.
        /// When this <see cref="Entity"/> has been found, all <see cref="EntityTurnTimelineCalculationData"/> advances in the timeline by the distance from 0 of the founded <see cref="Entity"/>.<see cref="EntityTurnTimelineCalculationData.CurrentTimelinePosition"/>.
        /// Then the founded <see cref="Entity"/> is pushed back to the timeline.
        /// </summary>
        /// <param name="p_turnTimeline"></param>
        /// <returns></returns>
        public static Entity IncrementTimeline(TurnTimeline p_turnTimeline)
        {
            Entity l_lowerTimelineScore   = null;
            float  l_currentComparedScore = 0.0f;

            RefDictionary <Entity, EntityTurnTimelineCalculationData> l_entityTurnTimelineDataLookup = p_turnTimeline.TimelineOrderingDatas;

            var l_entityTurnTimelineDataLookupEnumerator = l_entityTurnTimelineDataLookup.GetRefEnumerator();

            while (l_entityTurnTimelineDataLookupEnumerator.MoveNext())
            {
                var l_timelineOrderingDataEntry_ref = l_entityTurnTimelineDataLookupEnumerator.GetCurrentRef();
                if (l_lowerTimelineScore == null)
                {
                    l_lowerTimelineScore   = l_timelineOrderingDataEntry_ref.key;
                    l_currentComparedScore = l_timelineOrderingDataEntry_ref.value.CurrentTimelinePosition;
                }
                else if (l_timelineOrderingDataEntry_ref.value.CurrentTimelinePosition < l_currentComparedScore)
                {
                    l_lowerTimelineScore   = l_timelineOrderingDataEntry_ref.key;
                    l_currentComparedScore = l_timelineOrderingDataEntry_ref.value.CurrentTimelinePosition;
                }
            }

            if (l_lowerTimelineScore != null)
            {
                float l_removedTimelineScore = l_currentComparedScore;

                // All entities advances in the timeline
                l_entityTurnTimelineDataLookupEnumerator = l_entityTurnTimelineDataLookup.GetRefEnumerator();
                while (l_entityTurnTimelineDataLookupEnumerator.MoveNext())
                {
                    l_entityTurnTimelineDataLookupEnumerator.GetCurrentRef().value.CurrentTimelinePosition += (-1 * l_removedTimelineScore);
                }

                // The next Entity is pushed back on the Timeline
                l_entityTurnTimelineDataLookup.ValueRef(l_lowerTimelineScore).CurrentTimelinePosition = EntityTurnTimelineCalculationData.calculateReferenceTurnTimelineScore(l_lowerTimelineScore);
            }

            return(l_lowerTimelineScore);
        }