IEnumerator ChangeState() { yield return(new WaitForSeconds(9.5f)); Debug.Log("change state"); state = TrainState.ATTACKABLE; }
private void OnEvaluatingUpdate(float dt) { simulation.OnUpdate(dt); if (IsVisualizationEnabled) { simulationVisualization.OnUpdate(dt); } if (TrackEvaluationFinished) { // Increment to the next track currentTrackIndex++; // All evaluation has finished, move onto breeding if (currentTrackIndex == tracks.Count) { this.trainingState = TrainState.Breeding; return; } // Will reset all cars to the initial position for the track provided simulation.SetTrack(currentTrack); simulation.Reset(); // Resets all car visuals & sets new track visualization if (IsVisualizationEnabled) { simulationVisualization.SetTrack(currentTrack); simulationVisualization.Reset(); } } }
private void OnBreedingUpdate() { // Perform one generation of our GA genericAlgorithm.DoGeneration(); simulation.SetCars(genericAlgorithm.GetPopulation().Cast <ICarController>()); simulation.ResetCars(); // Add the metrics we will use to judge our cars fitness simulation.GetCars().ForEach(car => this.AddFitnessMetrics(car)); // Reset our simulation currentTrackIndex = 0; simulation.SetTrack(currentTrack); simulation.Reset(); // Reset the visualisation if (IsVisualizationEnabled) { // Reset all cars simulationVisualization.InitializeCars(simulation.GetCars()); // Reset all track visuals - not the most efficient but works really clean simulationVisualization.SetTrack(currentTrack); simulationVisualization.Reset(); } trainingState = TrainState.Evaluating; }
// Update is called once per frame void Update() { lifetime += Time.deltaTime; switch (state) { case TrainState.Going_To: if (!driveTo(path[0].position)) { state = TrainState.Going_From; } break; case TrainState.Going_From: if (!driveTo(path[1].position)) { Destroy(gameObject); } break; } if (lifetime > 1.75) { Destroy(gameObject); } }
public void GetStateTest() { string trainID = "StateTestTrain"; TrackBlock block = new TrackBlock("block", TrackOrientation.EastWest, new Point(35, 0), 50.0, 0, 0, false, false, 40, TrackAllowedDirection.Both, false, null, null, "block", "block"); block.NextBlock = block; Direction direction = Direction.East; Train target = new Train(trainID, block, direction); TrainState state = target.GetState(); Assert.AreEqual(null, state.Announcement); Assert.AreEqual(0, state.BlockProgress); Assert.AreEqual(false, state.BrakeFailure); Assert.AreEqual(1, state.Cars); Assert.AreEqual(0, state.Crew); Assert.AreEqual(block, state.CurrentBlock); Assert.AreEqual(direction, state.Direction); Assert.AreEqual(TrainState.Door.Open, state.Doors); Assert.AreEqual(false, state.EngineFailure); Assert.AreEqual(TrainState.Light.Off, state.Lights); Assert.AreEqual(40900, state.Mass); Assert.AreEqual(0, state.Passengers); Assert.AreEqual(false, state.SignalPickupFailure); Assert.AreEqual(0, state.Speed); Assert.AreEqual(0, state.Temperature); Assert.AreEqual(trainID, state.TrainID); Assert.AreEqual(35, state.X); Assert.AreEqual(0, state.Y); }
/// <summary> /// 게임 모드에 의해 시작됨, 게임 시작 이후 최초 한번 호출 /// </summary> public void OnStart() { LogHelper.LogInfo($"train start {GetNetworkId()}"); IsStarted = true; mCreateTime = mapData.jMapMovePathData[0].firstStartDelayTime + Timing.sInstance.GetFrameStartTime(); IsRun = true; mState = TrainState.Init; }
protected override void Awake() { base.Awake(); maxHp = hp = 5; MoveDir = Vector3.zero; state = TrainState.IDLE; //state = TrainState.ATTACKABLE; isAtkReady = false; }
// METHOD: TrainController //-------------------------------------------------------------------------------------- /// <summary> /// Primary constructor /// </summary> /// /// <param name="myTrain">The train associated with this controller</param> //-------------------------------------------------------------------------------------- public TrainController(ITrain myTrain) { this.m_myTrain = myTrain; this.m_currentState = m_myTrain.GetState(); this.m_trainID = m_currentState.TrainID; this.m_currentBlock = m_currentState.CurrentBlock; this.m_passengerGenerator = new Random((int)DateTime.Now.Ticks); this.ManualSpeed = -1; }
/// <summary> /// 值改变 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cLookUp_EditValueChanged(object sender, EventArgs e) { if (ListIsValid == null) { return; } selSource = EditValue == null ? null : ListIsValid.Find(model => model.Codes == EditValue); }
private void BeginTrain(TrainItem[] trainItems, int group, int wordsCount, TrainType type) { this.trainItems = trainItems; this.group = group; this.wordsCount = wordsCount; this.type = type; index = 0; state = TrainState.Training; }
// METHOD: TrainOperator //-------------------------------------------------------------------------------------- /// <summary> /// Secondary constructor, to be used by the CTC /// </summary> /// /// <param name="myTrain">The train associated with this GUI</param> /// <param name="myTrainController">The train controller associated with this GUI</param> //-------------------------------------------------------------------------------------- public TrainOperator(ITrain myTrain, TrainController myTrainController) { InitializeComponent(); m_isDemo = false; this.m_myTrain = myTrain; this.m_myTrainState = m_myTrain.GetState(); this.m_myTrainController = myTrainController; engineFailure.Enabled = false; brakeFailure.Enabled = false; powerFailure.Enabled = false; circuitFailure.Enabled = false; }
public TrainBase(TrainState state) { State = state; Destination = TrainManagerBase.CurrentOptions.InitialDestination; Station = -1; RouteLimits = new[] { double.PositiveInfinity }; CurrentRouteLimit = double.PositiveInfinity; CurrentSectionLimit = double.PositiveInfinity; Cars = new CarBase[] { }; Specs.DoorOpenMode = DoorMode.AutomaticManualOverride; Specs.DoorCloseMode = DoorMode.AutomaticManualOverride; }
internal Train(TrainState state) { State = state; Destination = Game.InitialDestination; Station = -1; RouteLimits = new double[] { double.PositiveInfinity }; CurrentRouteLimit = double.PositiveInfinity; CurrentSectionLimit = double.PositiveInfinity; Cars = new TrainManager.Car[] { }; Specs.DoorOpenMode = DoorMode.AutomaticManualOverride; Specs.DoorCloseMode = DoorMode.AutomaticManualOverride; }
void ChangeState(TrainState _newState) { state = _newState; switch (_newState) { case TrainState.EN_ROUTE: // keep current speed break; case TrainState.ARRIVING: float maxSpeed = parentLine.maxTrainSpeed; speed_on_platform_arrival = Mathf.Clamp(speed, maxSpeed * 0.1f, maxSpeed); break; case TrainState.DOORS_OPEN: // slight delay, then open the required door speed = 0f; stateDelay = Metro.INSTANCE.Train_delay_doors_OPEN; break; case TrainState.UNLOADING: Prepare_DISEMBARK(); break; case TrainState.LOADING: Prepare_EMBARK(); break; case TrainState.DOORS_CLOSE: passengers_to_DISEMBARK.Clear(); passengers_to_EMBARK.Clear(); // once totalPassengers == (totalPassengers + (waitingToBoard - availableSpaces)) - shut the doors stateDelay = Metro.INSTANCE.Train_delay_doors_CLOSE; // sort out vars for next stop (nextPlatform, door side, passengers wanting to get off etc) break; case TrainState.DEPARTING: // Determine next platform / station we'll be stopping at Update_NextPlatform(); // slight delay stateDelay = Metro.INSTANCE.Train_delay_departure; // get list of passengers who wish to depart at the next stop break; case TrainState.EMERGENCY_STOP: break; } }
public Train(int _trainIndex, int _parentLineIndex, float _startPosition, int _totalCarriages) { trainIndex = _trainIndex; parentLineIndex = _parentLineIndex; parentLine = Metro.INSTANCE.metroLines[parentLineIndex]; currentPosition = _startPosition; state = TrainState.EN_ROUTE; totalCarriages = _totalCarriages; SetupCarriages(); passengers = new List <Commuter>(); passengers_to_DISEMBARK = new List <Commuter>(); passengers_to_EMBARK = new List <Commuter>(); speed = 0f; accelerationStrength = Metro.INSTANCE.Train_accelerationStrength * parentLine.speedRatio; railFriction = Metro.INSTANCE.Train_railFriction; ChangeState(TrainState.DEPARTING); }
public override void Read(NetIncomingMessage inInputStream) { bool stateBit; UInt32 readState = 0; stateBit = inInputStream.ReadBoolean(); if (stateBit) { Vector3 location = default(Vector3); inInputStream.Read(ref location); Vector3 velocity = default(Vector3); inInputStream.Read(ref velocity); SetVelocity(velocity); SetLocation(location + velocity * (NetworkManager.Instance.GetRoundTripTimeClientSide() * 0.5f)); IsResetLocation = inInputStream.ReadBoolean(); //core.LogHelper.LogInfo($"train pos x{GetLocation().x}, y{GetLocation().y}, z{GetLocation().z}, IsResetLocation{IsResetLocation}"); readState |= (UInt32)ReplicationState.Pose; } stateBit = inInputStream.ReadBoolean(); if (stateBit) { mapObjectId = inInputStream.ReadUInt16(); readState |= (UInt32)ReplicationState.MapObjectID; } stateBit = inInputStream.ReadBoolean(); if (stateBit) { mLastState = mState; mState = (TrainState)inInputStream.ReadUInt32(3); readState |= (UInt32)ReplicationState.State; } OnAfterDeserialize(readState); }
// METHOD: CreateTrain_Click //-------------------------------------------------------------------------------------- /// <summary> /// Start the GUI, and create a train and train controller if in a demo /// </summary> /// /// <param name="sender">Sender</param> /// <param name="e">Event Arguments</param> //-------------------------------------------------------------------------------------- private void CreateTrain_Click(object sender, EventArgs e) { if (m_isDemo) { m_startingBlock = new TrackBlock("Block1", TrackOrientation.EastWest, new Point(0, 0), 1650, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block0", "Block2"); m_startingBlock.NextBlock = new TrackBlock("Block2", TrackOrientation.EastWest, new Point(1650, 0), 50, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block1", "Block3"); m_startingBlock.Authority = new BlockAuthority(70, 3); m_startingBlock.NextBlock.Authority = new BlockAuthority(70, 2); m_startingBlock.NextBlock.NextBlock = new TrackBlock("Block3", TrackOrientation.EastWest, new Point(1700, 0), 1000, 0, 0, true, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block2", "Block4"); m_startingBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block4", TrackOrientation.EastWest, new Point(2700, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block3", "Block5"); m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block5", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block4", "Block6"); m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock = new TrackBlock("Block6", TrackOrientation.EastWest, new Point(2800, 0), 100, 0, 0, false, false, 70, TrackAllowedDirection.Both, false, "controller1", "controller2", "Block5", "Block7"); m_startingBlock.NextBlock.NextBlock.Authority = new BlockAuthority(70, 1); m_startingBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0); m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0); m_startingBlock.NextBlock.NextBlock.NextBlock.NextBlock.NextBlock.Authority = new BlockAuthority(40, 0); m_startingBlock.Transponder = new Transponder("SHADYSIDE", 1); m_startingBlock.NextBlock.Transponder = new Transponder("SHADYSIDE", 0); m_myTrain = new TrainLib.Train("train1", m_startingBlock, Direction.East); m_myTrainState = m_myTrain.GetState(); m_myTrainController = new TrainController(m_myTrain); m_myTrainController.Schedule = GetRedlineSchedule(); Timer updateTimer = new Timer(); updateTimer.Tick += new EventHandler(Update); updateTimer.Interval = 40; updateTimer.Enabled = true; updateTimer.Start(); } m_myTimer = new Timer(); m_myTimer.Tick += new EventHandler(UpdateDisplay); m_myTimer.Interval = 500; m_myTimer.Enabled = true; m_myTimer.Start(); }
/// <summary> /// Sets the text information for a train /// </summary> /// <param name="train">Train</param> public void SetTrainInfo(ITrain train) { if (train == null) { return; } TrainState state = train.GetState(); if (state == null) { return; } m_displayedBlock = null; m_displayedTrain = train; Dictionary <string, string> info = new Dictionary <string, string>(); info.Add("Number of cars:", state.Cars.ToString()); info.Add("Crew members:", state.Crew.ToString()); info.Add("Direction:", state.Direction.ToString()); info.Add("Door Status:", state.Doors.ToString()); info.Add("Light Status:", state.Lights.ToString()); info.Add("Mass:", state.Mass.ToString()); info.Add("Passengers:", state.Passengers.ToString()); info.Add("Speed:", string.Format("{0:0.00} {1}", state.Speed.ToString(), KPH)); info.Add("Temperature:", state.Temperature.ToString()); info.Add("Position:", string.Format("{0:0.00} , {1:0.00}", state.X.ToString(), state.Y.ToString())); if (state.TrainID != null) { SetInfo(state.TrainID.ToString(), info); } else { SetInfo(UNKNOWN_TEXT, info); } }
internal TrackFollowingObject(TrainState state) : base(state) { }
private Train(TrainState state) { this.State = state; }
public TrackFollowingObject(TrainState state) : base(state) { }
public void UpdateTrainState(Guid trainId, TrainState state) { switch (state) { case TrainState.Cancelled: case TrainState.Terminated: const string cancelSql = @" UPDATE [dbo].[LiveTrain] SET [TrainStateId] = [TrainStateId] + @state WHERE [Id] = @trainId"; ExecuteNonQuery(cancelSql, new { trainId, state }); break; } }
public void SetLights(TrainState.Light lights) { }
public void SetDoors(TrainState.Door doors) { }
public void Restore() { state = TrainState.Begin; }
public FlashcardsStatusService(NavigationManager navigation) { state = TrainState.Begin; this.navigation = navigation; }
void FixedUpdate() { if (data.isPlaying) { } var trainPos = trainGo.transform.position; var prevTrainState = trainState; switch (trainState) { case TrainState.CLOSE1: if (0.5f <= trainTime) { trainState = TrainState.CLOSE2; } break; case TrainState.CLOSE2: if (trainTime == 0f) { doorGo.GetComponent <Animator>().Play("close"); } if (1f <= trainTime) { trainState = TrainState.CLOSE3; } break; case TrainState.CLOSE3: trainState = TrainState.RUN; break; case TrainState.RUN: var dist = trainTargetX - trainPos.x; if (15f < dist) { trainTargetSpeed = 3f; } else { trainTargetSpeed = 0.1f; } trainSpeed = Mathf.MoveTowards(trainSpeed, trainTargetSpeed, 0.1f * Time.deltaTime); if (dist == 0f) { trainState = TrainState.OPEN1; } break; case TrainState.OPEN1: if (1f <= trainTime) { trainState = TrainState.OPEN2; } break; case TrainState.OPEN2: if (trainTime == 0f) { doorGo.GetComponent <Animator>().Play("open"); } if (1f <= trainTime) { trainState = TrainState.OPEN3; } break; case TrainState.OPEN3: break; } trainTime += Time.deltaTime; if (prevTrainState != trainState) { trainTime = 0f; } trainPos.x = Mathf.MoveTowards(trainPos.x, trainTargetX, trainSpeed * Time.deltaTime); trainGo.transform.position = trainPos; // { // var rb = playerGo.GetComponent<Rigidbody2D>(); // // playerGo.OnCollisionEnter2DAsObservable().Subscribe(_col => { // // UnityEngine.Tilemaps.Tilemap tilemap; // // tilemap. // // }); // var v = rb.velocity; // v.x = 2f; // if (hasJump_) { // v.y = 4f; // hasJump_ = false; // } // rb.velocity = v; // } for (var i = objectList_.Count - 1; 0 <= i; i--) { var obj = objectList_[i]; { var player = obj.player; if (player != null) { UpdatePlayer(obj, player); } } { var stone = obj.stone; if (stone != null) { } } obj.time += Time.deltaTime; } for (var i = objectList_.Count - 1; 0 <= i; i--) { var obj = objectList_[i]; if (!obj.hasDestroy) { continue; } objectList_.RemoveAt(i); GameObject.Destroy(obj.gameObject); } if (data.isPlaying) { data.time += Time.deltaTime; } }
private List <TrainState> CreateSource() { List <TrainState> lists = new List <TrainState>(); TrainState os12 = new TrainState(); os12.Codes = ""; os12.StateNames = ""; lists.Add(os12); TrainState os1 = new TrainState(); os1.Codes = "10"; os1.StateNames = "资料受理"; lists.Add(os1); TrainState os2 = new TrainState(); os2.Codes = "36"; os2.StateNames = "预报班"; lists.Add(os2); TrainState os3 = new TrainState(); os3.Codes = "40"; os3.StateNames = "报班中"; lists.Add(os3); TrainState os4 = new TrainState(); os4.Codes = "50"; os4.StateNames = "科一培训"; lists.Add(os4); TrainState os5 = new TrainState(); os5.Codes = "60"; os5.StateNames = "科二培训"; lists.Add(os5); TrainState os6 = new TrainState(); os6.Codes = "70"; os6.StateNames = "科三培训"; lists.Add(os6); TrainState os7 = new TrainState(); os7.Codes = "74"; os7.StateNames = "科四培训"; lists.Add(os7); TrainState os8 = new TrainState(); os8.Codes = "80"; os8.StateNames = "毕业归档"; lists.Add(os8); TrainState os9 = new TrainState(); os9.Codes = "88"; os9.StateNames = "退学处理中"; lists.Add(os9); TrainState os10 = new TrainState(); os10.Codes = "90"; os10.StateNames = "退学归档"; lists.Add(os10); TrainState os11 = new TrainState(); os11.Codes = "100"; os11.StateNames = "复训"; lists.Add(os11); return(lists); }
public void StopTrain() { state = TrainState.End; navigation.NavigateTo("flashcards/results"); // Maybe it's wrong way & redirect need to be moved to a razor file }