• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getNeighbourStates

 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;
 }
开发者ID:phealeyh,项目名称:31927-Cell-Assignment,代码行数:26,代码来源:Cells.cs


示例17: Attack

    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;
    }
开发者ID:Wandermayer,项目名称:GamersRhapsodyGameJam,代码行数:32,代码来源:Enemy.cs


示例18: Tick

        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");
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:30,代码来源:HarvesterDockSequence.cs


示例19: Start

 // Use this for initialization
 void Start()
 {
     GameObject groupped =  GameObject.Find("SpawnerGroup");
     SpawnerGroupScript scripta = groupped.GetComponent<SpawnerGroupScript>();
     spawnInterval = scripta.spawnInterval;
     state = State.SPAWNING;
 }
开发者ID:TeamMutiny,项目名称:mutiny-shmup,代码行数:8,代码来源:EnemySpawnerController.cs


示例20: Initialize

		protected void Initialize()
		{
			connections = new List<Connection>();
			inputs = new List<int>();
			actionState = State.Integrating;
			CurrentMembranePotential = config.RestingPotential;
		}
开发者ID:Ukio-G,项目名称:neurosim,代码行数:7,代码来源:Neuron.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StateEnum类代码示例发布时间:2022-05-24
下一篇:
C# StatType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap