Наследование: MonoBehaviour
Пример #1
0
 public void CanTurn(Rotation rotation)
 {
     var ant = new Ant(_initialDirection, _initialPosition);
     var expectedDirection = _initialDirection.Rotate(rotation);
     ant.Turn(rotation);
     ant.Direction.Should().Be(expectedDirection);
 }
Пример #2
0
 static Rotation CreateRotation()
 {
     var rotation = new Rotation { Id = 2, Name = "TheRotation", RotationType = RotationTypes.Rotation1 };
       var startTime = new DateTime(1, 1, 1, 7, 0, 0);
       rotation.RotationShifts.Add(new RotationShift(TimeConstants.Weekday, startTime, startTime.AddHours(12).AddMinutes(-1)));
       return rotation;
 }
Пример #3
0
 public bool Rotate(Rotation rotation)
 {
     int deltaX, deltaY;
     Deck head = Decks.First();
     if (IsShipRotatable())
     {
         GetRotationDirection(out deltaY, out deltaX);
         for (int i = 1; i < Decks.Count; i++)
         {
             int newX = 0, newY = 0;
             switch (rotation)
             {
                 case Rotation.Left:
                     newX = head.X - deltaX * i;
                     newY = head.Y - deltaY * i;
                     break;
                 case Rotation.Right:
                     newX = head.X + deltaX * i;
                     newY = head.Y + deltaY * i;
                     break;
             }
             if (AreCoordinatesNotNegative(newX, newY))
             {
                 Decks.ElementAt(i).X = newX;
                 Decks.ElementAt(i).Y = newY;
             }
             else
             {
                 return false;
             }
         }
     }
     return true;
 }
 public override void FromReader(IMinecraftDataReader reader)
 {
     Rotation = new Rotation(
         reader.ReadFloat(), 
         reader.ReadFloat(), 
         reader.ReadFloat());
 }
Пример #5
0
        public ShipInstance(Position pos, Rotation r, Ship ship)
        {
            this.pos = pos;
            this.rotation = r;
            this.ship = ship;

            this.sunken = false;
        }
Пример #6
0
 public static void ReversePath(Rotation[] path)
 {
     for (int i = 0; i < path.Length; i++)
     {
         path[i] = (Rotation)(((byte)path[i] + 2) % 4);
     }
     Array.Reverse(path);
 }
Пример #7
0
		public X3DViewpoint (float? fieldOfView, Vector3? position, 
		                     Rotation orientation, Vector3? centerOfRotation)
		{
			this.FieldOfView = fieldOfView;
			this.Position = position;
			this.Orientation = orientation;
			this.CenterOfRotation = centerOfRotation;
		}
Пример #8
0
		public X3DTransform (X3DNode[] nodes,  
			Vector3? translation, 
			Rotation rotatio, 
			Vector3? scale) : base (nodes)
		{
			this.Translation = translation;
			this.Rotation = rotatio;
			this.Scale = scale;
		}
Пример #9
0
        private void SetRotation(Rotation rotation)
        {
            var prefabRotation = doorPrefab.transform.eulerAngles;

            prefabRotation.y = RotationHelper.GetEulerAngle(rotation);

            this.goReference.transform.eulerAngles = prefabRotation;
            this.rotation = rotation;
        }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     originalPos = transform.position;
     originalPos.z = 0;
     leashLength = 0.5f;
     moveSpeed = 1.0f;
     playerController = memoizer.GetMemoizedComponent<CharacterController>(gameObject);
     rotateScript = memoizer.GetMemoizedComponent<Rotation>(GameObject.FindGameObjectWithTag("Sphere"));
 }
Пример #11
0
 public SETItem(EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Position = new Vertex();
     Rotation = new Rotation();
     Scale = new Vertex();
     objdef = LevelData.ObjDefs[id];
     bounds = objdef.GetBounds(this);
 }
Пример #12
0
 // Apply a full move to the board
 // This swaps CurrentPlayer
 public bool ApplyMove(int xCoord, int yCoord, PieceColor color, Rotation r)
 {
     bool placed = this.PlacePieceAt(xCoord, yCoord, color);
     if (placed)
     {
         this.DoRotation(r);
         this.CurrentPlayer = (color == PieceColor.White) ? PieceColor.Black : PieceColor.White;
     }
     return placed;
 }
        public float Rotate(Rotation rotation, float _Rotation)
        {
            if (rotation == Rotation.Left)
                return RotateLeft(_Rotation);

            if (rotation == Rotation.Right)
                return RotateRight(_Rotation);

            return 0;
        }
Пример #14
0
 public Rotation(string name, double roll, double pitch, double yaw)
 {
     self = this;
     self.name = name;
     self.roll = roll;
     self.pitch = pitch;
     self.yaw = yaw;
     self.r = new Matrix3();
     r.from_euler(roll, pitch, yaw);
 }
Пример #15
0
        private void SpawnDoor(IntVector3 position, Rotation rotation)
        {
            if (this.goReference == null) {
                PreloadPrefabs();

                this.goReference = doorPrefab.Spawn();
                this.goReference.transform.position = position.ToVector3();

                SetRotation(rotation);
            }
        }
Пример #16
0
 public Direction Rotate(Rotation rotation)
 {
     switch (rotation)
     {
         case Rotation.Left:
             return new Direction(-_dy, _dx);
         case Rotation.Right:
             return new Direction(_dy, -_dx);
         default:
             throw new ArgumentOutOfRangeException("rotation");
     }
 }
Пример #17
0
        public void Test_Rover_Can_Rotate_90_Degrees(Direction startDirection, Rotation rotateDirection, Direction endDirection)
        {
            var startPosition = new Position { Direction = startDirection, X = 0, Y = 0 };
            var rover = new Rover(startPosition);

            rover.Rotate(rotateDirection);

            var newPosition = rover.GetCurrentPosition();
            var expectedPosition = new Position { Direction = endDirection, X = 0, Y = 0 };

            Assert.AreEqual(newPosition, expectedPosition);
        }
        public void GenerateMessage()
        {
            var rotation = new Rotation {
                Id = 1,
                Name = "Name",
                RotationType = RotationTypes.Rotation3
            };
            var rotationMessage = new RotationMessage(rotation);

            ServiceTestHelper.AssertDomainMessageProperties(rotation, rotationMessage);
            Assert.AreEqual(rotation.RotationType, rotationMessage.RotationType);
        }
Пример #19
0
 protected void copyFromOverlay(Overlay overlay)
 {
     copyFromImageModifer(overlay);
     _position = new IntVector2(overlay._position);
     _mirror = overlay._mirror;
     _alpha = overlay._alpha;
     _textureAlpha = overlay._textureAlpha;
     _alphaOption = overlay._alphaOption;
     _normalScale = overlay._normalScale;
     _normalOption = overlay._normalOption;
     _blendMethod = overlay._blendMethod;
     _rotation = overlay._rotation;
 }
Пример #20
0
        public void Rotate(Rotation direction)
        {
            switch(direction)
            {
                case Rotation.Left:
                    RotateLeft();
                    break;

                case Rotation.Right:
                    RotateRight();
                    break;
            }
        }
Пример #21
0
        public static Directions Rotate(this Directions direction, Rotation rotation)
        {
            // Counter Clockwise
            if (rotation == Rotation.CounterClockwise)
            {
                switch (direction)
                {
                    default:
                        return Directions.None;
                    case Directions.Up:
                        return Directions.UpperLeft;
                    case Directions.UpperLeft:
                        return Directions.Left;
                    case Directions.Left:
                        return Directions.LowerLeft;
                    case Directions.LowerLeft:
                        return Directions.Down;
                    case Directions.Down:
                        return Directions.LowerRight;
                    case Directions.LowerRight:
                        return Directions.Right;
                    case Directions.Right:
                        return Directions.UpperRight;
                    case Directions.UpperRight:
                        return Directions.Up;
                }
            }

            // Clockwise
            switch (direction)
            {
                default:
                    return Directions.None;
                case Directions.Up:
                    return Directions.UpperRight;
                case Directions.UpperRight:
                    return Directions.Right;
                case Directions.Right:
                    return Directions.LowerRight;
                case Directions.LowerRight:
                    return Directions.Down;
                case Directions.Down:
                    return Directions.LowerLeft;
                case Directions.LowerLeft:
                    return Directions.Left;
                case Directions.Left:
                    return Directions.UpperLeft;
                case Directions.UpperLeft:
                    return Directions.Up;
            }
        }
Пример #22
0
    void Start()
    {
        movement = GameObject.FindGameObjectWithTag("Player").GetComponent<Movement> ();
        flashing = GameObject.FindGameObjectWithTag("Flashing").GetComponent<Flashing> ();
        shaking = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraShake> ();
        rotation = GameObject.FindGameObjectWithTag("Rotation").GetComponent<Rotation> ();

        statusText.GetComponent<Text> ().text = "";

        level = 0;
        cookieTotal = 0;
        cookieAmount = 0;
        clip1 = GetComponents<AudioSource> ()[0].clip;
    }
Пример #23
0
        public void Block_Set_When_RotationAdded()
        {
            var block = new Block();
            var rotation1 = new Rotation();

            block.Rotations.Add(rotation1);
            Assert.AreEqual(block, rotation1.Block);

            var rotation2 = new Rotation();
            var rotation3 = new Rotation();
            block.Rotations.AddRange(new List<Rotation> { rotation2, rotation3 });
            Assert.AreEqual(block, rotation2.Block);
            Assert.AreEqual(block, rotation3.Block);
        }
Пример #24
0
 public ActionResult Index()
 {
     var initialRotationModel = new Rotation();
     initialRotationModel.TeamRotations = new TeamRotation[2];
     initialRotationModel.TeamRotations[0] = new TeamRotation()
     {
         ShirtNumbers = new int[] { 5, 12, 6, 7, 10, 1 }
     };
     initialRotationModel.TeamRotations[1] = new TeamRotation()
     {
         ShirtNumbers = new int[] { 13, 9, 2, 10, 12, 4 }
     };
     return View(initialRotationModel);
 }
Пример #25
0
        public void Rotate(Direction direction)
        {
            switch(direction)
            {
                case Direction.Clockwise:
                    this._rotation = (Rotation)(((int)_rotation + 1) % 4);
                    break;

                case Direction.Counterclockwise:
                    if (_rotation == Rotation.None) _rotation = Rotation.Cw270;
                    else _rotation = (Rotation)((int)_rotation - 1);
                    break;
            }
        }
