public void RandomizeTypeAndWeight() { Type = GetRandomEnum <RockType>(); Weight = Random.Range(1, 5); Debug.Log(Weight); //Debug.Log(Type); }
protected override void Directingsetting() { pathnum = 0; openPotal.SetActive(true); closePotal.SetActive(false); AssetManager.Effect.Retrieve("DirectionSound_PotalOpen", gameObject.transform); if (SceneManager.GetActiveScene().name == GameData.Instance.Segment02) { m_potalType = RockType.Seg2; potalFX.SetActive(false); transform.localScale = new Vector3(5f, 5f, 5f); } else { m_potalType = RockType.Seg1; } switch (m_potalType) { case RockType.Seg1: m_coroutine = CoroutineManager.Instance.Register(RockMove()); break; case RockType.Seg2: m_coroutine = CoroutineManager.Instance.Register(RockMoveSegTwo()); break; } }
public void RockJobProcessTimeOfCompletedJobIsCorrectWhenRockRequiringBothProcessingTypesSentForProcessing() { //TODO - rationalise this its not pretty var rockJobProcessor = new RockJobProcessor(); const double weight = 3; const RockType rockType = RockType.Gneiss; double crushProcessMinWeightLoss = CrushProcessMinWeightLoss(weight); double crushProcessMaxWeightLoss = CrushProcessMaxWeightLoss(weight); double expectedCrushProcessTimeLow = ((weight - crushProcessMaxWeightLoss) * CrushingProcessingTimePerKilo); double expectedCrushProcessTimeHigh = ((weight - crushProcessMinWeightLoss) * CrushingProcessingTimePerKilo); double expectedProcessTimeLow = (expectedCrushProcessTimeLow) + ((weight - crushProcessMaxWeightLoss) * SmoothingProcessingTimePerKilo); double expectedProcessTimeHigh = (expectedCrushProcessTimeHigh) + ((weight - crushProcessMinWeightLoss) * SmoothingProcessingTimePerKilo); var rockJob = new RockJob(rockType, weight, this); Console.WriteLine("Sending {0} item of weight {1} for processing", rockType, weight); Console.WriteLine("Expected process time between {0}ms and {1}ms", expectedProcessTimeLow, expectedProcessTimeHigh); rockJobProcessor.Process(rockJob); Assert.GreaterOrEqual(rockJob.ProcessTime, expectedProcessTimeLow, "Process time not as expected"); Assert.LessOrEqual(rockJob.ProcessTime, expectedProcessTimeHigh, "Process time not as expected"); Console.WriteLine("Test Complete"); }
/// <summary> /// Initializes a new instance of the <see cref="Rock" /> class. /// </summary> /// <param name="rockType">Type of the rock.</param> public Rock(RockType rockType, Vector2 position) { this.entity = new Entity() .AddComponent(new Transform2D() { X = position.X, Y = position.Y, DrawOrder = 0.2f, }) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); string textureName; Vector2 rockOrigin, seaweedsPosition; switch (rockType) { case RockType.Center: textureName = "centralRock"; rockOrigin = Vector2.Center; seaweedsPosition = Vector2.Zero; break; case RockType.Left: textureName = "leftRock"; rockOrigin = Vector2.Zero; seaweedsPosition = new Vector2(225,135); break; case RockType.Right: textureName = "rightRock"; rockOrigin = Vector2.UnitX; seaweedsPosition = new Vector2(-170, 100); break; default: textureName = "centralRock"; rockOrigin = Vector2.Zero; seaweedsPosition = Vector2.Zero; break; } this.entity.AddComponent(new Sprite(Directories.TexturePath + string.Format("{0}.wpk", textureName)) { IsGlobalAsset = true}); this.entity.AddComponent(new PerPixelCollider(Directories.TexturePath + string.Format("{0}Collider.wpk", textureName), 0.5f) { IsGlobalAsset = true}); this.entity.FindComponent<Transform2D>().Origin = rockOrigin; // Seaweeds Entity seaweeds = new Entity() .AddComponent(new Transform2D() { Origin = new Vector2(0.5f, 1), X = seaweedsPosition.X, Y = seaweedsPosition.Y, DrawOrder = 0.1f, }) .AddComponent(new Sprite(Directories.TexturePath + "seaweedsSpriteSheet.wpk") { IsGlobalAsset = true}) .AddComponent(Animation2D.Create<TexturePackerGenericXml>(Directories.TexturePath + "seaweedsSpriteSheet.xml") .Add("wave", new SpriteSheetAnimationSequence() { First = 1, Length = 80, FramesPerSecond = 20 })) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); this.entity.AddChild(seaweeds); seaweeds.FindComponent<Animation2D>().Play(true); this.Collider = this.entity.FindComponent<Collider2D>(false); }
public Guid ProcessRock(RockType rockType, double weight) { var rockJob = new RockJob(rockType, weight, this); _jobCatalogue.Add(rockJob.JobId, rockJob); _processJobs.Add(rockJob); return(rockJob.JobId); }
public RockJob(RockType rockType, double weight, IRockJobMonitor monitor) { _rockType = rockType; _originWeight = weight; _currentWeight = _originWeight; _monitor = monitor; _jobId = Guid.NewGuid(); }
public static decimal GetMiningExperienceFromType(RockType type) { switch (type) { default: return(5m); } return(0); }
public Rock GetRock(RockType rockType) { if (!flywieghts.ContainsKey(rockType)) { AddFlyweight(rockType); } return flywieghts[rockType]; }
static public void InitImages(SuitType player) { for (int i = (int)RockType.rook; i != (int)RockType.pawn + 1; i++) { RockType rock = (RockType)i; WhiteImages[i] = Image.FromFile("B:\\code\\C#\\Gess\\rocks\\white_" + rock.ToString() + ".gif"); BlackImages[i] = Image.FromFile("B:\\code\\C#\\Gess\\rocks\\black_" + rock.ToString() + ".gif"); } }
public Rock GetRock(RockType rockType) { if (!flywieghts.ContainsKey(rockType)) { AddFlyweight(rockType); } return(flywieghts[rockType]); }
public static decimal GetMiningExperienceFromType(RockType type) { switch (type) { case RockType.Rune: return(100); default: return(5m); } }
RockProductionType GetProductionType(RockType _type) { if (_type == RockType.sharp) { return RockProductionType.common; } else { return RockProductionType.enriched; } }
public void RockJobProcessTimeOfCompletedJobIsCorrectWhenRockRequiringSmoothingSentForProcessing() { var rockJobProcessor = new RockJobProcessor(); const double weight = 5.6; const RockType rockType = RockType.Granit; const int expectedProcessTime = (int)(weight * SmoothingProcessingTimePerKilo); var rockJob = new RockJob(rockType, weight, this); Console.WriteLine("Sending {0} item of weight {1} for processing", rockType, weight); Console.WriteLine("Expected process time {0}ms", expectedProcessTime); rockJobProcessor.Process(rockJob); Assert.AreEqual(expectedProcessTime, rockJob.ProcessTime, "Process time not as expected"); Console.WriteLine("Test Complete"); }
private void AddFlyweight(RockType rockType) { Rock rock = null; switch (rockType) { case RockType.Jagged: rock = new JaggedRock(); break; case RockType.Smooth: rock = new SmoothRock(); break; } this.flywieghts.Add(rockType, rock); this.TotalObjectsCreated++; }
public Rock(RockType myType) { rockType = myType; switch (rockType) { case RockType.kNormalRock: _Difficulty = 5; break; case RockType.kClayRock: _Difficulty = 2; break; case RockType.kIronRock: _Difficulty = 10; break; default: _Difficulty = 9001; break; } this._Tag = SpriteType.kRockType; this.MyWorldObjectTag = WorldObjectTag.kRockTag; this._CurrentState = SpriteState.kStateActive; _TrueStartHP = 8; ItemBundle output = new ItemBundle(); output.outputID = Enums.ItemID.kItemOre; output.amount = 1; output.odds = 100; CurrentDrop = output; InteractText = "Mine"; Setup(); }
public static bool TryConvert(this CraftResource r, out RockType t) { if (r == CraftResource.None) { t = RockType.None; return(true); } if (r < CraftResource.BloodRock) { t = RockType.None; return(false); } if (r > CraftResource.BlackRock) { t = RockType.None; return(false); } t = (RockType)r; return(true); }
public Rock(string filename, ContentManager Content, Vector2 vec, int rType, bool animated=true) : base(filename, Content, vec, animated) { rockType = (RockType)rType; switch (rType) { case ((int)RockType.DIRT): mineTime = 1.0f; break; case ((int)RockType.STONE): mineTime = 2.5f; break; case ((int)RockType.IRON): mineTime = 10.0f; break; case ((int)RockType.DIAMOND): mineTime = 20.0f; break; case ((int)RockType.MARSIUM): mineTime = 60.0f; break; } }
public void RockJobPostProcessWeightCorrectAfterProcessingWhenBothProcessingTypesApplied() { var rockJobProcessor = new RockJobProcessor(); const RockType rockType = RockType.Gneiss; var rockJob = new RockJob(rockType, 6.8, this); double smoothProcessMaxWeightLoss = SmoothProcessMaxWeightLoss(rockJob.CurrentWeight); double smoothProcessMinWeightLoss = SmoothProcessMinWeightLoss(rockJob.CurrentWeight); double crushProcessMaxWeightLoss = CrushProcessMaxWeightLoss(rockJob.CurrentWeight); double crushProcessMinWeightLoss = CrushProcessMinWeightLoss(rockJob.CurrentWeight); double expectedMinWeight = rockJob.OriginWeight - (smoothProcessMaxWeightLoss + crushProcessMaxWeightLoss); double expectedMaxWeight = rockJob.OriginWeight - (smoothProcessMinWeightLoss + crushProcessMinWeightLoss); Console.WriteLine("Sending {0} item of weight {1} for processing", rockType, rockJob.OriginWeight); Console.WriteLine("Expected Minimum Weight after processing {0}", expectedMinWeight); Console.WriteLine("Expected Maximum Weight after processing {0}", expectedMaxWeight); rockJobProcessor.Process(rockJob); Assert.GreaterOrEqual(rockJob.CurrentWeight, expectedMinWeight, "Post process weight not within the expected bounds"); Assert.LessOrEqual(rockJob.CurrentWeight, expectedMaxWeight, "Post process weight not within the expected bounds"); Console.WriteLine("Actual Post Process Weight {0}", rockJob.CurrentWeight); Console.WriteLine("Test Complete"); }
public Rock(RockType type, RockSize size) { _rockType = type; _rockSize = size; _rockProductionType = GetProductionType(type); }
public static bool TryConvert(this CraftResource r, out RockType t) { if (r == CraftResource.None) { t = RockType.None; return true; } if (r < CraftResource.BloodRock) { t = RockType.None; return false; } if (r > CraftResource.BlackRock) { t = RockType.None; return false; } t = (RockType)r; return true; }
public Piece(Square Square, RockType InType, SuitType inSuit) { Type = InType; Suit = inSuit; sq = Square; }
private void GetPawnMoves(out List <Square> moving_moves, out List <Square> killing_moves) { moving_moves = new List <Square>(16); killing_moves = new List <Square>(16); int nRow = Suit == SuitType.black ? 1 : -1; int mRow = Suit == SuitType.black ? 1 : 6; int oRow = Suit == SuitType.black ? 2 : -2; int xRow = Suit == SuitType.black ? 7 : 0; Piece nullPiece = new Piece(new Square(0, 0), RockType.pawn, SuitType.white); // Piece one square ahead, if any Piece piece1 = sq.row + nRow <= 7 && sq.row + nRow >= 0 ? resources.mf.GetPieceInSq(resources.mf.grid[sq.col, sq.row + nRow]) : nullPiece; // Piece two squares ahead, if any Piece piece2 = sq.row + oRow <= 7 && sq.row + oRow >= 0 ? resources.mf.GetPieceInSq(resources.mf.grid[sq.col, sq.row + oRow]) : nullPiece; // Piece forward-right if (sq.row + nRow <= 7 && sq.row + nRow >= 0 && sq.col - nRow <= 7 && sq.col - nRow >= 0) { Square Sqr = resources.mf.grid[sq.col - nRow, sq.row + nRow]; Piece piece = resources.mf.GetPieceInSq(Sqr); if (piece != null && Sqr != null && piece.suit != Suit && SafeForKing(Sqr)) { killing_moves.Add(Sqr); } } // Piece forward-left if (sq.row + nRow <= 7 && sq.row + nRow >= 0 && sq.col + nRow <= 7 && sq.col + nRow >= 0) { Square Sqr = resources.mf.grid[sq.col + nRow, sq.row + nRow]; Piece piece = resources.mf.GetPieceInSq(Sqr); if (piece != null && Sqr != null && piece.suit != Suit && SafeForKing(Sqr)) { killing_moves.Add(Sqr); } } if (sq.row == xRow) { type = RockType.queen; return; } // One square ahead. Only if there's no piece occupying that square. if (piece2 != nullPiece && piece1 == null && SafeForKing(resources.mf.grid[sq.col, sq.row + nRow])) { moving_moves.Add(resources.mf.grid[sq.col, sq.row + nRow]); } // Two squares ahead. Only if there's no piece occupying that square. if (piece2 != nullPiece && piece2 == null && sq.row == mRow && SafeForKing(resources.mf.grid[sq.col, sq.row + oRow])) { moving_moves.Add(resources.mf.grid[sq.col, sq.row + oRow]); } }
/// <summary> /// Adiciona uma rocha ao inventário /// </summary> /// <param name="rockType">Tipo de rocha</param> /// <param name="amount">Quantidade</param> public void AddRock(RockType rockType, int amount) { rock[rockType] += amount; }
/// <summary> /// Initializes a new instance of the <see cref="Rock" /> class. /// </summary> /// <param name="rockType">Type of the rock.</param> public Rock(RockType rockType, Vector2 position) { this.entity = new Entity() .AddComponent(new Transform2D() { X = position.X, Y = position.Y, DrawOrder = 0.2f, }) .AddComponent(new SpriteRenderer(DefaultLayers.Alpha)); string textureName; Vector2 rockOrigin, seaweedsPosition; switch (rockType) { case RockType.Center: textureName = "centralRock"; rockOrigin = Vector2.Center; seaweedsPosition = Vector2.Zero; break; case RockType.Left: textureName = "leftRock"; rockOrigin = Vector2.Zero; seaweedsPosition = new Vector2(225, 135); break; case RockType.Right: textureName = "rightRock"; rockOrigin = Vector2.UnitX; seaweedsPosition = new Vector2(-170, 100); break; default: textureName = "centralRock"; rockOrigin = Vector2.Zero; seaweedsPosition = Vector2.Zero; break; } this.entity.AddComponent(new Sprite(Directories.TexturePath + string.Format("{0}.wpk", textureName)) { IsGlobalAsset = true }); this.entity.AddComponent(new PerPixelCollider(Directories.TexturePath + string.Format("{0}Collider.wpk", textureName), 0.5f) { IsGlobalAsset = true }); this.entity.FindComponent <Transform2D>().Origin = rockOrigin; // Seaweeds Entity seaweeds = new Entity() .AddComponent(new Transform2D() { Origin = new Vector2(0.5f, 1), X = seaweedsPosition.X, Y = seaweedsPosition.Y, DrawOrder = 0.1f, }) .AddComponent(new Sprite(Directories.TexturePath + "seaweedsSpriteSheet.wpk") { IsGlobalAsset = true }) .AddComponent(Animation2D.Create <TexturePackerGenericXml>(Directories.TexturePath + "seaweedsSpriteSheet.xml") .Add("wave", new SpriteSheetAnimationSequence() { First = 1, Length = 80, FramesPerSecond = 20 })) .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha)); this.entity.AddChild(seaweeds); seaweeds.FindComponent <Animation2D>().Play(true); this.Collider = this.entity.FindComponent <Collider2D>(false); }