當前位置: 首頁>>代碼示例>>C#>>正文


C# CharacterState.GetType方法代碼示例

本文整理匯總了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

    }
開發者ID:kimha578,項目名稱:jwUnityStudy,代碼行數:29,代碼來源:AIStateWalk.cs

示例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;
        }
    }
開發者ID:kimha578,項目名稱:jwUnityStudy,代碼行數:15,代碼來源:AIStateWalk.cs

示例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

    }
開發者ID:kimha578,項目名稱:jwUnityStudy,代碼行數:37,代碼來源:AIStateWalk.cs


注:本文中的CharacterState.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。