Пример #26
0
		private static void Verify(string originalMapText, string expectedMapText, Rotation rotation, bool flipHorizontal, bool flipVertical)
		{
			char[,] originalMap = { { originalMapText[0], originalMapText[2] }, { originalMapText[1], originalMapText[3] } };
			char[,] expectedMap = { { expectedMapText[0], expectedMapText[2] }, { expectedMapText[1], expectedMapText[3] } };

			bool result;
			char[,] actualMap;
			try
			{
				actualMap = Process(originalMap, rotation, flipHorizontal, flipVertical);

				result = (actualMap[0, 0] == expectedMap[0, 0]) && (actualMap[0, 1] == expectedMap[0, 1]) &&
						 (actualMap[1, 0] == expectedMap[1, 0]) && (actualMap[1, 1] == expectedMap[1, 1]);
			}
			catch
			{
				actualMap = new[,] { { 'e', 'e' }, { 'e', 'e' } };
				result = false;
			}

			var what = $"{rotation}{(flipHorizontal ? "+FH" : "")}{(flipVertical ? "+FV" : "")}".PadRight(15);

			if (!result)
			{
				Console.ForegroundColor = ConsoleColor.Red;
				Console.WriteLine("{0}     {1}{2}   {3}{4}", what.PadLeft(15), expectedMap[0, 0], expectedMap[1, 0], actualMap[0, 0], actualMap[1, 0]);
				Console.WriteLine("{0}     {1}{2}   {3}{4}", "".PadLeft(15), expectedMap[0, 1], expectedMap[1, 1], actualMap[0, 1], actualMap[1, 1]);
				Console.WriteLine();
			}
			else
			{
				Console.ForegroundColor = ConsoleColor.Green;
				Console.WriteLine("{0} OK", what);
			}

			Console.ForegroundColor = ConsoleColor.Gray;
		}
Пример #27
0
    //Pause function added to the move (ends)

	public void Start()
	{
	    try
	    {
            _pauseMenuPanel = Helper.Find<RectTransform>("PauseMenuPanel");
            _pauseMenuStartLocation = _pauseMenuPanel.rect.yMin;
	    }
	    catch (Exception)
	    {
            //Continue with bussiness as usual...
            //Detta händer om det inte finns någon paus-meny och knapp
	    }
        
		_mover = GetComponent<Mover>();
		_rotation = GetComponentInChildren<Rotation>();

		Floor floor = Helper.Find<Floor>("Floor");
		_gridManager = floor.GridManager;
		_pathFinder = new PathFinder(_gridManager);
        
        //Audio related
		_lockAudioSourceLocation = this.gameObject.transform.rotation;
	    _audioComponent = this.gameObject.transform.FindChild("AudioComponent").gameObject;
        _avatarSoul = GameObject.Find("AvatarSoul");

	    if (_avatarSoul != null)        //ADD soul if it is multiple characters
	    {
	        _soulMover = _avatarSoul.GetComponentInChildren<SoulMover>();

            //Om det finns en soul ta bort audio listener och ljus på avatar
            AudioListener audioList = GetComponent<AudioListener>();
	        Light lightOnChar = GetComponentInChildren<Light>();

	        if (audioList != null)
	        {
	            audioList.enabled = false;
	        }
	        if (lightOnChar != null)
	        {
	            lightOnChar.enabled = false;
	        }
	    }

	    _soundEffectPlayer = GetComponentInChildren<SoundEffectPlayer>();
        
		AvatarStates avatarStates = new AvatarStates(gameObject);
		_stateMachine = avatarStates.GetStateMachine();
	}
Пример #28
0
 /// <summary>
 /// Creates a Levelitem from an external file.
 /// </summary>
 /// <param name="dev">Current Direct3D device.</param>
 /// <param name="filePath">location of the file to use.</param>
 /// <param name="position">Position to place the resulting model (worldspace).</param>
 /// <param name="rotation">Rotation to apply to the model.</param>
 public LevelItem(Device dev, string filePath, Vertex position, Rotation rotation, int index, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.index = index;
     COL = new COL
     {
         Model = new NJS_OBJECT
         {
             Position = position,
             Rotation = rotation
         }
     };
     ImportModel(filePath, dev);
     COL.CalculateBounds();
     Paste();
 }
Пример #29
0
        public FallingL(Point2D center, Rotation rotation, char symbol, ConsoleColor color)
        {
            this.Center = center;
            this.Rotation = rotation;
            this.relativeBody = new List<Pixel>();

            //Here should come the body definitions in relative to center coordinates for creating new shape!
            relativeBody.Add(new Pixel(0, -1, symbol, color));
            relativeBody.Add(new Pixel(0, 0, symbol, color));
            relativeBody.Add(new Pixel(0, 1, symbol, color));
            relativeBody.Add(new Pixel(1, 1, symbol, color));

            this.Body = new List<Pixel>();
            for(int i = 0; i < relativeBody.Count; i++) Body.Add(new Pixel(0,0,'@', ConsoleColor.Gray));
            this.ReCalculateBody();
        }
Пример #30
0
 public SETItem(byte[] file, int address, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     ushort _id = ByteConverter.ToUInt16(file, address);
     ID = _id;
     ClipLevel = (byte)(_id >> 12);
     ushort xrot = BitConverter.ToUInt16(file, address + 2);
     ushort yrot = BitConverter.ToUInt16(file, address + 4);
     ushort zrot = BitConverter.ToUInt16(file, address + 6);
     Rotation = new Rotation(xrot, yrot, zrot);
     Position = new Vertex(file, address + 8);
     Scale = new Vertex(file, address + 0x14);
     isLoaded = true;
     objdef = LevelData.ObjDefs[id];
     bounds = objdef.GetBounds(this);
 }
Пример #31
0
 public override void Turn(Rotation rotate)
 {
     PlayerTurn(this, rotate);
 }
Пример #32
0
        private void startTranscode()
        {
            Dictionary <String, Object> options = new Dictionary <string, object>();

            if (State.Width != null)
            {
                options.Add("Width", State.Width.Value);
            }

            if (State.Height != null)
            {
                options.Add("Height", State.Height.Value);
            }

            options.Add("QualityLevel", State.JpegQuality);
            options.Add("Rotation", Enum.Parse(typeof(Rotation), State.JpegRotationCollectionView.CurrentItem.ToString()));
            options.Add("Interlace", Enum.Parse(typeof(PngInterlaceOption), State.PngInterlacingCollectionView.CurrentItem.ToString()));
            options.Add("TiffCompression", Enum.Parse(typeof(TiffCompressOption), State.TiffCompressionCollectionView.CurrentItem.ToString()));
            options.Add("FlipHorizontal", State.FlipHorizontal);
            options.Add("FlipVertical", State.FlipVertical);

            TotalProgress    = 0;
            TotalProgressMax = State.Items.Count;

            foreach (MediaFileItem item in State.Items)
            {
                if (CancellationToken.IsCancellationRequested)
                {
                    return;
                }

                FileStream imageStream = null;

                item.EnterReadLock();
                try
                {
                    ItemProgress = 0;

                    if (MediaFormatConvert.isImageFile(item.Location))
                    {
                        String outputPath = State.OutputPath + "\\" + Path.GetFileNameWithoutExtension(item.Location) + "." + ((String)State.OutputFormatCollectionView.CurrentItem).ToLower();

                        outputPath = FileUtils.getUniqueFileName(outputPath);

                        ItemInfo = "Loading image: " + item.Location;

                        imageStream = File.Open(item.Location, FileMode.Open, FileAccess.Read);
                        Rotation rotation = ImageUtils.getBitmapRotation(imageStream);
                        imageStream.Position = 0;

                        BitmapImage loadedImage = new BitmapImage();

                        loadedImage.BeginInit();
                        loadedImage.CacheOption  = BitmapCacheOption.OnLoad;
                        loadedImage.StreamSource = imageStream;
                        loadedImage.Rotation     = rotation;
                        loadedImage.EndInit();

                        imageStream.Close();
                        imageStream = null;

                        ItemInfo = "Writing image: " + outputPath;

                        ImageTranscoder.writeImage(outputPath, loadedImage, options,
                                                   State.IsCopyMetadata ? item.Metadata as ImageMetadata : null, this);

                        InfoMessages.Add("Finished: " + item.Location + " -> " + outputPath);
                    }
                    else
                    {
                        InfoMessages.Add("Skipped: " + item.Location + " is not a image file");
                    }

                    TotalProgress++;
                    ItemProgress = 100;
                }
                catch (Exception e)
                {
                    InfoMessages.Add("Error: " + e.Message);
                    Logger.Log.Error("Error: " + e.Message);
                    return;
                }
                finally
                {
                    item.ExitReadLock();
                    if (imageStream != null)
                    {
                        imageStream.Close();
                    }
                }
            }
        }
Пример #33
0
 //只变化Y轴的角度
 public static UnityEngine.Quaternion ToRotation3D(this Rotation rot)
 {
     return(UnityEngine.Quaternion.Euler(0, -rot.Angle * 180 / Settings.Pi, 0));
 }
Пример #34
0
        public void HandleNuke(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null || Session.GetHabbo() == null || Item == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = null;

            User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Item.ExtraData == "")
                {
                    Item.ExtraData = "0";
                }

                if (Item.ExtraData == "0")
                {
                    int Minutes = RoleplayManager.NPACoolDown;

                    User.ClearMovement(true);
                    User.SetRot(Rotation.Calculate(User.Coordinate.X, User.Coordinate.Y, Item.GetX, Item.GetY), false);

                    // 135 Cycles approximately 1 minute
                    Item.ExtraData = "1";
                    Item.UpdateState(false, true);
                    Item.RequestUpdate(135 * Minutes, true);

                    // Start the nuking process.
                    object[] Params = { Session };
                    RoleplayManager.TimerManager.CreateTimer("nuking", 1000, false, Params);

                    Session.Shout("*Começa a invadir a máquina nuclear, comandando-a para explodir a cidade*", 4);

                    #region Notify all on-duty NPA associates

                    lock (PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
                    {
                        foreach (GameClient client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
                        {
                            if (client == null || client.GetHabbo() == null || client.GetRoleplay() == null)
                            {
                                continue;
                            }

                            if (!Groups.GroupManager.HasJobCommand(client, "npa") && !client.GetHabbo().GetPermissions().HasRight("corporation_rights"))
                            {
                                continue;
                            }

                            if (!client.GetRoleplay().IsWorking)
                            {
                                continue;
                            }

                            if (client.GetRoleplay().DisableRadio)
                            {
                                continue;
                            }

                            client.SendWhisper("[Alerta RÁDIO] [BOMBA NUCLEAR] Atenção! Alguém entrou na máquina nuclear, e ordenou que explodisse a cidade! Descubra quem é e interrompe-os rapidamente!", 30);
                        }
                    }

                    #endregion
                }
                else
                {
                    Session.SendWhisper("Opa, parece que alguém recentemente usou. Por favor, tente novamente mais tarde!", 1);
                }
            }
            else
            {
                if (User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                }
            }
        }
