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


C# FSM.SetParamValue方法代码示例

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


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

示例1: DummyFsmUpdate

	static void DummyFsmUpdate(FSM fsm)
	{
		//const int updatePerMs = (int)(1f / 60f * 1000);
		const int updatePerMs = (int)(1000);
		
		bool speedAdding = true;
		bool gravityAdding = false;
		bool hpAdding = false;
		
		int perNumGravityEnabled = 5;
		int gravityNum = 0;
		
		//		var task = Task.Factory.StartNew((Action)(() =>
		
//		while (true)
//		{
			fsm.Update();
			
			var speed = fsm.GetParamValue<int>(P_SPEED);
			var hp = fsm.GetParamValue<int>(P_HP);
			var gravity = fsm.GetParamValue<int>(P_GRAVITY);
			
			if (hp <= -5) hpAdding = true;
			else if (hp > 100) hpAdding = false;
			hp += (hpAdding ? 4 : -4);
			
			fsm.SetParamValue(P_HP, hp); // minus 10 hp per frame, to dead when hp less and equals 0
			
			if (hp > 0) // is alive, then to do somthing...
			{
				if (speed <= 0) speedAdding = true;
				else if (speed > 20) speedAdding = false;
				fsm.SetParamValue(P_SPEED, (speed + (speedAdding ? 1 : -1))); // to run when speed greater and equals 10, back to idle when speed less than 10
				
				if (gravity <= -10) gravityAdding = true;
				else if (gravity > 10)  gravityAdding = false;
				fsm.SetParamValue(P_GRAVITY, (gravity + (gravityAdding ? 1 : -1))); // to fly when gravity less and equals 0
				
				gravityNum += 1;
				if (gravityNum % perNumGravityEnabled == 0)
				{
					fsm.SetParamValue(P_GRAVITY_ENABLED, !fsm.GetParamValue<bool>(P_GRAVITY_ENABLED));
				}
			}
//			Thread.Sleep(updatePerMs);
//		}
	}
开发者ID:TrojanFighter,项目名称:U3D-DesignerBehaviorTest1,代码行数:47,代码来源:TestFSM.cs

示例2: EnterState

	public override void EnterState(FSM fsm)
	{
		Debug.Log(string.Format("->Enter State : {0}", Name));
		Debug.Log(string.Format("Oh~~ Shit!!! NO! NO! NO!"));
		// enter dead state, initialize params
		fsm.SetParamValue(TestFSM.P_SPEED, (int)0);
		fsm.SetParamValue(TestFSM.P_GRAVITY, (int)10);
	}
开发者ID:TrojanFighter,项目名称:U3D-DesignerBehaviorTest1,代码行数:8,代码来源:TestFSM.cs

示例3: checkLife

	public bool checkLife(FSM fsm)
	{
		float curHP = m_unit.getCurProperty((int)GlobalDef.NewHeroProperty.PRO_LIFEPOINT);
		float maxHP = m_unit.getProperty((int)GlobalDef.NewHeroProperty.PRO_LIFEPOINT);
		float percent = curHP / maxHP;

		//检测逃跑
		for(int i = 0; i < hpPercentRunaway.Length; i++)
		{
			if(percent <= hpPercentRunaway[i] && canRunaway[i] == true)
			{
				canRunaway[i] = false;
				fsm.SetParamValue(AI_Define.P_STATE, (int)AI_Define.AI_State.S_RUN_AWAY);
				return true;
			}
		}
		//检测翻滚
		int energy = (int)m_unit.getCurProperty ((int)GlobalDef.NewHeroProperty.PRO_MOVEPOWER);
		for(int i = 0; i < hpPercent.Length; i++)
		{
			if(percent < hpPercent[i] && canRoll[i] && energy > 0)
			{
				canRoll[i] = false;
				fsm.SetParamValue(AI_Define.P_STATE, (int)AI_Define.AI_State.S_ROLLINGBACK);
				return true;
			}
		}
		return false;
	}
开发者ID:TrojanFighter,项目名称:U3D-DesignerBehaviorTest1,代码行数:29,代码来源:Player_Hit.cs


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