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


C# State.GetType方法代码示例

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


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

示例1: OnEnable

	private void OnEnable(){
		if (!(target is State)) {
			return;
		}
		state = (State)target;
		stateList = new ReorderableList (state.GetType().ToString().Split('.').Last());
		stateFields = state.GetType ()
			.GetFields (BindingFlags.Public | BindingFlags.Instance)
			.Where (x => x.DeclaringType.IsSubclassOf (typeof(State)))
			.ToArray();

		object[] attributes=state.GetType().GetCustomAttributes(true);
		bool isTrigger=false;
		foreach(object attribute in attributes){
			if(attribute is TriggerAttribute){
				isTrigger=true;
			}
		}

		if (!isTrigger) {
			actionList = new ReorderableList (state.actions, "Actions", true);
			actionList.onAddCallback = AddAction;
			actionList.onRemoveCallback = RemoveAction;
			actionList.drawElementCallback = DrawActionElement;
			actionList.onHeaderClick = OnActionHeaderClick;
		}

		transitionList = new ReorderableList (state.transitions, "Transitions", true,false,false);
		transitionList.onRemoveCallback = RemoveTransition;
		transitionList.drawElementCallback = DrawTransitionElement;
		transitionList.onSelectCallback = TransitionSelected;

	}
开发者ID:gongchangyou,项目名称:AIController,代码行数:33,代码来源:StateInspector.cs

示例2: ChangeState

 //Function to handle statemachine
 public void ChangeState( State<EnemySniperScript> s )
 {
     if(s.GetType().Name == "Sniper_AttackPlayer"){
         CurrentState = StateID.attacking;
     }
     if(s.GetType().Name == "Sniper_MoveToPlayer"){
         CurrentState = StateID.moving;
     }
     StateMachine.ChangeState ( s );
 }
开发者ID:jcollins2014,项目名称:Project,代码行数:11,代码来源:EnemySniperScript.cs