Пример #35
0
        internal override void OnUserSay(Rooms.RoomUser User, string Message)
        {
            RoomUser Pet = GetRoomUser();

            if (Pet.PetData.DBState != Pets.DatabaseUpdateState.NeedsInsert)
            {
                Pet.PetData.DBState = Pets.DatabaseUpdateState.NeedsUpdate;
            }


            if (Message.ToLower().Equals(Pet.PetData.Name.ToLower()))
            {
                Pet.SetRot(Rotation.Calculate(Pet.X, Pet.Y, User.X, User.Y), false);
                return;
            }

            if (Message.ToLower().StartsWith(Pet.PetData.Name.ToLower() + " ") && User.GetClient().GetHabbo().Username.ToLower() == GetRoomUser().PetData.OwnerName.ToLower())
            {
                string Command = Message.Substring(Pet.PetData.Name.ToLower().Length + 1);

                int r = ButterflyEnvironment.GetRandomNumber(1, 8); // Made Random

                if (Pet.PetData.Energy > 10 && r < 6 || Pet.PetData.Level > 15)
                {
                    RemovePetStatus(); // Remove Status

                    switch (PetCommandHandeler.TryInvoke(Command))
                    {
                        // TODO - Level you can use the commands at...

                        #region free
                    case 1:
                        RemovePetStatus();

                        //int randomX = ButterflyEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeX);
                        //int randomY = ButterflyEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeY);
                        Point nextCoord = GetRoom().GetGameMap().getRandomWalkableSquare();
                        Pet.MoveTo(nextCoord.X, nextCoord.Y);

                        Pet.PetData.AddExpirience(10);     // Give XP

                        break;
                        #endregion

                        #region here
                    case 2:

                        RemovePetStatus();

                        int NewX = User.X;
                        int NewY = User.Y;

                        ActionTimer = 30;     // Reset ActionTimer

                        #region Rotation
                        if (User.RotBody == 4)
                        {
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 0)
                        {
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 6)
                        {
                            NewX = User.X - 1;
                        }
                        else if (User.RotBody == 2)
                        {
                            NewX = User.X + 1;
                        }
                        else if (User.RotBody == 3)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 1)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 7)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 5)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y + 1;
                        }
                        #endregion

                        Pet.PetData.AddExpirience(10);     // Give XP

                        Pet.MoveTo(NewX, NewY);
                        break;
                        #endregion

                        #region sit
                    case 3:
                        // Remove Status
                        RemovePetStatus();

                        Pet.PetData.AddExpirience(10);     // Give XP

                        // Add Status
                        Pet.Statusses.Add("sit", TextHandling.GetString(Pet.Z));
                        ActionTimer = 25;
                        EnergyTimer = 10;
                        break;
                        #endregion

                        #region lay
                    case 4:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));

                        Pet.PetData.AddExpirience(10);     // Give XP

                        ActionTimer = 30;
                        EnergyTimer = 5;
                        break;
                        #endregion

                        #region dead
                    case 5:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("ded", TextHandling.GetString(Pet.Z));

                        Pet.PetData.AddExpirience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        SpeechTimer = 45;
                        ActionTimer = 30;

                        break;
                        #endregion

                        #region sleep
                    case 6:
                        // Remove Status
                        RemovePetStatus();

                        Pet.Chat(null, "ZzzZZZzzzzZzz", false);
                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));

                        Pet.PetData.AddExpirience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        EnergyTimer = 5;
                        SpeechTimer = 30;
                        ActionTimer = 45;
                        break;
                        #endregion

                        #region jump
                    case 7:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("jmp", TextHandling.GetString(Pet.Z));

                        Pet.PetData.AddExpirience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        EnergyTimer = 5;
                        SpeechTimer = 10;
                        ActionTimer = 5;
                        break;
                        #endregion

                    default:
                        string[] Speech = PetLocale.GetValue("pet.unknowncommand");

                        Random RandomSpeech = new Random();
                        Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);
                        break;
                    }
                    Pet.PetData.PetEnergy(false); // Remove Energy
                    Pet.PetData.PetEnergy(false); // Remove Energy
                }
                else
                {
                    RemovePetStatus(); // Remove Status

                    if (Pet.PetData.Energy < 10)
                    {
                        string[] Speech = PetLocale.GetValue("pet.tired");

                        Random RandomSpeech = new Random();
                        Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);

                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));

                        SpeechTimer = 50;
                        ActionTimer = 45;
                        EnergyTimer = 5;
                    }
                    else
                    {
                        string[] Speech = PetLocale.GetValue("pet.lazy");

                        Random RandomSpeech = new Random();
                        Pet.Chat(null, Speech[RandomSpeech.Next(0, Speech.Length - 1)], false);

                        Pet.PetData.PetEnergy(false); // Remove Energy
                    }
                }
            }
            //Pet = null;
        }
Пример #36
0
 public void SetLastTileRotation(Rotation rotation)
 {
     isLastTileRotationSet = true;
     lastTileRotation      = Quaternion.Euler(rotation.ToEulerAngles());
 }
Пример #37
0
        internal void OnCycle(ref int idleCount)
        {
            ToRemove.Clear();
            int userCounter = 0;

            foreach (RoomUnit unit in UnitList.Values)
            {
                unit.OnCycle();

                bool     updated = false;
                RoomUser user    = unit as RoomUser;
                if (room.GotFreeze() && user != null)
                {
                    room.GetFreeze().CycleUser(user);
                }

                if (unit.SetStep)
                {
                    if (room.GetGameMap().CanWalk(unit.SetX, unit.SetY, unit.AllowOverride))
                    {
                        room.GetGameMap().UpdateUnitMovement(new Point(unit.Coordinate.X, unit.Coordinate.Y), new Point(unit.SetX, unit.SetY), unit);
                        List <RoomItem> items = room.GetGameMap().GetCoordinatedItems(new Point(unit.X, unit.Y));

                        unit.X = unit.SetX;
                        unit.Y = unit.SetY;
                        unit.Z = unit.SetZ;

                        lock (items)
                        {
                            foreach (RoomItem item in items)
                            {
                                item.UserWalksOffFurni(unit);
                            }
                        }

                        if (user != null && unit.X == room.GetGameMap().Model.DoorX&& unit.Y == room.GetGameMap().Model.DoorY&& !ToRemove.Contains(unit))
                        {
                            ToRemove.Add(user);
                            continue;
                        }

                        UpdateUserStatus(unit, true);
                    }
                    unit.SetStep = false;
                }

                if (unit.IsWalking)
                {
                    // Find next square
                    GameMap     map   = room.GetGameMap();
                    SquarePoint Point = DreamPathfinder.GetNextStep(unit.X, unit.Y, unit.GoalX, unit.GoalY, map.Map, map.ItemHeightMap,
                                                                    map.Model.MapSizeX, map.Model.MapSizeY, unit.AllowOverride, map.DiagonalEnabled);

                    if (Point.X == unit.X && Point.Y == unit.Y) //No path found, or reached goal (:
                    {
                        unit.IsWalking = false;
                        unit.RemoveStatus("mv");

                        UpdateUserStatus(unit, false);
                    }
                    else
                    {
                        // Let's walk!
                        int nextX = Point.X;
                        int nextY = Point.Y;

                        //unit.RemoveStatus("mv");

                        double nextZ = room.GetGameMap().SqAbsoluteHeight(nextX, nextY);

                        unit.Statuses.Remove("lay");
                        unit.Statuses.Remove("sit");

                        unit.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ));

                        bool moonWalk = user == null ? false : user.moonwalkEnabled;

                        int newRot = Rotation.Calculate(unit.X, unit.Y, nextX, nextY, moonWalk);

                        unit.RotBody = newRot;
                        unit.RotHead = newRot;

                        unit.SetStep = true;
                        unit.SetX    = nextX;
                        unit.SetY    = nextY;
                        unit.SetZ    = nextZ;

                        updated = true;

                        room.GetGameMap().Map[unit.X, unit.Y] = unit.SqState;       // REstore the old one
                        unit.SqState = room.GetGameMap().Map[unit.SetX, unit.SetY]; //Backup the new one

                        if (user != null)
                        {
                            UpdateUserEffect(user, user.SetX, user.SetY);
                            if (user.IsSitting == true)
                            {
                                user.IsSitting = false;
                            }

                            if (user.IsLaying == true)
                            {
                                user.IsLaying = false;
                            }
                        }

                        if (!room.AllowWalkthrough)
                        {
                            room.GetGameMap().Map[nextX, nextY] = 0;
                        }
                    }
                    unit.UpdateNeeded = true;
                }
                else
                {
                    if (unit.Statuses.ContainsKey("mv"))
                    {
                        unit.Statuses.Remove("mv");
                        unit.UpdateNeeded = true;
                    }
                }

                if (user != null)
                {
                    userCounter++;
                }

                if (!updated && user != null)
                {
                    UpdateUserEffect(user, user.X, user.Y);
                }
            }

            if (userCounter == 0)
            {
                idleCount++;
            }


            foreach (RoomUser toRemove in ToRemove)
            {
                GameClient client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(toRemove.ID);
                if (client != null)
                {
                    RemoveUserFromRoom(client, true, false);
                    client.CurrentRoomUserID = -1;
                }
                else
                {
                    RemoveRoomUnit(toRemove);
                }
            }

            if (userCount != userCounter)
            {
                UpdateUserCount(userCounter);
            }
        }
Пример #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextFooter" /> class.
 /// </summary>
 /// <param name="Links">Link to the document.</param>
 /// <param name="Background">Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.</param>
 /// <param name="HorizontalAlignment">Gets or sets Horizontal alignment of stamp on the page. </param>
 /// <param name="Opacity">Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.</param>
 /// <param name="Rotate">Sets or gets the rotation of stamp content according Rotation values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property.  If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.</param>
 /// <param name="RotateAngle">Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle. </param>
 /// <param name="XIndent">Horizontal stamp coordinate, starting from the left.</param>
 /// <param name="YIndent">Vertical stamp coordinate, starting from the bottom.</param>
 /// <param name="Zoom">Zooming factor of the stamp. Allows to scale stamp.</param>
 /// <param name="TextAlignment">Alignment of the text inside the stamp.</param>
 /// <param name="Value">Gets or sets string value which is used as stamp on the page.</param>
 /// <param name="TextState">Gets text properties of the stamp. See TextState for details.</param>
 /// <param name="BottomMargin">Gets or sets bottom margin of stamp.</param>
 /// <param name="LeftMargin">Gets or sets left margin of stamp.</param>
 /// <param name="RightMargin">Gets or sets right margin of stamp.</param>
 public TextFooter(List <Link> Links = default(List <Link>), bool?Background = default(bool?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), double?Opacity = default(double?), Rotation Rotate = default(Rotation), double?RotateAngle = default(double?), double?XIndent = default(double?), double?YIndent = default(double?), double?Zoom = default(double?), HorizontalAlignment TextAlignment = default(HorizontalAlignment), string Value = default(string), TextState TextState = default(TextState), double?BottomMargin = default(double?), double?LeftMargin = default(double?), double?RightMargin = default(double?))
 {
     this.Links               = Links;
     this.Background          = Background;
     this.HorizontalAlignment = HorizontalAlignment;
     this.Opacity             = Opacity;
     this.Rotate              = Rotate;
     this.RotateAngle         = RotateAngle;
     this.XIndent             = XIndent;
     this.YIndent             = YIndent;
     this.Zoom          = Zoom;
     this.TextAlignment = TextAlignment;
     this.Value         = Value;
     this.TextState     = TextState;
     this.BottomMargin  = BottomMargin;
     this.LeftMargin    = LeftMargin;
     this.RightMargin   = RightMargin;
 }
