Ejemplo n.º 1
0
        public static void Update()
        {
            var timeBase = TimeBase.GetTimeBase();

            if (Globals.Timing.TimeMs > sUpdateTime)
            {
                if (!timeBase.SyncTime)
                {
                    sGameTime = sGameTime.Add(new TimeSpan(0, 0, 0, 0, (int)(1000 * timeBase.Rate)));

                    //Not sure if Rate is negative if time will go backwards but we can hope!
                }
                else
                {
                    sGameTime = DateTime.Now;
                }

                //Calculate what "timeRange" we should be in, if we're not then switch and notify the world
                //Gonna do this by minutes
                var minuteOfDay   = sGameTime.Hour * 60 + sGameTime.Minute;
                var expectedRange = (int)Math.Floor(minuteOfDay / (float)timeBase.RangeInterval);

                if (expectedRange != sTimeRange)
                {
                    sTimeRange = expectedRange;

                    //Send the Update to everyone!
                    PacketSender.SendTimeToAll();
                }

                sUpdateTime = Globals.Timing.TimeMs + 1000;
            }
        }
Ejemplo n.º 2
0
        public static bool MeetsCondition(
            TimeBetweenCondition condition,
            Player player,
            Event eventInstance,
            QuestBase questBase
            )
        {
            if (condition.Ranges[0] > -1 &&
                condition.Ranges[1] > -1 &&
                condition.Ranges[0] < 1440 / TimeBase.GetTimeBase().RangeInterval&&
                condition.Ranges[1] < 1440 / TimeBase.GetTimeBase().RangeInterval)
            {
                return(Time.GetTimeRange() >= condition.Ranges[0] && Time.GetTimeRange() <= condition.Ranges[1]);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public static void Init()
        {
            var timeBase = TimeBase.GetTimeBase();

            if (timeBase.SyncTime)
            {
                sGameTime = DateTime.Now;
            }
            else
            {
                sGameTime = new DateTime(
                    DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Globals.Rand.Next(0, 24),
                    Globals.Rand.Next(0, 60), Globals.Rand.Next(0, 60)
                    );
            }

            sTimeRange  = -1;
            sUpdateTime = 0;
        }
Ejemplo n.º 4
0
        private void UpdateFormElements(ConditionTypes type)
        {
            grpVariable.Hide();
            grpHasItem.Hide();
            grpSpell.Hide();
            grpClass.Hide();
            grpLevelStat.Hide();
            grpSelfSwitch.Hide();
            grpPowerIs.Hide();
            grpTime.Hide();
            grpStartQuest.Hide();
            grpQuestInProgress.Hide();
            grpQuestCompleted.Hide();
            grpGender.Hide();
            grpMapIs.Hide();
            grpEquippedItem.Hide();
            grpFreeInventorySlots.Hide();
            switch (type)
            {
            case ConditionTypes.VariableIs:
                grpVariable.Show();

                cmbCompareGlobalVar.Items.Clear();
                cmbCompareGlobalVar.Items.AddRange(ServerVariableBase.Names);
                cmbComparePlayerVar.Items.Clear();
                cmbComparePlayerVar.Items.AddRange(PlayerVariableBase.Names);

                cmbBooleanGlobalVariable.Items.Clear();
                cmbBooleanGlobalVariable.Items.AddRange(ServerVariableBase.Names);
                cmbBooleanPlayerVariable.Items.Clear();
                cmbBooleanPlayerVariable.Items.AddRange(PlayerVariableBase.Names);

                break;

            case ConditionTypes.HasItem:
                grpHasItem.Show();
                cmbItem.Items.Clear();
                cmbItem.Items.AddRange(ItemBase.Names);

                break;

            case ConditionTypes.ClassIs:
                grpClass.Show();
                cmbClass.Items.Clear();
                cmbClass.Items.AddRange(ClassBase.Names);

                break;

            case ConditionTypes.KnowsSpell:
                grpSpell.Show();
                cmbSpell.Items.Clear();
                cmbSpell.Items.AddRange(SpellBase.Names);

                break;

            case ConditionTypes.LevelOrStat:
                grpLevelStat.Show();

                break;

            case ConditionTypes.SelfSwitch:
                grpSelfSwitch.Show();

                break;

            case ConditionTypes.AccessIs:
                grpPowerIs.Show();

                break;

            case ConditionTypes.TimeBetween:
                grpTime.Show();
                cmbTime1.Items.Clear();
                cmbTime2.Items.Clear();
                var time = new DateTime(2000, 1, 1, 0, 0, 0);
                for (var i = 0; i < 1440; i += TimeBase.GetTimeBase().RangeInterval)
                {
                    var addRange = time.ToString("h:mm:ss tt") + " " + Strings.EventConditional.to + " ";
                    time      = time.AddMinutes(TimeBase.GetTimeBase().RangeInterval);
                    addRange += time.ToString("h:mm:ss tt");
                    cmbTime1.Items.Add(addRange);
                    cmbTime2.Items.Add(addRange);
                }

                break;

            case ConditionTypes.CanStartQuest:
                grpStartQuest.Show();
                cmbStartQuest.Items.Clear();
                cmbStartQuest.Items.AddRange(QuestBase.Names);

                break;

            case ConditionTypes.QuestInProgress:
                grpQuestInProgress.Show();
                cmbQuestInProgress.Items.Clear();
                cmbQuestInProgress.Items.AddRange(QuestBase.Names);

                break;

            case ConditionTypes.QuestCompleted:
                grpQuestCompleted.Show();
                cmbCompletedQuest.Items.Clear();
                cmbCompletedQuest.Items.AddRange(QuestBase.Names);

                break;

            case ConditionTypes.NoNpcsOnMap:
                break;

            case ConditionTypes.GenderIs:
                grpGender.Show();

                break;

            case ConditionTypes.MapIs:
                grpMapIs.Show();

                break;

            case ConditionTypes.IsItemEquipped:
                grpEquippedItem.Show();
                cmbEquippedItem.Items.Clear();
                cmbEquippedItem.Items.AddRange(ItemBase.Names);

                break;

            case ConditionTypes.HasFreeInventorySlots:
                grpFreeInventorySlots.Show();

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 public object Time()
 {
     return(TimeBase.GetTimeBase());
 }
Ejemplo n.º 6
0
 //TimeDataPacket
 private static void HandlePacket(TimeDataPacket packet)
 {
     TimeBase.GetTimeBase().LoadFromJson(packet.TimeJson);
 }
Ejemplo n.º 7
0
 public static Color GetTimeColor()
 {
     return(TimeBase.GetTimeBase().DaylightHues[sTimeRange]);
 }