private Vector3 GetRandomStartPosition(float scale) { var area = RandomEnum <AreaType> .Get(); var rand = UnityEngine.Random.Range(0.0f, 1.0f); switch (area) { case AreaType.top: { return(new Vector3(m_level.Left + rand * m_level.Width, m_level.Top + scale, 0)); } case AreaType.bottom: { return(new Vector3(m_level.Left + rand * m_level.Width, m_level.Bottom - scale, 0)); } case AreaType.right: { return(new Vector3(m_level.Right + scale, m_level.Bottom + rand * m_level.Height, 0)); } case AreaType.left: { return(new Vector3(m_level.Left - scale, m_level.Bottom + rand * m_level.Height, 0)); } } throw Assert.CreateException(); }
public void TestMethod1() { Options option; for (int i = 0; i < 10; ++i) { option = RandomEnum.Of <Options>(); Console.WriteLine(option); } }
public void ReturnsSingleMatchingTransformForJobType() { int supportedTransform = new RandomNumberBetween(0, 2); GeneratePublishingCsvJobsCreationAction action = new RandomEnum <GeneratePublishingCsvJobsCreationAction>(); GivenTheTransformSupportsTheJobType(action, supportedTransform); _serviceLocator.GetService(action) .Should() .BeSameAs(_transforms[supportedTransform].Object); }
public void ReturnsSingleMatchingTransformForJobType() { int supportedTransform = new RandomNumberBetween(0, 2); FundingLineCsvGeneratorJobType jobType = new RandomEnum <FundingLineCsvGeneratorJobType>(); GivenTheTransformSupportsTheJobType(jobType, supportedTransform); _serviceLocator.GetService(jobType) .Should() .BeSameAs(_batchProcessors[supportedTransform].Object); }
private void SpawnUFO() { UFO ufo = m_ufoFactory.Create(); var ufoType = RandomEnum <UFOType> .Get(); var score = m_ufoDataFactory.GetScore(ufoType); var ufoData = m_ufoDataFactory.GetData(ufoType); ufo.Score = score; ufo.transform.position = GetRandomStartPosition(ufo.Scale); }
private void SpawnAsteroid() { var random_AsteroidType = RandomEnum <AsteroidType> .Get(); var data = m_asteroidDataFactoryInterface.GetData(random_AsteroidType); if (data == null || random_AsteroidType == AsteroidType.none) { return; } Asteroid asteroid = m_asteroidFactory.Create(); InitializeAsteroid(ref asteroid, data, random_AsteroidType); asteroid.transform.position = GetRandomStartPosition(asteroid.ScaleFactor); }
public void AddCreature_GetBestCreatures(int size, int seed) { //arrange NewBestCretureFoundEventDelegate <FakeCreature> newBestFound = (_, __) => { }; RatedCreature <FakeCreature> foreFather = new RatedCreature <FakeCreature>(new FakeCreature(-1), -1); DisposedCreaturesStore <FakeCreature> disposedCreatures = new DisposedCreaturesStore <FakeCreature>(); DefaultSelector <FakeCreature> selector = new DefaultSelector <FakeCreature>(newBestFound, foreFather, size, disposedCreatures); RandomEnum rndE = new RandomEnum(seed); List <RatedCreature <FakeCreature> > insertedCreatures = new List <RatedCreature <FakeCreature> >(); int limit = size * 10; insertedCreatures.Add(foreFather); foreach (var num in rndE) { if (--limit < 0) { break; } insertedCreatures.Add(new RatedCreature <FakeCreature>(new FakeCreature(num), num)); } //act foreach (var creature in insertedCreatures) { selector.AddCreature(creature); } //Assert insertedCreatures.Sort((x, y) => y.CompareTo(x)); var expected = insertedCreatures.Take(size).ToList(); var actual = (from cr in selector.GetSurvivingCreatures() orderby cr.FitnessValue descending select cr).ToList(); Assert.AreEqual(expected.Count, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.AreEqual(expected[i].FitnessValue, actual[i].FitnessValue); } }
public virtual void GenerateQuality(int value) { if (value > 7) { value = 7; } if (material == Material.Metal) { MetalMaterial randomMaterial = RandomEnum.IndexOf <MetalMaterial>(value); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Wood) { WoodMaterial randomMaterial = RandomEnum.IndexOf <WoodMaterial>(value); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Cloth) { LightMaterial randomMaterial = RandomEnum.IndexOf <LightMaterial>(value); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Leather) { LeatherMaterial randomMaterial = RandomEnum.IndexOf <LeatherMaterial>(value); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Gem) { GemMaterial randomMaterial = RandomEnum.IndexOf <GemMaterial>(value); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } //change values based on material quality; defence *= levelMultiplyer; }
public void GenMonsterStrength(int targetStrength) // pass in a level value for more controll. { int multiplyer = targetStrength - baseLevel; if (multiplyer > 0) //zero use base stats. shouldnt be negative but if it is use base stats. { name = RandomEnum.IndexOf <MonsterStrength>(multiplyer).ToString() + " " + name; multiplyer++; // max level = 8 min level is 0 therefor a rat can have a 9x multiplyer... health *= multiplyer; minDamage *= multiplyer; maxDamage *= multiplyer; //accuracy - constant? //attackSpeed *= multiplyer; armor *= multiplyer; //difficultyToHit - constant? } }
public virtual void GenerateQuality() //if value <0 do random value. testing random material generation. { if (material == Material.Metal) { MetalMaterial randomMaterial = RandomEnum.Of <MetalMaterial>(); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Wood) { WoodMaterial randomMaterial = RandomEnum.Of <WoodMaterial>(); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Cloth) { LightMaterial randomMaterial = RandomEnum.Of <LightMaterial>(); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Leather) { LeatherMaterial randomMaterial = RandomEnum.Of <LeatherMaterial>(); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } else if (material == Material.Gem) { GemMaterial randomMaterial = RandomEnum.Of <GemMaterial>(); name = randomMaterial.ToString() + " " + name; levelMultiplyer = (int)randomMaterial + 1;//starts at zero } //change values based on material quality; defence *= levelMultiplyer; //attackSpeed *= levelMultiplyer;?? }
public async Task GetLatestEarlierPublishedProviderVersionByStatus() { string fundingStreamId = NewRandomString(); string fundingPeriodId = NewRandomString(); long timeStamp = NewRandomTimeStamp(); string providerId = NewRandomString(); PublishedProviderStatus status = new RandomEnum <PublishedProviderStatus>(); PublishedProviderVersion expectedLatestEarlierDocument = NewPublishedProviderVersion(); GivenTheLatestEarlierDocument(@"SELECT TOP 1 * FROM publishedProviderVersion p WHERE p.documentType = 'PublishedProviderVersion' AND p._ts < @sinceTimeStamp AND p.content.fundingStreamId = @fundingStreamId AND p.content.fundingPeriodId = @fundingPeriodId AND p.content.providerId = @providerId AND p.content.status = @status AND p.deleted = false ORDER BY p._ts DESC", expectedLatestEarlierDocument, ("@fundingPeriodId", fundingPeriodId), ("@fundingStreamId", fundingStreamId), ("@sinceTimeStamp", timeStamp), ("@providerId", providerId), ("@status", status)); PublishedProviderVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedProviderVersion(fundingStreamId, fundingPeriodId, timeStamp, providerId, status); actualLatestEarlierDocument .Should() .BeSameAs(expectedLatestEarlierDocument); }
public async Task GetLatestEarlierPublishedProviderVersionByStatusFromVersion() { string fundingStreamId = NewRandomString(); string fundingPeriodId = NewRandomString(); decimal version = NewRandomInteger(); string providerId = NewRandomString(); PublishedProviderStatus status = new RandomEnum <PublishedProviderStatus>(); PublishedProviderVersion expectedLatestEarlierDocument = NewPublishedProviderVersion(); GivenTheLatestEarlierDocument(@"SELECT TOP 1 * FROM publishedProviderVersion p WHERE p.documentType = 'PublishedProviderVersion' AND StringToNumber(CONCAT(Tostring(p.content.majorVersion), '.', Tostring(p.content.minorVersion))) < @version AND p.content.fundingStreamId = @fundingStreamId AND p.content.fundingPeriodId = @fundingPeriodId AND p.content.providerId = @providerId AND p.content.status = @status AND p.deleted = false ORDER BY p.content.majorVersion DESC, p.content.minorVersion DESC", expectedLatestEarlierDocument, ("@fundingPeriodId", fundingPeriodId), ("@fundingStreamId", fundingStreamId), ("@version", version), ("@providerId", providerId), ("@status", status)); PublishedProviderVersion actualLatestEarlierDocument = await _repository.GetLatestEarlierPublishedProviderVersionFromVersion(fundingStreamId, fundingPeriodId, version, providerId, status); actualLatestEarlierDocument .Should() .BeSameAs(expectedLatestEarlierDocument); }
/// <summary> /// ボールの間隔、x座標に関してランダムにボールを生成します。これは、ゲームが実行中のみ機能します。 /// </summary> static GameSceneState MaybeRandomGenerateBall(GameSceneState state) { if (state.gameState != GameState.Playing) { return(state); } var latestBall = GetLast(state.ballState); var nextPos = state.ballGenerator?.MaybeGenerate(state.canvasSize, latestBall); if (nextPos.HasValue) { state.ballGenerator = BallGenerator.RandomPos(50, 300); var ballXPos = state.barState.movePos.GetPos(RandomEnum <BarPosition> .GetRandom()).x; // ボールを生成する(yの相対位置、x方向はランダム) var ballPos = new Vector2(ballXPos, latestBall.position.y + nextPos.Value); var newBall = state.ballInitState; newBall.movesBall = true; newBall.position = ballPos; state.ballState.Add(newBall); } return(state); }
public virtual void TestEnum(RandomEnum param) { }
IndustryType GetRandomIndustry() { return(RandomEnum <IndustryType> .GenerateValue()); }
public static void DoSomething03(RandomEnum @enum) => s_value = @enum;
private void DoThings() { if (!intialized) { return; } if (!IsPerformingAction && Player != null) { DestinationTile = Player.GetComponent <PlayerData>().CurrentTile; int shortestDistance = PathNode.GetDistanceToNode(CurrentTile, DestinationTile, GameGrid); foreach (GameObject go in Player.GetComponent <PlayerData>().AllStructures) { int distance = PathNode.GetDistanceToNode(CurrentTile, go.GetComponent <StructureData>().CurrentTile, GameGrid); if (distance < shortestDistance && go.GetComponent <BeaconData>() != null) { shortestDistance = distance; DestinationTile = go.GetComponent <StructureData>().CurrentTile; } } Tile realDestination = DestinationTile; if (shortestDistance > BeaconData.DistressRadius) { if (CurrentTile.Neighbours.Count > 0) { Tile.Sides side; do { side = RandomEnum.Of <Tile.Sides>(); } while (!CurrentTile.Neighbours.ContainsKey(side)); DestinationTile = CurrentTile.Neighbours[side]; if (DestinationTile.Neighbours.Count > 0) { do { do { side = RandomEnum.Of <Tile.Sides>(); } while (!DestinationTile.Neighbours.ContainsKey(side)); DestinationTile = DestinationTile.Neighbours[side]; } while (DestinationTile == CurrentTile); } } else { return; } } TileTobeMovedTo = CalculatePath(); if (TileTobeMovedTo != CurrentTile) { TypeOfPerformingAction[PlayerActions.Move] = true; Vector3 dest = TileTobeMovedTo.Position; // Animator animCtrl = this.gameObject.GetComponent<Animator>(); if (dest.x > Position.x) { direction = 1; } else if (dest.x < Position.x) { direction = -1; } IsPerformingAction = true; CurrentTile.Savior = null; TileTobeMovedTo.Savior = this.gameObject; } } }
/// <summary> /// Update /// </summary> /// <param name="time">Elapsed game time</param> public override void Update(GameTime time) { // Target range int range = Game.Random.Next(Monster.SightRange); // Direction to face to while (true) { CardinalPoint direction = RandomEnum.Get <CardinalPoint>(); if (direction == Monster.Location.Direction) { continue; } //int dir = Dice.GetD20(1); Point vector = Monster.Location.Coordinate; /* * // Depending the current direction * switch (Monster.Location.Direction) * { * case CardinalPoint.North: * { * if (dir < 10) * { * direction = CardinalPoint.West; * vector.X--; * } * else * { * direction = CardinalPoint.East; * vector.X++; * } * } * break; * case CardinalPoint.South: * { * if (dir < 10) * { * direction = CardinalPoint.East; * vector.X++; * } * else * { * direction = CardinalPoint.West; * vector.X--; * } * * } * break; * case CardinalPoint.West: * { * if (dir < 10) * { * direction = CardinalPoint.North; * vector.Y--; * } * else * { * direction = CardinalPoint.South; * vector.Y++; * } * * } * break; * case CardinalPoint.East: * { * if (dir < 10) * { * direction = CardinalPoint.South; * vector.Y++; * } * else * { * direction = CardinalPoint.North; * vector.Y--; * } * * } * break; * } */ // Depending the current direction switch (direction) { case CardinalPoint.North: { vector.Y--; } break; case CardinalPoint.South: { vector.Y++; } break; case CardinalPoint.West: { vector.X--; } break; case CardinalPoint.East: { vector.X++; } break; } // Check the block Square block = Monster.Maze.GetSquare(vector); if (block != null) { // Automatic direction changing //Monster.Location.Direction = direction; //Monster.StateManager.PushState(new MoveState(Monster, range, direction)); return; } } }
public static void SetIndependence(GameEntity company, bool independence) { if (independence) { company.isIndependentCompany = true; if (!company.hasInvestmentStrategy) { company.AddInvestmentStrategy(CompanyGrowthStyle.Aggressive, VotingStyle.Percent75, RandomEnum <InvestorInterest> .GenerateValue(InvestorInterest.None)); } } else { company.isIndependentCompany = false; if (company.hasInvestmentStrategy) { company.RemoveInvestmentStrategy(); } } }