示例#1
0
 public static int Distance(VisibleObject obj, int x, int y)
 {
     return(Distance(obj.X, obj.Y, x, y));
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavPoint"/> struct.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <param name="timeOfArrival">The time of arrival.</param>
 public NavPoint(VisibleObject location = null)
 {
     this.TimeOfArrival = NavPoint.UNKNOWN_TIME_OF_ARRIVAL;
     this.Location      = location;
 }
示例#3
0
            public ServerPacket GenerateBasePacket(User invoker, VisibleObject invokee)
            {
                byte   color   = 0;
                ushort sprite  = 0;
                byte   objType = 0;

                var dialogPacket = new ServerPacket(0x30);

                dialogPacket.WriteByte((byte)(DialogType));

                if (invokee is Creature)
                {
                    var creature = (Creature)invokee;
                    sprite  = (ushort)(0x4000 + creature.Sprite);
                    objType = 1;
                }
                else if (invokee is ItemObject)
                {
                    var item = (ItemObject)invokee;
                    objType = 2;
                    sprite  = (ushort)(0x8000 + item.Sprite);
                    color   = item.Color;
                }
                else if (invokee is Reactor)
                {
                    objType = 4;
                }

                if (Sprite != 0)
                {
                    sprite = Sprite;
                }
                else
                {
                    // If dialog sprite is unset, try using invokee's sprite;
                    // then try user dialog state (global sequence)
                    sprite = invokee?.DialogSprite ?? invoker.DialogState?.Associate?.DialogSprite ?? 0;
                }

                dialogPacket.WriteByte(objType);
                // If no invokee ID, we use 0xFFFFFFFF; 99.9% of the time this is an async dialog request
                dialogPacket.WriteUInt32(invokee?.Id ?? UInt32.MaxValue);
                dialogPacket.WriteByte(0); // Unknown value
                Log.Debug("Sprite is {Sprite}", sprite);
                dialogPacket.WriteUInt16(sprite);
                dialogPacket.WriteByte(color);
                dialogPacket.WriteByte(0); // Unknown value
                dialogPacket.WriteUInt16(sprite);
                dialogPacket.WriteByte(color);
                Log.Debug("Dialog group id {SequenceId}, index {Index}", Sequence.Id, Index);
                dialogPacket.WriteUInt16((ushort)Sequence.Id);
                dialogPacket.WriteUInt16((ushort)Index);

                dialogPacket.WriteBoolean(HasPrevDialog());
                dialogPacket.WriteBoolean(HasNextDialog());

                dialogPacket.WriteByte(0);
                // TODO: Allow override here from DialogSequence
                dialogPacket.WriteString8(invokee?.Name ?? invoker.DialogState?.Associate?.Name ?? Sequence.DisplayName);
                var displayText = EvaluateDisplayText(invoker, invokee);

                if (!string.IsNullOrEmpty(displayText))
                {
                    dialogPacket.WriteString16(displayText);
                }

                return(dialogPacket);
            }
示例#4
0
 public virtual void ShowTo(User invoker, VisibleObject invokee)
 {
 }
示例#5
0
文件: Map.cs 项目: saroque/server
        public void Insert(VisibleObject obj, byte x, byte y, bool updateClient = true)
        {
            if (Objects.Add(obj))
            {
                obj.Map = this;
                obj.X = x;
                obj.Y = y;

                EntityTree.Add(obj);

                var user = obj as User;
                if (user != null)
                {
                    if (updateClient)
                    {
                        obj.SendMapInfo();
                        obj.SendLocation();
                    }
                    Users.Add(user.Name, user);
                }

                var value = obj as Reactor;
                if (value != null)
                {
                    Reactors.Add(new Tuple<byte, byte>((byte)x,(byte)y), value);
                }

                var affectedObjects = EntityTree.GetObjects(obj.GetViewport());

                foreach (var target in affectedObjects)
                {
                    target.AoiEntry(obj);
                    obj.AoiEntry(target);
                }

            }
        }
示例#6
0
 public void RunCallback(User target, VisibleObject associate)
 {
     ActiveDialog.RunCallback(target, associate);
 }
示例#7
0
 void Start()
 {
     PointableObject = Target.GetComponent <PointableObject>();
     VisibleObject   = Target.GetComponent <VisibleObject>();
 }
示例#8
0
 public static int Distance(VisibleObject obj1, VisibleObject obj2)
 {
     return(Distance(obj1.X, obj1.Y, obj2.X, obj2.Y));
 }
示例#9
0
文件: Map.cs 项目: saroque/server
 public void NotifyNearbyAoiEntry(VisibleObject objectToAdd)
 {
     foreach (var obj in EntityTree.GetObjects(objectToAdd.GetViewport()))
     {
         if (obj is User)
         {
             Logger.DebugFormat("Notifying {0} of item {1} at {2},{3} with sprite {4}", obj.Name, objectToAdd.Name,
                 objectToAdd.X, objectToAdd.Y, objectToAdd.Sprite);
             var user = obj as User;
             user.AoiEntry(objectToAdd);
         }
     }
 }
示例#10
0
文件: Map.cs 项目: saroque/server
        public void Remove(VisibleObject obj)
        {
            if (Objects.Remove(obj))
            {
                EntityTree.Remove(obj);

                if (obj is User)
                {
                    var user = obj as User;
                    Users.Remove(user.Name);
                    if (user.ActiveExchange != null)
                        user.ActiveExchange.CancelExchange(user);
                }

                var affectedObjects = EntityTree.GetObjects(obj.GetViewport());

                foreach (var target in affectedObjects)
                {
                    // If the target of a Remove is a player, we insert a 250ms delay to allow the animation
                    // frame to complete.
                    if (target is User)
                        ((User)target).AoiDeparture(obj, 250);
                    else
                        target.AoiDeparture(obj);

                    obj.AoiDeparture(target);
                }

                obj.Map = null;
                obj.X = 0;
                obj.Y = 0;
            }
        }
示例#11
0
文件: Map.cs 项目: saroque/server
 public void NotifyNearbyAoiDeparture(VisibleObject objectToRemove)
 {
     foreach (var obj in EntityTree.GetObjects(objectToRemove.GetViewport()))
     {
         if (obj is User)
         {
             var user = obj as User;
             user.AoiDeparture(objectToRemove);
         }
     }
 }
示例#12
0
文件: Map.cs 项目: saroque/server
 public static int Distance(VisibleObject obj, int x, int y)
 {
     return Distance(obj.X, obj.Y, x, y);
 }
示例#13
0
文件: Map.cs 项目: saroque/server
 public static int Distance(VisibleObject obj1, VisibleObject obj2)
 {
     return Distance(obj1.X, obj1.Y, obj2.X, obj2.Y);
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavPoint"/> struct.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <param name="timeOfArrival">The time of arrival.</param>
 public NavPoint(VisibleObject location, DateTime timeOfArrival)
 {
     this.TimeOfArrival = timeOfArrival;
     this.Location      = location;
 }
示例#15
0
 void Awake()
 {
     Collider      = GetComponent <CircleCollider2D>();
     VisibleObject = GetComponent <VisibleObject>();
 }
示例#16
0
 public override void AoiEntry(VisibleObject obj)
 {
     ShowTo(obj);
 }
示例#17
0
 void Awake()
 {
     VisibleObject = GetComponent <VisibleObject>();
 }
示例#18
0
文件: Circle.cs 项目: temik911/audio
 internal override VisibleObject Copy(VisibleObject parent)
 {
     Marker marker = new Circle(Cell);
     marker.Parent = (EntityCollection)parent;
     return marker;
 }
 private void RequestLoadingIfNeeded(VisibleObject visibleObject)
 {
     visibleObject.VisualsRequest.RequestLoad(this);
 }