Пример #39
0
 public void SetRotation(float roll, float pitch, float yaw)
 {
     Rotation = new Rotation(roll, pitch, yaw);
 }
Пример #40
0
    private void CreateRagdoll(float3 positionOffset, quaternion rotationOffset, int ragdollIndex = 1, bool internalCollisions = false)
    {
        var entities = new NativeList <Entity>(Allocator.Temp);

        // Head
        float  headRadius   = 0.1f;
        float3 headPosition = new float3(0, 1.8f, 0);
        Entity head;

        {
            CollisionFilter filter = internalCollisions ? layerFilter(layer.Head, layer.Torso) : groupFilter(-ragdollIndex);
            BlobAssetReference <Unity.Physics.Collider> collider = Unity.Physics.SphereCollider.Create(new SphereGeometry
            {
                Center = float3.zero,
                Radius = headRadius
            }, filter);
            head = CreateDynamicBody(headPosition, quaternion.identity, collider, float3.zero, float3.zero, 5.0f);
        }
        entities.Add(head);

        // Torso
        float3 torsoSize;
        float3 torsoPosition;
        Entity torso;

        {
            //UnityEngine.Mesh torsoMesh = (UnityEngine.Mesh)Resources.Load("torso", typeof(UnityEngine.Mesh));
            torsoSize     = torsoMesh.bounds.size;
            torsoPosition = headPosition - new float3(0, headRadius * 3.0f / 4.0f + torsoSize.y, 0);

            CollisionFilter filter = internalCollisions ? layerFilter(layer.Torso, layer.Thigh | layer.Head | layer.UpperArm | layer.Pelvis) : groupFilter(-ragdollIndex);

            NativeArray <float3> points = new NativeArray <float3>(torsoMesh.vertices.Length, Allocator.TempJob);
            for (int i = 0; i < torsoMesh.vertices.Length; i++)
            {
                points[i] = torsoMesh.vertices[i];
            }
            BlobAssetReference <Unity.Physics.Collider> collider = ConvexCollider.Create(
                points, ConvexHullGenerationParameters.Default, CollisionFilter.Default
                );
            points.Dispose();
            collider.Value.Filter = filter;
            torso = CreateDynamicBody(torsoPosition, quaternion.identity, collider, float3.zero, float3.zero, 20.0f);
        }
        entities.Add(torso);

        // Neck
        {
            float3 pivotHead             = new float3(0, -headRadius, 0);
            float3 pivotBody             = math.transform(math.inverse(GetBodyTransform(torso)), math.transform(GetBodyTransform(head), pivotHead));
            float3 axis                  = new float3(0, 1, 0);
            float3 perpendicular         = new float3(0, 0, 1);
            float  coneAngle             = (float)math.PI / 5.0f;
            float  minPerpendicularAngle = 0.0f;           // unlimited
            float  maxPerpendicularAngle = (float)math.PI; // unlimited
            float  twistAngle            = (float)math.PI / 3.0f;

            BlobAssetReference <JointData> ragdoll0, ragdoll1;
            JointData.CreateRagdoll(pivotHead, pivotBody, axis, axis, perpendicular, perpendicular,
                                    coneAngle, minPerpendicularAngle, maxPerpendicularAngle, -twistAngle, twistAngle,
                                    out ragdoll0, out ragdoll1);
            CreateJoint(ragdoll0, head, torso);
            CreateJoint(ragdoll1, head, torso);
        }

        // Arms
        {
            float           armLength      = 0.25f;
            float           armRadius      = 0.05f;
            CollisionFilter armUpperFilter = internalCollisions ? layerFilter(layer.UpperArm, layer.Torso | layer.Forearm) : groupFilter(-ragdollIndex);
            CollisionFilter armLowerFilter = internalCollisions ? layerFilter(layer.Forearm, layer.UpperArm | layer.Hand) : groupFilter(-ragdollIndex);

            BlobAssetReference <Unity.Physics.Collider> upperArmCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(-armLength / 2, 0, 0),
                Vertex1 = new float3(armLength / 2, 0, 0),
                Radius  = armRadius
            }, armUpperFilter);
            BlobAssetReference <Unity.Physics.Collider> foreArmCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(-armLength / 2, 0, 0),
                Vertex1 = new float3(armLength / 2, 0, 0),
                Radius  = armRadius
            }, armLowerFilter);

            float           handLength = 0.025f;
            float           handRadius = 0.055f;
            CollisionFilter handFilter = internalCollisions ? layerFilter(layer.Hand, layer.Forearm) : groupFilter(-ragdollIndex);

            BlobAssetReference <Unity.Physics.Collider> handCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(-handLength / 2, 0, 0),
                Vertex1 = new float3(handLength / 2, 0, 0),
                Radius  = handRadius
            }, handFilter);

            for (int i = 0; i < 2; i++)
            {
                float s = i * 2 - 1.0f;

                float3 upperArmPosition = torsoPosition + new float3(s * (torsoSize.x + armLength) / 2.0f, 0.9f * torsoSize.y - armRadius, 0.0f);
                Entity upperArm         = CreateDynamicBody(upperArmPosition, quaternion.identity, upperArmCollider, float3.zero, float3.zero, 10.0f);
                float3 foreArmPosition  = upperArmPosition + new float3(armLength * s, 0, 0);
                Entity foreArm          = CreateDynamicBody(foreArmPosition, quaternion.identity, foreArmCollider, float3.zero, float3.zero, 5.0f);
                float3 handPosition     = foreArmPosition + new float3((armLength + handLength) / 2.0f * s, 0, 0);
                Entity hand             = CreateDynamicBody(handPosition, quaternion.identity, handCollider, float3.zero, float3.zero, 2.0f);

                entities.Add(upperArm);
                entities.Add(foreArm);
                entities.Add(hand);

                // shoulder
                {
                    float3 pivotArm              = new float3(-s * armLength / 2.0f, 0, 0);
                    float3 pivotBody             = math.transform(math.inverse(GetBodyTransform(torso)), math.transform(GetBodyTransform(upperArm), pivotArm));
                    float3 axis                  = new float3(s, 0, 0);
                    float3 perpendicular         = new float3(0, 0, 1);
                    float  coneAngle             = (float)math.PI / 2.0f;
                    float  minPerpendicularAngle = 0.0f;
                    float  maxPerpendicularAngle = (float)math.PI / 2.0f;
                    float  twistAngle            = (float)math.PI / 4.0f;

                    BlobAssetReference <JointData> ragdoll0, ragdoll1;
                    JointData.CreateRagdoll(pivotArm, pivotBody, axis, axis, perpendicular, perpendicular,
                                            coneAngle, minPerpendicularAngle, maxPerpendicularAngle, -twistAngle, twistAngle,
                                            out ragdoll0, out ragdoll1);
                    CreateJoint(ragdoll0, upperArm, torso);
                    CreateJoint(ragdoll1, upperArm, torso);
                }

                // elbow
                {
                    float3 pivotUpper    = new float3(s * armLength / 2.0f, 0, 0);
                    float3 pivotFore     = -pivotUpper;
                    float3 axis          = new float3(0, -s, 0);
                    float3 perpendicular = new float3(s, 0, 0);
                    float  minAngle      = 0.0f;
                    float  maxAngle      = 3.0f;

                    BlobAssetReference <JointData> hinge = JointData.CreateLimitedHinge(pivotFore, pivotUpper, axis, axis, perpendicular, perpendicular, minAngle, maxAngle);
                    CreateJoint(hinge, foreArm, upperArm);
                }

                // wrist
                {
                    float3 pivotFore     = new float3(s * armLength / 2.0f, 0, 0);
                    float3 pivotHand     = new float3(-s * handLength / 2.0f, 0, 0);
                    float3 axis          = new float3(0, -s, 0);
                    float3 perpendicular = new float3(s, 0, 0);
                    float  minAngle      = -0.3f;
                    float  maxAngle      = 0.6f;

                    BlobAssetReference <JointData> hinge = JointData.CreateLimitedHinge(pivotHand, pivotFore, axis, axis, perpendicular, perpendicular, minAngle, maxAngle);
                    CreateJoint(hinge, hand, foreArm);
                }
            }
        }

        // Pelvis
        float  pelvisRadius   = 0.08f;
        float  pelvisLength   = 0.22f;
        float3 pelvisPosition = torsoPosition - new float3(0, pelvisRadius * 0.75f, 0.0f);
        Entity pelvis;

        {
            CollisionFilter filter = internalCollisions ? layerFilter(layer.Pelvis, layer.Torso | layer.Thigh) : groupFilter(-ragdollIndex);
            BlobAssetReference <Unity.Physics.Collider> collider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(-pelvisLength / 2, 0, 0),
                Vertex1 = new float3(pelvisLength / 2, 0, 0),
                Radius  = pelvisRadius
            }, filter);
            pelvis = CreateDynamicBody(pelvisPosition, quaternion.identity, collider, float3.zero, float3.zero, 15.0f);
        }
        entities.Add(pelvis);

        // Waist
        {
            float3 pivotTorso            = float3.zero;
            float3 pivotPelvis           = math.transform(math.inverse(GetBodyTransform(pelvis)), math.transform(GetBodyTransform(torso), pivotTorso));
            float3 axis                  = new float3(0, -1, 0);
            float3 perpendicular         = new float3(0, 0, 1);
            float  coneAngle             = 0.1f;
            float  minPerpendicularAngle = -0.1f;
            float  maxPerpendicularAngle = (float)math.PI;
            float  twistAngle            = 0.1f;

            BlobAssetReference <JointData> ragdoll0, ragdoll1;
            JointData.CreateRagdoll(pivotPelvis, pivotTorso, axis, axis, perpendicular, perpendicular,
                                    coneAngle, minPerpendicularAngle, maxPerpendicularAngle, -twistAngle, twistAngle,
                                    out ragdoll0, out ragdoll1);
            CreateJoint(ragdoll0, pelvis, torso);
            CreateJoint(ragdoll1, pelvis, torso);
        }

        // Legs
        {
            float           thighLength = 0.32f;
            float           thighRadius = 0.08f;
            CollisionFilter thighFilter = internalCollisions ? layerFilter(layer.Thigh, layer.Pelvis | layer.Calf) : groupFilter(-ragdollIndex);
            BlobAssetReference <Unity.Physics.Collider> thighCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(0, -thighLength / 2, 0),
                Vertex1 = new float3(0, thighLength / 2, 0),
                Radius  = thighRadius
            }, thighFilter);

            float           calfLength = 0.32f;
            float           calfRadius = 0.06f;
            CollisionFilter calfFilter = internalCollisions ? layerFilter(layer.Calf, layer.Thigh | layer.Foot) : groupFilter(-ragdollIndex);
            BlobAssetReference <Unity.Physics.Collider> calfCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(0, -calfLength / 2, 0),
                Vertex1 = new float3(0, calfLength / 2, 0),
                Radius  = calfRadius
            }, calfFilter);

            float           footLength = 0.08f;
            float           footRadius = 0.06f;
            CollisionFilter footFilter = internalCollisions ? layerFilter(layer.Foot, layer.Calf) : groupFilter(-ragdollIndex);
            BlobAssetReference <Unity.Physics.Collider> footCollider = Unity.Physics.CapsuleCollider.Create(new CapsuleGeometry
            {
                Vertex0 = new float3(0),
                Vertex1 = new float3(0, 0, footLength),
                Radius  = footRadius
            }, footFilter);

            for (int i = 0; i < 2; i++)
            {
                float s = i * 2 - 1.0f;

                float3 thighPosition = pelvisPosition + new float3(s * pelvisLength / 2.0f, -thighLength / 2.0f, 0.0f);
                Entity thigh         = CreateDynamicBody(thighPosition, quaternion.identity, thighCollider, float3.zero, float3.zero, 10.0f);
                float3 calfPosition  = thighPosition + new float3(0, -(thighLength + calfLength) / 2.0f, 0);
                Entity calf          = CreateDynamicBody(calfPosition, quaternion.identity, calfCollider, float3.zero, float3.zero, 5.0f);
                float3 footPosition  = calfPosition + new float3(0, -calfLength / 2.0f, 0);
                Entity foot          = CreateDynamicBody(footPosition, quaternion.identity, footCollider, float3.zero, float3.zero, 2.0f);

                entities.Add(thigh);
                entities.Add(calf);
                entities.Add(foot);

                // hip
                {
                    float3 pivotThigh            = new float3(0, thighLength / 2.0f, 0);
                    float3 pivotBody             = math.transform(math.inverse(GetBodyTransform(torso)), math.transform(GetBodyTransform(thigh), pivotThigh));
                    float3 axis                  = new float3(0, -1, 0);
                    float3 perpendicular         = new float3(s, 0, 0);
                    float  coneAngle             = (float)math.PI / 4.0f;
                    float  minPerpendicularAngle = 0.0f;
                    float  maxPerpendicularAngle = 0.2f + (float)math.PI / 2.0f;
                    float  twistAngle            = 0.2f;

                    BlobAssetReference <JointData> ragdoll0, ragdoll1;
                    JointData.CreateRagdoll(pivotThigh, pivotBody, axis, axis, perpendicular, perpendicular,
                                            coneAngle, minPerpendicularAngle, maxPerpendicularAngle, -twistAngle, twistAngle,
                                            out ragdoll0, out ragdoll1);
                    CreateJoint(ragdoll0, thigh, torso);
                    CreateJoint(ragdoll1, thigh, torso);
                }

                // knee
                {
                    float3 pivotThigh    = new float3(0, -thighLength / 2.0f, 0);
                    float3 pivotCalf     = math.transform(math.inverse(GetBodyTransform(calf)), math.transform(GetBodyTransform(thigh), pivotThigh));
                    float3 axis          = new float3(-1, 0, 0);
                    float3 perpendicular = new float3(0, 0, 1);
                    float  minAngle      = -1.2f;
                    float  maxAngle      = 0.0f;

                    BlobAssetReference <JointData> hinge = JointData.CreateLimitedHinge(pivotCalf, pivotThigh, axis, axis, perpendicular, perpendicular, minAngle, maxAngle);
                    CreateJoint(hinge, calf, thigh);
                }

                // ankle
                {
                    float3 pivotCalf     = new float3(0, -calfLength / 2.0f, 0);
                    float3 pivotFoot     = float3.zero;
                    float3 axis          = new float3(-1, 0, 0);
                    float3 perpendicular = new float3(0, 0, 1);
                    float  minAngle      = -0.4f;
                    float  maxAngle      = 0.1f;

                    BlobAssetReference <JointData> hinge = JointData.CreateLimitedHinge(pivotFoot, pivotCalf, axis, axis, perpendicular, perpendicular, minAngle, maxAngle);
                    CreateJoint(hinge, foot, calf);
                }
            }
        }

        // reposition with offset information
        if (entities.Length > 0)
        {
            float3 center = float3.zero;
            for (int i = 0; i < entities.Length; i++)
            {
                var e = entities[i];
                center += EntityManager.GetComponentData <Translation>(e).Value;
            }
            center /= entities.Length;
            for (int i = 0; i < entities.Length; i++)
            {
                var         e = entities[i];
                Translation positionComponent = EntityManager.GetComponentData <Translation>(e);
                Rotation    rotationComponent = EntityManager.GetComponentData <Rotation>(e);

                float3     position = positionComponent.Value;
                quaternion rotation = rotationComponent.Value;

                float3 localPosition = position - center;
                localPosition = math.rotate(rotationOffset, localPosition);

                position = localPosition + center + positionOffset;
                rotation = math.mul(rotation, rotationOffset);

                positionComponent.Value = position;
                rotationComponent.Value = rotation;

                EntityManager.SetComponentData <Translation>(e, positionComponent);
                EntityManager.SetComponentData <Rotation>(e, rotationComponent);
            }
        }
    }
