private void ModifyShaft(Shaft shaft) { var randomElevatorHeight = Chance.Range(0, shaft.Height - 6); var randomElevatorPosition = shaft.BottomLeftCorner + (Directions.Up * randomElevatorHeight); shaft.AddFeature(randomElevatorPosition, FeatureTypes.Elevator); }
public void UpgradeActor() { _actor.LevelUp(FinanceManager.Settings); FinanceManager.UpdateMoney(-_price); _price *= FinanceManager.Settings.ActorUpgradePriceIncrement; UpdateUI(); _purchaseButton.interactable = _price <= FinanceManager.TotalMoney; _upgradeAmount.text = Mathf.Round(_price).ToString(); _capacityAmount.text = Mathf.Round(_actor.Settings.Skill * _actor.SkillMultiplier).ToString(); if (gameObject.tag == "Warehouse") { GameSaveDataController.SetWarehouseState(); } else if (gameObject.tag == "Elevator") { GameSaveDataController.SetElevatorState(); } else if (GetGrandparentTag(this.transform) == "Shaft") { Shaft shaft = transform.parent.GetComponentInParent <Shaft>(); if (shaft != null) { GameSaveDataController.SetShaftState(shaft); } } }
public override void Unselect() { Shaft.Unselect(); LeftTip.Unselect(); RightTip.Unselect(); base.IsSelected = false; }
public override void Select() { Shaft.Select(); LeftTip.Select(); RightTip.Select(); base.IsSelected = true; }
public override void Colourise(Color colour) { Shaft.Colourise(colour); LeftTip.Colourise(colour); RightTip.Colourise(colour); base.Colour = colour; }
public SerializableShaft(Shaft shaft) : base(shaft) { _isUncapped = shaft.IsUncapped; _bottomLeftCorner = shaft.BottomLeftCorner; _topRightCorner = shaft.TopRightCorner; }
public async Task Pipeline() { var shaft = new Shaft <IGetBasket <int, Frog> >(new TestGetTerminal()) .Add(new TestGetStation1()) .Add(new TestGetStation2()); var basket = new GetBasket <int, Frog>(22); await shaft.SendAsync(basket).ConfigureAwait(false); Assert.Equal(22, basket.AscentPayload.Id); Assert.Equal("Frank21", basket.AscentPayload.Name); Assert.Equal(DateTime.Today, basket.AscentPayload.DateOfBirth); Assert.Equal(22, basket.DescentPayload); shaft = new Shaft <IGetBasket <int, Frog> >(new TestGetTerminal()) .Add(new TestGetStation2()) .Add(new TestGetStation1()); basket = new GetBasket <int, Frog>(33); await shaft.SendAsync(basket).ConfigureAwait(false); Assert.Equal(33, basket.AscentPayload.Id); Assert.Equal("Frank12", basket.AscentPayload.Name); Assert.Equal(DateTime.Today, basket.AscentPayload.DateOfBirth); Assert.Equal(33, basket.DescentPayload); }
public override void MoveTo(float xOrigin, float yOrigin) { Shaft.MoveTo(xOrigin, yOrigin); LeftTip.MoveTo(xOrigin, yOrigin); RightTip.MoveTo(xOrigin, yOrigin); base.MoveTo(xOrigin, yOrigin); }
public override void Rotate(float degrees) { //Debug.WriteLine($"Arrow Rotate called with argument degrees = {degrees}"); Shaft.Rotate(degrees); LeftTip = new Line(base.XOrigin, base.YOrigin, Shaft.Colour, base.PenSize, TipLength, Shaft.Orientation - 30); RightTip = new Line(base.XOrigin, base.YOrigin, Shaft.Colour, base.PenSize, TipLength, Shaft.Orientation + 30); base.Rotate(degrees); }
//[MenuItem("Tools/Clear PlayerPrefs")] //private static void ClearSavedData() //{ // PlayerPrefs.DeleteAll(); // Debug.Log("Cleared all saved data"); //} public static void SetBuyNextShaftState(Shaft shaft) { if (mineSaveData[currentMineIndex].shaftsInMine.Any(s => s.shaftId == shaft.name)) { ShaftSaveData matchingShaftData = mineSaveData[currentMineIndex].shaftsInMine .Where(s => s.shaftId == shaft.name).First(); matchingShaftData.nextShaftUnlocked = true; } }
public override void Resize(float xUnits, float yUnits) { Length = xUnits; TipLength = xUnits / 5; Shaft.Resize(xUnits, yUnits); LeftTip = new Line(base.XOrigin, base.YOrigin, Shaft.Colour, base.PenSize, TipLength, Shaft.Orientation - 30); RightTip = new Line(base.XOrigin, base.YOrigin, Shaft.Colour, base.PenSize, TipLength, Shaft.Orientation + 30); Select(); }
public Stack <Shaft> createPathFromShaftDistances(int x, int y) { Stack <Shaft> path = new Stack <Shaft>(); // Find shafts accessible from starting position Queue <Shaft> checkShafts = new Queue <Shaft>(getReachableShaftsAt(x, y)); int dist = int.MaxValue; Shaft nextShaft = null; // Go through each shaft in queue and find one with minimum distance while (checkShafts.Count > 0) { Shaft checkShaft = checkShafts.Dequeue(); // If ditance is less than current minimum distance found so far, update // minimum distance found so far and also the the next shaft to take if (checkShaft.distFromStart < dist && checkShaft.distFromStart > -1) { dist = checkShaft.distFromStart; nextShaft = checkShaft; } // If the queue is empty, then we've checked all shafts, add onto path // and get the next set of connected shafts if we haven't reached the end // Also check if the minimum found distance is zero, which means we can stop if (checkShafts.Count == 0 || dist == 0) { // If a shaft was not found, then that means we've hit a dead end, return // an empty path to signal that no path is possible if (nextShaft == null) { path.Clear(); return(path); } path.Push(nextShaft); // Add shaft with minimunm found distance to path // If the minimum found distance is 0, then we've reached the end if (dist == 0) { checkShafts.Clear(); break; } // Add connected shafts to queue foreach (Shaft shaft in nextShaft.connectedShafts) { checkShafts.Enqueue(shaft); } nextShaft = null; // Set nextShaft to null to initialize for next set of shafts } } return(path); }
public void SetShaft(Shaft shaft) { _shaft = shaft; if (!_shaft.Locked) { Shaftview.Unlock(); StartCoroutine(ProduceMoney()); } UpdateView(); }
public static int GetShaftSaveData(Shaft shaft) { if (mineSaveData[currentMineIndex].shaftsInMine.Any(s => s.shaftId == shaft.name)) { ShaftSaveData matchingShaftData = mineSaveData[currentMineIndex].shaftsInMine .Where(s => s.shaftId == shaft.name).First(); return(matchingShaftData.shaftUpgradePressCount); } return(0); }
private void GetShaftAndGo(Directions direction) { currentShaft = connectingShafts[(int)direction]; if (currentShaft == null || currentShaft.waypoints.Count == 0) { Debug.Log("No shaft detected in direction " + direction); } phase = ElevatorPhase.ElevatorMoving; currentWaypoint = 0; }
public static void CreateStartShaftData(Shaft start) { var shaftData = new ShaftSaveData() { shaftId = start.name, shaftUpgradePressCount = 0, nextShaftUnlocked = false }; mineSaveData[currentMineIndex].shaftsInMine.Add(shaftData); }
// remove a connection to another shaft public void disconnectShafts(Shaft removeShaft) { if (connectedShafts.Contains(removeShaft)) { connectedShafts.Remove(removeShaft); } if (removeShaft.connectedShafts.Contains(this)) { removeShaft.connectedShafts.Remove(this); } }
private void RemoveShaft(Shaft remove) { for (int i = 0; i < connectingShafts.Length; ++i) { if (connectingShafts[i] == remove) { connectingShafts[i] = null; connected[i] = null; return; } } }
// add connected shaft if it isn't in the list already public void connectShafts(Shaft addShaft) { if (!connectedShafts.Contains(addShaft)) { connectedShafts.Add(addShaft); } if (!addShaft.connectedShafts.Contains(this)) { addShaft.connectedShafts.Add(this); } }
public static void CreateNewMineData(Mine mine, Shaft startShaft) { MineSaveData newMineSaveData = new MineSaveData(); mineSaveData[currentMineIndex] = newMineSaveData; mineSaveData[currentMineIndex].hasSavedMine = true; mineSaveData[currentMineIndex].mineId = mine.name; mineSaveData[currentMineIndex].totalMoney = startMoney; CreateStartShaftData(startShaft); var playerPrefData = JsonUtility.ToJson(mineSaveData[currentMineIndex]); PlayerPrefs.SetString(saveKeyName, playerPrefData); }
public async Task Simple() { var shaft = new Shaft <IGetBasket <int, Frog> >(new TestGetTerminal(), null); var basket = new GetBasket <int, Frog>(18); await shaft.SendAsync(basket).ConfigureAwait(false); Assert.Equal(typeof(OkNote), basket.Note.GetType()); Assert.Equal(18, basket.AscentPayload.Id); Assert.Equal("Frank", basket.AscentPayload.Name); Assert.Equal(DateTime.Today, basket.AscentPayload.DateOfBirth); Assert.Equal(18, basket.DescentPayload); }
static void Main(string[] args) { Shaft s1 = new Shaft(8); Shaft s2 = !s1; Shaft s3 = new Shaft(s1); s3[1] = true; // System.Console.WriteLine("Shaft 1: {0}", s1); System.Console.WriteLine("Shaft 2: {0}", s2); System.Console.WriteLine("Shaft 3: {0}", s3); }
public async Task ReturnEarly() { var shaft = new Shaft <IGetBasket <int, Frog> >(new TestGetTerminal()) .Add(new TestGetStation1()) .Add(new TestGetStation2()) .Add(new TestGetStationReturnEarly()); var basket = new GetBasket <int, Frog>(22); await shaft.SendAsync(basket).ConfigureAwait(false); Assert.True(basket.Note is ReturnNote); Assert.Equal(22, basket.AscentPayload.Id); Assert.Equal("Early Frog", basket.AscentPayload.Name); Assert.Equal(DateTime.Today.AddDays(-1), basket.AscentPayload.DateOfBirth); }
public void updateShaftsConnections(Queue <Shaft> updatedShafts) { // Update connections Queue <Shaft> otherShafts; // Queue to hold other shafts while (updatedShafts.Count > 0) { Shaft shaft = updatedShafts.Dequeue(); otherShafts = new Queue <Shaft>(updatedShafts); // check connections with other shafts while (otherShafts.Count > 0) { shaft.checkAndUpdateConnection(otherShafts.Dequeue()); } } }
public override void InitOutfit() { WipeLayers(); // add a "wooden stake" to our loot Shaft WoodenStake = new Shaft(); WoodenStake.Hue = 51; WoodenStake.Name = "wooden stake"; PackItem(WoodenStake); // black backpack. we need a backpack so our walking-dead can be disarmed, and black is cool Backpack.Hue = 0x01; // add Scepter Scepter weapon = new Scepter(); // can disarm, but can't steal weapon.LootType = LootType.Newbied; // can't steal weapon.Movable = false; // can't disarm weapon.Name = "an impaler"; // give it a name AddItem(weapon); Item hair = new LongHair(1); Item pants = new LongPants(0x1); Item shirt = new FancyShirt(); hair.Layer = Layer.Hair; AddItem(hair); AddItem(pants); AddItem(shirt); Item necklace = new GoldNecklace(); AddItem(necklace); Item ring = new GoldRing(); AddItem(ring); Item bracelet = new GoldBracelet(); AddItem(bracelet); Item boots = new Sandals(0x1); AddItem(boots); }
public override void InitOutfit() { WipeLayers(); // black backpack. we need a backpack so our walking-dead can be disarmed, and black is cool Shaft WoodenStake = new Shaft(); WoodenStake.Hue = 51; WoodenStake.Name = "wooden stake"; PackItem(WoodenStake); Backpack.Hue = 0x01; if (Utility.RandomBool()) { AddItem(new Cleaver()); } else { AddItem(new ButcherKnife()); } // walking dead are naked if (this.Female) { Item hair = new Item(0x203C); if (Utility.RandomMinMax(0, 100) <= 20) //20% chance to have black hair { hair.Hue = 0x1; } else { hair.Hue = Utility.RandomHairHue(); } hair.Layer = Layer.Hair; AddItem(hair); } else { Item hair2 = new Item(Utility.RandomList(0x203C, 0x203B)); hair2.Hue = Utility.RandomHairHue(); hair2.Layer = Layer.Hair; AddItem(hair2); } }
// Enter monster, see where he needs to go public override bool Enter(Monster mon) { print("TEST"); if (mon.path.Count == 0) { mon.targetY = mon.targetRoom.cellY; } else { Shaft next = mon.path.Peek(); mon.targetY = getConnectionFloor(next, mon.floor); } mon.floor = cellY; monsters.Add(mon); updateSprite(); return(true); }
public void ShaftContainsTest() { var shaft = new Shaft(new IntVector2(-2, -2), new IntVector2(2, 2), false); for (var x = -5; x <= 5; x++) { for (var y = -5; y <= 5; y++) { var expectation = y >= -2 && y <= 2 && x >= -2 && x <= 2; var actual = shaft.Contains(new IntVector2(x, y)); Assert.AreEqual(actual, expectation, $"Position: [{x},{y}] | Expected: {expectation} | Actual: {actual}"); } } }
/* * Simulation starts at day 1 * 10 dwarfs are born in hospital * 35% - type 1 * 30% - type 2 * 25% - type 3 * 10% - type 4 * Dwarfs are going to Mine * Each dwarf rools on how much times he must go down to Shaft (1-3 times) * there are 2 Shafts * Each Shaft can contain up to 5 dwarf at one time. * Dwarfs go down and go up in same time. * Dwarfs can dig in Shaft and have chance to dig resources. * 50% - nothing * 20% - dirty gold * 15% - silver * 10% - gold * 5% - mithril * If dwarf type is 4 he destroy Shaft along which all dwarves inside. * Dwarf have 5% chance to slip when going out of Shaft and die. * When all dwarfs end thier work they are going to sell thier ores to canthine * 1g - dirty gold * 1,5g - silver * 5g - gold * 10g - mithril * Then all ores are stored inside storage. * Dwarves are paid from Village (canthine is inside village) * When dwarfs sell thier orbs they are going to shop to buy goods * type 1 - buying food * rest not buying anything that they can eat =( * type 1 - 100% of what he digged goes to store. * type 2 - 75% of what he digged goes to store. * type 3 - 0% of what he digged goes to store. * store money goes to village (it is in village) * If dwarf did not ate he begs for food from Village. * Dwarf have 90% chance to get food from base. * After day one all cycle repeats but hospital produces only one dwarf which 10% chance. * * Simulation conditions * When shaft is destroyed it takes 3 days to rebuild eg (1 shaft in day 1 takes 3 days, 2 shafts in day 1 takes 3 days) - each shaft is rebuilded in 3 days they do not queue * When all dwarves are dead at end of simulation game stops. * When food in base is emptied game stops. * When money in base is emptied game stops. * When 30 day pass on successfully game stops. * After each action log is generated, eg Dwarf x digged y, Dwarf x paid y for z, Dwarf x begged for food etc. * After end of day summary is generated, eg Dwarf has been born, 5 dwarfs died by shaft explosion, 1 dwarf died by slipping, canthine buyed x ores and payed y cash, shop sold x items and gethered y money etc. * * */ static void Main(string[] args) { Logger.logger = new LogToConsole(); IDwarfTypeRandomizer rand = new DwarfTypeRandomizer(); List <Dwarf> dwarfs = DwarvenFactory.Create10Dwarfs(); Shaft shaft = new Shaft(); while (true) { shaft.GoDownTheShaft(dwarfs); shaft.StartWorking(); if (shaft.IsDestoryed) { shaft.RebuildShaft(); } } }
public void checkAndUpdateConnection(Shaft otherShaft) { // Get range of overlapping floors int y1 = Math.Max(cellY, otherShaft.cellY); int y2 = Math.Min(cellY + height - 1, otherShaft.cellY + otherShaft.height - 1); // Assume shafts are not connected for now disconnectShafts(otherShaft); // For each floor, check if each elevator are within each other's reachable ranges // Technically they should be the same reachable ranges, however to be extra careful for (int i = y1; i <= y2; i++) { if (isReachable(otherShaft.cellX, i) && otherShaft.isReachable(cellX, i)) { connectShafts(otherShaft); break; // Then shafts are connected, can stop checking } } }
public void MeshRectangle(Shaft shaft, int NcntOX, int NcntOY) { //Количество узлов сетки int nodeCount = NcntOX * NcntOY; //Генерирование массива узлов nodes = new Node[nodeCount]; bondary = new Bondary(); double stepOX = shaft._lenght / ((double)NcntOX - 1); double stepOY = shaft._width / ((double)NcntOY - 1); double baseX = 0; double baseY = 0; int k = 0; for (int i = 0; i < NcntOY; i++) for (int j = 0; j < NcntOX; j++) { nodes[k] = new Node(baseX + j * stepOX, baseY + i * stepOY); if (j == 0) { bondary.left.Add(k); } else if (j == (NcntOX - 1)) { bondary.right.Add(k); } if (i == 0) { bondary.bottom.Add(k); } else if (i == (NcntOY - 1)) { bondary.top.Add(k); } k++; } //Формирование сетки //количество квадаратов int ElementCount = (NcntOX - 1) * (NcntOY - 1); elements = new ElementType.Trigle2D[ElementCount * 2]; k = 0; for (int i = 0; i < NcntOY - 1; i++) for (int j = 0; j < NcntOX - 1; j++) { elements[k] = new ElementType.Trigle2D(j + i * NcntOX, j + i * NcntOX + 1, (i + 1) * NcntOX + j); k++; elements[k] = new ElementType.Trigle2D((i + 1) * NcntOX + j + 1, (i + 1) * NcntOX + j, i * NcntOX + 1 + j); k++; } }
/// <summary> /// Рисует прямоугольник /// </summary> /// <param name="lenght"></param> /// <param name="width"></param> /// <param name="r"></param> /// <param name="g"></param> /// <param name="b"></param> /// <param name="depth"></param> public static void Rectangle(Shaft shaft, float depth) { Gl.glTranslatef(0.0f, 0.0f, depth); Gl.glBegin(Gl.GL_QUADS); Gl.glVertex3f((float)shaft._lenght, (float)shaft._width, 0); // Top Right Of The Quad (Front) Gl.glVertex3f(0, (float)shaft._width, 0); Gl.glVertex3f(0, 0, 0); // Bottom Left Of The Quad (Front) Gl.glVertex3f((float)shaft._lenght, 0, 0); Gl.glEnd(); }
/* public static void fixedLeft(Node pnt,float r, float g, float b) { Gl.glColor3f(r,g,b); Gl.glBegin(Gl.GL_TRIANGLES); Gl.glVertex2f((float)pnt.X,(float)pnt.Y); Gl.glVertex2f((float)pnt.X - 0.01f, (float)pnt.Y + 0.01f); Gl.glVertex2f((float)pnt.X - 0.01f, (float)pnt.Y - 0.01f); Gl.glEnd(); } public static void fixedRight(Node pnt, float r, float g, float b) { Gl.glColor3f(r, g, b); Gl.glBegin(Gl.GL_TRIANGLES); Gl.glVertex2f((float)pnt.X, (float)pnt.Y); Gl.glVertex2f((float)pnt.X + 0.01f, (float)pnt.Y - 0.01f); Gl.glVertex2f((float)pnt.X + 0.01f, (float)pnt.Y + 0.01f); Gl.glEnd(); } public static void LoadTop(Node pnt, float r, float g, float b) { Gl.glColor3f(r, g, b); Gl.glBegin(Gl.GL_TRIANGLES); Gl.glVertex2f((float)pnt.X, (float)pnt.Y); Gl.glVertex2f((float)pnt.X + 0.005f, (float)pnt.Y + 0.01f); Gl.glVertex2f((float)pnt.X - 0.005f, (float)pnt.Y + 0.01f); Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f); Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f + 0.05f); Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f); Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f ); Gl.glVertex2f((float)pnt.X + 0.002f, (float)pnt.Y + 0.01f + 0.05f); Gl.glVertex2f((float)pnt.X - 0.002f, (float)pnt.Y + 0.01f + 0.05f); Gl.glEnd(); }*/ public static void Shaft(Shaft shaft, float depth) { Gl.glTranslatef(0.0f, 0.0f, depth); //Gl.glClearColor(0.5f, 0.5f, 0.75f, 1.0f); // цвет фона //Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // очистка буфера цвета /*Gl.glEnable(Gl.GL_BLEND); Gl.glEnable(Gl.GL_ALPHA_TEST); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glPointSize(5); Gl.glEnable(Gl.GL_POINT_SMOOTH); // включаем режим сглаживания точек */ Gl.glBegin(Gl.GL_QUADS); Gl.glVertex3f((float)shaft._lenght, (float)shaft._width, 0); // Top Right Of The Quad (Front) Gl.glVertex3f(0, (float)shaft._width, 0); Gl.glVertex3f(0, 0, 0); // Bottom Left Of The Quad (Front) Gl.glVertex3f((float)shaft._lenght, 0, 0); /* Gl.glColor3f(0.0f, 0.0f, 0.0f); Gl.glVertex3f((float)shaft._lenght + (float)(shaft._lenght/50), (float)shaft._width*1.5f, 0); // Top Right Of The Quad (Front) Gl.glVertex3f((float)shaft._lenght, (float)shaft._width*1.5f, 0); Gl.glVertex3f((float)shaft._lenght, -(float)shaft._width*1.5f, 0); // Bottom Left Of The Quad (Front) Gl.glVertex3f((float)shaft._lenght + (float)(shaft._lenght / 50), -(float)shaft._width*1.5f, 0); Gl.glVertex3f(0, (float)shaft._width*1.5f, 0); // Top Right Of The Quad (Front) Gl.glVertex3f(- (float)(shaft._lenght / 50), (float)shaft._width*1.5f, 0); Gl.glVertex3f(-(float)(shaft._lenght / 50), -(float)shaft._width*1.5f, 0); // Bottom Left Of The Quad (Front) Gl.glVertex3f(0, -(float)shaft._width*1.5f, 0); */ Gl.glEnd(); }