示例#1
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            BuzzStorage storage = (BuzzStorage)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed))
            {
                return;
            }

            if (storage.RemainingTime > 0)
            {
                storage.RemainingTime -= time.ElapsedMsDelta;
                Status = CycleStatus.NotStarted;
            }
            else
            {
                Status = CycleStatus.InProgress;

                if (storage.RemainingDistance <= 0)
                {
                    do
                    {
                        storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                    } while (storage.Direction.X == 0 && storage.Direction.Y == 0);
                    storage.Direction.Normalize();
                    storage.RemainingDistance = range;
                    Status = CycleStatus.Completed;
                }

                float dist = host.EntitySpeed(speed, time);

                host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist);
                host.UpdateCount++;

                storage.RemainingDistance -= dist;
            }

            state = storage;
        }
示例#2
0
 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     state = new BuzzStorage();
 }
示例#3
0
 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     state = new BuzzStorage();
 }