Пример #41
0
 public static Ordinal Rotate(this Ordinal ordinal, Rotation rotation) => rotation switch
 {
Пример #42
0
    Entity CreateBoid(Vector3 pos, Quaternion q, int i, float size)
    {
        Entity boidEntity = entityManager.CreateEntity(boidArchitype);

        Position p = new Position();

        p.Value = pos;

        Rotation r = new Rotation();

        r.Value = q;

        entityManager.SetComponentData(boidEntity, p);
        entityManager.SetComponentData(boidEntity, r);

        Scale s = new Scale();

        s.Value = new Vector3(size * 0.5f, size, size);
        //s.Value = new Vector3(2, 4, 10);

        entityManager.SetComponentData(boidEntity, s);


        entityManager.SetComponentData(boidEntity, new Boid()
        {
            boidId = i, mass = 1, maxSpeed = 100, maxForce = 400, weight = 200
        });
        entityManager.SetComponentData(boidEntity, new Seperation());
        entityManager.SetComponentData(boidEntity, new Alignment());
        entityManager.SetComponentData(boidEntity, new Cohesion());
        entityManager.SetComponentData(boidEntity, new Constrain());
        entityManager.SetComponentData(boidEntity, new Flee());
        entityManager.SetComponentData(boidEntity, new Wander()
        {
            distance = 2
            , radius = 1.2f, jitter = 80, target = Random.insideUnitSphere * 1.2f
        });

        entityManager.AddSharedComponentData(boidEntity, bodyMesh);

        // Make the head
        Entity headEntity = entityManager.CreateEntity(headArchitype);

        Position headPosition = new Position();

        headPosition.Value = pos + (q * Vector3.forward) * size;
        entityManager.SetComponentData(headEntity, headPosition);
        Rotation headRotation = new Rotation();

        headRotation.Value = q;
        entityManager.SetComponentData(headEntity, headRotation);
        entityManager.AddSharedComponentData(headEntity, bodyMesh);
        entityManager.SetComponentData(headEntity, s);

        entityManager.SetComponentData(headEntity, new Head()
        {
            boidId = i
        });
        // End head

        // Make the tail
        Entity   tailEntity   = entityManager.CreateEntity(tailArchitype);
        Position tailPosition = new Position();

        tailPosition.Value = pos - (q * Vector3.forward) * size;
        entityManager.SetComponentData(tailEntity, tailPosition);
        Rotation tailRotation = new Rotation();

        tailRotation.Value = q;
        entityManager.SetComponentData(tailEntity, tailRotation);
        entityManager.AddSharedComponentData(tailEntity, bodyMesh);
        entityManager.SetComponentData(tailEntity, s);
        entityManager.SetComponentData(tailEntity, new Tail()
        {
            boidId = i
        });
        // End tail

        return(boidEntity);
    }
Пример #43
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (ShowLegend != null)
         {
             hashCode = hashCode * 59 + ShowLegend.GetHashCode();
         }
         if (LegendGroup != null)
         {
             hashCode = hashCode * 59 + LegendGroup.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (UId != null)
         {
             hashCode = hashCode * 59 + UId.GetHashCode();
         }
         if (Ids != null)
         {
             hashCode = hashCode * 59 + Ids.GetHashCode();
         }
         if (CustomData != null)
         {
             hashCode = hashCode * 59 + CustomData.GetHashCode();
         }
         if (Meta != null)
         {
             hashCode = hashCode * 59 + Meta.GetHashCode();
         }
         if (MetaArray != null)
         {
             hashCode = hashCode * 59 + MetaArray.GetHashCode();
         }
         if (HoverLabel != null)
         {
             hashCode = hashCode * 59 + HoverLabel.GetHashCode();
         }
         if (Stream != null)
         {
             hashCode = hashCode * 59 + Stream.GetHashCode();
         }
         if (Transforms != null)
         {
             hashCode = hashCode * 59 + Transforms.GetHashCode();
         }
         if (UiRevision != null)
         {
             hashCode = hashCode * 59 + UiRevision.GetHashCode();
         }
         if (Labels != null)
         {
             hashCode = hashCode * 59 + Labels.GetHashCode();
         }
         if (Label0 != null)
         {
             hashCode = hashCode * 59 + Label0.GetHashCode();
         }
         if (DLabel != null)
         {
             hashCode = hashCode * 59 + DLabel.GetHashCode();
         }
         if (Values != null)
         {
             hashCode = hashCode * 59 + Values.GetHashCode();
         }
         if (Marker != null)
         {
             hashCode = hashCode * 59 + Marker.GetHashCode();
         }
         if (Text != null)
         {
             hashCode = hashCode * 59 + Text.GetHashCode();
         }
         if (HoverText != null)
         {
             hashCode = hashCode * 59 + HoverText.GetHashCode();
         }
         if (HoverTextArray != null)
         {
             hashCode = hashCode * 59 + HoverTextArray.GetHashCode();
         }
         if (ScaleGroup != null)
         {
             hashCode = hashCode * 59 + ScaleGroup.GetHashCode();
         }
         if (TextInfo != null)
         {
             hashCode = hashCode * 59 + TextInfo.GetHashCode();
         }
         if (HoverInfo != null)
         {
             hashCode = hashCode * 59 + HoverInfo.GetHashCode();
         }
         if (HoverInfoArray != null)
         {
             hashCode = hashCode * 59 + HoverInfoArray.GetHashCode();
         }
         if (HoverTemplate != null)
         {
             hashCode = hashCode * 59 + HoverTemplate.GetHashCode();
         }
         if (HoverTemplateArray != null)
         {
             hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode();
         }
         if (TextTemplate != null)
         {
             hashCode = hashCode * 59 + TextTemplate.GetHashCode();
         }
         if (TextTemplateArray != null)
         {
             hashCode = hashCode * 59 + TextTemplateArray.GetHashCode();
         }
         if (TextPosition != null)
         {
             hashCode = hashCode * 59 + TextPosition.GetHashCode();
         }
         if (TextPositionArray != null)
         {
             hashCode = hashCode * 59 + TextPositionArray.GetHashCode();
         }
         if (TextFont != null)
         {
             hashCode = hashCode * 59 + TextFont.GetHashCode();
         }
         if (InsideTextOrientation != null)
         {
             hashCode = hashCode * 59 + InsideTextOrientation.GetHashCode();
         }
         if (InsideTextFont != null)
         {
             hashCode = hashCode * 59 + InsideTextFont.GetHashCode();
         }
         if (OutsideTextFont != null)
         {
             hashCode = hashCode * 59 + OutsideTextFont.GetHashCode();
         }
         if (AutoMargin != null)
         {
             hashCode = hashCode * 59 + AutoMargin.GetHashCode();
         }
         if (Title != null)
         {
             hashCode = hashCode * 59 + Title.GetHashCode();
         }
         if (Domain != null)
         {
             hashCode = hashCode * 59 + Domain.GetHashCode();
         }
         if (Hole != null)
         {
             hashCode = hashCode * 59 + Hole.GetHashCode();
         }
         if (Sort != null)
         {
             hashCode = hashCode * 59 + Sort.GetHashCode();
         }
         if (Direction != null)
         {
             hashCode = hashCode * 59 + Direction.GetHashCode();
         }
         if (Rotation != null)
         {
             hashCode = hashCode * 59 + Rotation.GetHashCode();
         }
         if (Pull != null)
         {
             hashCode = hashCode * 59 + Pull.GetHashCode();
         }
         if (PullArray != null)
         {
             hashCode = hashCode * 59 + PullArray.GetHashCode();
         }
         if (IdsSrc != null)
         {
             hashCode = hashCode * 59 + IdsSrc.GetHashCode();
         }
         if (CustomDataSrc != null)
         {
             hashCode = hashCode * 59 + CustomDataSrc.GetHashCode();
         }
         if (MetaSrc != null)
         {
             hashCode = hashCode * 59 + MetaSrc.GetHashCode();
         }
         if (LabelsSrc != null)
         {
             hashCode = hashCode * 59 + LabelsSrc.GetHashCode();
         }
         if (ValuesSrc != null)
         {
             hashCode = hashCode * 59 + ValuesSrc.GetHashCode();
         }
         if (TextSrc != null)
         {
             hashCode = hashCode * 59 + TextSrc.GetHashCode();
         }
         if (HoverTextSrc != null)
         {
             hashCode = hashCode * 59 + HoverTextSrc.GetHashCode();
         }
         if (HoverInfoSrc != null)
         {
             hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode();
         }
         if (HoverTemplateSrc != null)
         {
             hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode();
         }
         if (TextTemplateSrc != null)
         {
             hashCode = hashCode * 59 + TextTemplateSrc.GetHashCode();
         }
         if (TextPositionSrc != null)
         {
             hashCode = hashCode * 59 + TextPositionSrc.GetHashCode();
         }
         if (PullSrc != null)
         {
             hashCode = hashCode * 59 + PullSrc.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #44
0
        public override string ConvertToString(object value)
        {
            Rotation rotation = (Rotation)value;

            return(rotation.ToString());
        }
Пример #45
0
        private void updateLoop()
        {
            if (isBattleBall)
            {
                int   teamAmount       = Teams.Length;
                int[] teamScores       = new int[teamAmount];
                bool  subtrSecond      = false;
                int   activeTeamAmount = 0;
                for (int i = 0; i < teamAmount; i++)
                {
                    if (Teams[i].Count > 0)
                    {
                        activeTeamAmount++;
                    }
                    else
                    {
                        teamScores[i] = -1;
                    }
                }

                Random RND = new Random(DateTime.Now.Millisecond * teamAmount);

                while (leftTime > 0)
                {
                    int[]         Amounts      = new int[3]; // [0] = unit amount, [1] = updated tile amount, [2] = moving units amount
                    StringBuilder Players      = new StringBuilder();
                    StringBuilder updatedTiles = new StringBuilder();
                    StringBuilder Movements    = new StringBuilder();

                    for (int i = 0; i < teamAmount; i++)
                    {
                        foreach (gamePlayer Player in Teams[i])
                        {
                            Players.Append("H" + Encoding.encodeVL64(Player.roomUID) + Encoding.encodeVL64(Player.X) + Encoding.encodeVL64(Player.Y) + Encoding.encodeVL64(Player.H) + Encoding.encodeVL64(Player.Z) + "HM");
                            if (Player.bbColorTile)
                            {
                                Player.bbColorTile = false;
                                updatedTiles.Append(Encoding.encodeVL64(Player.X) + Encoding.encodeVL64(Player.Y) + Encoding.encodeVL64((int)bbTColor[Player.X, Player.Y]) + Encoding.encodeVL64((int)bbTState[Player.X, Player.Y]));
                                Amounts[1]++;
                            }
                            if (Player.goalX != -1)
                            {
                                Coord Next = gamePathfinder.getNextStep(Player.X, Player.Y, Player.goalX, Player.goalY);
                                if (Next.X != -1 && Blocked[Next.X, Next.Y] == false)
                                {
                                    Amounts[2]++;
                                    Movements.Append("J" + Encoding.encodeVL64(Player.roomUID) + Encoding.encodeVL64(Next.X) + Encoding.encodeVL64(Next.Y));
                                    if (Next.X == Player.goalX && Next.Y == Player.goalY)
                                    {
                                        Player.goalX = -1;
                                    }

                                    Blocked[Player.X, Player.Y] = false;
                                    Blocked[Next.X, Next.Y]     = true;
                                    Player.Z = Rotation.Calculate(Player.X, Player.Y, Next.X, Next.Y);

                                    Player.X = Next.X;
                                    Player.Y = Next.Y;
                                    Player.H = Height[Next.X, Next.Y];

                                    if (bbTState[Next.X, Next.Y] != bbTileState.Sealed)
                                    {
                                        if (bbTColor[Next.X, Next.Y] == (bbTileColor)Player.teamID) // Already property of this team, increment the state
                                        {
                                            bbTState[Next.X, Next.Y]++;
                                        }
                                        else
                                        {
                                            bbTState[Next.X, Next.Y] = bbTileState.Touched;
                                            bbTColor[Next.X, Next.Y] = (bbTileColor)Player.teamID;
                                        }

                                        int extraPoints = 0;
                                        switch ((int)bbTState[Next.X, Next.Y]) // Check the new status and calculate extra points
                                        {
                                        case 1:
                                            extraPoints = activeTeamAmount;
                                            break;

                                        case 2:
                                            extraPoints = activeTeamAmount * 3;
                                            break;

                                        case 3:
                                            extraPoints = activeTeamAmount * 5;
                                            break;

                                        case 4:
                                            extraPoints = activeTeamAmount * 7;
                                            break;
                                        }
                                        teamScores[Player.teamID] += extraPoints;
                                        Player.Score      += extraPoints;
                                        Player.bbColorTile = true;
                                    }
                                }
                                else
                                {
                                    Player.goalX = -1; // Stop moving
                                }
                            }
                            Amounts[0]++;
                        }
                    }

                    string scoreString = "H" + Encoding.encodeVL64(teamAmount);
                    for (int i = 0; i < teamAmount; i++)
                    {
                        scoreString += Encoding.encodeVL64(teamScores[i]);
                    }

                    sendData("Ct" + Encoding.encodeVL64(Amounts[0]) + Players.ToString() + Encoding.encodeVL64(Amounts[1]) + updatedTiles.ToString() + scoreString + "I" + Encoding.encodeVL64(Amounts[2]) + Movements.ToString());

                    if (subtrSecond)
                    {
                        leftTime--;
                    }
                    subtrSecond = (subtrSecond != true);
                    Thread.Sleep(470);
                }
                State = gameState.Ended;

                StringBuilder Scores = new StringBuilder("Cx" + Encoding.encodeVL64(Config.Game_scoreWindow_restartGame_Seconds) + Encoding.encodeVL64(teamAmount));

                for (int i = 0; i < teamAmount; i++)
                {
                    int memberAmount = Teams[i].Count;
                    if (memberAmount > 0)
                    {
                        Scores.Append(Encoding.encodeVL64(memberAmount));
                        using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                        {
                            foreach (gamePlayer Player in Teams[i])
                            {
                                Scores.Append(Encoding.encodeVL64(Player.roomUID));
                                if (Player.User != null)
                                {
                                    dbClient.runQuery("UPDATE users SET bb_playedgames = bb_playedgames + 1,bb_totalpoints = bb_totalpoints + " + Player.Score + " WHERE id = '" + Player.User.userID + "' LIMIT 1");

                                    Scores.Append(Player.User._Username + Convert.ToChar(2));
                                }
                                else
                                {
                                    Scores.Append("M");
                                }
                                Scores.Append(Encoding.encodeVL64(Player.Score));
                            }
                        }
                        Scores.Append(Encoding.encodeVL64(teamScores[i]));
                    }
                    else
                    {
                        Scores.Append("M");
                    }
                }
                sendData(Scores.ToString());
            }
        }
Пример #46
0
 public Transform()
 {
     Position = new Position();
     Rotation = new Rotation();
 }
Пример #47
0
 private bool VerifyPuck(RoomUser user, int actualx, int actualy)
 {
     return(Rotation.Calculate(user.X, user.Y, actualx, actualy) == user.RotBody);
 }
Пример #48
0
 public FVector              TransformPositionNoScale(FVector V)
 {
     DiagnosticCheckNaN_All();
     return(Rotation.RotateVector(V) + Translation);
 }
 public bool Equals(MixedRealityTransform other)
 {
     return(Position == other.Position &&
            Rotation.Equals(other.Rotation));
 }
Пример #50
0
 /** Inverts the matrix and then transforms V - correctly handles scaling in this matrix. */
 public FVector              InverseTransformPosition(FVector V)
 {
     DiagnosticCheckNaN_All();
     return((Rotation.UnrotateVector(V - Translation)) * GetSafeScaleReciprocal(Scale3D));
 }
Пример #51
0
        // Point-to-point constraint
        // Cdot = v2 - v1
        //      = v2 + cross(w2, r2) - v1 - cross(w1, r1)
        // J = [-I -r1_skew I r2_skew ]
        // Identity used:
        // w k % (rx i + ry j) = w * (-ry i + rx j)

        // Angle constraint
        // Cdot = w2 - w1
        // J = [0 0 -1 0 0 1]
        // K = invI1 + invI2

        /// <summary>Initializes the velocity constraints.</summary>
        /// <param name="step">The time step for this update.</param>
        /// <param name="positions">The positions of the related bodies.</param>
        /// <param name="velocities">The velocities of the related bodies.</param>
        internal override void InitializeVelocityConstraints(TimeStep step, Position[] positions, Velocity[] velocities)
        {
            _tmp.IndexA          = BodyA.IslandIndex;
            _tmp.IndexB          = BodyB.IslandIndex;
            _tmp.LocalCenterA    = BodyA.Sweep.LocalCenter;
            _tmp.LocalCenterB    = BodyB.Sweep.LocalCenter;
            _tmp.InverseMassA    = BodyA.InverseMass;
            _tmp.InverseMassB    = BodyB.InverseMass;
            _tmp.InverseInertiaA = BodyA.InverseInertia;
            _tmp.InverseInertiaB = BodyB.InverseInertia;

            var cA = positions[_tmp.IndexA].Point;
            var aA = positions[_tmp.IndexA].Angle;
            var vA = velocities[_tmp.IndexA].LinearVelocity;
            var wA = velocities[_tmp.IndexA].AngularVelocity;

            var cB = positions[_tmp.IndexB].Point;
            var aB = positions[_tmp.IndexB].Angle;
            var vB = velocities[_tmp.IndexB].LinearVelocity;
            var wB = velocities[_tmp.IndexB].AngularVelocity;

            var qA = new Rotation(aA);
            var qB = new Rotation(aB);

            // Compute the effective mass matrix.
            _tmp.RotA = qA * -_tmp.LocalCenterA;
            _tmp.RotB = qB * -_tmp.LocalCenterB;

            // J = [-I -r1_skew I r2_skew]
            //     [ 0       -1 0       1]
            // r_skew = [-ry; rx]

            // Matlab
            // K = [ mA+r1y^2*iA+mB+r2y^2*iB,  -r1y*iA*r1x-r2y*iB*r2x,          -r1y*iA-r2y*iB]
            //     [  -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB,           r1x*iA+r2x*iB]
            //     [          -r1y*iA-r2y*iB,           r1x*iA+r2x*iB,                   iA+iB]

            var mA = _tmp.InverseMassA;
            var mB = _tmp.InverseMassB;
            var iA = _tmp.InverseInertiaA;
            var iB = _tmp.InverseInertiaB;

            Matrix22 k;

            k.Column1.X = mA + mB + iA * _tmp.RotA.Y * _tmp.RotA.Y + iB * _tmp.RotB.Y * _tmp.RotB.Y;
            k.Column1.Y = -iA * _tmp.RotA.X * _tmp.RotA.Y - iB * _tmp.RotB.X * _tmp.RotB.Y;
            k.Column2.X = k.Column1.Y;
            k.Column2.Y = mA + mB + iA * _tmp.RotA.X * _tmp.RotA.X + iB * _tmp.RotB.X * _tmp.RotB.X;

            _tmp.LinearMass = k.GetInverse();

            _tmp.AngularMass = iA + iB;
            if (_tmp.AngularMass > 0.0f)
            {
                _tmp.AngularMass = 1.0f / _tmp.AngularMass;
            }

// ReSharper disable RedundantCast Necessary for FarPhysics.
            _tmp.LinearError = (Vector2)(cB - cA) + (_tmp.RotB - _tmp.RotA) - qA * _linearOffset;
// ReSharper restore RedundantCast
            _tmp.AngularError = aB - aA - _angularOffset;

            var p = new Vector2(_linearImpulse.X, _linearImpulse.Y);

            vA -= mA * p;
            wA -= iA * (Vector2Util.Cross(ref _tmp.RotA, ref p) + _angularImpulse);
            vB += mB * p;
            wB += iB * (Vector2Util.Cross(ref _tmp.RotB, ref p) + _angularImpulse);

            velocities[_tmp.IndexA].LinearVelocity  = vA;
            velocities[_tmp.IndexA].AngularVelocity = wA;
            velocities[_tmp.IndexB].LinearVelocity  = vB;
            velocities[_tmp.IndexB].AngularVelocity = wB;
        }
Пример #52
0
 public FVector              InverseTransformPositionNoScale(FVector V)
 {
     DiagnosticCheckNaN_All();
     return(Rotation.UnrotateVector(V - Translation));
 }
Пример #53
0
        public void HandleBreakDown(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null || Session.GetHabbo() == null || Item == null)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = null;

            User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Item.ExtraData == "")
                {
                    Item.ExtraData = "0";
                }

                if (Item.ExtraData == "0")
                {
                    int Minutes = RoleplayManager.NPACoolDown;

                    User.ClearMovement(true);
                    User.SetRot(Rotation.Calculate(User.Coordinate.X, User.Coordinate.Y, Item.GetX, Item.GetY), false);

                    // 135 Cycles approximately 1 minute
                    Item.ExtraData = "1";
                    Item.UpdateState(false, true);
                    Item.RequestUpdate(135 * Minutes, true);

                    // Start the nuking breakdown process.
                    object[] Params = { Session };
                    RoleplayManager.TimerManager.CreateTimer("nuking_bd", 1000, false, Params);

                    Session.Shout("*Começa a quebrar as portas do sistema NPA*", 4);
                }
                else
                {
                    Session.SendWhisper("Opa, parece que o interruptor foi usado recentemente. Por favor, tente novamente mais tarde!", 1);
                }
            }
            else
            {
                if (User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                }
            }
        }
