本文整理汇总了C#中State类的典型用法代码示例。如果您正苦于以下问题:C# State类的具体用法?C# State怎么用?C# State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
State类属于命名空间,在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FSAString
public FSAString()
{
state = State.START;
fsachar = new FSAChar('\"');
raw = "";
val = "";
}
示例2: ServerConnection
/// <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);
}
}
示例3: AddTrapState
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;
}
示例4: creditsButtonPresed
public void creditsButtonPresed()
{
cameraAnimator.SetTrigger("Credits");
menuAnim.SetTrigger("Credits");
creditsAnimator.SetTrigger("Credits");
currentState = State.Credits;
}
示例5: ShowContent
/// <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);
}
示例6: GetDefaultStartTimeForState
public static TimeSpan GetDefaultStartTimeForState(State state)
{
return
DefaultStartTimeForState.ContainsKey(state)
? DefaultStartTimeForState[state]
: TimeSpan.Zero;
}
示例7: Load
/// <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;
}
}
}
}
示例8: Main
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");
}
示例9: Attack
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;
}
示例10: StateTest
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);
}
示例11: Update
// 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;
}
}
示例12: Project
public Project(string name, DateTime startDate, string details, State projectState)
{
this.Name = name;
this.StartDate = startDate;
this.Details = details;
this.State = projectState;
}
示例13: Update
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;
}
示例14: CanExecute
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;
}
示例15: SetTouchState
private void SetTouchState(State state, Vector2D position)
{
if (touch == null)
return; //ncrunch: no coverage
touch.SetTouchState(0, state, position);
AdvanceTimeAndUpdateEntities();
}