当前位置: 首页>>代码示例>>C#>>正文


C# State类代码示例

本文整理汇总了C#中State的典型用法代码示例。如果您正苦于以下问题:C# State类的具体用法?C# State怎么用?C# State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


State类属于命名空间,在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FSAString

 public FSAString()
 {
     state = State.START;
     fsachar = new FSAChar('\"');
     raw = "";
     val = "";
 }
开发者ID:JianpingZeng,项目名称:C-Compiler,代码行数:7,代码来源:string.cs

示例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);
            }
        }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:35,代码来源:ServerConnection.cs

示例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;
        }
开发者ID:onirtuen,项目名称:scopus,代码行数:28,代码来源:CrossAutomata.cs

示例4: creditsButtonPresed

 public void creditsButtonPresed()
 {
     cameraAnimator.SetTrigger("Credits");
     menuAnim.SetTrigger("Credits");
     creditsAnimator.SetTrigger("Credits");
     currentState = State.Credits;
 }
开发者ID:TeamBuzzinga,项目名称:AlphaDemo,代码行数:7,代码来源:MenuManager.cs

示例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);
        }
开发者ID:EricYan1,项目名称:Baconit,代码行数:32,代码来源:GlobalContentPresenter.xaml.cs

示例6: GetDefaultStartTimeForState

 public static TimeSpan GetDefaultStartTimeForState(State state)
 {
     return
         DefaultStartTimeForState.ContainsKey(state)
             ? DefaultStartTimeForState[state]
             : TimeSpan.Zero;
 }
开发者ID:MiroslavJelaska,项目名称:timer-for-competition,代码行数:7,代码来源:TimeConfig.cs

示例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;
                    }
                }
            }
        }
开发者ID:Yitzchok,项目名称:PublicDomain,代码行数:37,代码来源:LenientEcmaScriptDocument.cs

示例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");
    }
开发者ID:jayvan,项目名称:advent,代码行数:33,代码来源:17_2.cs

示例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;
    }
开发者ID:Lenakeiz,项目名称:TDS_Tutorial,代码行数:34,代码来源:Enemy.cs

示例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);
        }
开发者ID:WenningQiu,项目名称:appccelerate,代码行数:7,代码来源:StateTest.cs

示例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;
		}
	}
开发者ID:Ipsider,项目名称:EggplantColony,代码行数:61,代码来源:AntBehavior.cs

示例12: Project

 public Project(string name, DateTime startDate, string details, State projectState)
 {
     this.Name = name;
     this.StartDate = startDate;
     this.Details = details;
     this.State = projectState;
 }
开发者ID:HouseBreaker,项目名称:OOP,代码行数:7,代码来源:Project.cs

示例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;
        }
开发者ID:weimingtom,项目名称:db-diver,代码行数:28,代码来源:Shoal.cs

示例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;
 }
开发者ID:JohanGovers,项目名称:AIvsAI,代码行数:7,代码来源:PlanningAction.cs

示例15: SetTouchState

		private void SetTouchState(State state, Vector2D position)
		{
			if (touch == null)
				return; //ncrunch: no coverage
			touch.SetTouchState(0, state, position);
			AdvanceTimeAndUpdateEntities();
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:TouchDragDropTriggerTests.cs


注:本文中的State类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。