Пример #54
0
 public FVector              TransformVector(FVector V)
 {
     DiagnosticCheckNaN_All();
     return(Rotation.RotateVector(Scale3D * V));
 }
Пример #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Stamp" /> class.
 /// </summary>
 /// <param name="Type">Gets the stamp type. (required).</param>
 /// <param name="Background">Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top..</param>
 /// <param name="BottomMargin">Gets or sets bottom margin of stamp..</param>
 /// <param name="HorizontalAlignment">Gets or sets Horizontal alignment of stamp on the page. .</param>
 /// <param name="LeftMargin">Gets or sets left margin of stamp..</param>
 /// <param name="Opacity">Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0..</param>
 /// <param name="RightMargin">Gets or sets right margin of stamp..</param>
 /// <param name="Rotate">Sets or gets the rotation of stamp content according Rotation values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property.  If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None..</param>
 /// <param name="RotateAngle">Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle. .</param>
 /// <param name="TopMargin">Gets or sets top margin of stamp..</param>
 /// <param name="VerticalAlignment">Gets or sets vertical alignment of stamp on page..</param>
 /// <param name="XIndent">Horizontal stamp coordinate, starting from the left..</param>
 /// <param name="YIndent">Vertical stamp coordinate, starting from the bottom..</param>
 /// <param name="Zoom">Zooming factor of the stamp. Allows to scale stamp..</param>
 /// <param name="TextAlignment">Alignment of the text inside the stamp..</param>
 /// <param name="Value">Gets or sets string value which is used as stamp on the page..</param>
 /// <param name="TextState">Gets text properties of the stamp. See TextState for details..</param>
 /// <param name="FileName">Gets or sets the file name..</param>
 /// <param name="Width">Gets or sets image width. Setting this property allos to scal image horizontally..</param>
 /// <param name="Height">Gets or sets image height. Setting this image allows to scale image vertically..</param>
 /// <param name="PageIndex">Gets or sets the index of the page..</param>
 /// <param name="StartingNumber">Gets or sets value of the number of starting page. Other pages will be numbered starting from this value..</param>
 public Stamp(StampType Type = default(StampType), bool?Background = default(bool?), double?BottomMargin = default(double?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), double?LeftMargin = default(double?), double?Opacity = default(double?), double?RightMargin = default(double?), Rotation Rotate = default(Rotation), double?RotateAngle = default(double?), double?TopMargin = default(double?), VerticalAlignment VerticalAlignment = default(VerticalAlignment), double?XIndent = default(double?), double?YIndent = default(double?), double?Zoom = default(double?), HorizontalAlignment TextAlignment = default(HorizontalAlignment), string Value = default(string), TextState TextState = default(TextState), string FileName = default(string), double?Width = default(double?), double?Height = default(double?), int?PageIndex = default(int?), int?StartingNumber = default(int?))
 {
     // to ensure "Type" is required (not null)
     if (Type == null)
     {
         throw new InvalidDataException("Type is a required property for Stamp and cannot be null");
     }
     else
     {
         this.Type = Type;
     }
     this.Background          = Background;
     this.BottomMargin        = BottomMargin;
     this.HorizontalAlignment = HorizontalAlignment;
     this.LeftMargin          = LeftMargin;
     this.Opacity             = Opacity;
     this.RightMargin         = RightMargin;
     this.Rotate            = Rotate;
     this.RotateAngle       = RotateAngle;
     this.TopMargin         = TopMargin;
     this.VerticalAlignment = VerticalAlignment;
     this.XIndent           = XIndent;
     this.YIndent           = YIndent;
     this.Zoom           = Zoom;
     this.TextAlignment  = TextAlignment;
     this.Value          = Value;
     this.TextState      = TextState;
     this.FileName       = FileName;
     this.Width          = Width;
     this.Height         = Height;
     this.PageIndex      = PageIndex;
     this.StartingNumber = StartingNumber;
 }
