public FSAString() { state = State.START; fsachar = new FSAChar('\"'); raw = ""; val = ""; }
/// <summary> /// A connection to our server, always listening asynchronously. /// </summary> /// <param name="socket">The Socket for the connection.</param> /// <param name="args">The SocketAsyncEventArgs for asyncronous recieves.</param> /// <param name="dataReceived">A callback invoked when data is recieved.</param> /// <param name="disconnectedCallback">A callback invoked on disconnection.</param> public ServerConnection(Socket socket, SocketAsyncEventArgs args, DataReceivedCallback dataReceived, DisconnectedCallback disconnectedCallback) { logger = new ElibLogging("data"); this.AuthorizationType = Securtiy.AuthorizationType.Anonymous; lock (this) { var remotIP = socket.RemoteEndPoint as IPEndPoint; var localIP = socket.LocalEndPoint as IPEndPoint; State state = new State() { socket = socket, dataReceived = dataReceived, disconnectedCallback = disconnectedCallback, Device = new Device() { RemoteIP = remotIP.Address.ToString(), LocalIP = localIP.Address.ToString() } }; eventArgs = args; eventArgs.Completed += ReceivedCompleted; eventArgs.UserToken = state; ListenForData(eventArgs); } }
// Update is called once per frame void Update () { switch (state) { case State.IDLE: if(ball.transform.position.x > 0)//ball on ai side { attack_offset = Random.Range(0.25f, 0.8f); state = State.ATTACK; break; } if (idle_pos.x < transform.position.x) goLeft(); if (transform.position.x < idle_pos.x) goRight(); break; case State.ATTACK: if(ball.transform.position.x < 0) //ball on player side { float x = Random.Range(min_x, max_x - 3); idle_pos.x = x; state = State.IDLE; break; } if (ball.transform.position.x + attack_offset < transform.position.x) goLeft(); if (ball.transform.position.x > transform.position.x - attack_offset) goRight(); break; default: break; } }
private void opeation_Click(object sender, EventArgs e) { Button btn = sender as Button; firstNumber = double.Parse(display.Text); state = State.WaitingForSecondNumber; operation = btn.Text; }
private State AddTrapState(FiniteAutomata dfa) { var trapState = new State("trap") {Id = int.MaxValue}; for (int i = 0; i <= Byte.MaxValue; i++) { trapState.AddTransitionTo(trapState, InputChar.For((byte) i)); } var states = dfa.GetStates(); foreach (var state in states) { bool[] usedTransitions = new bool[Byte.MaxValue + 1]; // All nulls foreach (var transition in state.Transitions) { usedTransitions[transition.Key.Value] = true; // mark used symbol } for (int i = 0; i <= Byte.MaxValue; i++) { if (!usedTransitions[i]) { state.AddTransitionTo(trapState, InputChar.For((byte)i)); } } } return trapState; }
public EventDevelopment(DevelopmentState a_backState, LinkedList<Event> a_events) { if (a_events == null) { throw new ArgumentNullException(); } m_numOfAddedEvents = 0; m_state = State.neutral; m_backState = a_backState; m_buttonList = new LinkedList<Button>(); m_guiList = new LinkedList<GuiObject>(); m_buttonsToAdd = new Stack<Button>(); m_buttonsToRemove = new Stack<Button>(); m_eventsToRemove = new Stack<Button>(); m_eventsToAdd = new Stack<Event>(); m_events = new Dictionary<Button, Event>(); m_effects = new Dictionary<Button, EventEffect>(); m_triggers = new Dictionary<Button, EventTrigger>(); m_stateButtons = new Stack<LinkedList<Button>>(); foreach (Event t_e in a_events) { addEvent(t_e); } }
public void creditsButtonPresed() { cameraAnimator.SetTrigger("Credits"); menuAnim.SetTrigger("Credits"); creditsAnimator.SetTrigger("Credits"); currentState = State.Credits; }
// Use this for initialization void Start() { m_eState = State.A2B; transform.position = m_tPatrolPointA.position; m_tOrigin = m_tPatrolPointA; m_tTarget = m_tPatrolPointB; }
/// <summary> /// Called when we should show something /// </summary> /// <param name="link"></param> public void ShowContent(string link) { // Make sure we are in the correct state lock(this) { if(m_state != State.Idle) { return; } m_state = State.Opening; } // Create the content control m_contentControl = new FlipViewContentControl(); // This isn't great, but for now mock a post Post post = new Post() { Url = link, Id = "quinn" }; // Add the control to the UI ui_contentRoot.Children.Add(m_contentControl); // Set the post to begin loading m_contentControl.FlipPost = post; m_contentControl.IsVisible = true; // Show the panel ToggleShown(true); }
/// <summary> /// Create an instance of ModelProgramProvider for a given assembly /// </summary> /// <param name="modelAssemblyFile">The full path to the assembly file.</param> /// <param name="generator">Optional parameter generator.</param> public ModelProgramProvider(string modelAssemblyFile, ParameterGenerator/*?*/ generator) { modelAssembly = Assembly.LoadFrom(modelAssemblyFile); this.generator = generator; Initialize(); initialState = GetState(); }
public static TimeSpan GetDefaultStartTimeForState(State state) { return DefaultStartTimeForState.ContainsKey(state) ? DefaultStartTimeForState[state] : TimeSpan.Zero; }
public void OnNetworkData(double time, Vector3 position, Quaternion rotation) { // Shift the buffer sideways, deleting state 20 for (int i = m_BufferedState.Length - 1; i >= 1; i--) { m_BufferedState[i] = m_BufferedState[i - 1]; } // Record current state in slot 0 State state = new State(); state.timestamp = time; state.pos = position; state.rot = rotation; m_BufferedState[0] = state; // Update used slot count, however never exceed the buffer size // Slots aren't actually freed so this just makes sure the buffer is // filled up and that uninitalized slots aren't used. m_TimestampCount = Mathf.Min(m_TimestampCount + 1, m_BufferedState.Length); // Check if states are in order, if it is inconsistent you could reshuffel or // drop the out-of-order state. Nothing is done here for (int i = 0; i < m_TimestampCount - 1; i++) { if (m_BufferedState[i].timestamp < m_BufferedState[i + 1].timestamp) Debug.Log("State inconsistent"); } }
/// <summary> /// Loads the specified script. /// </summary> /// <param name="script">The script.</param> public virtual void Load(string script) { if (script != null) { int l = script.Length; char c; m_sb = new StringBuilder(100); m_state = State.None; m_isAllWhitespace = true; for (int i = 0; i < l; i++) { c = script[i]; switch (m_state) { default: if (c == '{') { } if (m_isAllWhitespace && !IsEcmaScriptWhitespace(c)) { m_isAllWhitespace = false; } m_sb.Append(c); continue; } } } }
// Use this for initialization void Start() { GameObject groupped = GameObject.Find("SpawnerGroup"); SpawnerGroupScript scripta = groupped.GetComponent<SpawnerGroupScript>(); spawnInterval = scripta.spawnInterval; state = State.SPAWNING; }
IEnumerator Attack() { pathfinder.enabled = false; currentState = State.Attacking; Vector3 OriginalPos = transform.position; Vector3 dirToTarget = (target.position - transform.position).normalized; Vector3 attackPos = target.position - dirToTarget * (myCollisionRadius); float attackSpeed = 3; float percent = 0; enemySkinMaterial.color = Color.red; bool hasAppliedDamage = false; while (percent <= 1) { if(percent >= 0.5f && !hasAppliedDamage){ hasAppliedDamage = true; targetEntity.TakeDamage(damage); } percent += Time.deltaTime * attackSpeed; float interpolation = (-Mathf.Pow(percent, 2) + percent) * 4; transform.position = Vector3.Lerp (OriginalPos, attackPos, interpolation); yield return null; } enemySkinMaterial.color = enemyOriginalColor; currentState = State.Chasing; pathfinder.enabled = true; }
public bool CanExecute(State s) { if (_prejudicates.Any(l => !l(s))) return false; if (_requires.Any(l => !s.Has(l.Key))) return false; if (_consumes.Any(l => !s.Sufficient(l.Key, l.Value))) return false; return true; }
void stateCell1() { text.text = "You've picked up the mirror, but the cell still looks bad.\n\n" + "[S to view Sheets, L to view Lock]"; if (Input.GetKeyDown (KeyCode.S)) {currState = State.sheets1;} else if (Input.GetKeyDown (KeyCode.L)) {currState = State.lock1;} }
public TenguBossStateMachine() { currState = 0; hold = 0; moveCount = 0; Random.seed = System.DateTime.Today.Millisecond; }
void stateMirror() { text.text = "The dirty old mirror on the wall seems loose.\n\n" + "[T to take the mirror, R to return to roaming your cell]"; if (Input.GetKeyDown (KeyCode.T)) {currState = State.cell1;} else if (Input.GetKeyDown (KeyCode.R)) {currState = State.cell;} }
protected void Initialize() { connections = new List<Connection>(); inputs = new List<int>(); actionState = State.Integrating; CurrentMembranePotential = config.RestingPotential; }
public World(IControls controls) { _controls = controls; _start = new State { Update = StartUpdate, Draw = StartDraw }; _alive = new State { Update = AliveUpdate, Draw = AliveDraw }; _dead = new State { Update = DeadUpdate, Draw = DeadDraw }; _gameOver = new State { Update = GameOverUpdate, Draw = GameOverDraw }; _state = _start; _viewer = new Viewer(); _bird = new Bird(controls); _pipeCollection = new PipeCollection(); }
private State[] getNeighbourStates(int position) { State[] neighbourStates = new State[4]; if (position == 0) { neighbourStates[0] = previousCells[SIZE - 1].getCurrentState; neighbourStates[1] = previousCells[position].getCurrentState; neighbourStates[2] = previousCells[position].getNextState; neighbourStates[3] = previousCells[position + 1].getCurrentState; } else if (position == SIZE - 1) { neighbourStates[0] = previousCells[SIZE - 2].getCurrentState; neighbourStates[1] = previousCells[position].getCurrentState; neighbourStates[2] = previousCells[position].getNextState; neighbourStates[3] = previousCells[0].getCurrentState; } else { neighbourStates[0] = previousCells[position - 1].getCurrentState; neighbourStates[1] = previousCells[position].getCurrentState; neighbourStates[2] = previousCells[position].getNextState; neighbourStates[3] = previousCells[position + 1].getCurrentState; } return neighbourStates; }
public static void Main() { string passcode = Console.ReadLine(); var initialState = new State(0, 0, passcode); int steps = 1; int longest = 0; var currentStates = new List<State>(); var nextStates = new List<State>(); var visited = new HashSet<string>(); currentStates.Add(initialState); while (currentStates.Count > 0) { foreach (State state in currentStates) { foreach (State nextState in state.Adjacent) { if (nextState.IsDestination) { longest = Math.Max(longest, steps); continue; } if (!visited.Contains(nextState.code)) { nextStates.Add(nextState); visited.Add(nextState.code); } } } currentStates = nextStates; nextStates = new List<State>(); steps++; } Console.WriteLine($"Longest path was {longest} steps"); }
public StateTest() { this.stateMachineInformation = A.Fake<IStateMachineInformation<States, Events>>(); this.extensionHost = A.Fake<IExtensionHost<States, Events>>(); this.testee = new State<States, Events>(States.A, this.stateMachineInformation, this.extensionHost); }
// Update is called once per frame void Update () { //Debug.Log ("Active state: " + activeState); //Debug.Log ("Food location" + foodLocation); //Debug.Log ("Found pheromone?" + foundPheromone); //Debug.Log ("Ant perspective: " + transportingFood); // A switch statement to change between the three behavior states. switch (activeState) { // The exploration behavior. case State.EXPLORE: explore (); // The transition conditions to another state. if (transportingFood) { activeState = State.TRANSPORT_FOOD; } if (foundPheromone) { activeState = State.FOLLOW_TRAIL; } break; // The behavior for following a pheromone trail. case State.FOLLOW_TRAIL: followTrail (); // The transition conditions to another state. if (transportingFood) { activeState = State.TRANSPORT_FOOD; } if (!foundFood) { activeState = State.EXPLORE; } break; // The food transportation behavior. case State.TRANSPORT_FOOD: transportFood (); // The transition conditions to another state. if (!transportingFood) { if (foodLocation != Vector3.zero) { activeState = State.FOLLOW_TRAIL; } else { activeState = State.EXPLORE; } } break; } }
public override void Update(State s, Room room) { base.Update(s, room); Vector2 direction = new Vector2((float)((TargetX - x) * (DiverGame.Random.NextDouble() * 0.2f + 0.8f)), (float)((TargetY - y) * (DiverGame.Random.NextDouble() * 0.2f + 0.8f))); if(direction.LengthSquared() > 0) direction.Normalize(); speedX += direction.X * 0.007f; speedY += direction.Y * 0.007f; speedX *= 0.999f; speedY *= 0.999f; float speed = (float)Math.Sqrt(speedX * speedX + speedY * speedY); animationGridFrame += speed * 0.25f + 0.03f; x += speedX; y += speedY; X = (int)x; Y = (int)y; float desiredRot = (float)Math.Atan2(speedX, -speedY) - (float)Math.PI / 2f; float rotDiff = desiredRot - rotation; while (rotDiff > MathHelper.Pi) rotDiff -= MathHelper.TwoPi; while (rotDiff < -MathHelper.Pi) rotDiff += MathHelper.TwoPi; rotation += rotDiff * 0.1f; }
public Project(string name, DateTime startDate, string details, State projectState) { this.Name = name; this.StartDate = startDate; this.Details = details; this.State = projectState; }
IEnumerator Attack() { currState = State.Attacking; pathFinder.enabled = false; skinMaterial.color = Color.red; Vector3 startPos = transform.position; Vector3 directionToTarget = (target.position - transform.position).normalized; Vector3 endPos = target.position - directionToTarget * (myCollisionRadius); //new Vector3(target.position.x, 1, target.position.z); float percent = 0.0f; float attackSpeed = 3.0f; bool hasAppliedDamage = false; while(percent <= 1.0f) { percent += Time.deltaTime * attackSpeed; float interpolation = ((- percent * percent) + percent) * 4; transform.position = Vector3.Lerp(startPos, endPos, interpolation); if(percent >= .5f && !hasAppliedDamage) { hasAppliedDamage = true; livingEntity.TakeDamage(damage); } yield return null; } pathFinder.enabled = true; skinMaterial.color = originalColor; currState = State.Chasing; }
public override Activity Tick(Actor self) { switch (state) { case State.Wait: return this; case State.Turn: state = State.DragIn; return Util.SequenceActivities(new Turn(112), this); case State.DragIn: state = State.Dock; return Util.SequenceActivities(new Drag(startDock, endDock, 12), this); case State.Dock: ru.PlayCustomAnimation(self, "dock", () => { ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop; }); state = State.Wait; return this; case State.Loop: if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc)) state = State.Undock; return this; case State.Undock: ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut); state = State.Wait; return this; case State.DragOut: return Util.SequenceActivities(new Drag(endDock, startDock, 12), NextActivity); } throw new InvalidOperationException("Invalid harvester dock state"); }
private void SetTouchState(State state, Vector2D position) { if (touch == null) return; //ncrunch: no coverage touch.SetTouchState(0, state, position); AdvanceTimeAndUpdateEntities(); }
internal Lobby(Client client) { Client = client; state = State.Init; }
// ----------------------------------------------------------------------------- // MoveBehavor public override void Init(bool _overridden) { switch (dState) { case State.NotDashing: if (!_overridden) { if (pcInput.DashButton && pcState.MovingHoriz) { dState = State.Initialize; } } break; case State.Initialize: if (_overridden) { dState = State.NotDashing; } else if (initialized) { dState = State.Move; } break; case State.Move: if (_overridden) { dState = State.NotDashing; } else if (targetReached) { dState = State.PostMomentum; } break; case State.PostMomentum: if (_overridden) { dState = State.NotDashing; } else if (momentumDone) { dState = State.Cooldown; } break; case State.Cooldown: if (_overridden || cooldownDone) { dState = State.NotDashing; } break; default: Debug.Log("switch: value match not found"); break; } // reset triggers if not dashing if (dState == State.NotDashing && (isActive || initialized || targetReached || cooldownDone)) { isActive = false; initialized = false; targetReached = false; momentumAddedLock = false; momentumDone = false; cooldownDone = false; } // Initialize dash if (dState == State.Initialize) { // determine hit point / end point wallHit = false; if (pcInput.RightButton) { castDir = Vector2.right; } else { castDir = Vector2.left; } startPoint = transform.position; endPoint = (Vector2)transform.position + (castDir * dist); // raycast RaycastHit2D hit = Physics2D.Raycast( transform.position, castDir, dist, dashMask); // if collided with wall if (hit.collider != null) { wallHit = true; hitPoint = hit.point; // set beside raycast hit object if (castDir == Vector2.right) { hitPoint += new Vector2(colliderRadius * -1, 0); } else { hitPoint += new Vector2(colliderRadius, 0); } } else { hitPoint = endPoint; } // init dash variables isActive = true; initialized = true; cooldownTimer = 0; momentumTimer = 0; dashTimer = dashDuration * 0.25f; // add a little skip to the beginning of dash // create burst effect GameObject burst = Instantiate(dashBurstEffectPrefab, transform.position, Quaternion.identity) as GameObject; burst.GetComponent <ParticleSystem>().Play(); Destroy(burst, 1f); } // post momentum timer if (dState == State.PostMomentum) { momentumTimer += Time.fixedDeltaTime; if (momentumTimer > momentumDuration) { momentumDone = true; isActive = false; } } // Cooldown timer if (dState == State.Cooldown) { cooldownTimer += Time.fixedDeltaTime; if (cooldownTimer > cooldownDuration) { cooldownDone = true; } } }
public RenameFileEditor(TService service, State state, string fileName, CancellationToken cancellationToken) : base(service, state, fileName, cancellationToken) { }
// Playing state must be called internally void ChangeState(State state) { var newState = GetStateForEnum(state); ChangeState(state, newState); }
static Parser() { states[0] = new State(new int[] { 3, 4 }, new int[] { -1, 1, -3, 3 }); states[1] = new State(new int[] { 2, 2 }); states[2] = new State(-1); states[3] = new State(-2); states[4] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -4, 5, -5, 44, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[5] = new State(new int[] { 4, 6, 10, 7 }); states[6] = new State(-25); states[7] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 8, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[8] = new State(-4); states[9] = new State(-5); states[10] = new State(new int[] { 9, 11 }); states[11] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 12, -16, 28, -17, 27, -14, 17 }); states[12] = new State(new int[] { 24, 13, 25, 23, 4, -15, 10, -15, 14, -15, 22, -15 }); states[13] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -16, 14, -17, 27, -14, 17 }); states[14] = new State(new int[] { 27, 15, 26, 25, 24, -17, 25, -17, 4, -17, 10, -17, 14, -17, 22, -17, 19, -17, 8, -17, 3, -17, 5, -17, 11, -17, 13, -17, 15, -17, 17, -17, 20, -17, 23, -17, 12, -17, 16, -17, 21, -17 }); states[15] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -17, 16, -14, 17 }); states[16] = new State(-20); states[17] = new State(-22); states[18] = new State(-14); states[19] = new State(-23); states[20] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 21, -16, 28, -17, 27, -14, 17 }); states[21] = new State(new int[] { 19, 22, 24, 13, 25, 23 }); states[22] = new State(-24); states[23] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -16, 24, -17, 27, -14, 17 }); states[24] = new State(new int[] { 27, 15, 26, 25, 24, -18, 25, -18, 4, -18, 10, -18, 14, -18, 22, -18, 19, -18, 8, -18, 3, -18, 5, -18, 11, -18, 13, -18, 15, -18, 17, -18, 20, -18, 23, -18, 12, -18, 16, -18, 21, -18 }); states[25] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -17, 26, -14, 17 }); states[26] = new State(-21); states[27] = new State(-19); states[28] = new State(new int[] { 27, 15, 26, 25, 24, -16, 25, -16, 4, -16, 10, -16, 14, -16, 22, -16, 19, -16, 8, -16, 3, -16, 5, -16, 11, -16, 13, -16, 15, -16, 17, -16, 20, -16, 23, -16, 12, -16, 16, -16, 21, -16 }); states[29] = new State(-6); states[30] = new State(-7); states[31] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 32, -16, 28, -17, 27, -14, 17 }); states[32] = new State(new int[] { 24, 13, 25, 23, 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 33, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[33] = new State(-26); states[34] = new State(-8); states[35] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 36, -16, 28, -17, 27, -14, 17 }); states[36] = new State(new int[] { 12, 37, 24, 13, 25, 23 }); states[37] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 38, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[38] = new State(-27); states[39] = new State(-9); states[40] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -4, 41, -5, 44, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[41] = new State(new int[] { 14, 42, 10, 7 }); states[42] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 43, -16, 28, -17, 27, -14, 17 }); states[43] = new State(new int[] { 24, 13, 25, 23, 4, -28, 10, -28, 14, -28, 22, -28 }); states[44] = new State(-3); states[45] = new State(-10); states[46] = new State(new int[] { 8, 18 }, new int[] { -14, 47 }); states[47] = new State(new int[] { 9, 48 }); states[48] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 49, -16, 28, -17, 27, -14, 17 }); states[49] = new State(new int[] { 16, 50, 24, 13, 25, 23 }); states[50] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 51, -16, 28, -17, 27, -14, 17 }); states[51] = new State(new int[] { 12, 52, 24, 13, 25, 23 }); states[52] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 53, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[53] = new State(-29); states[54] = new State(-11); states[55] = new State(new int[] { 18, 56 }); states[56] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 57, -16, 28, -17, 27, -14, 17 }); states[57] = new State(new int[] { 19, 58, 24, 13, 25, 23 }); states[58] = new State(-30); states[59] = new State(-12); states[60] = new State(new int[] { 8, 18, 6, 19, 18, 20 }, new int[] { -15, 61, -16, 28, -17, 27, -14, 17 }); states[61] = new State(new int[] { 21, 62, 24, 13, 25, 23 }); states[62] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 63, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[63] = new State(new int[] { 22, 64, 4, -32, 10, -32, 14, -32 }); states[64] = new State(new int[] { 8, 18, 3, 4, 5, 31, 11, 35, 13, 40, 15, 46, 17, 55, 20, 60, 23, 67 }, new int[] { -5, 65, -6, 9, -14, 10, -3, 29, -7, 30, -8, 34, -9, 39, -10, 45, -11, 54, -12, 59, -13, 66 }); states[65] = new State(-31); states[66] = new State(-13); states[67] = new State(new int[] { 8, 18 }, new int[] { -14, 68 }); states[68] = new State(new int[] { 28, 70, 4, -34, 10, -34, 14, -34, 22, -34 }, new int[] { -18, 69 }); states[69] = new State(-33); states[70] = new State(new int[] { 8, 18 }, new int[] { -14, 71 }); states[71] = new State(new int[] { 28, 70, 4, -34, 10, -34, 14, -34, 22, -34 }, new int[] { -18, 72 }); states[72] = new State(-35); rules[1] = new Rule(-2, new int[] { -1, 2 }); rules[2] = new Rule(-1, new int[] { -3 }); rules[3] = new Rule(-4, new int[] { -5 }); rules[4] = new Rule(-4, new int[] { -4, 10, -5 }); rules[5] = new Rule(-5, new int[] { -6 }); rules[6] = new Rule(-5, new int[] { -3 }); rules[7] = new Rule(-5, new int[] { -7 }); rules[8] = new Rule(-5, new int[] { -8 }); rules[9] = new Rule(-5, new int[] { -9 }); rules[10] = new Rule(-5, new int[] { -10 }); rules[11] = new Rule(-5, new int[] { -11 }); rules[12] = new Rule(-5, new int[] { -12 }); rules[13] = new Rule(-5, new int[] { -13 }); rules[14] = new Rule(-14, new int[] { 8 }); rules[15] = new Rule(-6, new int[] { -14, 9, -15 }); rules[16] = new Rule(-15, new int[] { -16 }); rules[17] = new Rule(-15, new int[] { -15, 24, -16 }); rules[18] = new Rule(-15, new int[] { -15, 25, -16 }); rules[19] = new Rule(-16, new int[] { -17 }); rules[20] = new Rule(-16, new int[] { -16, 27, -17 }); rules[21] = new Rule(-16, new int[] { -16, 26, -17 }); rules[22] = new Rule(-17, new int[] { -14 }); rules[23] = new Rule(-17, new int[] { 6 }); rules[24] = new Rule(-17, new int[] { 18, -15, 19 }); rules[25] = new Rule(-3, new int[] { 3, -4, 4 }); rules[26] = new Rule(-7, new int[] { 5, -15, -5 }); rules[27] = new Rule(-8, new int[] { 11, -15, 12, -5 }); rules[28] = new Rule(-9, new int[] { 13, -4, 14, -15 }); rules[29] = new Rule(-10, new int[] { 15, -14, 9, -15, 16, -15, 12, -5 }); rules[30] = new Rule(-11, new int[] { 17, 18, -15, 19 }); rules[31] = new Rule(-12, new int[] { 20, -15, 21, -5, 22, -5 }); rules[32] = new Rule(-12, new int[] { 20, -15, 21, -5 }); rules[33] = new Rule(-13, new int[] { 23, -14, -18 }); rules[34] = new Rule(-18, new int[] {}); rules[35] = new Rule(-18, new int[] { 28, -14, -18 }); }
/// <summary> /// Recupera as propriedades da string informada. /// </summary> /// <param name="propString"></param> /// <returns></returns> private Hashtable GetProperties(string propString) { bool flag = false; Hashtable hashtable = new Hashtable(); Tokenizer tokenizer = new Tokenizer(propString); string tokenValue = ""; int num = 0; State keyNeeded = State.keyNeeded; Stack stack = new Stack(); while (true) { switch (tokenizer.GetNextToken()) { case Tokenizer.UNNEST: if (keyNeeded != State.keyNeeded) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParanthesisMisplaced).Format()); } if (num < 1) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParenthesisUnexpected).Format()); } if (flag) { flag = false; } hashtable = stack.Pop() as Hashtable; num--; continue; case Tokenizer.ID: int num2; switch (keyNeeded) { case State.keyNeeded: if (tokenValue == "parameters") { flag = true; } tokenValue = tokenizer.TokenValue; num2 = tokenizer.GetNextToken(); if (((num2 == Tokenizer.CONTINUE) || (num2 == Tokenizer.UNNEST)) || ((num2 == Tokenizer.ID) || (num2 == Tokenizer.EOF))) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_KeyFollowingBadToken).Format()); } switch (num2) { case Tokenizer.ASSIGN: keyNeeded = State.valNeeded; continue; case Tokenizer.NEST: stack.Push(hashtable); hashtable[tokenValue.ToLower()] = new Hashtable(); hashtable = hashtable[tokenValue.ToLower()] as Hashtable; keyNeeded = State.keyNeeded; num++; break; } continue; case State.valNeeded: { string str2 = tokenizer.TokenValue; num2 = tokenizer.GetNextToken(); keyNeeded = State.keyNeeded; switch (num2) { case Tokenizer.ASSIGN: case Tokenizer.ID: case Tokenizer.EOF: throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_ValueFollowingBadToken).Format()); } if (flag) { hashtable[tokenValue] = str2; } else { hashtable[tokenValue.ToLower()] = str2; } switch (num2) { case Tokenizer.NEST: stack.Push(hashtable); hashtable[tokenValue.ToLower()] = new Hashtable(); hashtable = hashtable[tokenValue.ToLower()] as Hashtable; hashtable.Add("id", tokenValue); hashtable.Add("type", str2); keyNeeded = State.keyNeeded; num++; break; case Tokenizer.UNNEST: if (num < 1) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_CloseParenthesisUnexpected).Format()); } if (flag) { flag = false; } hashtable = stack.Pop() as Hashtable; num--; keyNeeded = State.keyNeeded; break; } continue; } } continue; case Tokenizer.EOF: if (keyNeeded != State.keyNeeded) { throw new ConfigurationException(ResourceMessageFormatter.Create(() => Caching.Properties.Resources.ConfigurationException_PropsConfigReader_InvalidEOF).Format()); } if (num > 0) { throw new ConfigurationException("Invalid property string, un-matched paranthesis"); } return(hashtable); } throw new ConfigurationException("Invalid property string"); } }
// Use this for initialization void Start() { _state = _startingState; _textComponent.text = _state.GetStateStory(); }
/// <summary> /// Gets the spans to fix by document for the <see cref="Scope"/> for this fix all occurences fix. /// If no spans are specified, it indicates the entire document needs to be fixed. /// </summary> public Task<ImmutableDictionary<Document, Optional<ImmutableArray<TextSpan>>>> GetFixAllSpansAsync(CancellationToken cancellationToken) => State.GetFixAllSpansAsync(cancellationToken);
//Wait time until the weapon can fire again public virtual IEnumerator FireRateCoolDown() { currentWeaponState = State.CoolingDown; yield return new WaitForSeconds(fireRate); currentWeaponState = State.Ready; }
//This is used to reset the weapon's state when equipped public void Refresh() { currentWeaponState = State.Ready; }
internal OneOrMany(T value) { _value = value; _values = default; _state = State.One; }
public BaseOperation() { m_state = State.Created; }
public static Address Create(Address1 address1, Address2 address2, City city, State state, PostalCode postalCode) => new Address(address1, address2, city, state, postalCode);
internal async Task Join() { if (state == State.Joining || state == State.Lobby) { return; } state = State.Joining; LobbyInfo lobbyInfo; try { lobbyInfo = await Client.lobbyService.Authorize(); } catch (Exception e) { state = State.Init; throw e; } try { lobbyConn = new LobbyConnection(); await lobbyConn.Connect(Client.AppId, lobbyInfo.Url, Client.GameVersion, Client.UserId, lobbyInfo.SessionToken); await lobbyConn.JoinLobby(); lobbyConn.OnMessage = (cmd, op, body) => { switch (cmd) { case CommandType.Lobby: switch (op) { case OpType.RoomList: HandleRoomListUpdated(body.RoomList); break; default: Logger.Error("unknown msg: {0}/{1} {2}", cmd, op, body); break; } break; case CommandType.Statistic: break; case CommandType.Error: { Logger.Error("error msg: {0}", body); ErrorInfo errorInfo = body.Error.ErrorInfo; Client.OnError?.Invoke(errorInfo.ReasonCode, errorInfo.Detail); } break; default: Logger.Error("unknown msg: {0}/{1} {2}", cmd, op, body); break; } }; state = State.Lobby; } catch (Exception e) { if (lobbyConn != null) { await lobbyConn.Close(); } state = State.Init; throw e; } }
public static void Add(State state) { _states.Add(state); }
public void SetTarget(Transform newTarget, State newState) { target = newTarget; state = newState; }
public void Chase(Transform other, State newState) { _aiDestinationSetter.target = other; }
public static List <string> SerialiseState(State newState, List <string> importedProvinces) { string vp1provID = "ProvinceID"; string vp2provID = "ProvinceID"; Dictionary <int, string> provinceDict = new Dictionary <int, string> (); if (importedProvinces != null) { int i = 0; foreach (var provinceID in importedProvinces) { provinceDict.Add(i, provinceID); i++; } provinceDict.TryGetValue(MainClass.GetRandomNumber(0, provinceDict.Count), out vp1provID); provinceDict.TryGetValue(MainClass.GetRandomNumber(0, provinceDict.Count), out vp2provID); } var retVal = new List <string> (); retVal.Add(""); retVal.Add("state = {"); retVal.Add("\tid = " + newState.StateId); retVal.Add("\tname = " + newState.StateName); retVal.Add("\tmanpower = " + newState.Manpower); retVal.Add(""); retVal.Add("\tstate_category = " + newState.StateCategory); retVal.Add(""); retVal.Add("\tresources = {"); foreach (var pair in newState.Resources) { if (pair.Value != 0) { retVal.Add("\t\t" + pair.Key + "=" + pair.Value); } } retVal.Add("\t}"); retVal.Add(""); retVal.Add("\thistory = {"); retVal.Add("\t\t" + newState.History.Owner); retVal.Add(""); if (newState.History.VictoryPoints1 != 0) { retVal.Add("\t\tvictory_points = {"); retVal.Add("\t\t\t" + vp1provID + " " + newState.History.VictoryPoints1 + " #change if ProvinceID"); retVal.Add("\t\t}"); } if (newState.History.VictoryPoints2 != 0) { retVal.Add("\t\tvictory_points = {"); retVal.Add("\t\t\t" + vp2provID + " " + newState.History.VictoryPoints2 + " #change if ProvinceID"); retVal.Add("\t\t}"); } retVal.Add(""); retVal.Add("\t\tbuildings = {"); foreach (var pair in newState.History.Buildings) { if (pair.Value != 0) { retVal.Add("\t\t\t" + pair.Key + "=" + pair.Value); } } retVal.Add("\t\t}"); retVal.Add(""); retVal.Add("\t\t" + newState.History.Core); if (newState.History.Core2.IsNotNullOrEmpty()) { retVal.Add("\t\t" + newState.History.Core2); } retVal.Add("\t}"); retVal.Add(""); retVal.Add("\tprovinces = {"); string provinces = GenerateProvincesString(vp1provID, vp2provID, importedProvinces, provinceDict); retVal.Add("\t\t" + vp1provID + " " + vp2provID + " " + provinces + " #change these if ProvinceID"); retVal.Add("\t}"); retVal.Add("}"); return(retVal); }
void Awake() { cam = GetComponentInChildren <Camera>(); state = State.Idle; }
public void Reset() { state = State.Idle; }
protected void AddErrorState(string member, Exception ex) { State.AddError(member, ex.GetExceptionMessage()); }
// Use this for initialization void Start() { state = startingState; textComponent.text = state.GetStoryText(); }
public override bool MoveToAttribute(string name) { int depth; XPathNavigator nav = GetElemNav(out depth); if (null == nav) { return(false); } string prefix, localname; ValidateNames.SplitQName(name, out prefix, out localname); // watch for a namespace name bool IsXmlnsNoPrefix = false; if ((IsXmlnsNoPrefix = (0 == prefix.Length && localname == "xmlns")) || (prefix == "xmlns")) { if (IsXmlnsNoPrefix) { localname = string.Empty; } if (nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) { do { if (nav.LocalName == localname) { goto FoundMatch; } } while (nav.MoveToNextNamespace(XPathNamespaceScope.Local)); } } else if (0 == prefix.Length) { // the empty prefix always means empty namespaceUri for attributes if (nav.MoveToAttribute(localname, string.Empty)) { goto FoundMatch; } } else { if (nav.MoveToFirstAttribute()) { do { if (nav.LocalName == localname && nav.Prefix == prefix) { goto FoundMatch; } } while (nav.MoveToNextAttribute()); } } return(false); FoundMatch: if (_state == State.InReadBinary) { _readBinaryHelper.Finish(); _state = _savedState; } MoveToAttr(nav, depth + 1); return(true); }
void TransitionState(State state) { mCurrentState = state; }
/// <summary> /// Move to the next reader state. Return false if that is ReaderState.Closed. /// </summary> public override bool Read() { _attrCount = -1; switch (_state) { case State.Error: case State.Closed: case State.EOF: return(false); case State.Initial: // Starting state depends on the navigator's item type _nav = _navToRead; _state = State.Content; if (XPathNodeType.Root == _nav.NodeType) { if (!_nav.MoveToFirstChild()) { SetEOF(); return(false); } _readEntireDocument = true; } else if (XPathNodeType.Attribute == _nav.NodeType) { _state = State.Attribute; } _nodeType = ToXmlNodeType(_nav.NodeType); break; case State.Content: if (_nav.MoveToFirstChild()) { _nodeType = ToXmlNodeType(_nav.NodeType); _depth++; _state = State.Content; } else if (_nodeType == XmlNodeType.Element && !_nav.IsEmptyElement) { _nodeType = XmlNodeType.EndElement; _state = State.EndElement; } else { goto case State.EndElement; } break; case State.EndElement: if (0 == _depth && !_readEntireDocument) { SetEOF(); return(false); } else if (_nav.MoveToNext()) { _nodeType = ToXmlNodeType(_nav.NodeType); _state = State.Content; } else if (_depth > 0 && _nav.MoveToParent()) { Debug.Assert(_nav.NodeType == XPathNodeType.Element, _nav.NodeType.ToString() + " == XPathNodeType.Element"); _nodeType = XmlNodeType.EndElement; _state = State.EndElement; _depth--; } else { SetEOF(); return(false); } break; case State.Attribute: case State.AttrVal: if (!_nav.MoveToParent()) { SetEOF(); return(false); } _nodeType = ToXmlNodeType(_nav.NodeType); _depth--; if (_state == State.AttrVal) { _depth--; } goto case State.Content; case State.InReadBinary: _state = _savedState; _readBinaryHelper.Finish(); return(Read()); } return(true); }
public override bool MoveToNextAttribute() { switch (_state) { case State.Content: return(MoveToFirstAttribute()); case State.Attribute: { if (XPathNodeType.Attribute == _nav.NodeType) { return(_nav.MoveToNextAttribute()); } // otherwise it is on a namespace... namespace are in reverse order Debug.Assert(XPathNodeType.Namespace == _nav.NodeType); XPathNavigator nav = _nav.Clone(); if (!nav.MoveToParent()) { return(false); // shouldn't happen } if (!nav.MoveToFirstNamespace(XPathNamespaceScope.Local)) { return(false); // shouldn't happen } if (nav.IsSamePosition(_nav)) { // this was the last one... start walking attributes nav.MoveToParent(); if (!nav.MoveToFirstAttribute()) { return(false); } // otherwise we are there _nav.MoveTo(nav); return(true); } else { XPathNavigator prev = nav.Clone(); for (; ;) { if (!nav.MoveToNextNamespace(XPathNamespaceScope.Local)) { Debug.Fail("Couldn't find Namespace Node! Should not happen!"); return(false); } if (nav.IsSamePosition(_nav)) { _nav.MoveTo(prev); return(true); } prev.MoveTo(nav); } // found previous namespace position } } case State.AttrVal: _depth--; _state = State.Attribute; if (!MoveToNextAttribute()) { _depth++; _state = State.AttrVal; return(false); } _nodeType = XmlNodeType.Attribute; return(true); case State.InReadBinary: _state = _savedState; if (!MoveToNextAttribute()) { _state = State.InReadBinary; return(false); } _readBinaryHelper.Finish(); return(true); default: return(false); } }
internal Configuration(State <A, S> state, Word <A, S> remainingWord, Stack <A, S> stack) { State = state; RemainingWord = remainingWord; Stack = stack; }
protected bool invulnerable; //Used to give the mobile temporary invincibility after getting hit etc. public abstract void ChangeState(State <Mobile> state);
private void ChangeState(State stateToChangeTo) { controller.xMove = controller.yMove = 0; currentState = stateToChangeTo; }
public static void Edit(State state) { var selectedState = _states.FirstOrDefault(c => c.StateAbbreviation == state.StateAbbreviation); selectedState.StateName = state.StateName; }