// Use this for initialization void Start () { // Initiate Enemy RaycastHit raycastHit; if (Physics.Raycast(new Ray(transform.position, Physics.gravity), out raycastHit)) { GameObject gameObject = raycastHit.transform.gameObject; if (gameObject) { Pole pole = gameObject.GetComponent<Pole>(); if (pole) { currPole = pole; nextPole = currPole.GetNastepnik(); endDirection = nextPole.transform.position - currPole.transform.position; startDirection = endDirection;//wartosc umowna, moze wymyslimy lepiej z poprzednika; endPosition = (currPole.transform.position + nextPole.transform.position)*0.5f + new Vector3(0f, offsetY, 0f); startPosition = endPosition - endDirection; currentPercentOfPole = 0.5f; } } } }
private static void MoveTower(int height, Pole fromPole, Pole toPole, Pole withPole) { if (height == 0) return; MoveTower(height - 1, fromPole, withPole, toPole); MoveDisk(fromPole, toPole); MoveTower(height - 1, withPole, toPole, fromPole); }
private static void MoveDisk(Pole fromPole, Pole toPole) { Console.WriteLine("---"); Console.WriteLine("From: " + fromPole.Name); Console.WriteLine("To: " + toPole.Name); Console.WriteLine("---"); toPole.AddDisk(fromPole.RemoveDisk()); }
public void RemoveHitPole(Pole pole) { hitList.Remove(pole); if (hitList.Count != 0) { return; } if (playerIsOn) { Debug.LogWarning("Player is on"); SetColor(Status.Highlighted); canControl = true; } else { Debug.LogWarning("Player not on"); SetColor(Status.Running); } }
void ChangePolarity() { if (Input.GetAxisRaw("Fire1") == 1 && !lTriggerDown) { red.SetActive(true); polarity = Pole.RED; lTriggerDown = true; blue.SetActive(false); } if (Input.GetAxisRaw("Fire2") == 1 && !rTriggerDown) { blue.SetActive(true); rTriggerDown = true; polarity = Pole.BLUE; red.SetActive(false); } if (Input.GetAxisRaw("Fire1") == 0 && lTriggerDown) { red.SetActive(false); if (!rTriggerDown) { polarity = Pole.NONE; } lTriggerDown = false; } if (Input.GetAxisRaw("Fire2") == 0 && rTriggerDown) { blue.SetActive(false); if (!lTriggerDown) { polarity = Pole.NONE; } rTriggerDown = false; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("PoleTop")) { Pole pole = other.transform.parent.GetComponent <Pole>(); bool wasGoalPole = gameManager.OnPoleReached(pole); if (wasGoalPole) { canRotate = true; } else { if (gameManager.IsFirstPole(pole) && !hasTouchedFirstPole) { hasTouchedFirstPole = true; } else { gameManager.OnPlayerDied(); } } } }
static void Main(string[] args) { var fromPole = new Pole("from"); var toPole = new Pole("to"); var withPole = new Pole("with"); fromPole.AddDisk(3); fromPole.AddDisk(2); fromPole.AddDisk(1); fromPole.Print(); toPole.Print(); withPole.Print(); MoveTower(3, fromPole, toPole, withPole); Console.WriteLine(); fromPole.Print(); toPole.Print(); withPole.Print(); Console.WriteLine(); Console.WriteLine("Tower Moved Successfully"); Console.Read(); }
private void Move() { if (selectedDisk != null && selectedPole != null) { if (selectedPole.Deck.Count == 0) { PushinPole(); selectedDisk.locate = selectedPole; selectedDisk = null; selectedPole = null; } else if (selectedDisk.Size < selectedPole.Deck.Peek().Size) { PushinPole(); selectedDisk.locate = selectedPole; selectedDisk = null; selectedPole = null; } else if (selectedDisk.Size > selectedPole.Deck.Peek().Size) { Debug.Log("不可以這樣放"); } } }
private void DrawPoles(DxRenderContext renderContext, Cell cell, float normalizer) { SlimDX.Direct3D11.Device device = DeviceContext.Device; DxMesh sphere = Meshes.GetMesh("sphere"); SetMesh(device, sphere); Pole[] poles = { cell.GetPole(PoleType.Left), cell.GetPole(PoleType.Right) }; Material[] materials = { renderContext.StyleAspect.Resolve <PoleStyle>(poles[0]).LeftPole, renderContext.StyleAspect.Resolve <PoleStyle>(poles[1]).RightPole }; for (int i = 0; i < 2; i++) { ConstBuffer.Material = materials[i]; Pole pole = poles[i]; float radius = (float)renderContext.StyleAspect.Resolve <PoleStyle>(pole).Radius; Matrix transform = Matrix.Scaling(radius, radius, radius); transform *= Matrix.Translation((float)pole.Position.X * normalizer, (float)pole.Position.Y * normalizer, (float)pole.Position.Z * normalizer); ConstBuffer.World = Matrix.Transpose(transform); SetBuffer(device, ConstBuffer); DrawMesh(device, sphere); } }
public PoleViewModels GetForEmployee(string id) { Pole pole = Repository.GetForEmployee(id); return(pole == null ? null : Mapper.DataToModel(pole)); }
private void AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false) { InputActionButton uiButton; if (!showInvert) { uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputActionButtonPrefab); } else { uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputAxisActionButtonPrefab); } uiButton._label.text = elementMap.elementIdentifierName; uiButton._actionElementMap = elementMap; uiButton._button.onClick.Add(new EventDelegate(delegate { if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup) { if (UICamera.currentTouchID == -1) { this._replaceElementMap = true; this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert); this._entry.controllerMap = controllerMap; this._entry.uiButton = uiButton; this.StartPollInput(); } else if (UICamera.currentTouchID == -2) { this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert); controllerMap.DeleteElementMap(this._entry.actionElementMapId); this._knownActionMaps.Remove(elementMap); UnityEngine.Object.Destroy(uiButton.gameObject); uiRow._actionGrid.repositionNow = true; Dictionary<InputActionRow, int> actionRowMappingCount2; Dictionary<InputActionRow, int> expr_181 = actionRowMappingCount2 = this._actionRowMappingCount; InputActionRow uiRow3; InputActionRow expr_189 = uiRow3 = uiRow; int num2 = actionRowMappingCount2[uiRow3]; expr_181[expr_189] = num2 - 1; this.CheckActionMappingCount(uiRow); this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay; } } })); if (showInvert) { uiButton._invertAxisToggle.gameObject.SetActive(true); uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert; uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate { if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup) { uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value; } })); } uiButton.transform.parent = uiRow._actionGrid.transform; uiButton.transform.localPosition = Vector3.zero; uiButton.transform.localScale = Vector3.one; this._knownActionMaps.Add(elementMap, uiButton); Dictionary<InputActionRow, int> actionRowMappingCount; Dictionary<InputActionRow, int> expr_18C = actionRowMappingCount = this._actionRowMappingCount; InputActionRow uiRow2; InputActionRow expr_194 = uiRow2 = uiRow; int num = actionRowMappingCount[uiRow2]; expr_18C[expr_194] = num + 1; }
public Pole(Pole p, KolorPola kolor_pola) : this(p.xmin, p.xmax, p.ymin, p.ymax) { kolor = kolor_pola; }
public void TestInitialize() { Pole = Pole.getInstance(); Pole.NewState(4); }
public Pole ModelToData(Pole pole, PoleViewModels model) { pole.Name = model.Name; pole.Manager_ID = new Guid(model.ManagerId); return(pole); }
public void Save(Pole p) { mBMSEntities.Poles.Add(p); mBMSEntities.SaveChanges(); }
internal Rail(Rail previous) { this.Index = previous.Index; this.Status = previous.Status; this.Updated = false; this.StartX = previous.EndX; this.StartY = previous.EndY; this.EndX = previous.EndX; this.EndY = previous.EndY; this.Type = previous.Type; this.WallType = previous.WallType; this.WallSide = previous.WallSide; this.DikeType = previous.DikeType; this.DikeSide = previous.DikeSide; this.Pole = previous.Pole; this.Forms = null; this.FormCount = 0; this.Cracks = null; this.CrackCount = 0; this.FreeObjs = null; this.FreeObjCount = 0; this.Beacons = null; this.BeaconCount = 0; this.Stops = null; this.StopCount = 0; this.Limits = null; this.LimitCount = 0; }
// Update is called once per frame void Update () { float deltaPercentOfPole = Speed * Time.deltaTime; if (currPole.isSchody) deltaPercentOfPole *= 0.5f; currentPercentOfPole += deltaPercentOfPole; if (currentPercentOfPole > 1.0f) { currentPercentOfPole = currentPercentOfPole - 1.0f; startDirection = endDirection; startPosition = endPosition; currPole = nextPole; nextPole = currPole.GetNastepnik(); endPosition = (currPole.transform.position + nextPole.transform.position) * 0.5f + new Vector3(0f, offsetY, 0f); endDirection = nextPole.transform.position - currPole.transform.position; if (nextPole.isSchody) //jesli to schody { endPosition.y = startPosition.y; //endDirection.y = 0.0f; } else if (currPole.isSchody) { endPosition.y = nextPole.transform.position.y + 0.75f; //startDirection = endPosition - startPosition; endDirection = endPosition - startPosition; } } Vector3 currentDirection; if (!this.currPole.isSchody) { Vector3 midPoint = startPosition + startDirection * 0.5f; Vector3 newPosition = startPosition * (1f - currentPercentOfPole) * (1f - currentPercentOfPole) + midPoint * 2f * (1f - currentPercentOfPole) * currentPercentOfPole + endPosition * currentPercentOfPole * currentPercentOfPole; if (this.humanoid) newPosition.y = Mathf.Lerp(startPosition.y, endPosition.y, currentPercentOfPole); this.transform.position = newPosition; } else { this.transform.position = Vector3.Lerp(startPosition,endPosition,currentPercentOfPole); } currentDirection = Vector3.Lerp(startDirection, endDirection, currentPercentOfPole); if (nextPole.isSchody) { currentDirection.y = startDirection.y; const float threshold = 0.6f; if(currentPercentOfPole > threshold) { currentDirection.y = Mathf.Lerp(startDirection.y, endDirection.y, (currentPercentOfPole - threshold) / (1f - threshold)); } } if (this.humanoid) currentDirection.y = 0.0f; this.transform.LookAt(this.transform.position + currentDirection); // this.transform.position = startPosition + startDirection* // Vector3.Lerp(startPosition, endPosition, currentPercentOfPole);//startPosition + Vector3.Lerp(startDirection, endDirection, currentPercentOfPole); /* RaycastHit raycastHit; if (Physics.Raycast(new Ray(transform.position, Physics.gravity), out raycastHit)) { GameObject gameObject = raycastHit.transform.gameObject; if (gameObject) { Pole pole = gameObject.GetComponent<Pole>(); if (pole) { if (currPole == null && nextPole == null) nextPole = pole; else if (currPole != null && nextPole == null) nextPole = currPole.GetNastepnik(); } } } if (nextPole) { Vector3 srcPos = transform.position; Vector3 dstPos = nextPole.transform.position + new Vector3(0f, 0.75f, 0f); Vector3 move = dstPos - srcPos; // Not yet reached destination. if (move.sqrMagnitude > Mathf.Epsilon) { transform.LookAt(dstPos); float distance = Speed * Time.deltaTime; if (distance * distance < move.sqrMagnitude) { move.Normalize(); move *= distance; } transform.position = srcPos + move; } // Already reached destination. else { currPole = nextPole; nextPole = null; } }*/ Debug.DrawRay( startPosition, startDirection * 0.25f, Color.green, 0f, false); Debug.DrawRay( endPosition, endDirection * 0.25f, Color.red, 0f, false); }
private void DrawAddActionMapButton(int playerId, InputAction action, Pole actionAxisContribution, ControlRemappingDemo1.ControllerSelection controller, ControllerMap controllerMap, bool assignFullAxis) { if (GUILayout.Button("Add...", new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { this.EnqueueAction(new ControlRemappingDemo1.ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap, ControlRemappingDemo1.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false)); } GUILayout.Space(10f); }
private void DrawInvertButton(int playerId, InputAction action, Pole actionAxisContribution, ControlRemappingDemo1.ControllerSelection controller, ControllerMap controllerMap, ActionElementMap elementMap) { bool invert = elementMap.invert; bool flag = GUILayout.Toggle(invert, "Invert", new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); if (flag != invert) { elementMap.invert = flag; } GUILayout.Space(10f); }
private void AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false) { InputActionButton uiButton; if (!showInvert) { uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputActionButtonPrefab); } else { uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputAxisActionButtonPrefab); } uiButton._label.text = elementMap.elementIdentifierName; uiButton._actionElementMap = elementMap; uiButton._button.onClick.Add(new EventDelegate(delegate { if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup) { if (UICamera.currentTouchID == -1) { this._replaceElementMap = true; this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert); this._entry.controllerMap = controllerMap; this._entry.uiButton = uiButton; this.StartPollInput(); } else if (UICamera.currentTouchID == -2) { this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert); controllerMap.DeleteElementMap(this._entry.actionElementMapId); this._knownActionMaps.Remove(elementMap); UnityEngine.Object.Destroy(uiButton.gameObject); uiRow._actionGrid.repositionNow = true; Dictionary <InputActionRow, int> actionRowMappingCount2; Dictionary <InputActionRow, int> expr_181 = actionRowMappingCount2 = this._actionRowMappingCount; InputActionRow uiRow3; InputActionRow expr_189 = uiRow3 = uiRow; int num2 = actionRowMappingCount2[uiRow3]; expr_181[expr_189] = num2 - 1; this.CheckActionMappingCount(uiRow); this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay; } } })); if (showInvert) { uiButton._invertAxisToggle.gameObject.SetActive(true); uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert; uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate { if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup) { uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value; } })); } uiButton.transform.parent = uiRow._actionGrid.transform; uiButton.transform.localPosition = Vector3.zero; uiButton.transform.localScale = Vector3.one; this._knownActionMaps.Add(elementMap, uiButton); Dictionary <InputActionRow, int> actionRowMappingCount; Dictionary <InputActionRow, int> expr_18C = actionRowMappingCount = this._actionRowMappingCount; InputActionRow uiRow2; InputActionRow expr_194 = uiRow2 = uiRow; int num = actionRowMappingCount[uiRow2]; expr_18C[expr_194] = num + 1; }
public ElementAssignmentChange(int playerId, InputMappingAction.ElementAssignmentChangeType changeType, int actionElementMapId, int actionId, Pole actionAxisContribution, InputActionType actionType, bool assignFullAxis, bool invert) { this.playerId = playerId; this.changeType = changeType; this.actionElementMapId = actionElementMapId; this.actionId = actionId; this.actionAxisContribution = actionAxisContribution; this.actionType = actionType; this.assignFullAxis = assignFullAxis; this.invert = invert; }
private void InitAddActionMapButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, bool assignFullAxis) { uiRow._addButton.onClick.Add(new EventDelegate(delegate { if (this._actionRowMappingCount[uiRow] < this._maxMappingPerAction && UICamera.currentTouchID == -1 && !this.enabled) { this._replaceElementMap = false; this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false); this._entry.uiRow = uiRow; this.StartPollInput(); } })); }
IEnumerator AnimateMove(Disc disc, Pole from, Pole to) { yield return(new WaitForSeconds(1f / (1 + Mathf.Pow(3, discCount) / 56))); disc.transform.position = to.transform.position + to.discLocation + Vector3.up * (to.discs.Count - 1) * discHeight; }
private bool SaveMeterUnitCollection(List <NodeMeter> data) { ErrorList.Clear(); DateTime fromDate = dtpfromDate.Value.Date; DateTime toDate = dtptoDate.Value.Date; string transformerId = string.Empty; if (!cboTransformer.SelectedValue.Equals("0")) { transformerId = cboTransformer.SelectedValue.ToString(); } bool checkData = false; if (!string.IsNullOrEmpty(transformerId)) { checkData = mbmsEntities.MeterBills.Any(x => EntityFunctions.TruncateTime(x.InvoiceDate) >= fromDate && EntityFunctions.TruncateTime(x.InvoiceDate) <= toDate && x.MeterUnitCollect.TransformerID == transformerId); } else { checkData = mbmsEntities.MeterBills.Any(x => EntityFunctions.TruncateTime(x.InvoiceDate) >= fromDate && EntityFunctions.TruncateTime(x.InvoiceDate) <= toDate); } if (checkData) { MessageBox.Show("Bill Units can't re-collect because data is already calculated and printed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } try { List <MBMS.DAL.MeterUnitCollect> meterUnitCollectList = new List <MBMS.DAL.MeterUnitCollect>(); foreach (NodeMeter item in data) { MBMS.DAL.MeterUnitCollect meterUnit = new MBMS.DAL.MeterUnitCollect(); Customer customerinfo = mbmsEntities.Customers.Where(x => x.CustomerCode == item.nod_csm_id && x.Active == true).SingleOrDefault();//eg >>450-050-545-450-TPYTR05-00000428 if (customerinfo == null) { ErrorList.Append("Set customer record for :" + item.nod_csm_id); MessageBox.Show(ErrorList.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } meterUnit.MeterUnitCollectID = Guid.NewGuid().ToString(); meterUnit.CustomerID = customerinfo.CustomerID; string y = item.nod_bill_from; string m = item.nod_bill_from; string d = item.nod_bill_from; meterUnit.FromDate = item.nod_bill_from == ""?dtpfromDate.Value:Convert.ToDateTime(y.Substring(0, 4) + "-" + m.Substring(4, 2) + "-" + d.Substring(6, 2)); meterUnit.ToDate = item.nod_bill_to == ""?dtptoDate.Value:Convert.ToDateTime(item.nod_bill_to); meterUnit.TotalMeterUnit = (decimal)item.nod_pres_eng; meterUnit.BillMonth = (int)item.nod_bill_month; Transformer transformer = mbmsEntities.Transformers.Where(x => x.QuarterID == customerinfo.QuarterID && x.Active == true).SingleOrDefault(); if (transformer == null) { ErrorList.Append("Set transformer record for :" + customerinfo.Quarter.QuarterNameInEng); MessageBox.Show(ErrorList.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } meterUnit.TransformerID = transformer.TransformerID; Pole p = mbmsEntities.Poles.Where(x => x.TransformerID == transformer.TransformerID && x.Active == true).SingleOrDefault(); if (p == null) { ErrorList.Append("Set Pole record for :" + customerinfo.Quarter.QuarterNameInEng); MessageBox.Show(ErrorList.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } meterUnit.PoleID = p.PoleID; meterUnit.MeterID = customerinfo.MeterID; meterUnit.GPSX = Convert.ToDecimal(item.nod_gps_h); meterUnit.GPSY = Convert.ToDecimal(item.nod_gps_l); meterUnit.MeterStatus = item.nod_status; meterUnit.OMRModelNo = item.nod_model; meterUnit.DigitalModelNo = item.nod_model; meterUnit.BillCode = customerinfo.BillCode7Layer.BillCode7LayerNo.ToString(); meterUnit.Active = true; meterUnit.CreatedDate = DateTime.Now; meterUnit.CreatedUserID = UserID; meterUnitCollectList.Add(meterUnit); } iMeterUnitColleciton.MeterUnitCollectionsProces(meterUnitCollectList); return(true); } catch (Exception ex) { MessageBox.Show("Error occur" + ex.Message, "Error"); return(false); } }
public void GenerateTowers() { Pole currentRaytracedField = GetCurrentlyRaytracedField(); if (currentRaytracedField != null) { if (!currentRaytracedField.poleNaWieze ) { return; } if(currentRaytracedField != lastRaytracedField) { if(lastRaytracedField) { lastRaytracedField.GetComponent<Renderer>().material = normalMaterial; } lastRaytracedField = currentRaytracedField; } // If there is some tower on the field - don't add new tower here. if( currentRaytracedField.tower != null ) { return; } Renderer renderer = currentRaytracedField.gameObject.GetComponent<Renderer>(); renderer.material = highlightedMat; if (!Input.GetMouseButtonDown(0)) { return; } Tower.TowerType towerType = Tower.TowerType.MAGE_TOWER; Vector3 fieldPos = currentRaytracedField.gameObject.transform.position; Vector3 towerPos = new Vector3(); Quaternion towerRotation = Quaternion.Euler(0, 0, 0); // Choose appropiate prefab. Tower tower = null; switch (towerType) { case Tower.TowerType.CANNON_TOWER: { if (cannonTower == null) { return; } towerPos = new Vector3(fieldPos.x, fieldPos.y + 1.55f, fieldPos.z + 1.7f); tower = cannonTower; tower.damage = 10; tower.fireSpeed = 1; break; } case Tower.TowerType.FIRE_TOWER: { if (fireTower == null) { return; } towerPos = new Vector3(fieldPos.x, fieldPos.y + 1.55f, fieldPos.z + 1.7f); tower = fireTower; tower.damage = 30; tower.fireSpeed = 3; break; } case Tower.TowerType.GHOST_TOWER: { if (ghostTower == null) { return; } towerPos = new Vector3(fieldPos.x + 0.21f, fieldPos.y + 0.79f, fieldPos.z + 0.38f); tower = ghostTower; tower.damage = 60; tower.fireSpeed = 6; break; } case Tower.TowerType.MAGE_TOWER: { if (mageTower == null) { return; } towerPos = new Vector3(fieldPos.x, fieldPos.y + 0.5f, fieldPos.z - 0.02f); tower = mageTower; tower.damage = 100; tower.fireSpeed = 10; break; } } Tower newTower = Instantiate(tower, towerPos, towerRotation) as Tower; tower.gameController = gameController; tower.range = 100; tower.fireSpeed = 0.5f; currentRaytracedField.tower = tower; renderer.material = normalMaterial; lastRaytracedField = null; newTower.gameObject.transform.parent = currentRaytracedField.transform; } }
public ElementAssignmentChange( int playerId, int controllerId, ControllerType controllerType, ControllerMap controllerMap, ElementAssignmentChangeType changeType, int actionElementMapId, int actionId, Pole actionAxisContribution, InputActionType actionType, bool assignFullAxis, bool invert ) : base(QueueActionType.ElementAssignment) { this.playerId = playerId; this.controllerId = controllerId; this.controllerType = controllerType; this.controllerMap = controllerMap; this.changeType = changeType; this.actionElementMapId = actionElementMapId; this.actionId = actionId; this.actionAxisContribution = actionAxisContribution; this.actionType = actionType; this.assignFullAxis = assignFullAxis; this.invert = invert; }
private static bool czyStoiPionekNaTymPolu(Pole p, List <Pionek> tablica) { return(tablica.Where((pionek) => pionek.Wiersz == p.Wiersz && pionek.Kolumna == p.Kolumna).Count() != 0); }
private void DrawInvertButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap, ActionElementMap elementMap) { bool value = elementMap.invert; bool newValue = GUILayout.Toggle(value, "Invert", GUILayout.ExpandWidth(false)); if(newValue != value) { elementMap.invert = newValue; } GUILayout.Space(10); }
private void btnSave2HHUDB_Click(object sender, EventArgs e) { if (meterList.Count == 0) { MessageBox.Show("There is no Meter data to save HHU db file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cbofileName.SelectedItem.Equals("Select One")) { MessageBox.Show("Select HHU db file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult ok = MessageBox.Show("are you sure to save data?", "information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ok == DialogResult.Yes) { BuildSQLiteConnection(); MetersServices sqlitemetersservices = new MetersServices(); List <MPS.SQLiteHelper.Meters> sqlpoleList = new List <MPS.SQLiteHelper.Meters>(); string sqlCommand = string.Format("SELECT * FROM Meters"); var data = sqlitemetersservices.GetAll(sqlCommand); foreach (var v in data) { foreach (Meter m in meterList) { if (m.MeterNo == v.mtr_id) { MessageBox.Show("(" + m.MeterNo + ") Meter code already exists in HHU db file.", "information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } foreach (Meter m in meterList) { MPS.SQLiteHelper.Meters meter = new MPS.SQLiteHelper.Meters(); meter.mtr_id = m.MeterNo; meter.mtr_inst = m.InstalledDate.ToString(); meter.mtr_make = m.ManufactureBy; meter.mtr_model = m.Model.ToString(); meter.mtr_create = m.CreatedDate.ToString(); Customer c = mbmsEntities.Customers.Where(x => x.MeterID == m.MeterID).SingleOrDefault(); if (c == null) { MessageBox.Show("set customer data for>" + m.MeterNo, "information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } meter.mtr_csm_id = mbmsEntities.Customers.Where(x => x.MeterID == m.MeterID).SingleOrDefault().CustomerCode; Pole p = mbmsEntities.Poles.Where(x => x.Transformer.QuarterID == c.QuarterID).SingleOrDefault(); if (p == null) { MessageBox.Show("set Pole data for>" + m.MeterNo, "information", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } meter.mtr_pole = p.PoleNo; sqlpoleList.Add(meter); } try { sqlitemetersservices.AddRange(sqlpoleList); MessageBox.Show("Meters data to HHU db file is successfully saved.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Error occur when saving Meters to HHU db file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public async Task <Pole> SavePole(Pole pole) { return(await _polesRepository.UpdateOneAsync(pole)); }
public MainWindow() { InitializeComponent(); DataContext = new Pole(); DataGrid.MouseLeftButtonUp += ((Pole)DataContext).Click; }
void Calculate() { exportLists.ForEach(e => e.List.Clear()); //clear all vector map data before calculate //list of target transforms var targetList = new List <Transform>(); var noTarget = true; foreach (var t in targets) { if (t != null) { noTarget = false; targetList.Add(t); } } if (noTarget) { targetList.Add(transform); } //initial collection var segBldrs = new List <VectorMapSegmentBuilder>(); var signalLightPoles = new List <VectorMapPole>(); foreach (var t in targetList) { if (t == null) { continue; } var vmsb = t.GetComponentsInChildren <VectorMapSegmentBuilder>(); var vmp = t.GetComponentsInChildren <VectorMapPole>(); segBldrs.AddRange(vmsb); signalLightPoles.AddRange(vmp); } bool missingPoints = false; var allSegs = new HashSet <VectorMapSegment>(); //All segments regardless of segment actual type //connect builder reference for each segment foreach (var segBldr in segBldrs) { segBldr.segment.builder = segBldr; allSegs.Add(segBldr.segment); } //Link before and after segment for each segment foreach (var segment in allSegs) { //Make sure clear everything that might have data left over by previous generation segment.befores.Clear(); segment.afters.Clear(); segment.targetWorldPositions.Clear(); //this is to avoid accidentally connect two nearby stoplines if ((segment.builder as VectorMapStopLineSegmentBuilder) != null) { continue; } //each segment must have at least 2 waypoints for calculation so complement to 2 waypoints as needed while (segment.targetLocalPositions.Count < 2) { segment.targetLocalPositions.Add(Vector3.zero); missingPoints = true; } var firstPt = segment.builder.transform.TransformPoint(segment.targetLocalPositions[0]); var lastPt = segment.builder.transform.TransformPoint(segment.targetLocalPositions[segment.targetLocalPositions.Count - 1]); foreach (var segment_cmp in allSegs) { if (segment_cmp.builder.GetType() != segment.builder.GetType()) { continue; } var firstPt_cmp = segment_cmp.builder.transform.TransformPoint(segment_cmp.targetLocalPositions[0]); var lastPt_cmp = segment_cmp.builder.transform.TransformPoint(segment_cmp.targetLocalPositions[segment_cmp.targetLocalPositions.Count - 1]); if ((firstPt - lastPt_cmp).magnitude < PROXIMITY) { segment.befores.Add(segment_cmp); } if ((lastPt - firstPt_cmp).magnitude < PROXIMITY) { segment.afters.Add(segment_cmp); } } } if (missingPoints) { Debug.Log("Some segment has less than 2 waypoints, complement it to 2"); } var allLnSegs = new HashSet <VectorMapSegment>(); var allLinSegs = new HashSet <VectorMapSegment>(); foreach (var segment in allSegs) { if (segment.builder.GetType() == typeof(VectorMapLaneSegmentBuilder)) { allLnSegs.Add(segment); } if (segment.builder.GetType() == typeof(VectorMapStopLineSegmentBuilder)) { allLinSegs.Add(segment); } if (segment.builder.GetType() == typeof(VectorMapWhiteLineSegmentBuilder)) { allLinSegs.Add(segment); } } //New sets for newly converted(to world space) segments var allConvertedLnSeg = new HashSet <VectorMapSegment>(); //for lane segments var allConvertedLinSeg = new HashSet <VectorMapSegment>(); //for line segments //Filter and convert all lane segments if (allLnSegs.Count > 0) { var startLnSegs = new HashSet <VectorMapSegment>(); //The lane segments that are at merging or forking or starting position var visitedLnSegs = new HashSet <VectorMapSegment>(); //tracking for record foreach (var lnSeg in allLnSegs) { if (lnSeg.befores.Count != 1 || (lnSeg.befores.Count == 1 && lnSeg.befores[0].afters.Count > 1)) //no any before segments { startLnSegs.Add(lnSeg); } } foreach (var startLnSeg in startLnSegs) { ConvertAndJointSegmentSet(startLnSeg, allLnSegs, allConvertedLnSeg, visitedLnSegs); } while (allLnSegs.Count > 0)//Remaining should be isolated loops { VectorMapSegment pickedSeg = null; foreach (var lnSeg in allLnSegs) { pickedSeg = lnSeg; break; } if (pickedSeg != null) { ConvertAndJointSegmentSet(pickedSeg, allLnSegs, allConvertedLnSeg, visitedLnSegs); } } } //convert all line segments if (allLinSegs.Count > 0) { //setup world positions and their proper befores and afters for all line segments foreach (var linSeg in allLinSegs) { var convertedSeg = new VectorMapSegment(); convertedSeg.builder = linSeg.builder; foreach (var localPos in linSeg.targetLocalPositions) { convertedSeg.targetWorldPositions.Add(linSeg.builder.transform.TransformPoint(localPos)); //Convert to world position } convertedSeg.befores = linSeg.befores; convertedSeg.afters = linSeg.afters; foreach (var beforeSeg in convertedSeg.befores) { for (int i = 0; i < beforeSeg.afters.Count; i++) { if (beforeSeg.afters[i] == linSeg) { beforeSeg.afters[i] = convertedSeg; } } } foreach (var afterSeg in convertedSeg.afters) { for (int i = 0; i < afterSeg.befores.Count; i++) { if (afterSeg.befores[i] == linSeg) { afterSeg.befores[i] = convertedSeg; } } } allConvertedLinSeg.Add(convertedSeg); } } //set up all lanes vector map data var lnSegTerminalIDsMapping = new Dictionary <VectorMapSegment, int[]>(); //tracking for record if (allConvertedLnSeg.Count > 0) { foreach (var lnSeg in allConvertedLnSeg) { List <Vector3> positions; List <LaneInfo> laneInfos; var cast = (lnSeg as VectorMapLaneSegment); List <LaneInfo> waypointLaneInfos = (cast == null ? new List <LaneInfo>(new LaneInfo[lnSeg.targetWorldPositions.Count]) : cast.laneInfos); //Interpolate based on waypoint world positions VectorMapUtility.Interpolate(lnSeg.targetWorldPositions, waypointLaneInfos, out positions, out laneInfos, 1.0f / exportScaleFactor, true); //interpolate and divide to ensure 1 meter apart lnSegTerminalIDsMapping.Add(lnSeg, new int[2]); for (int i = 0; i < positions.Count; i++) { //Point var pos = positions[i]; var vectorMapPos = GetVectorMapPosition(pos); var vmPoint = Point.MakePoint(points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); points.Add(vmPoint); //DtLane var deltaDir = Vector3.zero; if (i < positions.Count - 1) { deltaDir = positions[i + 1] - pos; } else { if (lnSeg.afters.Count > 0) { deltaDir = lnSeg.afters[0].targetWorldPositions[0] - pos; } else { deltaDir = pos - positions[i - 1]; } } Vector3 eulerAngles = Quaternion.FromToRotation(Vector3.right, deltaDir).eulerAngles; var convertedEulerAngles = VectorMapUtility.GetRvizCoordinates(eulerAngles); var vmDTLane = DtLane.MakeDtLane(dtLanes.Count + 1, i, vmPoint.PID, -convertedEulerAngles.z * Mathf.Deg2Rad, .0, .1, .1); dtLanes.Add(vmDTLane); //Lane int beforeLaneID = 0; int laneId = lanes.Count + 1; if (i > 0) { beforeLaneID = lanes.Count; var beforeLane = lanes[beforeLaneID - 1]; beforeLane.FLID = laneId; lanes[beforeLaneID - 1] = beforeLane; //This is needed for struct copy to be applied back } var vmLane = Lane.MakeLane(laneId, vmDTLane.DID, beforeLaneID, 0, laneInfos[i].laneCount, laneInfos[i].laneNumber); lanes.Add(vmLane); if (i == 0) { lnSegTerminalIDsMapping[lnSeg][(int)TerminalType.START] = vmLane.LnID; } if (i == positions.Count - 1) { lnSegTerminalIDsMapping[lnSeg][(int)TerminalType.END] = vmLane.LnID; } } } //Assuming merging and diversing won't happen at the same spot //correcting start and end lanes's BLID and FLID to the lane segment's before and after lane IDs in other lane segments //each lane will have up to 4 before lane Ids and after lane Ids to set, later executed operation will be ignore if number exceeds 4 //correcting DtLanes last lane's dir value foreach (var lnSeg in allConvertedLnSeg) { var terminalIdPair = lnSegTerminalIDsMapping[lnSeg]; if (lnSeg.befores.Count > 0) { var segStartId = terminalIdPair[(int)TerminalType.START]; var ln = lanes[segStartId - 1]; for (int i = 0; i < lnSeg.befores.Count; i++) { int beforeSegAfterLn = lnSegTerminalIDsMapping[lnSeg.befores[i]][(int)TerminalType.END]; //chose the BLID that has not been set to meaningful lane id if (ln.BLID == 0) { ln.BLID = beforeSegAfterLn; } else if (ln.BLID2 == 0) { ln.BLID2 = beforeSegAfterLn; //ln.JCT = 3; //means merging } else if (ln.BLID3 == 0) { ln.BLID3 = beforeSegAfterLn; } else if (ln.BLID4 == 0) { ln.BLID4 = beforeSegAfterLn; } } lanes[segStartId - 1] = ln; } if (lnSeg.afters.Count > 0) { var segEndId = terminalIdPair[(int)TerminalType.END]; var ln = lanes[segEndId - 1]; int afterSegStartLn = lnSegTerminalIDsMapping[lnSeg.afters[0]][(int)TerminalType.START]; for (int i = 0; i < lnSeg.afters.Count; i++) { afterSegStartLn = lnSegTerminalIDsMapping[lnSeg.afters[i]][(int)TerminalType.START]; //chose the FLID that has not been set to meaningful lane id if (ln.FLID == 0) { ln.FLID = afterSegStartLn; } else if (ln.FLID2 == 0) { ln.FLID2 = afterSegStartLn; ln.JCT = 1; //means branching } else if (ln.FLID3 == 0) { ln.FLID3 = afterSegStartLn; } else if (ln.FLID4 == 0) { ln.FLID4 = afterSegStartLn; } } lanes[segEndId - 1] = ln; //Adjust last dtlane of each lane segment var endDtLn = dtLanes[lanes[segEndId - 1].DID - 1]; var DtLnAfter = dtLanes[lanes[afterSegStartLn - 1].DID - 1]; var pointPos = GetUnityPosition(new VectorMapPosition() { Bx = points[endDtLn.PID - 1].Bx, Ly = points[endDtLn.PID - 1].Ly, H = points[endDtLn.PID - 1].H }); var pointAfterPos = GetUnityPosition(new VectorMapPosition() { Bx = points[DtLnAfter.PID - 1].Bx, Ly = points[DtLnAfter.PID - 1].Ly, H = points[DtLnAfter.PID - 1].H }); var deltaDir = pointAfterPos - pointPos; Vector3 eulerAngles = Quaternion.FromToRotation(Vector3.right, deltaDir).eulerAngles; var convertedEulerAngles = VectorMapUtility.GetRvizCoordinates(eulerAngles); endDtLn.Dir = -convertedEulerAngles.z * Mathf.Deg2Rad; dtLanes[endDtLn.DID - 1] = endDtLn; } } } //set up all lines vector map data var linSegTerminalIDsMapping = new Dictionary <VectorMapSegment, KeyValuePair <int, LineType>[]>(); //tracking for record var stopLinkIDMapping = new Dictionary <VectorMapStopLineSegmentBuilder, List <int> >(); if (allConvertedLinSeg.Count > 0) { foreach (var linSeg in allConvertedLinSeg) { var linType = LineType.NONE; if (linSeg.builder.GetType() == typeof(VectorMapStopLineSegmentBuilder)) //If it is stopline { linType = LineType.STOP; } else if (linSeg.builder.GetType() == typeof(VectorMapWhiteLineSegmentBuilder)) //if it is whiteline { var whiteLineBuilder = linSeg.builder as VectorMapWhiteLineSegmentBuilder; if (whiteLineBuilder.lineColor == LineColor.WHITE) { linType = LineType.WHITE; } else if (whiteLineBuilder.lineColor == LineColor.YELLOW) { linType = LineType.YELLOW; } } var positions = linSeg.targetWorldPositions; linSegTerminalIDsMapping.Add(linSeg, new KeyValuePair <int, LineType>[2] { new KeyValuePair <int, LineType>(-1, LineType.NONE), new KeyValuePair <int, LineType>(-1, LineType.NONE) }); for (int i = 0; i < positions.Count - 1; i++) { //Point var startPos = positions[i]; var endPos = positions[i + 1]; var vectorMapPos = GetVectorMapPosition(startPos); var vmStartPoint = Point.MakePoint(points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); points.Add(vmStartPoint); vectorMapPos = GetVectorMapPosition(endPos); var vmEndPoint = Point.MakePoint(points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); points.Add(vmEndPoint); //Line int beforeLineID = 0; if (i > 0) { beforeLineID = lines.Count; var beforeLine = lines[beforeLineID - 1]; beforeLine.FLID = lines.Count + 1; lines[beforeLineID - 1] = beforeLine; //This is needed for struct copy to be applied back } var vmLine = Line.MakeLine(lines.Count + 1, vmStartPoint.PID, vmEndPoint.PID, beforeLineID, 0); lines.Add(vmLine); if (i == 0) { linSegTerminalIDsMapping[linSeg][(int)TerminalType.START] = new KeyValuePair <int, LineType>(vmLine.LID, linType); } if (i == positions.Count - 2) { linSegTerminalIDsMapping[linSeg][(int)TerminalType.END] = new KeyValuePair <int, LineType>(vmLine.LID, linType); } int LinkID; MakeVisualLine(vmLine, linType, out LinkID); if (linType == LineType.STOP) { var builder = (VectorMapStopLineSegmentBuilder)linSeg.builder; if (stopLinkIDMapping.ContainsKey(builder)) { stopLinkIDMapping[builder].Add(LinkID); } else { stopLinkIDMapping.Add((VectorMapStopLineSegmentBuilder)linSeg.builder, new List <int>() { LinkID }); } } } } //correcting each segment's start and end line segments BLID and FLID to new line segments that is between each segment and their adjacent segment //only make BLID/FLID set to only one of the new line segments' last/first line ID because in the vector map format one line only has one BLID and one FLID //Later executed operation will overrite previously configured BLID and/or FLID foreach (var linSeg in allConvertedLinSeg) { var terminalIdPairs = linSegTerminalIDsMapping[linSeg]; if (linSeg.befores.Count > 0 && linSegTerminalIDsMapping.ContainsKey(linSeg.befores[0])) //if before line doesn't exist in the record set then no operation to avoid extra in between line { var tPairs = terminalIdPairs[(int)TerminalType.START]; var segStartId = tPairs.Key; var segStartLin = lines[segStartId - 1]; var beforeSegEndLinId = linSegTerminalIDsMapping[linSeg.befores[0]][(int)TerminalType.END].Key; //only make BLID set to only one of the line segments' last line ID var newLin = Line.MakeLine(lines.Count + 1, lines[beforeSegEndLinId - 1].FPID, segStartLin.BPID, beforeSegEndLinId, segStartLin.LID); lines.Add(newLin); MakeVisualLine(newLin, tPairs.Value); segStartLin.BLID = beforeSegEndLinId; lines[segStartId - 1] = segStartLin; } if (linSeg.afters.Count > 0 && linSegTerminalIDsMapping.ContainsKey(linSeg.afters[0])) //if before line doesn't exist in the record set then no operation to avoid extra in between line { var tPairs = terminalIdPairs[(int)TerminalType.END]; var segEndId = tPairs.Key; var segEndLin = lines[segEndId - 1]; var afterSegStartLinId = linSegTerminalIDsMapping[linSeg.afters[0]][(int)TerminalType.START].Key; //only make FLID set to only one of the line segments' first line ID var newLin = Line.MakeLine(lines.Count + 1, segEndLin.FPID, lines[afterSegStartLinId - 1].BPID, segEndLin.LID, afterSegStartLinId); lines.Add(newLin); MakeVisualLine(newLin, tPairs.Value); segEndLin.FLID = newLin.LID; lines[segEndId - 1] = segEndLin; } } } //Setup all traffic light poles and their corrsponding traffic lights var tempMapping = new Dictionary <VectorMapPole, int>(); foreach (var pole in signalLightPoles) { //Vector var pos = pole.transform.position; var vectorMapPos = GetVectorMapPosition(pos); var PID = points.Count + 1; var vmPoint = Point.MakePoint(PID, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); points.Add(vmPoint); var VID = vectors.Count + 1; float Vang = Vector3.Angle(pole.transform.forward, Vector3.up); float Hang = .0f; if (Vang != .0f) { var projectedHorizonVec = Vector3.ProjectOnPlane(pole.transform.forward, Vector3.up); Hang = Vector3.Angle(projectedHorizonVec, Vector3.forward) * (Vector3.Cross(Vector3.forward, projectedHorizonVec).y > 0 ? 1 : -1); } var vmVector = Vector.MakeVector(VID, PID, Hang, Vang); vectors.Add(vmVector); float Length = pole.length; float Dim = .4f; var PLID = poles.Count + 1; var vmPole = Pole.MakePole(PLID, VID, Length, Dim); poles.Add(vmPole); tempMapping.Add(pole, PLID); } foreach (var pole in signalLightPoles) { var PLID = tempMapping[pole]; foreach (var signalLight in pole.signalLights) { var trafficLightAim = signalLight.transform.forward; foreach (var lightData in signalLight.signalDatas) { //Vector var trafficLightPos = signalLight.transform.TransformPoint(lightData.localPosition); var vectorMapPos = GetVectorMapPosition(trafficLightPos); var PID = points.Count + 1; var vmPoint = Point.MakePoint(PID, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); points.Add(vmPoint); var VID = vectors.Count + 1; float Vang = Vector3.Angle(trafficLightAim, Vector3.up); float Hang = .0f; if (Vang != .0f) { var projectedHorizonVec = Vector3.ProjectOnPlane(trafficLightAim, Vector3.up); Hang = Vector3.Angle(projectedHorizonVec, Vector3.forward) * (Vector3.Cross(Vector3.forward, projectedHorizonVec).y > 0 ? 1 : -1); } var vmVector = Vector.MakeVector(VID, PID, Hang, Vang); vectors.Add(vmVector); //Signaldata int ID = signalDatas.Count + 1; int Type = (int)lightData.type; int LinkID = -1; if (signalLight.hintStopline != null) { LinkID = PickAimingLinkID(signalLight.transform, stopLinkIDMapping[signalLight.hintStopline]); } else { LinkID = FindProperStoplineLinkID(trafficLightPos, trafficLightAim); } var vmSignalData = SignalData.MakeSignalData(ID, VID, PLID, Type, LinkID); signalDatas.Add(vmSignalData); } } } }
public override void PoleChange(Pole pole) { m_poleChange(); base.PoleChange(pole); }
// constructors internal Rail(int index) { this.Index = index; this.Status = RailStatus.NotAvailable; this.Updated = false; this.StartX = 0.0; this.StartY = 0.0; this.EndX = 0.0; this.EndY = 0.0; this.Type = 0; this.WallType = -1; this.WallSide = 0; this.DikeType = -1; this.DikeSide = 0; this.Pole = new Pole(-1, 0, 0.0, 1); this.Forms = null; this.FormCount = 0; this.Cracks = null; this.CrackCount = 0; this.FreeObjs = null; this.FreeObjCount = 0; this.Beacons = null; this.BeaconCount = 0; this.Stops = null; this.StopCount = 0; this.Limits = null; this.LimitCount = 0; }
static void Main(string[] args) { int numerRundy = 1; string zmiennaImie; Plansza Monopoly = new Plansza();//dziala poprawnie Plansza.Instrukcja_gry(); ///////////////////////////////////////////////////// int[] tabl = { 95, 250, 500, 900, 1250 }; Pole jakiespole = new Pole(21, "Chiny", 490, false, "brak", 95, tabl, 0); PoleSpecjalne jakiespolespecjalne = new PoleSpecjalne(22, "Szansa", "Wygrales na loterii", 100); MonopolyField costam = new Pole(21, "Chiny", 490, false, "brak", 95, tabl, 0); MonopolyField costam2 = new PoleSpecjalne(22, "Szansa", "Wygrales na loterii", 100); //Console.WriteLine("Pole jekiespole typ {0}", jakiespole.Typ()); //Console.WriteLine("PoleSpecjalne jekiespolespecjalne typ {0}", jakiespolespecjalne.Typ()); //Console.WriteLine("MonopolyField costam typ {0}", costam.Typ()); //Console.WriteLine("MonopolyField costam2 typ {0}", costam2.Typ()); //jakiespole.ObrazujKarte(); //jakiespolespecjalne.ObrazujKarte(); //costam.ObrazujKarte(); //costam2.ObrazujKarte();//działa //Console.WriteLine("Pole jakiespole Iledomkow: {0}", jakiespole.Iledomkow()); //Console.WriteLine("PoleSpecjalne jakiespolespecjalne Iledomkow: {0}", jakiespolespecjalne.Iledomkow()); //Console.WriteLine("MonopolyField costam Iledomkow : {0}", costam.Iledomkow()); //Console.WriteLine("MonopolyField costam2 Iledomkow : {0}", costam2.Iledomkow()); List <MonopolyField> MojeWszystkiePola = new List <MonopolyField>(); MojeWszystkiePola.Add(new Pole(21, "Chiny", 490, false, "brak", 95, tabl, 0)); MojeWszystkiePola.Add(new PoleSpecjalne(22, "Szansa", "Wygrales na loterii", 100)); MojeWszystkiePola.Add(new Pole(23, "Chiny", 490, false, "brak", 95, tabl, 0)); MojeWszystkiePola.Add(new PoleSpecjalne(24, "Szansa", "Wygrales na loterii", 200)); MojeWszystkiePola.Add(new Pole(25, "Chiny", 490, false, "brak", 95, tabl, 0)); MojeWszystkiePola.Add(new PoleSpecjalne(26, "Szansa", "Wygrales na loterii", 300)); MojeWszystkiePola.Add(new Pole(27, "Chiny", 490, false, "brak", 95, tabl, 0)); MojeWszystkiePola.Add(new PoleSpecjalne(28, "Szansa", "Wygrales na loterii", 400)); int z = 0; foreach (MonopolyField item in MojeWszystkiePola) { if (item.Typ() == "S") { Console.WriteLine(item.Nazwa); Console.WriteLine(item.Typ()); item.ObrazujKarte(); z++; } } //Console.WriteLine(z); //Console.WriteLine(MojeWszystkiePola.Count()); //sprawdzic funkcje co wyrzuca ///////////////////////////////////////////////////////// //Monopoly.Instrukcja_gry(); Console.WriteLine("Podaj liczbę graczy "); string liczba_graczy_str = Console.ReadLine(); int liczba_graczy = Int32.Parse(liczba_graczy_str); Plansza.CzyscKonsole(); //Monopoly.CzyscKonsole(); for (int i = 0; i < liczba_graczy; i++) { Console.WriteLine("Podaj imie gracza {0}", i + 1); zmiennaImie = Console.ReadLine(); Plansza.CzyscKonsole(); //Monopoly.CzyscKonsole(); Monopoly.Gracze.Add(new Gracz(i + 1, zmiennaImie, 3000, 0, new List <Pole>(), liczba_graczy));//5000 Monopoly.Gracze[i].PrzywitanieGracza(); Console.WriteLine("Kliknij Enter, aby kontynuować..."); Console.ReadLine(); Plansza.CzyscKonsole(); //Monopoly.CzyscKonsole(); } Monopoly.UstawPlansze(liczba_graczy);//ustawia liczbę pol w zalezności od ilosci graczy /////////////////////////////////////////////////////////////////// while (true) { Monopoly.CzyJuzKoniecGry(); Monopoly.KoniecGry(); if (Monopoly.CzyWywalamyGracza() == true)//wywaliło false { int zmienna = Monopoly.KogoWywalamyDwa(); Monopoly.Gracze.RemoveAt(zmienna - 1); Console.WriteLine("Wyrzucilismy gracza z gry!"); Console.WriteLine("Pozostało {0} graczy", Monopoly.Gracze.Count()); Console.WriteLine("Kliknij Enter, aby kontynuować z mniejszą liczbą graczy"); Console.ReadLine(); Plansza.CzyscKonsole(); //Monopoly.CzyscKonsole(); } Plansza.CzyscKonsole(); //Monopoly.CzyscKonsole(); Console.WriteLine(Monopoly.IloscGraczy()); Console.WriteLine("_________________Runda nr.{0}_________", numerRundy); Monopoly.InformacjaOPlanszy(); foreach (Gracz gracz in Monopoly.Gracze) { gracz.Infor(); Console.WriteLine("{0}, kliknij Enter by losować", gracz.Name); Console.ReadLine(); Console.WriteLine("Losowanie..."); System.Threading.Thread.Sleep(2000); gracz.ZmienAktPoz(Monopoly.losuj()); System.Threading.Thread.Sleep(2000); if (gracz.AktualnaPozycjaNaPlanszy > Monopoly.Pola.Count())//10 { gracz.AktualnaPozycjaNaPlanszy = (gracz.AktualnaPozycjaNaPlanszy - Monopoly.Pola.Count()) % Monopoly.Pola.Count(); if (gracz.AktualnaPozycjaNaPlanszy == 0) { gracz.AktualnaPozycjaNaPlanszy = 1; } } Console.WriteLine("\nAktualna pozycja na planszy:" + gracz.AktualnaPozycjaNaPlanszy); ////////////////////////////////////////// if (Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Czy_zajete == false) //WOLNA DZIAŁKA { if (gracz.Kwota >= Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Koszt) //jezeli gracz ma wiecej hajsu niż koszt dzialki { Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].ObrazujKarte(); Console.WriteLine("\tCzy chcesz kupić wolną dzialkę?"); if (Monopoly.decyzja() == true) { System.Threading.Thread.Sleep(2000); Console.WriteLine("\tKupiles dzialke o numerze {0}", gracz.AktualnaPozycjaNaPlanszy); gracz.ZmienKwote(Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Koszt); //ODEJMOWANIE Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].ZmianaWlasciciela(gracz.Name); //PRZYPISANIE WLASCICIELA DO DZIALKI Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Czy_zajete = true; gracz.Dzialki.Add(Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1]); // PRZYPISANIE DZIALKI DO GRACZA Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Infor(); Console.WriteLine("\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } else { Console.WriteLine("\n\tNie zdecydowałeś się na kupno działki."); Console.WriteLine("\n\tRuch kolejnego gracza"); Console.WriteLine(" "); } } else { Console.WriteLine("\tBrak środkow na koncie.Graj rozważnie"); Console.WriteLine("\tRuch kolejnego gracza"); Console.WriteLine(""); } } else if (Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Czy_zajete == true)//DZIALKA ZAJETA { System.Threading.Thread.Sleep(2000); Console.WriteLine("\t\t\tWjechales w zajętą dzialkę!"); if (Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Wlasciciel == gracz.Name)//jezeli dzialka nasza to { Console.WriteLine("\t\t\tRozważ budowę domków"); Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].InformacjaDlaWlascicielaODomkach(); if (Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Iledomkow() < 5)//gdy jest mozliwosc kupna domku { Console.WriteLine("\t\t\tCzy chcesz kupić domek?"); if (Monopoly.decyzja() == true)//jezeli tak { System.Threading.Thread.Sleep(2000); Console.WriteLine("\t\t\tChcesz kupić domek!"); //sprawdzenie czy nas stac if (gracz.Kwota >= Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].OplataZaDomek)// jezeli tak { Console.WriteLine("\t\t\tZdecydowaleś się na kupno domku!"); gracz.ZmienKwote(Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].OplataZaDomek);//odejmowanie hajsu za domek Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].ZmienLiczbeDomkow(); Console.WriteLine("\t\t\tZmieniono liczbę domkow na {0}", Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow); Console.WriteLine("\t\t\tRuch kolejnego gracza"); Console.WriteLine(""); } else { Console.WriteLine("\t\t\t\tNie stać cię na kupno domku"); Console.WriteLine("\t\t\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } } else//jezeli nie { System.Threading.Thread.Sleep(2000); Console.WriteLine("\t\t\tNie chcesz kupić domku"); Console.WriteLine("\t\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } } else { System.Threading.Thread.Sleep(1000); Console.WriteLine("\t\t\t\tTu już stoji hotel! Więcej domków nie jesteś w stanie kupić"); Console.WriteLine("\t\t\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } } else { System.Threading.Thread.Sleep(2000); Console.WriteLine("\t\t\tTa dzialka ma już swojego innego wlasciciela"); foreach (Gracz szukanygracz in Monopoly.Gracze) { if (szukanygracz.Name == Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Wlasciciel) { if (Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow != 0) { Console.WriteLine("\t\t\t\nA jej wlascicielem jest {0}", Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Wlasciciel); gracz.ZmienKwote(Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow - 1]); szukanygracz.ZmienKwote(-Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow - 1]); Console.WriteLine("\t\t\tZaplaciłeś mu {0}", Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow - 1]); Console.WriteLine("\t\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } else { Console.WriteLine("\t\t\tA jej wlascicielem jest {0}", Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].Wlasciciel); gracz.ZmienKwote(Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow]); szukanygracz.ZmienKwote(-Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow]); Console.WriteLine("\t\t\tZaplaciłeś mu {0}", Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].KwotaZaWejscie[Monopoly.Pola[gracz.AktualnaPozycjaNaPlanszy - 1].IleDomkow]); Console.WriteLine("\t\t\tRuch kolejnego gracza"); Console.WriteLine(" "); } } } } } Console.WriteLine("Kliknij Enter, by zakończyć swój ruch..."); Console.ReadLine(); } Console.WriteLine("\t\t\tKliknij Enter aby rozpocząć {0} rundę: ", numerRundy + 1); numerRundy++; Console.WriteLine(""); Console.ReadLine(); System.Threading.Thread.Sleep(2000); } }
public gameForm() { InitializeComponent(); mainPole = new Pole(this, 500, 500); }
private void DrawActionAssignmentButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap) { if(GUILayout.Button(elementMap.elementIdentifierName, GUILayout.ExpandWidth(false), GUILayout.MinWidth(30.0f))) { EnqueueAction(new ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap, ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert)); } GUILayout.Space(4); }
public Move(Pole fromPole, Pole toPole) { this.FromPole = fromPole; this.ToPole = toPole; }
private void DrawAddActionMapButton(int playerId, InputAction action, Pole actionAxisContribution, ControllerSelection controller, ControllerMap controllerMap, bool assignFullAxis) { if(GUILayout.Button("Add...", GUILayout.ExpandWidth(false))) { EnqueueAction(new ElementAssignmentChange(playerId, controller.id, controller.type, controllerMap, ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false)); } GUILayout.Space(10); }
public Sprite GetElement(ControllerElementType elementType, int elementID, AxisRange range = AxisRange.Full, Pole axis = Pole.Positive) { if (elementType == ControllerElementType.Axis) { return(GetAxis(elementID, range, axis)); } else if (elementType == ControllerElementType.Button) { return(GetButton(elementID)); } return(null); }
bool Calculate() { // Initial collection var laneSegments = new List <MapLane>(); var lineSegments = new List <MapLine>(); var signalLightPoles = new List <MapPole>(); laneSegments.AddRange(MapAnnotationData.GetData <MapLane>()); lineSegments.AddRange(MapAnnotationData.GetData <MapLine>()); signalLightPoles.AddRange(MapAnnotationData.GetData <MapPole>()); var allVectorLaneSegments = new HashSet <MapVectorLane>(); var allLineSegments = new HashSet <MapLine>(); foreach (var laneSegment in laneSegments) { var vectorLaneSegment = new MapVectorLane(); vectorLaneSegment.copyFromMapLane(laneSegment); allVectorLaneSegments.Add(vectorLaneSegment); } // Link before and after segment for each lane segment foreach (var laneSegment in allVectorLaneSegments) { // Each segment must have at least 2 waypoints for calculation, otherwise exit while (laneSegment.MapWorldPositions.Count < 2) { Debug.LogError("Some segment has less than 2 waypoints. Cancelling map generation."); return(false); } // Link lanes var firstPt = laneSegment.MapWorldPositions[0]; var lastPt = laneSegment.MapWorldPositions[laneSegment.MapWorldPositions.Count - 1]; foreach (var laneSegmentCmp in allVectorLaneSegments) { if (laneSegment == laneSegmentCmp) { continue; } var firstPt_cmp = laneSegmentCmp.MapWorldPositions[0]; var lastPt_cmp = laneSegmentCmp.MapWorldPositions[laneSegmentCmp.MapWorldPositions.Count - 1]; if ((firstPt - lastPt_cmp).magnitude < MapAnnotationTool.PROXIMITY / MapAnnotationTool.EXPORT_SCALE_FACTOR) { laneSegment.Befores.Add(laneSegmentCmp); } if ((lastPt - firstPt_cmp).magnitude < MapAnnotationTool.PROXIMITY / MapAnnotationTool.EXPORT_SCALE_FACTOR) { laneSegment.Afters.Add(laneSegmentCmp); } } } foreach (var lineSegment in lineSegments) { if (lineSegment.lineType != MapData.LineType.VIRTUAL) { allLineSegments.Add(lineSegment); } } // Link before and after segment for each line segment foreach (var lineSegment in allLineSegments) { if (lineSegment.lineType != MapData.LineType.STOP) { continue; // Skip stop lines } // Each segment must have at least 2 waypoints for calculation, otherwise exit while (lineSegment.mapLocalPositions.Count < 2) { Debug.LogError("Some segment has less than 2 waypoints. Cancelling map generation."); return(false); } // Link lanes var firstPt = lineSegment.transform.TransformPoint(lineSegment.mapLocalPositions[0]); var lastPt = lineSegment.transform.TransformPoint(lineSegment.mapLocalPositions[lineSegment.mapLocalPositions.Count - 1]); foreach (var lineSegmentCmp in allLineSegments) { if (lineSegment == lineSegmentCmp) { continue; } if (lineSegmentCmp.lineType != MapData.LineType.STOP) { continue; // Skip stop lines } var firstPt_cmp = lineSegmentCmp.transform.TransformPoint(lineSegmentCmp.mapLocalPositions[0]); var lastPt_cmp = lineSegmentCmp.transform.TransformPoint(lineSegmentCmp.mapLocalPositions[lineSegmentCmp.mapLocalPositions.Count - 1]); if ((firstPt - lastPt_cmp).magnitude < MapAnnotationTool.PROXIMITY / MapAnnotationTool.EXPORT_SCALE_FACTOR) { lineSegmentCmp.mapLocalPositions[lineSegmentCmp.mapLocalPositions.Count - 1] = lineSegmentCmp.transform.InverseTransformPoint(firstPt); lineSegmentCmp.mapWorldPositions[lineSegmentCmp.mapWorldPositions.Count - 1] = firstPt; } if ((lastPt - firstPt_cmp).magnitude < MapAnnotationTool.PROXIMITY / MapAnnotationTool.EXPORT_SCALE_FACTOR) { lineSegmentCmp.mapLocalPositions[0] = lineSegmentCmp.transform.InverseTransformPoint(lastPt); lineSegmentCmp.mapWorldPositions[0] = lastPt; } } } // New sets for newly converted(to world space) segments var allConvertedLaneSegments = new HashSet <MapVectorLane>(); //for lane segments // Filter and convert all lane segments if (allVectorLaneSegments.Count > 0) { var startLaneSegs = new HashSet <MapVectorLane>(); // The lane segments that are at merging or forking or starting position var visitedLaneSegs = new HashSet <MapVectorLane>(); // tracking for record foreach (var laneSegment in allVectorLaneSegments) { if (laneSegment.Befores.Count != 1 || (laneSegment.Befores.Count == 1 && laneSegment.Befores[0].Afters.Count > 1)) //no any before segments { startLaneSegs.Add(laneSegment); } } foreach (var startLaneSeg in startLaneSegs) { ConvertAndJointSingleConnectedSegments(startLaneSeg, allVectorLaneSegments, ref allConvertedLaneSegments, visitedLaneSegs); } while (allVectorLaneSegments.Count > 0) // Remaining should be isolated loops { MapVectorLane pickedLaneSeg = null; foreach (var laneSegment in allVectorLaneSegments) { pickedLaneSeg = laneSegment; break; } if (pickedLaneSeg != null) { ConvertAndJointSingleConnectedSegments(pickedLaneSeg, allVectorLaneSegments, ref allConvertedLaneSegments, visitedLaneSegs); } } } // Set up all lanes vector map data var laneSegTerminalIDsMapping = new Dictionary <MapVectorLane, int[]>(); //tracking for record if (allConvertedLaneSegments.Count > 0) { foreach (var laneSegment in allConvertedLaneSegments) { List <Vector3> positions; var laneCount = laneSegment.LaneCount; var laneNumber = laneSegment.LaneNumber; //Interpolate based on waypoint world positions Interpolate(laneSegment.MapWorldPositions, out positions, 1.0f / MapAnnotationTool.EXPORT_SCALE_FACTOR, true); //interpolate and divide to ensure 1 meter apart laneSegTerminalIDsMapping.Add(laneSegment, new int[2]); for (int i = 0; i < positions.Count; i++) { //Point var pos = positions[i]; var vectorMapPos = VectorMapUtility.GetVectorMapPosition(pos, MapAnnotationTool.EXPORT_SCALE_FACTOR); var vmPoint = Point.MakePoint(Points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); Points.Add(vmPoint); //Node var vmNode = Node.MakeNode(Nodes.Count, Points.Count + 1); Nodes.Add(vmNode); //DtLane var deltaDir = Vector3.zero; if (i < positions.Count - 1) { deltaDir = positions[i + 1] - pos; } else { if (laneSegment.Afters.Count > 0) { deltaDir = laneSegment.Afters[0].MapWorldPositions[0] - pos; } else { deltaDir = pos - positions[i - 1]; } } Vector3 eulerAngles = Quaternion.FromToRotation(Vector3.right, deltaDir).eulerAngles; var convertedEulerAngles = VectorMapUtility.GetRvizCoordinates(eulerAngles); var vmDTLane = DtLane.MakeDtLane(DtLanes.Count + 1, i, vmPoint.PID, -convertedEulerAngles.z * Mathf.Deg2Rad, .0, .1, .1); DtLanes.Add(vmDTLane); //Lane int beforeLaneID = 0; int laneId = Lanes.Count + 1; if (i > 0) { beforeLaneID = Lanes.Count; // beforeLaneID won't be 0 since we add one vmLane to Lanes when i == 0 var beforeLane = Lanes[beforeLaneID - 1]; beforeLane.FLID = laneId; Lanes[beforeLaneID - 1] = beforeLane; //This is needed for struct copy to be applied back } var speedLimit = (int)laneSegment.SpeedLimit; var vmLane = Lane.MakeLane(laneId, vmDTLane.DID, beforeLaneID, 0, (Nodes.Count - 1), Nodes.Count, laneCount, laneNumber, speedLimit); Lanes.Add(vmLane); // if positions.Count is n, then Lanes.Count is n-1. if (i == 0) { laneSegTerminalIDsMapping[laneSegment][(int)TerminalType.START] = vmLane.LnID; } if (i == positions.Count - 1) { laneSegTerminalIDsMapping[laneSegment][(int)TerminalType.END] = vmLane.LnID; } } } //Assuming merging and diversing won't happen at the same spot //correcting start and end lanes's BLID and FLID to the lane segment's before and after lane IDs in other lane segments //each lane will have up to 4 before lane Ids and after lane Ids to set, later executed operation will be ignore if number exceeds 4 //correcting DtLanes last lane's dir value foreach (var laneSegment in allConvertedLaneSegments) { var terminalIdPair = laneSegTerminalIDsMapping[laneSegment]; if (laneSegment.Befores.Count > 0) { var segStartId = terminalIdPair[(int)TerminalType.START]; var ln = Lanes[segStartId - 1]; for (int i = 0; i < laneSegment.Befores.Count; i++) { int beforeSegAfterLn = laneSegTerminalIDsMapping[laneSegment.Befores[i]][(int)TerminalType.END]; //chose the BLID that has not been set to meaningful lane id if (ln.BLID == 0) { ln.BLID = beforeSegAfterLn; } else if (ln.BLID2 == 0) { ln.BLID2 = beforeSegAfterLn; //ln.JCT = 3; //means merging } else if (ln.BLID3 == 0) { ln.BLID3 = beforeSegAfterLn; } else if (ln.BLID4 == 0) { ln.BLID4 = beforeSegAfterLn; } } Lanes[segStartId - 1] = ln; } if (laneSegment.Afters.Count > 0) { var segEndId = terminalIdPair[(int)TerminalType.END]; var ln = Lanes[segEndId - 1]; int afterSegStartLn = laneSegTerminalIDsMapping[laneSegment.Afters[0]][(int)TerminalType.START]; for (int i = 0; i < laneSegment.Afters.Count; i++) { afterSegStartLn = laneSegTerminalIDsMapping[laneSegment.Afters[i]][(int)TerminalType.START]; //chose the FLID that has not been set to meaningful lane id if (ln.FLID == 0) { ln.FLID = afterSegStartLn; } else if (ln.FLID2 == 0) { ln.FLID2 = afterSegStartLn; ln.JCT = 1; //means branching } else if (ln.FLID3 == 0) { ln.FLID3 = afterSegStartLn; } else if (ln.FLID4 == 0) { ln.FLID4 = afterSegStartLn; } } Lanes[segEndId - 1] = ln; // Adjust last dtlane of each lane segment var endDtLn = DtLanes[Lanes[segEndId - 1].DID - 1]; var DtLnAfter = DtLanes[Lanes[afterSegStartLn - 1].DID - 1]; var pointPos = VectorMapUtility.GetUnityPosition(new VectorMapPosition() { Bx = Points[endDtLn.PID - 1].Bx, Ly = Points[endDtLn.PID - 1].Ly, H = Points[endDtLn.PID - 1].H }, MapAnnotationTool.EXPORT_SCALE_FACTOR); var pointAfterPos = VectorMapUtility.GetUnityPosition(new VectorMapPosition() { Bx = Points[DtLnAfter.PID - 1].Bx, Ly = Points[DtLnAfter.PID - 1].Ly, H = Points[DtLnAfter.PID - 1].H }, MapAnnotationTool.EXPORT_SCALE_FACTOR); var deltaDir = pointAfterPos - pointPos; Vector3 eulerAngles = Quaternion.FromToRotation(Vector3.right, deltaDir).eulerAngles; var convertedEulerAngles = VectorMapUtility.GetRvizCoordinates(eulerAngles); endDtLn.Dir = -convertedEulerAngles.z * Mathf.Deg2Rad; DtLanes[endDtLn.DID - 1] = endDtLn; } } } // Set up all lines vector map data var lineSegTerminalIDsMapping = new Dictionary <MapLine, KeyValuePair <int, LineType>[]>(); //tracking for record var stoplineLinkIDMapping = new Dictionary <MapLine, List <int> >(); if (allLineSegments.Count > 0) { foreach (var lineSegment in allLineSegments) { var lineType = LineType.NONE; if (lineSegment.lineType == MapData.LineType.STOP) //If it is stopline { lineType = LineType.STOP; } else if (lineSegment.lineType == MapData.LineType.SOLID_WHITE || lineSegment.lineType == MapData.LineType.DOUBLE_WHITE || lineSegment.lineType == MapData.LineType.DOTTED_WHITE) { lineType = LineType.WHITE; } else if (lineSegment.lineType == MapData.LineType.SOLID_YELLOW || lineSegment.lineType == MapData.LineType.DOUBLE_YELLOW || lineSegment.lineType == MapData.LineType.DOTTED_YELLOW) { lineType = LineType.YELLOW; } var positions = lineSegment.mapWorldPositions; lineSegTerminalIDsMapping.Add(lineSegment, new KeyValuePair <int, LineType>[2] { new KeyValuePair <int, LineType>(-1, LineType.NONE), new KeyValuePair <int, LineType>(-1, LineType.NONE) }); for (int i = 0; i < positions.Count - 1; i++) { //Point var startPos = positions[i]; var endPos = positions[i + 1]; var vectorMapPos = VectorMapUtility.GetVectorMapPosition(startPos, MapAnnotationTool.EXPORT_SCALE_FACTOR); var vmStartPoint = Point.MakePoint(Points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); Points.Add(vmStartPoint); vectorMapPos = VectorMapUtility.GetVectorMapPosition(endPos, MapAnnotationTool.EXPORT_SCALE_FACTOR); var vmEndPoint = Point.MakePoint(Points.Count + 1, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); Points.Add(vmEndPoint); //Line int beforeLineID = 0; if (i > 0) { beforeLineID = Lines.Count; var beforeLine = Lines[beforeLineID - 1]; beforeLine.FLID = Lines.Count + 1; Lines[beforeLineID - 1] = beforeLine; //This is needed for struct copy to be applied back } var vmLine = Line.MakeLine(Lines.Count + 1, vmStartPoint.PID, vmEndPoint.PID, beforeLineID, 0); Lines.Add(vmLine); if (i == 0) { lineSegTerminalIDsMapping[lineSegment][(int)TerminalType.START] = new KeyValuePair <int, LineType>(vmLine.LID, lineType); } if (i == positions.Count - 2) { lineSegTerminalIDsMapping[lineSegment][(int)TerminalType.END] = new KeyValuePair <int, LineType>(vmLine.LID, lineType); } int LinkID; MakeVisualLine(vmLine, lineType, out LinkID); if (lineType == LineType.STOP) { if (LinkID < 1) { Debug.LogError("Some stopline can not find have a correct linkID that equals to a nearby lane's id", lineSegment.gameObject); UnityEditor.Selection.activeGameObject = lineSegment.gameObject; Debug.LogError($"Selected the problematic {nameof(lineSegment)}"); return(false); } if (stoplineLinkIDMapping.ContainsKey(lineSegment)) { stoplineLinkIDMapping[lineSegment].Add(LinkID); //Debug.Log("Extra IDs for same builder: " + stopLinkIDMapping[builder].Count); } else { stoplineLinkIDMapping.Add(lineSegment, new List <int>() { LinkID }); } } } } //correcting each segment's start and end line segments BLID and FLID to new line segments that is between each segment and their adjacent segment //only make BLID/FLID set to only one of the new line segments' last/first line ID because in the vector map format one line only has one BLID and one FLID //Later executed operation will overrite previously configured BLID and/or FLID foreach (var lineSegment in allLineSegments) { var terminalIdPairs = lineSegTerminalIDsMapping[lineSegment]; if (lineSegment.befores.Count > 0 && lineSegTerminalIDsMapping.ContainsKey(lineSegment.befores[0])) //if before line doesn't exist in the record set then no operation to avoid extra in between line { var tPairs = terminalIdPairs[(int)TerminalType.START]; var segStartId = tPairs.Key; var segStartLin = Lines[segStartId - 1]; var beforeSegEndLinId = lineSegTerminalIDsMapping[lineSegment.befores[0]][(int)TerminalType.END].Key; //only make BLID set to only one of the line segments' last line ID var newLin = Line.MakeLine(Lines.Count + 1, Lines[beforeSegEndLinId - 1].FPID, segStartLin.BPID, beforeSegEndLinId, segStartLin.LID); Lines.Add(newLin); MakeVisualLine(newLin, tPairs.Value); segStartLin.BLID = beforeSegEndLinId; Lines[segStartId - 1] = segStartLin; } if (lineSegment.afters.Count > 0 && lineSegTerminalIDsMapping.ContainsKey(lineSegment.afters[0])) //if before line doesn't exist in the record set then no operation to avoid extra in between line { var tPairs = terminalIdPairs[(int)TerminalType.END]; var segEndId = tPairs.Key; var segEndLin = Lines[segEndId - 1]; var afterSegStartLinId = lineSegTerminalIDsMapping[lineSegment.afters[0]][(int)TerminalType.START].Key; //only make FLID set to only one of the line segments' first line ID var newLin = Line.MakeLine(Lines.Count + 1, segEndLin.FPID, Lines[afterSegStartLinId - 1].BPID, segEndLin.LID, afterSegStartLinId); Lines.Add(newLin); MakeVisualLine(newLin, tPairs.Value); segEndLin.FLID = newLin.LID; Lines[segEndId - 1] = segEndLin; } } } //Setup all traffic light poles and their corrsponding traffic lights var tempIDMapping = new Dictionary <MapPole, int>(); //builder pole id mapping foreach (var pole in signalLightPoles) { //Vector var pos = pole.transform.position; var vectorMapPos = VectorMapUtility.GetVectorMapPosition(pos, MapAnnotationTool.EXPORT_SCALE_FACTOR); var PID = Points.Count + 1; var vmPoint = Point.MakePoint(PID, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); Points.Add(vmPoint); var VID = Vectors.Count + 1; float Vang = Vector3.Angle(pole.transform.forward, Vector3.up); float Hang = .0f; if (Vang != .0f) { var projectedHorizonVec = Vector3.ProjectOnPlane(pole.transform.forward, Vector3.up); Hang = Vector3.Angle(projectedHorizonVec, Vector3.forward) * (Vector3.Cross(Vector3.forward, projectedHorizonVec).y > 0 ? 1 : -1); } var vmVector = Vector.MakeVector(VID, PID, Hang, Vang); Vectors.Add(vmVector); float Length = pole.length; float Dim = .4f; var PLID = Poles.Count + 1; var vmPole = Pole.MakePole(PLID, VID, Length, Dim); Poles.Add(vmPole); tempIDMapping.Add(pole, PLID); } foreach (var pole in signalLightPoles) { var PLID = tempIDMapping[pole]; foreach (var signalLight in pole.signalLights) { if (signalLight == null || !signalLight.gameObject.activeInHierarchy) { continue; } var trafficLightAim = signalLight.transform.forward; foreach (var lightData in signalLight.signalData) { //Vector var trafficLightPos = signalLight.transform.TransformPoint(lightData.localPosition); var vectorMapPos = VectorMapUtility.GetVectorMapPosition(trafficLightPos, MapAnnotationTool.EXPORT_SCALE_FACTOR); var PID = Points.Count + 1; var vmPoint = Point.MakePoint(PID, vectorMapPos.Bx, vectorMapPos.Ly, vectorMapPos.H); Points.Add(vmPoint); var VID = Vectors.Count + 1; float Vang = Vector3.Angle(trafficLightAim, Vector3.up); float Hang = .0f; if (Vang != .0f) { var projectedHorizonVec = Vector3.ProjectOnPlane(trafficLightAim, Vector3.up); Hang = Vector3.Angle(projectedHorizonVec, Vector3.forward) * (Vector3.Cross(Vector3.forward, projectedHorizonVec).y > 0 ? 1 : -1); } var vmVector = Vector.MakeVector(VID, PID, Hang, Vang); Vectors.Add(vmVector); //Signaldata int ID = SignalDataList.Count + 1; int Type = (int)lightData.signalColor; int LinkID = -1; if (signalLight.stopLine != null) { if (!stoplineLinkIDMapping.ContainsKey(signalLight.stopLine)) { Debug.LogError("Selected the related stopline that is not in the mapping"); UnityEditor.Selection.activeGameObject = signalLight.stopLine.gameObject; return(false); } LinkID = PickAimingLinkID(signalLight.transform, stoplineLinkIDMapping[signalLight.stopLine]); if (LinkID < 0) { Debug.LogError("Selected the related stopline that is related to the missing LinkID"); UnityEditor.Selection.activeGameObject = signalLight.stopLine.gameObject; return(false); } } else { Debug.LogError($"some signal light({nameof(MapSignal)}) have null stopline"); UnityEditor.Selection.activeGameObject = signalLight.gameObject; Debug.LogError($"selected the problematic {nameof(MapSignal)}"); return(false); #if THIS_IS_NOT_USED LinkID = FindProperStoplineLinkID(trafficLightPos, trafficLightAim); #endif } if (Type == 2) { Type = 3; } else if (Type == 3) { Type = 2; } var vmSignalData = SignalData.MakeSignalData(ID, VID, PLID, Type, LinkID); SignalDataList.Add(vmSignalData); } } } return(true); }
public Sprite GetImage(ControllerType controlType, ControllerElementType elementType, int elementID, AxisRange range = AxisRange.Full, Pole axis = Pole.Positive) { Sprite image = null; int controllerPlatform = 0; if (controlType == ControllerType.Joystick) { if (lPadInputs.Count == 0) { return(null); } if (ControllerStatusManager.currentGamepadType != eGamepadButtonType.Generic) { if (ControllerStatusManager.nativeGamepadType == eGamepadButtonType.PlayStation3 || ControllerStatusManager.nativeGamepadType == eGamepadButtonType.PlayStation4) { elementID = dPS4InputConverts[elementID]; } } // Xbox Controls if ((int)ControllerStatusManager.currentGamepadType <= 2) { controllerPlatform = 0; } else if ((int)ControllerStatusManager.currentGamepadType < 5) // PS Controls { controllerPlatform = 1; } } switch (controlType) { case ControllerType.Keyboard: image = keyInputs.GetElement(ControllerElementType.Button, elementID); break; case ControllerType.Mouse: image = mouseInputs.GetElement(elementType, elementID, range); break; case ControllerType.Joystick: image = lPadInputs[controllerPlatform].GetElement(elementType, elementID, range, axis); break; } return(image); }
void Awake() { S = this; }
public void TestInitialize() { AntiPlayer = new AntiPlayer(); Pole = Pole.getInstance(); Player = Player.getInstance(); }
public Pole Add(Pole entity) { var obj = poleRepository.Add(entity); return(obj); }
public void BuildCurrent() { GameObject building = null; Buildable temp = CurrentBuildable; switch (CurrentBuildable) { case Buildable.Powerstation_down: case Buildable.Powerstation_left: case Buildable.Powerstation_right: case Buildable.Powerstation_up: { //Check Validator bool valid = current.GetComponent <RoadValidityChecker>().IsValid(); World w = FindObjectOfType <World>(); Vector2 newPlacement = Vector2.zero; if (valid || PossibleToHelp(CurrentBuildable, current, out newPlacement)) { //build if (Game.Instance.SubtractResource(CurrentBuildable.GetCost())) { Road r = w.roadmap.BuildPowerstation(CurrentBuildable, current.transform.position.ToVector2(), w); building = r.gameObject; ResetState(); ConnectConnectibles(LevelManager.properties.PoleRadius, r.GetComponentsInChildren <Connectible>()); } else { Game.Instance.Warn(LocaleManager.locale.InsufficientResources); ResetState(); } } else { //do nothing Game.Instance.Warn(LocaleManager.locale.InvalidPlacement); } break; } case Buildable.Pole: { //check validity if (Game.Instance.SubtractResource(CurrentBuildable.GetCost())) { Pole p = Pole.BuildPole(current.transform.position.ToVector2()); //Destroy the dummy first, else it will try to connect it. building = p.gameObject; ResetState(); ConnectConnectibles(LevelManager.properties.PoleRadius, p.GetComponent <Connectible>()); } else { Game.Instance.Warn(LocaleManager.locale.InsufficientResources); ResetState(); } break; } case Buildable.Plant: { bool valid = current.GetComponent <RoadValidityChecker>().IsValid(); if (valid) { if (Game.Instance.SubtractResource(CurrentBuildable.GetCost())) { Powerplant p = FindObjectOfType <World>().BuildPowerplant(current.transform.position.ToVector2()); //Destroy the dummy first, else it will try to connect it. building = p.gameObject; ResetState(); ConnectConnectibles(LevelManager.properties.PoleRadius, p.GetComponent <Connectible>()); } else { Game.Instance.Warn(LocaleManager.locale.InsufficientResources); ResetState(); } } else { Game.Instance.Warn(LocaleManager.locale.InvalidPlacement); } break; } } //Add to action stack if successful if (building != null) { Deconstructible d = building.AddComponent <Deconstructible>(); d.building = temp; actionStack.Push(d); } UnfoldDecorations(); }
public Cell(Pole p, int x, int y) { pole = p; this.x = x; this.y = y; }
public void Prebuild(Buildable buildable) { if (current != null) { CancelCurrent(); } SetBuilding(buildable); //Attach object to mouse and create the effect of being built switch (buildable) { case Buildable.Powerstation_left: { current = CreateChargeSpotLeft(); AttachToMouse(current); AttachWeaver(current, Side.left); SetTemporaryConnectibles(current); AddConnectibleWeaversToStations(current); break; } case Buildable.Powerstation_right: { current = CreateChargeSpotRight(); AttachToMouse(current); AttachWeaver(current, Side.right); SetTemporaryConnectibles(current); AddConnectibleWeaversToStations(current); break; } case Buildable.Powerstation_up: { current = CreateChargeSpotUp(); AttachToMouse(current); AttachWeaver(current, Side.up); SetTemporaryConnectibles(current); AddConnectibleWeaversToStations(current); break; } case Buildable.Powerstation_down: { current = CreateChargeSpotDown(); AttachToMouse(current); AttachWeaver(current, Side.down); SetTemporaryConnectibles(current); AddConnectibleWeaversToStations(current); break; } case Buildable.Pole: { current = Pole.CreatePole().gameObject; AttachToMouse(current); current.GetComponent <FollowMouse>().discrete = false; current.AddComponent <PoleWeaver>(); //Set temporary connection SetTemporaryConnectibles(current); break; } case Buildable.Plant: { current = Powerplant.CreatePowerplant().gameObject; AttachToMouse(current); //reuse of RoadValidityChecker current.AddComponent <RoadValidityChecker>(); current.AddComponent <ConnectibleWeaver>(); SetTemporaryConnectibles(current); break; } } //Fold all houses FoldDecorations(); }
private void Awake() { myPole = GetComponentInParent <Pole>(); }
public static GameObject CreatePole() { return(Pole.CreatePole().gameObject); }