示例#1
0
    private void PrepareTrainers(Creature challenger, Creature player)
    {
        var pos          = challenger.GetPosition();
        var playerNewPos = pos.GetRelative(MabiMath.ByteToRadian(challenger.Direction), BattleDistance);

        _challengerMonsterPos = playerNewPos.GetRelative(pos, -MonsterDistance);
        _playerMonsterPos     = pos.GetRelative(playerNewPos, -MonsterDistance);

        //challenger.Region.AddProp(new Prop(10, challenger.RegionId, _challengerMonsterPos.X, _challengerMonsterPos.Y, 0));
        //challenger.Region.AddProp(new Prop(10, challenger.RegionId, _playerMonsterPos.X, _playerMonsterPos.Y, 0));

        // Camera
        var packet = new Packet(Op.SetCamera, player.EntityId);

        packet.PutFloat(1000);                                                                                              // distance
        packet.PutFloat(0);
        packet.PutFloat(5);                                                                                                 // pitch
        packet.PutFloat(MabiMath.DirectionToRadian(pos.X - playerNewPos.X, pos.Y - playerNewPos.Y) * (180 / Math.PI) + 25); // yaw
        packet.PutFloat(0);
        player.Client.Send(packet);

        // Move and turn
        player.Jump(playerNewPos);
        player.TurnTo(pos);
        challenger.TurnTo(playerNewPos);
    }
示例#2
0
文件: Dungeon.cs 项目: trueever/aura
        /// <summary>
        /// Returns the radian rotation for the given dungeon direction.
        /// </summary>
        /// <remarks>
        /// TODO: Move somewhere? Direction maybe? Or an extension?
        /// </remarks>
        /// <param name="direction"></param>
        /// <returns></returns>
        private static float Rotation(int direction)
        {
            switch (direction)
            {
            case Direction.Up: return(MabiMath.DirectionToRadian(0, -1));

            case Direction.Down: return(MabiMath.DirectionToRadian(0, 1));

            case Direction.Left: return(MabiMath.DirectionToRadian(1, 0));

            case Direction.Right: return(MabiMath.DirectionToRadian(-1, 0));
            }

            throw new ArgumentException("Invalid direction '" + direction + "'.");
        }
示例#3
0
    private void SpawnGate(Dungeon dungeon)
    {
        var region      = dungeon.Regions.Last();
        var endLocation = dungeon.GetEndRoomCenter();
        var direction   = MabiMath.DirectionToRadian(0, -1);

        var gate = new Prop(GatePropId, endLocation.RegionId, endLocation.X, endLocation.Y, direction);

        gate.Info.Color2 = 0xffffffff;
        gate.Behavior    = OnTouchGate;
        region.AddProp(gate);

        var portal = new Prop(GatePortalPropId, endLocation.RegionId, endLocation.X, endLocation.Y, direction);

        portal.Behavior = OnTouchPortal;
        region.AddProp(portal);
    }
示例#4
0
        /// <summary>
        /// Creates new door prop.
        /// </summary>
        /// <param name="propId"></param>
        /// <param name="regionId"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="direction">Direction the door faces in, in degree.</param>
        /// <param name="doorType"></param>
        /// <param name="name"></param>
        /// <param name="state"></param>
        public Door(int propId, int regionId, int x, int y, int direction, DungeonBlockType doorType, string name, string state = "open")
            : base(propId, regionId, x, y, direction, 1, 0, state, "", "")
        {
            this.Name      = name;
            this.DoorType  = doorType;
            this.BlockBoss = false;
            this.Behavior  = this.DefaultBehavior;
            _isSwitchDoor  = false;
            _closedFrom    = new Position(x / Dungeon.TileSize, y / Dungeon.TileSize);

            // Set direction and adjust Y for boss doors
            if (doorType == DungeonBlockType.BossDoor)
            {
                this.Info.Direction = MabiMath.DirectionToRadian(0, 1);
                this.Info.Y        += Dungeon.TileSize + Dungeon.TileSize / 2;
            }
            else
            {
                this.Info.Direction = MabiMath.DegreeToRadian(direction);
            }
        }