コード例 #1
0
        // serialize loader
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            bool somebool = reader.ReadBool();             // change later to wether its on/off

            m_CurEntry = reader.ReadInt();

            m_nextAct = reader.ReadDateTime();

            for (int i = 0; i < 12; i++)
            {
                WayPoint    way    = (WayPoint)reader.ReadItem();
                string      actstr = reader.ReadString();
                ScheduleAct act    = ScheduleAct.None;
                try {
                    act = (ScheduleAct)Enum.Parse(typeof(ScheduleAct), actstr);
                }
                catch {
                    // TODO -- Some form of error report
                }

                m_Entries[i] = new ScheduleEntry(way, act);
            }

            SetUpScheduler();
        }
コード例 #2
0
        // Clean up code goes here, for instance getting up before wandering off
        public void CleanUp()
        {
            if (m_Schedule.CurEntry < 0)
            {
                return;
            }

            ScheduleAct act = m_Schedule.Entries[m_Schedule.CurEntry].activity;
        }
コード例 #3
0
        public void Tick()
        {
            // don't do activities if you're still moving
            if (m_Mobile.CurrentWayPoint != null)
            {
                return;
            }

            int hours;
            int minutes;

            Time.GetTime(out hours, out minutes);

            // Divide hours by 2 to get current schedule
            int entry = hours >> 1;

            if (m_Schedule.CurEntry != entry && m_Schedule.Entries[entry].activity != ScheduleAct.None)
            {
                // Clean up before starting on the new entry
                CleanUp();

                m_Schedule.CurEntry = entry;

                // Check to see if there's a waypoint, and thus movement first
                if (m_Schedule.Entries[entry].waypoint != null)
                {
                    WayPoint wp = m_Schedule.Entries[entry].waypoint;

                    // if thewaypoint isn't close enough teleport the npc there
                    //if (!m_Mobile.InLOS(wp))
                    //	m_Mobile.MoveToWorld(wp.Location, wp.Map);

                    m_Mobile.CurrentWayPoint = wp;

                    // TODO : make this an option, use custom speed if given
                    if (m_Mobile.CurrentSpeed <= 0.25)
                    {
                        m_Mobile.CurrentSpeed = m_Mobile.ActiveSpeed;
                    }
                    else
                    {
                        m_Mobile.CurrentSpeed = 0.25;
                    }

                    IsWalking = true;

                    return;
                }
            }

            // No waypoint, no new stuffs, so do stuff!

            // Return speed to passive once arrived at location
            if (IsWalking)
            {
                m_Mobile.CurrentSpeed = m_Mobile.PassiveSpeed;
                IsWalking             = false;
                m_Schedule.nextAct    = DateTime.Now;
            }

            if (m_Schedule.nextAct != DateTime.MinValue)
            {
                ScheduleAct act = m_Schedule.Entries[entry].activity;

                if (act == ScheduleAct.Wander)
                {
                    Wander();
                }
                else if (act == ScheduleAct.Eat)
                {
                    FindSeat(15);
                }
            }
        }
コード例 #4
0
 public ScheduleEntry()
 {
     waypoint = null;
     activity = ScheduleAct.None;
 }
コード例 #5
0
 public ScheduleEntry(WayPoint w, ScheduleAct a)
 {
     waypoint = w;
     activity = a;
 }