本文整理汇总了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
}