protected override void Because_of() { Expression<Func<object, object>> ctor = (input) => new Dest((int)input); object o = ctor.Compile()(5); _dest = Mapper.Map<Source, Dest>(new Source { Foo = 5, Bar = 10 }); }
protected override void Because_of() { var source = new Source(); _destination = new Dest { Value1 = "Foo", Value2 = 10, Unmapped = "Asdf" }; Mapper.Map(source, _destination); }
protected override void Because_of() { var source = new OtherSource { Children = new Collection<Child> { new OtherChild(), new OtherChild() } }; _dest = Mapper.Map<Source, Dest>(source); }
// Konstruktor // Parametry - pozycja poczatkowa, predkosc public AI(Vector2 initPos, float initXVel) { // Ustawienie pozycji poczatkowej this._position = initPos; // Ustawienie koloru tla trasy this.reference = new Color(114, 114, 113, 255); // Ustawienie predkosci this._velocity = new Vector2(initXVel, 0f); // Ustawienie predkosci poczatkowej this._initialVelocity = initXVel; // Ustawienie kierunku jazdy this.destination = Dest.East; }
public void PropertiesCopierTesting() { Source source = new Source { PropA = "A", PropB = "B", PropC = "C", PropX = "X", PropY = "Y", PropZ = 1 }; Dest dest = new Dest(); // Укажем правильные свойства. PropertiesCopier.Copy(dest, source, new string[] { "A", "B" }); Assert.AreEqual("A", dest.PropA); Assert.AreEqual("B", dest.PropB); Assert.AreEqual(null, dest.PropD); Assert.AreEqual(null, dest.PropX); Assert.AreEqual(null, dest.PropY); Assert.AreEqual(null, dest.PropZ); }
public static void Export(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity==null) return; var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var sendThread = new Thread(() => { if ((type&Dest.Site)!=0 && NetworkController.Instance.BossLink.Any(x=>x.Value==entity&&x.Key.StartsWith("!"))) ToTeraDpsApi(stats.BaseStats, entity); if ((type&Dest.Excel)!=0) ExcelExport.ExcelSave(stats); }); sendThread.Start(); }
public NFe() { ide = new Ide(); emit = new Emit(); dest = new Dest(); avulsa = new Avulsa(); entrega = new Entrega(); autXML = new List<ConvertTxt.autXML>(); retirada = new Retirada(); det = new List<Det>(); Transp = new Transp(); Cobr = new Cobr(); InfAdic = new InfAdic(); cana = new Cana(); protNFe = new protNFe(); /// /// NFC-e pag = new List<pag>(); infNFe.Versao = (decimal)2.0; }
//Metoda odpowiedzialna za kolizję, obroty i sam wyścig public void Update(GameTime gameTime, Camera camera) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } //Odliczanie rozpoczęte if (clock.isRunning == false) { clock.start(3); //Gdy zegar odlicza porusznie zablokowane //Odpowiednie położenie mapy Matrix mapTransform = Matrix.CreateTranslation(new Vector3(backgroundPosition, 0.0f)); //Odpowiednie ustawienie pierwsego AI Matrix firstAiTransform = Matrix.CreateTranslation(new Vector3(-firstAiOrigin, 0.0f)) * Matrix.CreateRotationZ(firstAi.rotation) * Matrix.CreateTranslation(new Vector3(firstAi.position, 0.0f)); //Odpowiednie ustawienie drugiego AI Matrix secondAiTransform = Matrix.CreateTranslation(new Vector3(-secondAiOrigin, 0.0f)) * Matrix.CreateRotationZ(secondAi.rotation) * Matrix.CreateTranslation(new Vector3(secondAi.position, 0.0f)); //Odpowiednie ustawienie gracza Matrix playerTransform = Matrix.CreateTranslation(new Vector3(-playerOrigin, 0.0f)) * Matrix.CreateRotationZ(playerRotation) * Matrix.CreateTranslation(new Vector3(playerPosition, 0.0f)); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura playerRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, playerTexture.Width, playerTexture.Height), playerTransform); //Centralna część tekstury gracza playerOrigin = new Vector2(playerRectangle.Width / 2, playerRectangle.Height / 2); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura dla pierszego AI firstAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, firstAiTexture.Width, firstAiTexture.Height), firstAiTransform); //Centralna część tekstury pierwszego AI firstAiOrigin = new Vector2(firstAiRectangle.Width / 2, firstAiRectangle.Height / 2); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura dla drugiego AI secondAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, secondAiTexture.Width, secondAiTexture.Height), secondAiTransform); //Centralna część tekstury pierwszego AI secondAiOrigin = new Vector2(secondAiRectangle.Width / 2, secondAiRectangle.Height / 2); //Prostokąt dla mapy mapRectangle = new Rectangle((int)backgroundPosition.X, (int)backgroundPosition.Y, backgroundTexture.Width, backgroundTexture.Height); firstAi.CalculatePosition(backgroundTexture); secondAi.CalculatePosition(backgroundTexture); camera.Update(gameTime, playerPosition, playerRectangle); } else if (lap > maxlap || firstAi.lap > maxlap || secondAi.lap > maxlap) { ; // Nie robimy nic, gdy wyścig został wygrany } else if (clock.isFinished == true) { //Gdy zegar skończy odliczać start wyścigu //Cześć zmiennych jest taka sama jak powyżej ponieważ odpowiada tylko za przedstawienie mapy, gracza, AI podczas odliczania do rozpoczęcia // wyścigu Matrix mapTransform = Matrix.CreateTranslation(new Vector3(backgroundPosition, 0.0f)); Matrix firstAiTransform = Matrix.CreateTranslation(new Vector3(-firstAiOrigin, 0.0f)) * Matrix.CreateRotationZ(firstAi.rotation) * Matrix.CreateTranslation(new Vector3(firstAi.position, 0.0f)); Matrix secondAiTransform = Matrix.CreateTranslation(new Vector3(-secondAiOrigin, 0.0f)) * Matrix.CreateRotationZ(secondAi.rotation) * Matrix.CreateTranslation(new Vector3(secondAi.position, 0.0f)); Matrix playerTransform = Matrix.CreateTranslation(new Vector3(-playerOrigin, 0.0f)) * Matrix.CreateRotationZ(playerRotation) * Matrix.CreateTranslation(new Vector3(playerPosition, 0.0f)); playerRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, playerTexture.Width, playerTexture.Height), playerTransform); playerOrigin = new Vector2(playerRectangle.Width / 2, playerRectangle.Height / 2); firstAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, firstAiTexture.Width, firstAiTexture.Height), firstAiTransform); firstAiOrigin = new Vector2(firstAiRectangle.Width / 2, firstAiRectangle.Height / 2); secondAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, secondAiTexture.Width, secondAiTexture.Height), secondAiTransform); secondAiOrigin = new Vector2(secondAiRectangle.Width / 2, secondAiRectangle.Height / 2); mapRectangle = new Rectangle((int)backgroundPosition.X, (int)backgroundPosition.Y, backgroundTexture.Width, backgroundTexture.Height); //Dalsza część //Poruszanie do przodu uwzględniając rotację if (this.playerCollision) { if (playerVelocity.X > -0.5 && playerVelocity.X < 0.5 && playerVelocity.Y > -0.5 && playerVelocity.Y < 0.5) { this.playerCollision = false; } else { playerVelocity *= 1 - friction; } } else if (Keyboard.GetState().IsKeyDown(Keys.Up)) { //Obroty samochodu if (Keyboard.GetState().IsKeyDown(Keys.Right)) { playerRotation += 0.05f; } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { playerRotation -= 0.05f; } playerVelocity.X = (float)Math.Cos(playerRotation) * playerTangentialVelocity; playerVelocity.Y = (float)Math.Sin(playerRotation) * playerTangentialVelocity; } else if (playerVelocity != Vector2.Zero) { playerVelocity *= 1 - friction; } // Kolizja z przeciwnikiem za pomocą metody Per Piksel Collision if (firstAiRectangle.Intersects(playerRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(firstAiTransform, firstAiTexture.Width, firstAiTexture.Height, firstAiTextureData, playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData)) { //Odbicie od przeciwnika po współrzędnej X i Y pod odpowiednim kątem playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } } if (secondAiRectangle.Intersects(playerRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(secondAiTransform, secondAiTexture.Width, secondAiTexture.Height, secondAiTextureData, playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData)) { //Odbicie od przeciwnika po współrzędnej X i Y pod odpowiednim kątem playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } } //Kolizja przeciwnika pierwszego z autem gracza if (playerRectangle.Intersects(firstAiRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, firstAiTransform, firstAiTexture.Width, firstAiTexture.Height, firstAiTextureData)) { //Wykrywanie kierunku w jakim porusza się gracz i wzależności od tego odbicie od drugiego pojazdu po odpowiedniej współrzędnej if (playerDestination == Dest.East) { //Jak jedziemy w kierunku wchodnim zmiana następuje po współrzędnej X float tmp = (playerVelocity.X + (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.South) { //Jak jedziemy w kierunku południowym zmiana nastepuje po współrzędnej Y float tmp = (playerVelocity.Y - (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } if (playerDestination == Dest.West) { //Jak jedziemy w kierunku zachodnim zmiana nastepuje po współrzędnej X float tmp = (playerVelocity.X - (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.North) { //Jak jedziemy w kierunku północnym zmiana nastepuje w po współrzędnej Y float tmp = (playerVelocity.Y + (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } } } //Kolizja przeciwnika drugiego z autem gracza if (playerRectangle.Intersects(secondAiRectangle)) { //Jeśli kolizja jest wykryta if (Collisions.IntersectPixels(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, secondAiTransform, secondAiTexture.Width, secondAiTexture.Height, secondAiTextureData)) { //Wykrywanie kierunku w jakim porusza się gracz i wzależności od tego odbicie od drugiego pojazdu po odpowiedniej współrzędnej if (playerDestination == Dest.East) { //Jak jedziemy w kierunku wchodnim zmiana następuje po współrzędnej X float tmp = (playerVelocity.X + (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.South) { //Jak jedziemy w kierunku południowym zmiana nastepuje po współrzędnej Y float tmp = (playerVelocity.Y - (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } if (playerDestination == Dest.West) { //Jak jedziemy w kierunku zachodnim zmiana nastepuje po współrzędnej X float tmp = (playerVelocity.X - (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.North) { //Jak jedziemy w kierunku północnym zmiana nastepuje w po współrzędnej Y float tmp = (playerVelocity.Y + (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } } } //Kolizja auta gracza z bandami if (Collisions.Intersect(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, mapTransform, backgroundTexture.Width, backgroundTexture.Height, mapTextureData)) { //Odbicie pod odpowiednim kątem po współrzędnych X i Y playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } //Wykrywanie kierunku poruszania sięsamochodu float round = (float)Math.Round(playerRotation, 4); float sround = (float)(Math.Round(Math.Sin(round), 4)); float cround = (float)(Math.Round(Math.Cos(round), 4)); if ((sround >= 0.5 && sround <= 1) && (cround >= -0.5 && cround <= 0.5)) { playerDestination = Dest.South; } else if ((sround <= -0.5 && sround >= -1) && (cround >= -0.5 && cround <= 0.5)) { playerDestination = Dest.North; } else if ((sround >= -0.5 && sround <= 0.5) && (cround >= 0.5 && cround <= 1)) { playerDestination = Dest.East; } else if ((sround >= -0.5 && sround <= 0.5) && (cround <= -0.5 && cround >= -1)) { playerDestination = Dest.West; } playerPosition = (playerVelocity + playerPosition); Color[] c = new Color[1]; backgroundTexture.GetData(0, new Rectangle((int)playerPosition.X + 400, (int)playerPosition.Y, 1, 1), c, 0, c.Length); Color black = new Color(43, 42, 41); Color white = new Color(254, 254, 254); if (c[0] == black || c[0] == white) { lapChange = true; } else { if (lapChange && (DateTime.Now.Subtract(lastLapChange) > TimeSpan.FromSeconds(1))) { lastLapChange = DateTime.Now; lap++; } lapChange = false; } firstAi.CalculatePosition(backgroundTexture); secondAi.CalculatePosition(backgroundTexture); camera.Update(gameTime, playerPosition, playerRectangle); } else { clock.checkTime(gameTime); } base.Update(gameTime); }
//Metoda odpowiedzialna za kolizję, obroty i sam wyścig public void Update(GameTime gameTime, Camera camera) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } //Odliczanie rozpoczęte if (clock.isRunning == false) { clock.start(3); //Gdy zegar odlicza porusznie zablokowane //Odpowiednie położenie mapy Matrix mapTransform = Matrix.CreateTranslation(new Vector3(backgroundPosition, 0.0f)); //Odpowiednie ustawienie pierwsego AI Matrix firstAiTransform = Matrix.CreateTranslation(new Vector3(-firstAiOrigin, 0.0f)) * Matrix.CreateRotationZ(firstAi.rotation) * Matrix.CreateTranslation(new Vector3(firstAi.position, 0.0f)); //Odpowiednie ustawienie drugiego AI Matrix secondAiTransform = Matrix.CreateTranslation(new Vector3(-secondAiOrigin, 0.0f)) * Matrix.CreateRotationZ(secondAi.rotation) * Matrix.CreateTranslation(new Vector3(secondAi.position, 0.0f)); //Odpowiednie ustawienie gracza Matrix playerTransform = Matrix.CreateTranslation(new Vector3(-playerOrigin, 0.0f)) * Matrix.CreateRotationZ(playerRotation) * Matrix.CreateTranslation(new Vector3(playerPosition, 0.0f)); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura playerRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, playerTexture.Width, playerTexture.Height), playerTransform); //Centralna część tekstury gracza playerOrigin = new Vector2(playerRectangle.Width / 2, playerRectangle.Height / 2); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura dla pierszego AI firstAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, firstAiTexture.Width, firstAiTexture.Height), firstAiTransform); //Centralna część tekstury pierwszego AI firstAiOrigin = new Vector2(firstAiRectangle.Width / 2, firstAiRectangle.Height / 2); //Wyliczenie odpowiednie położenie prostokąta w którym jest umieszczona tekstura dla drugiego AI secondAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, secondAiTexture.Width, secondAiTexture.Height), secondAiTransform); //Centralna część tekstury pierwszego AI secondAiOrigin = new Vector2(secondAiRectangle.Width / 2, secondAiRectangle.Height / 2); //Prostokąt dla mapy mapRectangle = new Rectangle((int)backgroundPosition.X, (int)backgroundPosition.Y, backgroundTexture.Width, backgroundTexture.Height); firstAi.CalculatePosition(backgroundTexture); secondAi.CalculatePosition(backgroundTexture); camera.Update(gameTime, playerPosition, playerRectangle); } else if (lap > maxlap || firstAi.lap > maxlap || secondAi.lap > maxlap) { ; // Nie robimy nic, gdy wyścig został wygrany } else if (clock.isFinished == true) { //Gdy zegar skończy odliczać start wyścigu //Cześć zmiennych jest taka sama jak powyżej ponieważ odpowiada tylko za przedstawienie mapy, gracza, AI podczas odliczania do rozpoczęcia // wyścigu Matrix mapTransform = Matrix.CreateTranslation(new Vector3(backgroundPosition, 0.0f)); Matrix firstAiTransform = Matrix.CreateTranslation(new Vector3(-firstAiOrigin, 0.0f)) * Matrix.CreateRotationZ(firstAi.rotation) * Matrix.CreateTranslation(new Vector3(firstAi.position, 0.0f)); Matrix secondAiTransform = Matrix.CreateTranslation(new Vector3(-secondAiOrigin, 0.0f)) * Matrix.CreateRotationZ(secondAi.rotation) * Matrix.CreateTranslation(new Vector3(secondAi.position, 0.0f)); Matrix playerTransform = Matrix.CreateTranslation(new Vector3(-playerOrigin, 0.0f)) * Matrix.CreateRotationZ(playerRotation) * Matrix.CreateTranslation(new Vector3(playerPosition, 0.0f)); playerRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, playerTexture.Width, playerTexture.Height), playerTransform); playerOrigin = new Vector2(playerRectangle.Width / 2, playerRectangle.Height / 2); firstAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, firstAiTexture.Width, firstAiTexture.Height), firstAiTransform); firstAiOrigin = new Vector2(firstAiRectangle.Width / 2, firstAiRectangle.Height / 2); secondAiRectangle = Collisions.CalculateBoundingRectangle(new Rectangle(0, 0, secondAiTexture.Width, secondAiTexture.Height), secondAiTransform); secondAiOrigin = new Vector2(secondAiRectangle.Width / 2, secondAiRectangle.Height / 2); mapRectangle = new Rectangle((int)backgroundPosition.X, (int)backgroundPosition.Y, backgroundTexture.Width, backgroundTexture.Height); //Dalsza część //Poruszanie do przodu uwzględniając rotację if (this.playerCollision) { if (playerVelocity.X > -0.5 && playerVelocity.X < 0.5 && playerVelocity.Y > -0.5 && playerVelocity.Y < 0.5) { this.playerCollision = false; } else { playerVelocity *= 1 - friction; } } else if (Keyboard.GetState().IsKeyDown(Keys.Up)) { //Obroty samochodu if (Keyboard.GetState().IsKeyDown(Keys.Right)) playerRotation += 0.05f; if (Keyboard.GetState().IsKeyDown(Keys.Left)) playerRotation -= 0.05f; playerVelocity.X = (float)Math.Cos(playerRotation) * playerTangentialVelocity; playerVelocity.Y = (float)Math.Sin(playerRotation) * playerTangentialVelocity; } else if (playerVelocity != Vector2.Zero) { playerVelocity *= 1 - friction; } // Kolizja z przeciwnikiem za pomocą metody Per Piksel Collision if (firstAiRectangle.Intersects(playerRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(firstAiTransform, firstAiTexture.Width, firstAiTexture.Height, firstAiTextureData, playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData)) { //Odbicie od przeciwnika po współrzędnej X i Y pod odpowiednim kątem playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } } if (secondAiRectangle.Intersects(playerRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(secondAiTransform, secondAiTexture.Width, secondAiTexture.Height, secondAiTextureData, playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData)) { //Odbicie od przeciwnika po współrzędnej X i Y pod odpowiednim kątem playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } } //Kolizja przeciwnika pierwszego z autem gracza if (playerRectangle.Intersects(firstAiRectangle)) { //Jeśli zaszła kolizja if (Collisions.IntersectPixels(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, firstAiTransform, firstAiTexture.Width, firstAiTexture.Height, firstAiTextureData)) { //Wykrywanie kierunku w jakim porusza się gracz i wzależności od tego odbicie od drugiego pojazdu po odpowiedniej współrzędnej if (playerDestination == Dest.East) { //Jak jedziemy w kierunku wchodnim zmiana następuje po współrzędnej X float tmp = (playerVelocity.X + (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.South) { //Jak jedziemy w kierunku południowym zmiana nastepuje po współrzędnej Y float tmp = (playerVelocity.Y - (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } if (playerDestination == Dest.West) { //Jak jedziemy w kierunku zachodnim zmiana nastepuje po współrzędnej X float tmp = (playerVelocity.X - (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.North) { //Jak jedziemy w kierunku północnym zmiana nastepuje w po współrzędnej Y float tmp = (playerVelocity.Y + (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } } } //Kolizja przeciwnika drugiego z autem gracza if (playerRectangle.Intersects(secondAiRectangle)) { //Jeśli kolizja jest wykryta if (Collisions.IntersectPixels(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, secondAiTransform, secondAiTexture.Width, secondAiTexture.Height, secondAiTextureData)) { //Wykrywanie kierunku w jakim porusza się gracz i wzależności od tego odbicie od drugiego pojazdu po odpowiedniej współrzędnej if (playerDestination == Dest.East) { //Jak jedziemy w kierunku wchodnim zmiana następuje po współrzędnej X float tmp = (playerVelocity.X + (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.South) { //Jak jedziemy w kierunku południowym zmiana nastepuje po współrzędnej Y float tmp = (playerVelocity.Y - (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } if (playerDestination == Dest.West) { //Jak jedziemy w kierunku zachodnim zmiana nastepuje po współrzędnej X float tmp = (playerVelocity.X - (float)1); playerVelocity.X = (playerVelocity.X + tmp); this.playerCollision = true; } if (playerDestination == Dest.North) { //Jak jedziemy w kierunku północnym zmiana nastepuje w po współrzędnej Y float tmp = (playerVelocity.Y + (float)1); playerVelocity.Y = (playerVelocity.Y + tmp); this.playerCollision = true; } } } //Kolizja auta gracza z bandami if (Collisions.Intersect(playerTransform, playerTexture.Width, playerTexture.Height, playerTextureData, mapTransform, backgroundTexture.Width, backgroundTexture.Height, mapTextureData)) { //Odbicie pod odpowiednim kątem po współrzędnych X i Y playerVelocity.X = -playerVelocity.X; playerVelocity.Y = -playerVelocity.Y; this.playerCollision = true; } //Wykrywanie kierunku poruszania sięsamochodu float round = (float)Math.Round(playerRotation, 4); float sround = (float)(Math.Round(Math.Sin(round), 4)); float cround = (float)(Math.Round(Math.Cos(round), 4)); if ((sround >= 0.5 && sround <= 1) && (cround >= -0.5 && cround <= 0.5)) { playerDestination = Dest.South; } else if ((sround <= -0.5 && sround >= -1) && (cround >= -0.5 && cround <= 0.5)) { playerDestination = Dest.North; } else if ((sround >= -0.5 && sround <= 0.5) && (cround >= 0.5 && cround <= 1)) { playerDestination = Dest.East; } else if ((sround >= -0.5 && sround <= 0.5) && (cround <= -0.5 && cround >= -1)) { playerDestination = Dest.West; } playerPosition = (playerVelocity + playerPosition); Color[] c = new Color[1]; backgroundTexture.GetData(0, new Rectangle((int)playerPosition.X + 400, (int)playerPosition.Y, 1, 1), c, 0, c.Length); Color black = new Color(43, 42, 41); Color white = new Color(254, 254, 254); if (c[0] == black || c[0] == white) { lapChange = true; } else { if (lapChange && (DateTime.Now.Subtract(lastLapChange) > TimeSpan.FromSeconds(1))) { lastLapChange = DateTime.Now; lap++; } lapChange = false; } firstAi.CalculatePosition(backgroundTexture); secondAi.CalculatePosition(backgroundTexture); camera.Update(gameTime, playerPosition, playerRectangle); } else { clock.checkTime(gameTime); } base.Update(gameTime); }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && NetworkController.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!0"))) { ToTeraDpsApi(stats.BaseStats, entity); } if (type.HasFlag(Dest.Site) && NetworkController.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!") && !x.Key.StartsWith("!0"))) { ToPrivateServer(stats.BaseStats, entity, NetworkController.Instance.BossLink.Where(x => x.Value == entity && x.Key.StartsWith("!") && !x.Key.StartsWith("!0")) .Select(x => int.Parse(x.Key.Substring(1, x.Key.IndexOf(" ", StringComparison.Ordinal) - 1))).ToList()); } if (type.HasFlag(Dest.Excel)) { ExcelExport.ExcelSave(stats, stats.BaseStats.members.Select(x => x.playerName) .FirstOrDefault(x => NetworkController.Instance.MeterPlayers.Select(z => z.Name).Contains(x)), type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
public int StageFiles(StagedFileType FileType, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true) { int FilesAdded = 0; // make sure any ..'s are removed Utils.CollapseRelativeDirectories(ref InPath); if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bAllowNotForLicenseesFiles && (FileToCopy.Contains("NotForLicensees") || FileToCopy.Contains("NoRedist"))) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't deploy {0}; it was supposed to start with {1}", FileToCopy, InPath); } string FileToRemap = FileToCopy; // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToRemap.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); #if false // if the cooker rebases, I don't think we need to ever rebase while staging to a new path if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } // project relative stuff in a collapsed sandbox if (Dest.StartsWith(SourceRelativeProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = Dest.Substring(SourceRelativeProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } #endif } // project relative file else if (FileToRemap.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = FileToRemap.Substring(ProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } // engine relative file else if (FileToRemap.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = CommandUtils.CombinePaths(FileToRemap.Substring(LocalRoot.Length)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", FileToRemap, ProjectRoot, LocalRoot); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (NewName != null) { Dest = CommandUtils.CombinePaths(Path.GetDirectoryName(Dest), NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.NonUFS) { AddUniqueStagingFile(NonUFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.DebugNonUFS) { AddUniqueStagingFile(NonUFSStagingFilesDebug, FileToCopy, Dest); } FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { AutomationTool.ErrorReporter.Error(String.Format("No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard), (int)AutomationTool.ErrorCodes.Error_StageMissingFile); throw new AutomationException("No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard); } return(FilesAdded); }
protected override void Because_of() { _dest = Mapper.Map <Source, Dest>(new Source { Foo = 5, Bar = 10 }); }
public void Should_not_map_value_when_not_null() { var destination = new Dest { Value = 6}; Mapper.Map(new Source {Value = 5}, destination); destination.Value.ShouldEqual(6); }
public override byte[] GetBytes() { return(Dest.GetBytes()); }
public override void Write(byte data) { Dest.Write(SessionCryptoService.ReturnByte(data)); }
public override void Write(byte[] data, int offset, int count) { Dest.Write(SessionCryptoService.ProcessBytes(data, offset, count), offset, count); }
public override void Write(byte[] data) { Dest.Write(SessionCryptoService.ProcessBytes(data, 0)); }
private bool InternalExecute() { AddOutputMessage($"Operation {Title} started"); StartTime = DateTime.UtcNow; OperationStatus = FileOperationStatus.InProgress; if (!(Source is MediaBase source)) { return(false); } switch (Kind) { case TFileOperationKind.None: return(true); case TFileOperationKind.Ingest: case TFileOperationKind.Export: throw new InvalidOperationException("Invalid operation kind"); case TFileOperationKind.Copy: if (!File.Exists(source.FullPath) || !Directory.Exists(DestDirectory.Folder)) { return(false); } try { lock (_destMediaLock) { CreateDestMediaIfNotExists(); if (!(Dest.FileExists() && File.GetLastWriteTimeUtc(source.FullPath).Equals(File.GetLastWriteTimeUtc(Dest.FullPath)) && File.GetCreationTimeUtc(source.FullPath).Equals(File.GetCreationTimeUtc(Dest.FullPath)) && Source.FileSize.Equals(Dest.FileSize))) { Dest.MediaStatus = TMediaStatus.Copying; IsIndeterminate = true; if (!source.CopyMediaTo(Dest, ref Aborted)) { return(false); } } Dest.MediaStatus = TMediaStatus.Copied; ThreadPool.QueueUserWorkItem(o => Dest.Verify()); AddOutputMessage($"Copy operation {Title} finished"); return(true); } } catch (Exception e) { AddOutputMessage($"Copy operation {Title} failed with {e.Message}"); } return(false); case TFileOperationKind.Delete: try { if (Source.Delete()) { AddOutputMessage($"Delete operation {Title} finished"); return(true); } } catch (Exception e) { AddOutputMessage($"Delete operation {Title} failed with {e.Message}"); } return(false); case TFileOperationKind.Move: if (!File.Exists(source.FullPath) || !Directory.Exists(DestDirectory.Folder)) { return(false); } try { CreateDestMediaIfNotExists(); if (Dest.FileExists()) { if (File.GetLastWriteTimeUtc(source.FullPath).Equals(File.GetLastWriteTimeUtc(Dest.FullPath)) && File.GetCreationTimeUtc(source.FullPath).Equals(File.GetCreationTimeUtc(Dest.FullPath)) && source.FileSize.Equals(Dest.FileSize)) { source.Delete(); return(true); } else if (!Dest.Delete()) { AddOutputMessage("Move operation failed - destination media not deleted"); return(false); } } IsIndeterminate = true; Dest.MediaStatus = TMediaStatus.Copying; FileUtils.CreateDirectoryIfNotExists(Path.GetDirectoryName(Dest.FullPath)); File.Move(source.FullPath, Dest.FullPath); File.SetCreationTimeUtc(Dest.FullPath, File.GetCreationTimeUtc(source.FullPath)); File.SetLastWriteTimeUtc(Dest.FullPath, File.GetLastWriteTimeUtc(source.FullPath)); Dest.MediaStatus = TMediaStatus.Copied; ThreadPool.QueueUserWorkItem(o => Dest.Verify()); AddOutputMessage("Move operation finished"); Debug.WriteLine(this, "File operation succeed"); return(true); } catch (Exception e) { AddOutputMessage($"Move operation {Title} failed with {e.Message}"); } return(false); default: return(false); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Iss != null) { hashCode = hashCode * 59 + Iss.GetHashCode(); } if (Sub != null) { hashCode = hashCode * 59 + Sub.GetHashCode(); } if (Aud != null) { hashCode = hashCode * 59 + Aud.GetHashCode(); } if (Exp != null) { hashCode = hashCode * 59 + Exp.GetHashCode(); } if (Nbf != null) { hashCode = hashCode * 59 + Nbf.GetHashCode(); } if (Iat != null) { hashCode = hashCode * 59 + Iat.GetHashCode(); } if (Jti != null) { hashCode = hashCode * 59 + Jti.GetHashCode(); } if (Uuid != null) { hashCode = hashCode * 59 + Uuid.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (GivenName != null) { hashCode = hashCode * 59 + GivenName.GetHashCode(); } if (Nickname != null) { hashCode = hashCode * 59 + Nickname.GetHashCode(); } if (Email != null) { hashCode = hashCode * 59 + Email.GetHashCode(); } if (EmailVerified != null) { hashCode = hashCode * 59 + EmailVerified.GetHashCode(); } if (Zoneinfo != null) { hashCode = hashCode * 59 + Zoneinfo.GetHashCode(); } if (Locale != null) { hashCode = hashCode * 59 + Locale.GetHashCode(); } if (Cnf != null) { hashCode = hashCode * 59 + Cnf.GetHashCode(); } if (Orig != null) { hashCode = hashCode * 59 + Orig.GetHashCode(); } if (Dest != null) { hashCode = hashCode * 59 + Dest.GetHashCode(); } if (Mky != null) { hashCode = hashCode * 59 + Mky.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if JWToken instances are equal /// </summary> /// <param name="other">Instance of JWToken to be compared</param> /// <returns>Boolean</returns> public bool Equals(JWToken other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Iss == other.Iss || Iss != null && Iss.Equals(other.Iss) ) && ( Sub == other.Sub || Sub != null && Sub.Equals(other.Sub) ) && ( Aud == other.Aud || Aud != null && Aud.Equals(other.Aud) ) && ( Exp == other.Exp || Exp != null && Exp.Equals(other.Exp) ) && ( Nbf == other.Nbf || Nbf != null && Nbf.Equals(other.Nbf) ) && ( Iat == other.Iat || Iat != null && Iat.Equals(other.Iat) ) && ( Jti == other.Jti || Jti != null && Jti.Equals(other.Jti) ) && ( Uuid == other.Uuid || Uuid != null && Uuid.Equals(other.Uuid) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( GivenName == other.GivenName || GivenName != null && GivenName.Equals(other.GivenName) ) && ( Nickname == other.Nickname || Nickname != null && Nickname.Equals(other.Nickname) ) && ( Email == other.Email || Email != null && Email.Equals(other.Email) ) && ( EmailVerified == other.EmailVerified || EmailVerified != null && EmailVerified.Equals(other.EmailVerified) ) && ( Zoneinfo == other.Zoneinfo || Zoneinfo != null && Zoneinfo.Equals(other.Zoneinfo) ) && ( Locale == other.Locale || Locale != null && Locale.Equals(other.Locale) ) && ( Cnf == other.Cnf || Cnf != null && Cnf.Equals(other.Cnf) ) && ( Orig == other.Orig || Orig != null && Orig.Equals(other.Orig) ) && ( Dest == other.Dest || Dest != null && Dest.Equals(other.Dest) ) && ( Mky == other.Mky || Mky != null && Mky.Equals(other.Mky) )); }
private void Put(object key, object value, Dest putwhere) { Data dkey = new Data(), dvalue = new Data(); try { if (key != null) dkey = Data.New(key, parent.binfmt, parent.KeyType); else dkey = new Data(); // for putwhere == Current dvalue = Data.New(value, parent.binfmt, parent.ValueType); int ret = funcs.put(cursorp, ref dkey, ref dvalue, (uint)putwhere); if (ret == DB_KEYEXIST) { return; } CheckError(ret); } finally { dkey.Free(); dvalue.Free(); } }
public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown && FileToCopy.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } if (OtherPlatform) { continue; } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } ArchivedFiles.Add(FileToCopy, Dest); FilesAdded++; } } return(FilesAdded); }
// Obliczanie pozycji public void CalculatePosition(Texture2D background) { // Ustawiamy kolor pod czujkami - domyslnie przezroczysty, poniewaz nie moze // on wystapic w rzeczywistosci, co pozwoli nam okreslic, czy zostal on faktycznie // zmieniony w pozniejszym etapie. Color[] east_n = new Color[] { Color.Transparent }; Color[] east_f = new Color[] { Color.Transparent }; Color[] west_n = new Color[] { Color.Transparent }; Color[] west_f = new Color[] { Color.Transparent }; Color[] north_n = new Color[] { Color.Transparent }; Color[] north_f = new Color[] { Color.Transparent }; Color[] south_n = new Color[] { Color.Transparent }; Color[] south_f = new Color[] { Color.Transparent }; // Jezeli nie wykonujemy skretu if (!rotatefirstAiLeft && !rotatefirstAiRight) { // Pobieramy kolor tla pod dana czujka. Dodatkowe 400 pikseli wystepuje // ze wzgledu na przesuniecie tla. east_n = getBackgroundColor(400 + this.nearerSensor, 0, position, background); east_f = getBackgroundColor(400 + this.furtherSensor, 0, position, background); west_n = getBackgroundColor(400 - this.nearerSensor, 0, position, background); west_f = getBackgroundColor(400 - this.furtherSensor, 0, position, background); north_n = getBackgroundColor(400, -this.nearerSensor, position, background); north_f = getBackgroundColor(400, -this.furtherSensor, position, background); south_n = getBackgroundColor(400, this.nearerSensor, position, background); south_f = getBackgroundColor(400, this.furtherSensor, position, background); } // Ponownie - jesli nie wykonujemy skretu if (!rotatefirstAiLeft && !rotatefirstAiRight) { // Tworzymy zmienne dla czujek, ktore faktycznie bedziemy chcieli sprawdzac // (np. przy jezdzie w kierunku wschodnim sprawdzamy, czy mamy mozliwosc skretu // na polnoc i polodnie). Zapisujemy poczatkowo przezroczystosc, z tych samych // powodow co powyzej. Color[] check1_n = new Color[] { Color.Transparent }; Color[] check1_f = new Color[] { Color.Transparent }; Color[] check2_n = new Color[] { Color.Transparent }; Color[] check2_f = new Color[] { Color.Transparent }; // Ustawiamy czujki w zaleznosci od kierunku jazdy i tylko, gdy pod dalsza czujka // dla danego kierunku znajduje sie kolor inny, niz okreslony w zmiennej reference. // Czujki wskazuja na mozliwosc skretu w lewo (pierwsza) lub w prawo (druga). // Przy kierunku jazdy na wschod... if (destination == Dest.East && east_n[0] != reference) { // ...wlasciwymi czujkami sa polnocna i polodniowa. check1_n = north_n; check1_f = north_f; check2_n = south_n; check2_f = south_f; } // Przy kierunku jazdy na zachod... else if (destination == Dest.West && west_n[0] != reference) { // ...wlasciwymi czujkami sa polodniowa i polnocna. check1_n = south_n; check1_f = south_f; check2_n = north_n; check2_f = north_f; } // Przy kierunku jazdy na polnoc... else if (destination == Dest.North && north_n[0] != reference) { // ...wlasciwymi czujkami sa zachodnia i wschodnia. check1_n = west_n; check1_f = west_f; check2_n = east_n; check2_f = east_f; } // Przy kierunku jazdy na poludnie... else if (destination == Dest.South && south_n[0] != reference) { // ...wlasciwymi czujkami sa wschodnia i zachodnia. check1_n = east_n; check1_f = east_f; check2_n = west_n; check2_f = west_f; } // Jesli pierwsza czujka, polozona blizej auta, nie jest przezroczysta // (czyli odkrylismy trase)... if (check1_n[0] != Color.Transparent) { // ...dokonujemy dodatkowego sprawdzenia - porownujemy blizsze czujki if (check1_n[0] == check2_n[0]) { // Jesli blizsze czujki wskazuja ten sam kolor, odwolujemy sie // do czujek polozonych dalej i porownujemy je z kolorem trasy. // Jesli pierwsza czujka pobrala kolor trasy... if (check1_f[0] == reference) { // ...mamy mozliwosc skretu w lewo. rotatefirstAiLeft = true; } // Dla drugiej analogicznie. else if (check2_f[0] == reference) { rotatefirstAiRight = true; } } // ...w przeciwnym wypadku czujka blizsza ma jednoznaczna wartosc i // do niej mozemy sie odwolac (porownania ponizej jak w poprzednim warunku). else { if (check1_n[0] == reference) { rotatefirstAiLeft = true; } else if (check2_n[0] == reference) { rotatefirstAiRight = true; } } } } // Jesli wystapila kolizja if (collision) { if (velocity.X > -0.5 && velocity.X < 0.5 && velocity.Y > -0.5 && velocity.Y < 0.5) { collision = false; } else { velocity *= 1 - friction; } } // Jesli odkrylismy koniecznosc skretu... else if (rotatefirstAiLeft || rotatefirstAiRight) { // Jesli skrecamy w lewo... if (rotatefirstAiLeft) { // ...zwiekszamy wartosc zmiennej okreslajacej rotacje. rotation -= (float)(0.01 * 3.14); } // Jesli skrecamy w prawo... else { // ...zmniejszamy wartosc zmiennej okreslajacej rotacje. rotation += (float)(0.01 * 3.14); } // Zaokraglamy wartosc zmiennej obrotu do czterech miejsc po przecinku. float round = (float)Math.Round(rotation, 4); // Obliczamy sinus i cosinus z wartosci zmiennej obrotu, rowniez z zaokragleniem. float sround = (float)(Math.Round(Math.Sin(round), 4)); float cround = (float)(Math.Round(Math.Cos(round), 4)); // W zaleznosci od kierunku jazdy i wartosci funkcji sinus/cosinus jestesmy w stanie stwierdzic, // czy samochod dokonal pelnego obrotu. Wykonujemy ogolne sprawdzenia - dla kierunkow wschod/zachod // zmienna sinus powinna przyjac wartosc 0, 1 lub -1, aby mozna bylo uznac skret za zakonczony. // Analogicznie zachowa sie zmienna cosinus dla kierunkow polnoc/poludnie. if (((destination == Dest.East || destination == Dest.West) && (sround == 0 || sround == 1 || sround == -1)) || ((destination == Dest.North || destination == Dest.South) && (cround == 0 || cround == 1 || cround == -1))) { // Jesli sinus wynosi 1... if (sround == 1) { // ...zmieniamy kierunek na poludniowy, destination = Dest.South; // predkosc pozioma zmieniamy na zero, _velocity.X = 0; // predkosc pionowa ustawiamy na wartosc poczatkowa, _velocity.Y = this._initialVelocity; // okreslamy stosowna wartosc obrotu, aby auto wyswietlilo sie w pelni pionowo rotation = 1.57f; } // Analogicznie ustawiamy zmienne dla innych spodziewanych wartosci funkcji. else if (sround == -1) { destination = Dest.North; _velocity.X = 0; _velocity.Y = -this._initialVelocity; rotation = 4.71f; } else { if (cround == 1) { destination = Dest.East; _velocity.X = this._initialVelocity; _velocity.Y = 0; rotation = 0f; } else if (cround == -1) { destination = Dest.West; _velocity.X = -this._initialVelocity; _velocity.Y = 0; rotation = 3.14f; } } // Skret zostal zakonczony, wiec zmieniamy wartosc flagi. rotatefirstAiLeft = false; rotatefirstAiRight = false; } // Jezeli nie skonczylismy skrecac else { // Zmieniamy predkosc (a co za tym idzie - przesuniecie) zgodnie // z zmienna obrotu i predkoscia skretu. _velocity.X = (float)Math.Cos(rotation) * tangentialVelocity; _velocity.Y = (float)Math.Sin(rotation) * tangentialVelocity; } } // Tworzymy zmienna tablicowa, gdzie przechowamy kolor planszy bezposrednio pod samochodem Color[] c = new Color[1]; // Pobieramy kolor planszy pod samochodem. background.GetData(0, new Rectangle((int)this._position.X + 400, (int)this._position.Y, 1, 1), c, 0, c.Length); // Zmienne referencyjne - kolor bialy i czarny (ktory na planszy jest niemal bialy i nie do konca czarny). // Kolory te wystepuja tylko w miejscu, gdzie konczy sie okrazenie. Color black = new Color(43, 42, 41); Color white = new Color(254, 254, 254); // Jesli kolor pod samochodem to ktorys z kolorow referencyjnych... if (c[0] == black || c[0] == white) { // ...ustawiamy flage zmiany okrazenia. lapChange = true; } // W przeciwnym wypadku... else { // ...sprawdzamy, czy flaga zmiany okrazenia jest podniesiona oraz czy od ostatniej zmiany // uplynelo 5 sekund (poniewaz pole, gdzie moze sie dokonac zmiana jest szerokie i w czasie // normalnego przejazdu mozna by wielokrotnie przestawic numer aktualnego okrazenia). if (lapChange && (DateTime.Now.Subtract(lastLapChange) > TimeSpan.FromSeconds(5))) { // Jesli zmieniamy okrazenie - zapisujemy czas zmiany lastLapChange = DateTime.Now; // Oraz zwiekszamy licznik _lap++; } // Po zmianach zdejmujemy flage zmiany okrazenia. lapChange = false; } // Zmieniamy polozenie auta zgodnie z jego aktualna predkoscia. this._position += this._velocity; }
/// <summary> /// Loads the bitmap from stream, processes, and renders, sending the result Bitmap to the 'consumer' callback for encoding or usage. /// </summary> /// <param name="s"></param> /// <param name="consumer"></param> /// <param name="options"></param> protected void Build(Stream s, BitmapConsumer consumer, JobOptions options) { var leaveSourceStreamOpen = ((options & JobOptions.LeaveSourceStreamOpen) != 0 || (options & JobOptions.RewindSourceStream) != 0); var bufferSource = ((options & JobOptions.BufferEntireSourceStream) != 0); var originalPosition = ((options & JobOptions.RewindSourceStream) != 0) ? s.Position : -1; var preserveTemp = ((options & JobOptions.PreserveTargetBitmap) != 0); try { try { //Buffer source stream if requested UnderlyingStream = bufferSource ? StreamUtils.CopyToMemoryStream(s, false, 0x1000) : s; //Allow early disposal (enables same-file edits) if (bufferSource && !leaveSourceStreamOpen) { s.Dispose(); s = null; } //Load bitmap Source = new Bitmap(UnderlyingStream, !IgnoreIccProfile); //Use size OriginalSize = Source.Size; //Do math Layout(); //Render to 'Dest' Render(); } finally { try { //Dispose loaded bitmap instance if (Source != null) { Source.Dispose(); } } finally { Source = null; //Ensure reference is null try { //Dispose buffer if (UnderlyingStream != null && s != UnderlyingStream) { UnderlyingStream.Dispose(); } } finally { UnderlyingStream = null; //Ensure reference is null //Dispose source stream or restore its position if (!leaveSourceStreamOpen && s != null) { s.Dispose(); } else if (originalPosition > -1 && s != null && s.CanSeek) { s.Position = originalPosition; } } } } //Fire callback to write to disk or use Bitmap instance directly consumer(Dest, options); } finally { //Temporary bitmap must be disposed if (!preserveTemp && Dest != null) { Dest.Dispose(); Dest = null; } } }
protected override void Because_of() { var source = new Source { Value = "a1" }; _dest = Mapper.Map<Source, Dest>(source); }
protected override void Because_of() { _dest = Mapper.Map <Source, Dest>(new Source { Foo = 5 }, opt => opt.ConstructServicesUsing(t => new Dest(6))); }
protected override void Because_of() { var source = new Source { Value = new Tuple<int, int>(10, 11) }; _dest = Mapper.Map<Source, Dest>(source); }
protected override void Because_of() { _dest = Mapper.Map <Source, Dest>(new Source()); }
protected override void Because_of() { _dest = Mapper.Map<Source, Dest>(new Source { Foo = 5 }, opt => opt.ConstructServicesUsing(t => new Dest(6))); }
public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (ArchivedFiles.ContainsKey(FileToCopy)) { if (ArchivedFiles[FileToCopy] != Dest) { throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest); } } else { ArchivedFiles.Add(FileToCopy, Dest); } FilesAdded++; } } return(FilesAdded); }
public override void Write(byte data) { ThrowIfEncrypted(); Dest.Write(data); }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && PacketProcessor.Instance.BossLink.Any(x => x.Value == entity && x.Key.StartsWith("!"))) { DpsServers.Where(x => PacketProcessor.Instance.BossLink.Where(y => y.Value == entity && y.Key.StartsWith("!")) .Select(y => y.Key.Substring(1, y.Key.IndexOf(" ", StringComparison.Ordinal) - 1)) .Contains(x.Guid.ToString())).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); } if (type.HasFlag(Dest.Excel)) { ExcelExporter.ExcelSave(stats, stats.BaseStats.members.Select(x => x.playerName) .FirstOrDefault(x => PacketProcessor.Instance.MeterPlayers.Select(z => z.Name).Contains(x)), type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
public override void Write(byte[] data, int offset, int count) { ThrowIfEncrypted(); Dest.Write(data, offset, count); }
public override string ToString() { return(Dest.ToString()); }
protected override void OnAfterExecute() { Region.Dispose(); Dest.Dispose(); }
protected override void Because_of() { var sourceList = new[] { new Source { Child1 = new ChildSource(), Child2 = new ChildSource(), Child3 = new ChildSource(), Child4 = new ChildSource() { GrandChild = new GrandChildSource() } } }; _dest = sourceList.AsQueryable().UseAsDataSource(Configuration).For<Dest>(d => d.Child2, d => d.Child4, d => d.Child4.GrandChild).FirstOrDefault(); }
public static void ManualExport(NpcEntity entity, AbnormalityStorage abnormality, Dest type) { if (entity == null) { return; } var stats = GenerateStats(entity, abnormality); if (stats == null) { return; } var name = stats.BaseStats.members.Select(x => x.playerName).FirstOrDefault(x => PacketProcessor.Instance.MeterPlayers.Select(z => z.Name).Contains(x)); if (type.HasFlag(Dest.Json)) { JsonExporter.JsonSave(stats, name, type.HasFlag(Dest.Manual)); } var sendThread = new Thread(() => { if (type.HasFlag(Dest.Site) && PacketProcessor.Instance.BossLink.Any(x => x.Value == entity && !x.Key.Success)) { DpsServers.Where(x => PacketProcessor.Instance.BossLink.Where(y => y.Value == entity && !y.Key.Success) .Select(y => y.Key.Server) .Contains(x.Data.HostName)).ToList().ForEach(x => x.CheckAndSendFightData(stats.BaseStats, entity)); } if (type.HasFlag(Dest.Excel)) { ExcelExporter.ExcelSave(stats, name, type.HasFlag(Dest.Manual)); } }); sendThread.Start(); }
protected override void Because_of() { _dest = Mapper.Map<Source, Dest>(new Source { Foo = 5, Bar = 10 }); }
public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bIsCombiningMultiplePlatforms) { FileReference InputFile = new FileReference(FileToCopy); bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (InputFile.IsUnderDirectory(LocalRoot)) { Search = InputFile.MakeRelativeTo(LocalRoot); } else if (InputFile.IsUnderDirectory(ProjectRoot)) { Search = InputFile.MakeRelativeTo(ProjectRoot); } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); } else { Dest = FileToCopy.Substring(InPath.Length); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (ArchivedFiles.ContainsKey(FileToCopy)) { if (ArchivedFiles[FileToCopy] != Dest) { throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest); } } else { ArchivedFiles.Add(FileToCopy, Dest); } FilesAdded++; } } return(FilesAdded); }
protected override void Because_of() { var source = new Source { Value = 10}; _result = Mapper.Map<Source, Dest>(source); }
public void Put(object key, object value, Dest putwhere) { Data dkey = new Data(), dvalue = new Data(); uint recno = 0; try { if (key != null && parent.KeyType != DataType.UInt) dkey = Data.New(key, parent.binfmt, parent.KeyType); else if (parent.KeyType == DataType.UInt) { recno = (uint) key; dkey = new Data (); dkey.flags = Data.DB_DBT_USERMEM; dkey.Size = sizeof (uint); dkey.ulen = dkey.Size; unsafe { dkey.Ptr = new IntPtr (&recno); } } else dkey = new Data(); // for putwhere == Current dvalue = Data.New(value, parent.binfmt, parent.ValueType); int ret = funcs.put(cursorp, ref dkey, ref dvalue, (uint)putwhere); if (ret == DB_KEYEXIST) { return; } CheckError(ret); } finally { dkey.Free(); dvalue.Free(); } }