Пример #56
0
        private void DeserializeWorldOrientation(Coherence.Replication.Protocol.Definition.IInBitStream protocolStream)
        {
            var ignored = new Rotation();

            unityReaders.Read(ref ignored, protocolStream);
        }
Пример #57
0
 public int GetLength()
 {
     return(16 + Position.GetLength() + Rotation.GetLength() + Scale.GetLength() + 8 + Instances.Count * Constants.SIZE_UINT16);
 }
Пример #58
0
        public void Execute()
        {
            CameraData  camData        = CameraDataFromEntity[camEntity];
            Translation camTranslation = TranslationFromEntity[camEntity];
            Rotation    camRotation    = RotationFromEntity[camEntity];

            float3 up    = math.mul(camRotation.Value, new float3(0, 1, 0));
            float3 right = math.mul(camRotation.Value, new float3(1, 0, 0));

            float minX = default;
            float maxX = default;
            float minY = default;
            float maxY = default;

            for (int i = 0; i < focusables.Length; i++)
            {
                float3 xValue = MathUtilities.ProjectOnNormal(focusables[i].Value, right);
                float3 yValue = MathUtilities.ProjectOnNormal(focusables[i].Value, up);

                if (i == 0)
                {
                    minX = maxX = xValue.x;
                    minY = maxY = yValue.y;
                }
                else
                {
                    minX = math.min(minX, xValue.x);
                    maxX = math.max(maxX, xValue.x);
                    minY = math.min(minY, yValue.y);
                    maxY = math.max(maxY, yValue.y);
                }
            }


            float width  = maxX - minX;
            float height = maxY - minY;

            float cameraHeight = math.clamp((height + camData.cameraPadding), camData.cameraMinSize, camData.cameraMaxSize);
            float cameraWidth  = cameraHeight * camData.cameraAspectRatio;

            if (cameraWidth < width)
            {
                cameraHeight = math.clamp(((width + camData.cameraPadding) / (camData.cameraAspectRatio)), camData.cameraMinSize, camData.cameraMaxSize);
            }


            float3 min = focusables[0].Value;
            float3 max = focusables[0].Value;

            for (int i = 0; i < focusables.Length; i++)
            {
                var t = focusables[i].Value;
                min.x = math.min(t.x, min.x);
                min.y = math.min(t.y, min.y);
                min.z = math.min(t.z, min.z);
                max.x = math.max(t.x, max.x);
                max.y = math.max(t.y, max.y);
                max.z = math.max(t.z, max.z);
            }

            float3 resultingPosition = (min + max) / 2f;

            resultingPosition.y = 0;


            camTranslation.Value = math.lerp(camTranslation.Value, resultingPosition, camData.cameraSharpness * deltaTime);
            camData.cameraSize   = math.lerp(camData.cameraSize, cameraHeight, camData.cameraSharpness * deltaTime);

            TranslationFromEntity[camEntity] = camTranslation;
            RotationFromEntity[camEntity]    = camRotation;
            CameraDataFromEntity[camEntity]  = camData;
        }
