public HostMoveFurnitureEventArgs(Func <Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id        = packet.ReadInteger();
     Tile      = new HPoint(packet.ReadInteger(), packet.ReadInteger());
     Direction = (HDirection)packet.ReadInteger();
 }
Example #2
0
        public HFurniture(HPacket packet)
        {
            Id     = packet.ReadInt32();
            TypeId = packet.ReadInt32();

            Tile   = new HPoint(packet.ReadInt32(), packet.ReadInt32());
            Facing = (HDirection)packet.ReadInt32();
            Tile.Z = double.Parse(packet.ReadUTF8(), CultureInfo.InvariantCulture);

            var loc1 = packet.ReadUTF8();
            var loc3 = packet.ReadInt32();

            int category = packet.ReadInt32();

            ReadData(packet, category);

            var loc4 = packet.ReadInt32();
            var loc5 = packet.ReadInt32();

            OwnerId = packet.ReadInt32();
            if (TypeId < 0)
            {
                var loc6 = packet.ReadUTF8();
            }
        }
Example #3
0
        private void Drag(int r, int c, Vector2 pos)
        {
            if (!this.dragFlag)
            {
                this.dragFlag = true;
            }

            Vector2 localPos = this.transform.InverseTransformPoint(pos);
            var     v        = localPos - this.DownPosition;
            var     d        = v.ToDirection().ToHDirection();

            if (this.DragDirection != HDirection.None && this.DragDirection != d)
            {
                return;
            }

            if (this.DragDirection == HDirection.None)
            {
                this.DragDirection = v.ToDirection().ToHDirection();
            }

            if (this.DragDirection != HDirection.None)
            {
                this.InitCubeBeDrag(r, c, this.DragDirection);
            }

            this.DragMove(localPos);
        }
        public FurnitureDropEventArgs(Func <Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id     = Packet.ReadInteger();
            TypeId = Packet.ReadInteger();

            int x = Packet.ReadInteger();
            int y = Packet.ReadInteger();

            Direction = (HDirection)Packet.ReadInteger();

            Tile = new HPoint(x, y,
                              double.Parse(Packet.ReadString(), CultureInfo.InvariantCulture));

            Packet.ReadString();
            Packet.ReadInteger();
            Packet.ReadInteger();
            Packet.ReadString();

            IsRental = (Packet.ReadInteger() != 1);
            Packet.ReadInteger();

            OwnerId   = Packet.ReadInteger();
            OwnerName = Packet.ReadString();
        }
Example #5
0
        private void HandleEndDrag(int r, int c, Vector2 pos)
        {
            do
            {
                Vector2 localPos = this.transform.InverseTransformPoint(pos);
                var     distance = localPos - this.DownPosition;

                var moveCount = 0;
                if (this.DragDirection == HDirection.None)
                {
                    break;
                }
                else if (this.DragDirection == HDirection.Horizon)
                {
                    moveCount = Mathf.FloorToInt(Mathf.Abs(distance.x) / CubeComponent.kCubeWidth);
                }
                else if (this.DragDirection == HDirection.Vertical)
                {
                    moveCount = Mathf.FloorToInt(Mathf.Abs(distance.y) / CubeComponent.kCubeHeight);
                }

                for (var i = 0; i < moveCount; ++i)
                {
                    this.LogicMove(distance.ToDirection(), r, c);
                }

                this.Refresh();
            } while (false);

            this.dragFlag      = false;
            this.LastPos       = null;
            this.DragDirection = HDirection.None;
            this.DelCubes();
            //this.Refresh();
        }
 public HostMoveFurnitureEventArgs(Func<Task> continuation, int step, HMessage packet)
     : base(continuation, step, packet)
 {
     Id = packet.ReadInteger();
     Tile = new HPoint(packet.ReadInteger(), packet.ReadInteger());
     Direction = (HDirection)packet.ReadInteger();
 }
        public HostMoveFurnitureEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;

            FurnitureId = _packet.ReadInt(0);
            Tile        = new HPoint(_packet.ReadInt(4), _packet.ReadInt(8));
            Direction   = (HDirection)_packet.ReadInt(12);
        }
Example #8
0
        public HDirection RotateLeft()
        {
            int direction = (int)Direction;

            if (direction <= 0)
            {
                direction = 8;
            }
            return(Direction = (HDirection)(direction - (direction % 2 == 0 ? 2 : 3)));
        }
Example #9
0
 public HFurniture(int id, int typeId, int ownerId,
     string ownerName, HPoint tile, HDirection direction)
 {
     Id = id;
     TypeId = typeId;
     OwnerId = ownerId;
     OwnerName = ownerName;
     Tile = tile;
     Direction = direction;
 }