示例3: SetState

		/// <summary>
		/// Sets state
		/// </summary>
		/// <param name="newState"></param>
		void SetState ( State newState )
		{						
			this.state = newState;
			Log.Message("CL: State: {0}", newState.GetType().Name );

			ClientStateChanged( this, new ClientEventArgs(){ ClientState = newState.ClientState, Message = newState.Message } );
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:11,代码来源:GameClient.Internal.cs

示例4: SwitchState

        public void SwitchState(State changeTo)
        {
            //Destroy the Current State
            if(activeState!= null)
                activeState.Destroy();

            //Setup new State
            activeState = changeTo;
            Debugger.Debug_Log("Initializing State-" + changeTo.GetType().Name);
            activeState.Init(_game, playerController);
    
        }
开发者ID:Cryofox,项目名称:ProjectScout_Platformer,代码行数:12,代码来源:StateManager.cs

示例5: Run

    public override IEnumerator Run(Brain controller)
    {
        if(!triggersBuilt) {
            foreach(TriggerManager manager in controlledTriggers) {
                manager.BuildTrigger(controller);
            }
            triggersBuilt = true;
        }
        yield return StartCoroutine(currentState.Run(controller));

        foreach(TriggerManager manager in currentState.GetTriggers()) {
            if(manager.ShouldTrigger()) {
                nextState = manager.target;
                Debug.Log("Triggered Transition: " + nextState.GetType().Name);
            }
        }
        if(nextState != null) {
            yield return StartCoroutine(currentState.Exit());
            currentState = nextState;
            nextState = null;
            yield return StartCoroutine(currentState.Enter(this, controller));
        }
    }
开发者ID:Syclamoth,项目名称:GamesAI6,代码行数:23,代码来源:Machine.cs

示例6: RequestStateTransition

 // Schedules a state transition at the next available time
 public void RequestStateTransition(State goToThis)
 {
     nextState = goToThis;
     Debug.Log("State Transition: " + nextState.GetType().Name);
 }
开发者ID:Syclamoth,项目名称:GamesAI6,代码行数:6,代码来源:Machine.cs

示例7: Handle

        /// <summary>
        /// Handles the received data
        /// </summary>
        private void Handle(int bytesReceived, Socket socket, State state)
        {
            int bytesRead = 0;
            int payloadLength, bytesAvailable, bytesNeeded;
            while (bytesRead < bytesReceived)
            {
                bytesAvailable = bytesReceived - bytesRead;
                if (bytesReceived > 0)
                {
                    if (state.packet.Length >= 7)
                    {
                        payloadLength = BitConverter.ToInt32(new byte[1].Concat(state.packet.Skip(2).Take(3)).Reverse().ToArray(), 0);
                        bytesNeeded = payloadLength - (state.packet.Length - 7);
                        if (bytesAvailable >= bytesNeeded)
                        {
                            state.packet = state.packet.Concat(state.buffer.Skip(bytesRead).Take(bytesNeeded)).ToArray();
                            bytesRead += bytesNeeded;
                            bytesAvailable -= bytesNeeded;
                            if (state.GetType() == typeof(ClientState))
                            {
                                Packet clientPacket = new Packet(state.packet, DataDestination.DATA_FROM_CLIENT);
                                Logger.LogPacket(clientPacket);
                                ServerSocket.Send(clientPacket.Raw);
                            }
                            else if (state.GetType() == typeof(ServerState))
                            {
                                Packet serverPacket = new Packet(state.packet, DataDestination.DATA_FROM_SERVER);
                                Logger.LogPacket(serverPacket);
                                ClientSocket.Send(serverPacket.Raw);
                            }
                            state.packet = new byte[0];
                        }
                        else
                        {
                            state.packet = state.packet.Concat(state.buffer.Skip(bytesRead).Take(bytesAvailable)).ToArray();
                            bytesRead = bytesReceived;
                            bytesAvailable = 0;
                        }
                    }
                    else if (bytesAvailable >= 7)
                    {
                        state.packet = state.packet.Concat(state.buffer.Skip(bytesRead).Take(7)).ToArray();
                        bytesRead += 7;
                        bytesAvailable -= 7;
                    }
                    else
                    {
                        state.packet = state.packet.Concat(state.buffer.Skip(bytesRead).Take(bytesAvailable)).ToArray();
                        bytesRead = bytesReceived;
                        bytesAvailable = 0;
                    }

                }
            }
        }
开发者ID:tempdban,项目名称:ClashRoyaleProxy,代码行数:58,代码来源:ReceiveSendThread.cs

示例8: GetLayerTypeFromState

 public static Type GetLayerTypeFromState(State state)
 {
     return GetLayerTypeFromState(state.GetType());
 }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:4,代码来源:StateMachineUtility.cs

示例9: ShowStates

		void ShowStates() {
			for (int i = 0; i < statesProperty.arraySize; i++) {
				currentStateProperty = statesProperty.GetArrayElementAtIndex(i);
				currentState = currentStateProperty.GetValue<State>();
				
				if (currentState == null) {
					DeleteFromArray(statesProperty, i);
					break;
				}
				
				BeginBox();
				
				Foldout(currentStateProperty, FormatStateType(currentState.GetType(), currentLayer).ToGUIContent(), GetStateStyle());
				Reorderable(statesProperty, i, true);
				
				ShowState();
				
				EndBox();
			}
		}
开发者ID:Kartoshka,项目名称:Crabby-Pulse-2,代码行数:20,代码来源:StateMachineEditor.cs

示例10: HandleNodeEvents

	private void HandleNodeEvents (State node)
	{
		Event ev = Event.current;
		switch (ev.type) {
		case EventType.mouseDown:
			if (node.position.Contains (ev.mousePosition) && Event.current.button == 0) {
				isDraggingState = true;
			}

			if (node.position.Contains (ev.mousePosition) && Event.current.button == 1) {
				GenericMenu genericMenu = new GenericMenu ();
				genericMenu.AddItem (new GUIContent ("Make Transition"), false, new GenericMenu.MenuFunction2 (this.MakeTransitionCallback), node);
				if (!((State)node).isDefaultState && node.GetType() != typeof(AnyState) && !(node is BaseTrigger)) {
					genericMenu.AddItem (new GUIContent ("Set As Default"), false, new GenericMenu.MenuFunction2 (this.SetDefaultCallback), node);
				} else {
					genericMenu.AddDisabledItem (new GUIContent ("Set As Default"));
				}
				
				if(node.GetType() == typeof(AnyState)){
					genericMenu.AddDisabledItem (new GUIContent ("Delete"));
				}else{
					genericMenu.AddItem (new GUIContent ("Delete"), false, new GenericMenu.MenuFunction2 (this.DeleteStateCallback), node);
				}

				if(node.GetType() == typeof(AnyState)){
					genericMenu.AddDisabledItem (new GUIContent ("Copy"));
				}else{
					genericMenu.AddItem (new GUIContent ("Copy"), false, new GenericMenu.MenuFunction2 (this.CopyState), node);
				}
				if(copyOfState!= null && node.GetType() != typeof(AnyState) && copyOfState.id != node.id){
					genericMenu.AddItem (new GUIContent ("Paste"), false, new GenericMenu.MenuFunction2 (this.PasteState), node);
				}else{
					genericMenu.AddDisabledItem (new GUIContent ("Paste"));
				}
				genericMenu.ShowAsContext ();
				ev.Use ();
			}
			break;
		case EventType.mouseUp:
			isDraggingState = false;
			Selection.activeObject=node;
			break;
		case EventType.mouseDrag:
			if (isDraggingState) {
				selectedState.position.x += Event.current.delta.x;
				selectedState.position.y += Event.current.delta.y;
				
				if (selectedState.position.y < 10) {
					selectedState.position.y = 10;
				}
				if (selectedState.position.x <  10) {
					selectedState.position.x = 10;
				}
				ev.Use ();
			}
			break;
		}
		
		if (node.position.Contains (ev.mousePosition) && (ev.type != EventType.MouseDown || ev.button != 0 ? false : ev.clickCount == 1)) {
			if (selectedState != node) {
				OnStateSelectionChanged (node);
			}
		}
	}
开发者ID:NusantaraBeta,项目名称:BrawlerRumble,代码行数:64,代码来源:AIEditorWindow.cs

示例11: DrawNode

	private void DrawNode (State node)
	{
		bool isTrigger=false;
		object[] attributes=node.GetType().GetCustomAttributes(true);
		foreach(object attribute in attributes){
			if(attribute is TriggerAttribute){
				isTrigger=true;
			}
		}
		UnityEditor.Graphs.Styles.Color color = node.isDefaultState ? UnityEditor.Graphs.Styles.Color.Orange : node.GetType () == typeof(AnyState) ? UnityEditor.Graphs.Styles.Color.Aqua : UnityEditor.Graphs.Styles.Color.Gray;
		if (isTrigger) {
			color=UnityEditor.Graphs.Styles.Color.Green;
		}

		GUI.Box (node.position, node.name, UnityEditor.Graphs.Styles.GetNodeStyle ("node", color, node == selectedState));
		DebugState (node);
		HandleNodeEvents (node);
	}
开发者ID:NusantaraBeta,项目名称:BrawlerRumble,代码行数:18,代码来源:AIEditorWindow.cs

示例12: Become

            protected void Become(State nextState)
            {
                if (mainWindow.state != null)
                {
                    mainWindow.state.Dispose();
                }

                mainWindow.state = nextState;

                if (nextState != null)
                    logger.Trace("State changed from {0} to {1}", GetType().Name, nextState.GetType().Name);
                else
                    logger.Trace("State stoped from {0}", GetType().Name);
            }
开发者ID:wuyuntao,项目名称:Mokap,代码行数:14,代码来源:MainWindow.xaml.cs


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