/// <summary> /// Called when a entity started crossing the crosswalk. /// </summary> /// <param name="_entity">Entity that started crossing.</param> public void OnStartedCrossing(EntityController _entity) { //DebugController.LogMessage($"Entity started crossing { _entity.gameObject.name }"); ClearTicket(_entity); SetTurnForCrossingEntity(_entity.GetEntityType); if (_entity.GetEntityType.Equals(EntityType.Pedestrian)) { if (!crossingPedestrians.ContainsKey(_entity)) { _entity.GetMovableComponent.AddOnMovement(OnEntityMoved); CrossingInfo newInfo = new CrossingInfo(); newInfo.lastPosition = _entity.transform.position; crossingPedestrians.Add(_entity, newInfo); } } else if (_entity.GetEntityType.Equals(EntityType.Vehicle)) { if (!crossingVehicle.ContainsKey(_entity)) { if (crossingPedestrians.Count > 0) { DebugController.LogMessage("This car is crossing with pedestrians doing it at the same time: " + _entity.gameObject.name); // TODO remover eso de aca if (_entity.gameObject.CompareTag("Car") && _entity.gameObject.name != "PlayerCar_PFB Variant") { _entity.SetCrossingWithPedestrianValue(true); } } _entity.GetMovableComponent.AddOnMovement(OnEntityMoved); CrossingInfo newInfo = new CrossingInfo(); newInfo.lastPosition = _entity.transform.position; crossingVehicle.Add(_entity, newInfo); } } }
private void simpleBtnDelete_Click(object sender, EventArgs e) { if (XtraMessageBox.Show("确认删除!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { int nIndex = this.gridView1.FocusedRowHandle; CrossingInfo delCross = mCrossingList[nIndex]; int retVal = dal.DeleteCrossing(delCross.ID); if (retVal >= 0) { loadData(); if (ShowCrossInfo != null) { try { ShowCrossInfo(""); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } }
private void simpleBtnModify_Click(object sender, EventArgs e) { int nIndex = this.gridView1.FocusedRowHandle; CrossingInfo modifyCross = mCrossingList[nIndex]; FrmCrossingAdd frmCrossInfoAdd = new FrmCrossingAdd(); frmCrossInfoAdd.setModifiedCross(modifyCross); frmCrossInfoAdd.ShowDialog(); if (frmCrossInfoAdd.DialogResult == System.Windows.Forms.DialogResult.OK) { loadData(); } }
private void OnEntityMoved(OnEntityMovementEventArgs _args) { if (_args.Entity.GetEntityType.Equals(EntityType.Pedestrian)) { if (crossingPedestrians.ContainsKey(_args.Entity)) { CrossingInfo info = crossingPedestrians[_args.Entity]; // First calculate the distance travelled since last frame. float distance; float delta = (_args.Entity.transform.position - info.lastPosition).magnitude; // Add to the calculated delta the stored distance to get the total. distance = info.distanceTravelled + delta; info.distanceTravelled = distance; info.lastPosition = _args.Entity.transform.position; crossingPedestrians[_args.Entity] = info; } else { DebugController.LogErrorMessage(string.Format("{0} moved but it has no crossing info stored.", _args.Entity.gameObject.name)); } } else if (_args.Entity.GetEntityType.Equals(EntityType.Vehicle)) { if (crossingVehicle.ContainsKey(_args.Entity)) { CrossingInfo info = crossingVehicle[_args.Entity]; // First calculate the distance travelled since last frame. float distance = (_args.Entity.transform.position - info.lastPosition).magnitude; // Add to the calculated distance the sotored distance to get the total. distance += info.distanceTravelled; info.distanceTravelled = distance; crossingVehicle[_args.Entity] = info; } else { DebugController.LogErrorMessage(string.Format("{0} moved but it has no crossing info stored.", _args.Entity.gameObject.name)); } } }
public List <CrossingInfo> GetCrossingInfos() { List <CrossingInfo> mList = new List <CrossingInfo>(); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * from tb_crossing"); CrossingInfo model = new CrossingInfo(); DataSet ds = null; MySqlDbHelper dbHelper = new MySqlDbHelper(); dbHelper.Connect(); ds = dbHelper.GetDataSet(strSql.ToString()); dbHelper.Close(); //DataSet ds = objODPHelper.Query(strSql.ToString(), null); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { model = DataRowToModel(ds.Tables[0].Rows[i]); mList.Add(model); } } else { return(null); } } return(mList); }
private CrossingInfo DataRowToModel(DataRow row) { CrossingInfo model = new CrossingInfo(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["CROSSING_ID"] != null) { model.CROSSING_ID = row["CROSSING_ID"].ToString(); } if (row["CROSSING_NAME"] != null) { model.CROSSING_NAME = row["CROSSING_NAME"].ToString(); } if (row["CREATE_TIME"] != null) { model.CREATE_TIME = row["CREATE_TIME"].ToString(); } if (row["IMAGE_DATA"] != null) { model.IMAGE_DATA = row["IMAGE_DATA"].ToString(); } if (row["CROSSING_CONFIG"] != null) { model.CROSSING_CONFIG = row["CROSSING_CONFIG"].ToString(); } if (row["DESC"] != null) { model.DESC = row["DESC"].ToString(); } } return(model); }
public void setModifiedCross(CrossingInfo userInfo) { this.mCrossInfo = userInfo; }