Example #10
0
        public HDirection RotateRight()
        {
            int direction = (int)Direction;

            if (direction >= 6)
            {
                direction = -2;
            }
            return(Direction = (HDirection)(direction + (direction % 2 == 0 ? 2 : 3)));
        }
Example #11
0
 public HFurniture(int id, int typeId, int ownerId,
                   string ownerName, HPoint tile, HDirection direction)
 {
     Id        = id;
     TypeId    = typeId;
     OwnerId   = ownerId;
     OwnerName = ownerName;
     Tile      = tile;
     Direction = direction;
 }
Example #12
0
        public static HDirection RotateLeft(this HDirection direction, int times)
        {
            int dirVal = (int)direction;

            while (times-- > 0)
            {
                dirVal = (dirVal <= 0 ? 7 : dirVal - 1);
            }

            return((HDirection)dirVal);
        }
Example #13
0
 public HFurnitureData(int furnitureOwnerId, string furnitureOwnerName,
                       int furnitureId, int furnitureTypeId, HPoint tile, HDirection direction, int state)
 {
     FurnitureOwnerId   = furnitureOwnerId;
     FurnitureOwnerName = furnitureOwnerName;
     FurnitureId        = furnitureId;
     furnitureTypeId    = FurnitureTypeId;
     Tile      = tile;
     Direction = direction;
     State     = state;
 }
Example #14
0
        public static HDirection RotateRight(this HDirection direction, int times)
        {
            int dirVal = (int)direction;

            while (times-- > 0)
            {
                dirVal = (dirVal >= 7 ? 0 : dirVal + 1);
            }

            return((HDirection)dirVal);
        }
Example #15
0
        public FurnitureMoveEventArgs(Func <Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id     = packet.ReadInteger();
            TypeId = packet.ReadInteger();

            int x = packet.ReadInteger();
            int y = packet.ReadInteger();

            Direction = (HDirection)packet.ReadInteger();
            Tile      = new HPoint(x, y, double.Parse(packet.ReadString()));

            // TODO: Find the chunks before OwnerId and read them.
            OwnerId = packet.ReadInteger(packet.Length - 6);
        }
        public FurnitureMoveEventArgs(Func<Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id = packet.ReadInteger();
            TypeId = packet.ReadInteger();

            int x = packet.ReadInteger();
            int y = packet.ReadInteger();
            Direction = (HDirection)packet.ReadInteger();

            Tile = new HPoint(x, y,
                double.Parse(packet.ReadString(), CultureInfo.InvariantCulture));

            // TODO: Find the chunks before OwnerId and read them.
            OwnerId = packet.ReadInteger(packet.Length - 6);
        }