Пример #59
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Pie other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                     ) &&
                 (
                     Visible == other.Visible ||
                     Visible != null &&
                     Visible.Equals(other.Visible)
                 ) &&
                 (
                     ShowLegend == other.ShowLegend ||
                     ShowLegend != null &&
                     ShowLegend.Equals(other.ShowLegend)
                 ) &&
                 (
                     LegendGroup == other.LegendGroup ||
                     LegendGroup != null &&
                     LegendGroup.Equals(other.LegendGroup)
                 ) &&
                 (
                     Opacity == other.Opacity ||
                     Opacity != null &&
                     Opacity.Equals(other.Opacity)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     UId == other.UId ||
                     UId != null &&
                     UId.Equals(other.UId)
                 ) &&
                 (
                     Equals(Ids, other.Ids) ||
                     Ids != null && other.Ids != null &&
                     Ids.SequenceEqual(other.Ids)
                 ) &&
                 (
                     Equals(CustomData, other.CustomData) ||
                     CustomData != null && other.CustomData != null &&
                     CustomData.SequenceEqual(other.CustomData)
                 ) &&
                 (
                     Meta == other.Meta ||
                     Meta != null &&
                     Meta.Equals(other.Meta)
                 ) &&
                 (
                     Equals(MetaArray, other.MetaArray) ||
                     MetaArray != null && other.MetaArray != null &&
                     MetaArray.SequenceEqual(other.MetaArray)
                 ) &&
                 (
                     HoverLabel == other.HoverLabel ||
                     HoverLabel != null &&
                     HoverLabel.Equals(other.HoverLabel)
                 ) &&
                 (
                     Stream == other.Stream ||
                     Stream != null &&
                     Stream.Equals(other.Stream)
                 ) &&
                 (
                     Equals(Transforms, other.Transforms) ||
                     Transforms != null && other.Transforms != null &&
                     Transforms.SequenceEqual(other.Transforms)
                 ) &&
                 (
                     UiRevision == other.UiRevision ||
                     UiRevision != null &&
                     UiRevision.Equals(other.UiRevision)
                 ) &&
                 (
                     Equals(Labels, other.Labels) ||
                     Labels != null && other.Labels != null &&
                     Labels.SequenceEqual(other.Labels)
                 ) &&
                 (
                     Label0 == other.Label0 ||
                     Label0 != null &&
                     Label0.Equals(other.Label0)
                 ) &&
                 (
                     DLabel == other.DLabel ||
                     DLabel != null &&
                     DLabel.Equals(other.DLabel)
                 ) &&
                 (
                     Equals(Values, other.Values) ||
                     Values != null && other.Values != null &&
                     Values.SequenceEqual(other.Values)
                 ) &&
                 (
                     Marker == other.Marker ||
                     Marker != null &&
                     Marker.Equals(other.Marker)
                 ) &&
                 (
                     Equals(Text, other.Text) ||
                     Text != null && other.Text != null &&
                     Text.SequenceEqual(other.Text)
                 ) &&
                 (
                     HoverText == other.HoverText ||
                     HoverText != null &&
                     HoverText.Equals(other.HoverText)
                 ) &&
                 (
                     Equals(HoverTextArray, other.HoverTextArray) ||
                     HoverTextArray != null && other.HoverTextArray != null &&
                     HoverTextArray.SequenceEqual(other.HoverTextArray)
                 ) &&
                 (
                     ScaleGroup == other.ScaleGroup ||
                     ScaleGroup != null &&
                     ScaleGroup.Equals(other.ScaleGroup)
                 ) &&
                 (
                     TextInfo == other.TextInfo ||
                     TextInfo != null &&
                     TextInfo.Equals(other.TextInfo)
                 ) &&
                 (
                     HoverInfo == other.HoverInfo ||
                     HoverInfo != null &&
                     HoverInfo.Equals(other.HoverInfo)
                 ) &&
                 (
                     Equals(HoverInfoArray, other.HoverInfoArray) ||
                     HoverInfoArray != null && other.HoverInfoArray != null &&
                     HoverInfoArray.SequenceEqual(other.HoverInfoArray)
                 ) &&
                 (
                     HoverTemplate == other.HoverTemplate ||
                     HoverTemplate != null &&
                     HoverTemplate.Equals(other.HoverTemplate)
                 ) &&
                 (
                     Equals(HoverTemplateArray, other.HoverTemplateArray) ||
                     HoverTemplateArray != null && other.HoverTemplateArray != null &&
                     HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)
                 ) &&
                 (
                     TextTemplate == other.TextTemplate ||
                     TextTemplate != null &&
                     TextTemplate.Equals(other.TextTemplate)
                 ) &&
                 (
                     Equals(TextTemplateArray, other.TextTemplateArray) ||
                     TextTemplateArray != null && other.TextTemplateArray != null &&
                     TextTemplateArray.SequenceEqual(other.TextTemplateArray)
                 ) &&
                 (
                     TextPosition == other.TextPosition ||
                     TextPosition != null &&
                     TextPosition.Equals(other.TextPosition)
                 ) &&
                 (
                     Equals(TextPositionArray, other.TextPositionArray) ||
                     TextPositionArray != null && other.TextPositionArray != null &&
                     TextPositionArray.SequenceEqual(other.TextPositionArray)
                 ) &&
                 (
                     TextFont == other.TextFont ||
                     TextFont != null &&
                     TextFont.Equals(other.TextFont)
                 ) &&
                 (
                     InsideTextOrientation == other.InsideTextOrientation ||
                     InsideTextOrientation != null &&
                     InsideTextOrientation.Equals(other.InsideTextOrientation)
                 ) &&
                 (
                     InsideTextFont == other.InsideTextFont ||
                     InsideTextFont != null &&
                     InsideTextFont.Equals(other.InsideTextFont)
                 ) &&
                 (
                     OutsideTextFont == other.OutsideTextFont ||
                     OutsideTextFont != null &&
                     OutsideTextFont.Equals(other.OutsideTextFont)
                 ) &&
                 (
                     AutoMargin == other.AutoMargin ||
                     AutoMargin != null &&
                     AutoMargin.Equals(other.AutoMargin)
                 ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     Domain == other.Domain ||
                     Domain != null &&
                     Domain.Equals(other.Domain)
                 ) &&
                 (
                     Hole == other.Hole ||
                     Hole != null &&
                     Hole.Equals(other.Hole)
                 ) &&
                 (
                     Sort == other.Sort ||
                     Sort != null &&
                     Sort.Equals(other.Sort)
                 ) &&
                 (
                     Direction == other.Direction ||
                     Direction != null &&
                     Direction.Equals(other.Direction)
                 ) &&
                 (
                     Rotation == other.Rotation ||
                     Rotation != null &&
                     Rotation.Equals(other.Rotation)
                 ) &&
                 (
                     Pull == other.Pull ||
                     Pull != null &&
                     Pull.Equals(other.Pull)
                 ) &&
                 (
                     Equals(PullArray, other.PullArray) ||
                     PullArray != null && other.PullArray != null &&
                     PullArray.SequenceEqual(other.PullArray)
                 ) &&
                 (
                     IdsSrc == other.IdsSrc ||
                     IdsSrc != null &&
                     IdsSrc.Equals(other.IdsSrc)
                 ) &&
                 (
                     CustomDataSrc == other.CustomDataSrc ||
                     CustomDataSrc != null &&
                     CustomDataSrc.Equals(other.CustomDataSrc)
                 ) &&
                 (
                     MetaSrc == other.MetaSrc ||
                     MetaSrc != null &&
                     MetaSrc.Equals(other.MetaSrc)
                 ) &&
                 (
                     LabelsSrc == other.LabelsSrc ||
                     LabelsSrc != null &&
                     LabelsSrc.Equals(other.LabelsSrc)
                 ) &&
                 (
                     ValuesSrc == other.ValuesSrc ||
                     ValuesSrc != null &&
                     ValuesSrc.Equals(other.ValuesSrc)
                 ) &&
                 (
                     TextSrc == other.TextSrc ||
                     TextSrc != null &&
                     TextSrc.Equals(other.TextSrc)
                 ) &&
                 (
                     HoverTextSrc == other.HoverTextSrc ||
                     HoverTextSrc != null &&
                     HoverTextSrc.Equals(other.HoverTextSrc)
                 ) &&
                 (
                     HoverInfoSrc == other.HoverInfoSrc ||
                     HoverInfoSrc != null &&
                     HoverInfoSrc.Equals(other.HoverInfoSrc)
                 ) &&
                 (
                     HoverTemplateSrc == other.HoverTemplateSrc ||
                     HoverTemplateSrc != null &&
                     HoverTemplateSrc.Equals(other.HoverTemplateSrc)
                 ) &&
                 (
                     TextTemplateSrc == other.TextTemplateSrc ||
                     TextTemplateSrc != null &&
                     TextTemplateSrc.Equals(other.TextTemplateSrc)
                 ) &&
                 (
                     TextPositionSrc == other.TextPositionSrc ||
                     TextPositionSrc != null &&
                     TextPositionSrc.Equals(other.TextPositionSrc)
                 ) &&
                 (
                     PullSrc == other.PullSrc ||
                     PullSrc != null &&
                     PullSrc.Equals(other.PullSrc)
                 ));
        }
Пример #60
0
 private Command(Rotation rotation)
 {
     _direction = null;
     _rotation  = rotation;
 }