本文整理匯總了C#中CharacterState.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# CharacterState.GetType方法的具體用法?C# CharacterState.GetType怎麽用?C# CharacterState.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CharacterState
的用法示例。
在下文中一共展示了CharacterState.GetType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnUpdate
public override void OnUpdate(CharacterState owner)
{
#if UNITY_EDITOR || UNITY_STANDALONE
owner.transform.position += owner.transform.forward * Time.deltaTime * speed;
#else //Server AI Logic
accumTime += Time.deltaTime;
if (accumTime > updateAccumTime)
{
if (owner.GetType() == typeof(MonsterCharacter))
{
MonsterCharacter monster = (MonsterCharacter)owner;
monster.SetStateIdle();
}
//Console.WriteLine("AIStateWalk.OnUpdate");
accumTime = 0.0f;
}
else
{
//owner.PosZ += speed * Time.deltaTime;
//Vector3.Forward of XnaGeometry is -Z
//so you should multiply -1 for serverside code
owner.transform.position += owner.transform.forward * Time.deltaTime * speed;
}
#endif
}
示例2: OnUpdate
public override void OnUpdate(CharacterState owner)
{
accumTime += Time.deltaTime;
if (accumTime > 3.0f)
{
if(owner.GetType() == typeof(MonsterCharacter))
{
MonsterCharacter monster = (MonsterCharacter)owner;
monster.SetStateIdle();
}
//Console.WriteLine("AIStateWalk.OnUpdate");
accumTime = 0.0f;
}
}
示例3: OnEnter
//Vector3 targetPos ;
public override void OnEnter(CharacterState owner)
{
base.OnEnter(owner);
accumTime = 0.0f;
#if UNITY_EDITOR || UNITY_STANDALONE
Debug.Log("AIStateWalk.OnEnter");
#else //Server Logic
uint uniqueID = 0;
if (owner.GetType() == typeof(MonsterCharacter))
{
uniqueID = ((MonsterCharacter)owner).UniqueID;
}
Random random = new Random((int)DateTime.Now.Ticks + (int)uniqueID);
float x = 0.5f - (float)random.NextDouble();
float y = 0.0f;// (float)random.NextDouble();
float z = 0.5f - (float)random.NextDouble();
Vector3 dir;
dir.X = x;
dir.Y = y;
dir.Z = z;
dir = Vector3.Normalize(dir);
owner.transform.forward = dir;
//update AccumTime
updateAccumTime = MIN_UPDATE_ACCUMTIME + (float)random.NextDouble() * (MAX_UPDATE_ACCUMTIME - MIN_UPDATE_ACCUMTIME);
//Console.WriteLine(string.Format("{0} AIStateWalk.OnEnter:{1} ", uniqueID, dir.ToString()));
GameServer.Program.SendToAllClient_MonsterState(owner,this);
#endif
}