Example #17
0
        private void InitCubeBeDrag(int r, int c, HDirection direct)
        {
            this.DragCubes.Clear();

            foreach (var cube in this.cubes)
            {
                if (direct == HDirection.Horizon && cube.Row == r)
                {
                    this.DragCubes.Add(cube);
                }

                if (direct == HDirection.Vertical && cube.Col == c)
                {
                    this.DragCubes.Add(cube);
                }
            }
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HEntityAction"/> class with the specified information.
        /// </summary>
        /// <param name="isEmpowered">The value that determines whether the <see cref="IHEntity"/> has privileges.</param>
        /// <param name="index">The room index value of the <see cref="IHEntity"/>.</param>
        /// <param name="tile">The <see cref="HPoint"/> of where the <see cref="IHEntity"/> is currently on.</param>
        /// <param name="movingTo">The <see cref="HPoint"/> of where the <see cref="IHEntity"/> will move to next.</param>
        /// <param name="sign">The <see cref="HSign"/> that the <see cref="IHEntity"/> has raised.</param>
        /// <param name="stance">The current <see cref="HStance"/> of the <see cref="IHEntity"/>.</param>
        /// <param name="headDirection">The <see cref="HDirection"/> of the <see cref="IHEntity"/>'s head.</param>
        /// <param name="bodyDirection">The <see cref="HDirection"/> of the <see cref="IHEntity"/>'s body.</param>
        /// <param name="lastAction">The <see cref="HAction"/> that the <see cref="IHEntity"/> has recently done.</param>
        public HEntityAction(bool isEmpowered, int index, HPoint tile, HPoint movingTo,
            HSign sign, HStance stance, HDirection headDirection, HDirection bodyDirection, HAction lastAction)
        {
            Index = index;
            IsEmpowered = isEmpowered;

            Tile = tile;
            MovingTo = movingTo;

            Sign = sign;
            Stance = stance;

            HeadDirection = headDirection;
            BodyDirection = bodyDirection;

            LastAction = lastAction;
        }
Example #19
0
        public HPlayerAction(bool empowered, int playerIndex, HPoint tile, HPoint movingTo, HSign sign,
                             HStance stance, HDirection headDirection, HDirection bodyDirection, HAction latestAction)
        {
            Empowered   = empowered;
            PlayerIndex = playerIndex;

            Tile     = tile;
            MovingTo = movingTo;

            Sign   = sign;
            Stance = stance;

            HeadDirection = headDirection;
            BodyDirection = bodyDirection;

            LatestAction = latestAction;
        }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HEntityAction"/> class with the specified information.
        /// </summary>
        /// <param name="isEmpowered">The value that determines whether the <see cref="IHEntity"/> has privileges.</param>
        /// <param name="index">The room index value of the <see cref="IHEntity"/>.</param>
        /// <param name="tile">The <see cref="HPoint"/> of where the <see cref="IHEntity"/> is currently on.</param>
        /// <param name="movingTo">The <see cref="HPoint"/> of where the <see cref="IHEntity"/> will move to next.</param>
        /// <param name="sign">The <see cref="HSign"/> that the <see cref="IHEntity"/> has raised.</param>
        /// <param name="stance">The current <see cref="HStance"/> of the <see cref="IHEntity"/>.</param>
        /// <param name="headDirection">The <see cref="HDirection"/> of the <see cref="IHEntity"/>'s head.</param>
        /// <param name="bodyDirection">The <see cref="HDirection"/> of the <see cref="IHEntity"/>'s body.</param>
        /// <param name="lastAction">The <see cref="HAction"/> that the <see cref="IHEntity"/> has recently done.</param>
        public HEntityAction(bool isEmpowered, int index, HPoint tile, HPoint movingTo,
                             HSign sign, HStance stance, HDirection headDirection, HDirection bodyDirection, HAction lastAction)
        {
            Index       = index;
            IsEmpowered = isEmpowered;

            Tile     = tile;
            MovingTo = movingTo;

            Sign   = sign;
            Stance = stance;

            HeadDirection = headDirection;
            BodyDirection = bodyDirection;

            LastAction = lastAction;
        }
        public PlayerActionEventArgs(HMessage packet)
        {
            _packet = packet;
            Header  = _packet.Header;
            int    x, y;
            string z, actionTxt;

            int position = 0;

            PlayerCount   = _packet.ReadInt(ref position);
            PlayerIndex   = _packet.ReadInt(ref position);
            x             = _packet.ReadInt(ref position);
            y             = _packet.ReadInt(ref position);
            z             = _packet.ReadString(ref position);
            Tile          = new HPoint(x, y, z);
            HeadDirection = (HDirection)_packet.ReadInt(ref position);
            BodyDirection = (HDirection)_packet.ReadInt(ref position);
            actionTxt     = _packet.ReadString(ref position);
            actionTxt     = actionTxt.GetChild("//mv ", '/');
        }
Example #22
0
 public static void UpdateFurniFacing(int id, HDirection direction)
 {
     try {
         if (Furni.Find(f => f.Id == id) != null)
         {
             Furni.Find(f => f.Id == id).Facing = direction;
         }
         if (RemFurni.Find(f => f.Id == id) != null)
         {
             RemFurni.Find(f => f.Id == id).Facing = direction;
         }
         if (Snapshot_Floor_Furnis_in_room.Find(f => f.Id == id) != null)
         {
             Snapshot_Floor_Furnis_in_room.Find(f => f.Id == id).Facing = direction;
         }
         if (OriginalFloorFurnis.Find(f => f.Id == id) != null)
         {
             OriginalFloorFurnis.Find(f => f.Id == id).Facing = direction;
         }
     }
     catch (Exception) { }
 }
Example #23
0
    public void move(HDirection dir)
    {
        float dirMod;

        switch (dir)
        {
        case HDirection.RIGHT:
            dirMod = 1;
            break;

        case HDirection.LEFT:
            dirMod = -1;
            break;

        default:
            dirMod = 0;
            break;
        }
        this.charState.lastFacing = this.charState.facing;
        this.charState.facing     = dir;
        this.rb2d.velocity        = new Vector2(moveSpeed * dirMod, this.rb2d.velocity.y);
    }
Example #24
0
        public FurnitureDropEventArgs(Func<Task> continuation, int step, HMessage packet)
            : base(continuation, step, packet)
        {
            Id = Packet.ReadInteger();
            TypeId = Packet.ReadInteger();

            int x = Packet.ReadInteger();
            int y = Packet.ReadInteger();

            Direction = (HDirection)Packet.ReadInteger();
            Tile = new HPoint(x, y, double.Parse(Packet.ReadString()));

            Packet.ReadString();
            Packet.ReadInteger();
            Packet.ReadInteger();
            Packet.ReadString();

            IsRental = (Packet.ReadInteger() != 1);
            Packet.ReadInteger();

            OwnerId = Packet.ReadInteger();
            OwnerName = Packet.ReadString();
        }
Example #25
0
    public HEntityUpdate(IHFormat format, ref ReadOnlySpan <byte> packetSpan)
    {
        Index = format.Read <int>(ref packetSpan);

        Tile = new HPoint(format.Read <int>(ref packetSpan), format.Read <int>(ref packetSpan),
                          float.Parse(format.ReadUTF8(ref packetSpan), CultureInfo.InvariantCulture));

        HeadFacing = (HDirection)format.Read <int>(ref packetSpan);
        BodyFacing = (HDirection)format.Read <int>(ref packetSpan);

        string action = format.ReadUTF8(ref packetSpan);

        string[] actionData = action.Split('/', StringSplitOptions.RemoveEmptyEntries);
        foreach (string actionInfo in actionData)
        {
            string[] actionValues = actionInfo.Split(' ');

            if (actionValues.Length < 2)
            {
                continue;
            }
            if (string.IsNullOrWhiteSpace(actionValues[0]))
            {
                continue;
            }

            switch (actionValues[0])
            {
            case "flatctrl":
            {
                IsController = true;
                break;
            }

            case "mv":
            {
                string[] values = actionValues[1].Split(',');
                if (values.Length >= 3)
                {
                    MovingTo = new HPoint(int.Parse(values[0]), int.Parse(values[1]),
                                          float.Parse(values[2], CultureInfo.InvariantCulture));
                }
                Action = HAction.Move;
                break;
            }

            case "sit":
            {
                Action = HAction.Sit;
                Stance = HStance.Sit;
                break;
            }

            case "lay":
            {
                Action = HAction.Lay;
                Stance = HStance.Lay;
                break;
            }

            case "sign":
            {
                Sign   = (HSign)int.Parse(actionValues[1]);
                Action = HAction.Sign;
                break;
            }
            }
        }
    }
Example #26
0
        public HEntityAction(HPacket packet)
        {
            Index = packet.ReadInt32();

            Tile = new HPoint(packet.ReadInt32(), packet.ReadInt32(),
                              double.Parse(packet.ReadUTF8(), CultureInfo.InvariantCulture));

            HeadFacing = (HDirection)packet.ReadInt32();
            BodyFacing = (HDirection)packet.ReadInt32();

            string[] actionData = packet.ReadUTF8()
                                  .Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string actionInfo in actionData)
            {
                string[] actionValues = actionInfo.Split(' ');

                if (actionValues.Length < 2)
                {
                    continue;
                }
                if (string.IsNullOrWhiteSpace(actionValues[0]))
                {
                    continue;
                }

                switch (actionValues[0])
                {
                case "flatctrl":
                {
                    IsEmpowered = true;
                    break;
                }

                case "mv":
                {
                    string[] values = actionValues[1].Split(',');
                    if (values.Length >= 3)
                    {
                        Tile = new HPoint(int.Parse(values[0]), int.Parse(values[1]),
                                          double.Parse(values[2], CultureInfo.InvariantCulture));
                    }
                    Action = HAction.Move;
                    break;
                }

                case "sit":
                {
                    Action = HAction.Sit;
                    Stance = HStance.Sit;
                    break;
                }

                case "lay":
                {
                    Action = HAction.Lay;
                    Stance = HStance.Lay;
                    break;
                }

                case "sign":
                {
                    Sign   = (HSign)int.Parse(actionValues[1]);
                    Action = HAction.Sign;
                    break;
                }
                }
            }
        }
Example #27
0
 public static HDirection ToLeft(this HDirection facing)
 {
     return((HDirection)(((int)facing - 1) & 7));
 }
Example #28
0
 public static HDirection ToRight(this HDirection facing)
 {
     return((HDirection)(((int)facing + 1) & 7));
 }
Example #29
0
File: Item.cs Project: mokujin/DN
        public override void Update(float dt)
        {
            if (!DoingAction)
                IntervalTimer.Update(dt);
            else
                PerfermingTimer.Update(dt);

            if (HDirection != HDirection.No)
                _lastGoodDirection = HDirection;

            if (HDirection == HDirection.No && VDirection == VDirection.No)
                HDirection = _lastGoodDirection;

            base.Update(dt);
        }