示例#1
0
    // 初始化aa
    public new bool init(sdGameActorCreateInfo kInfo)
    {
        base.init(kInfo);

        // 设置角色初始朝向aa
        mFaceDirection = transform.rotation * Vector3.forward;

        // 初始化技能树aa
        CreateSkill_Action(kInfo.mJob);

        // 初始化角色属性aa
        if (sdGlobalDatabase.Instance.globalData != null)
        {
            // 属性表
            if (Property == null)
            {
                Property = sdConfDataMgr.CloneHashTable(sdGlobalDatabase.Instance.globalData["MainCharBaseProp"] as Hashtable);
            }

            // 每次进图就满血满蓝aa
            if (Property.ContainsKey("HP") && Property.ContainsKey("MaxHP"))
            {
                Property["HP"] = Property["MaxHP"];
            }

            if (Property.ContainsKey("SP") && Property.ContainsKey("MaxSP"))
            {
                Property["SP"] = Property["MaxSP"];
            }
            //
            AddSuitBuff();

            // 设置到UIaa
            RefreshProp();

            //
            if (sdConfDataMgr.Instance().skilliconAtlas == null)
            {
                int job = int.Parse(Property["BaseJob"].ToString());
                sdConfDataMgr.Instance().LoadSkillIcon(job);
            }

            // 换装aa
            if (sdGlobalDatabase.Instance.globalData.Contains("MainCharItemInfo"))
            {
                SetItemInfo(sdGlobalDatabase.Instance.globalData["MainCharItemInfo"] as Hashtable);
            }

            // 技能aa
            if (sdGlobalDatabase.Instance.globalData.Contains("MainCharSkillInfo"))
            {
                SetSkillInfo(sdGlobalDatabase.Instance.globalData["MainCharSkillInfo"] as Hashtable);
            }

            // 初始Buffaa
            if (sdGlobalDatabase.Instance.globalData.Contains("InitBuff"))
            {
                int[] buffArray = (int[])sdGlobalDatabase.Instance.globalData["InitBuff"];
                if (buffArray != null)
                {
                    foreach (int id in buffArray)
                    {
                        AddBuff(id, 0, this);
                    }
                }
                sdGlobalDatabase.Instance.globalData["InitBuff"] = null;
            }

            // 宠物战队Buffaa
            List <int> kBuffList = sdNewPetMgr.Instance.GetPetGroupBuff(this);
            if (kBuffList != null)
            {
                foreach (int iBuffId in kBuffList)
                {
                    AddBuff(iBuffId, 0, this);
                }
            }
        }

        // 加载角色动画aa
        LoadAnimationFile(kInfo.mJob);

        // 初始化个体AI参数(自动战斗系统)aa
        FingerControl kFingerControl = sdGameLevel.instance.GetFingerControl();

        if (kFingerControl != null)
        {
            mAutoFight = kFingerControl;
            mAutoFight.NotifyChangeTarget += NotifyBattleSystemChangeTarget;

            sdSkill kSkill = skillTree.getSkill(1001);
            if (kSkill != null)
            {
                sdBaseState kState        = kSkill.actionStateList[0];
                int         iCastDistance = (int)kState.stateData["CastDistance"];
                mAutoFight.BattleDistance = (iCastDistance) * 0.001f;
            }
        }
        sdGuideMgr.Instance.Init(Property["Name"].ToString().Trim('\0'));

        // 初始化群体AI参数aa
        sdBehaviourNode kBehaviourNode = sdBehaviourManager.GetSingleton().GetBehaviourNode(1);

        if (kBehaviourNode != null)
        {
            kBehaviourNode.AddActor(this);
        }

        return(true);
    }
示例#2
0
    //
    protected override void Start()
    {
        base.Start();

        // 鑾峰彇妯″瀷鍙婃帶鍒跺櫒淇℃伅aa
        GameObject rootRenderNode = transform.FindChild("@RenderNode").gameObject;

        gatherRenderNodesInfo(rootRenderNode);
        gatherMeshes(rootRenderNode);
        GatherMeshShaders();
        renderNode = rootRenderNode;
        renderNode.SetActive(false);

        for (int k = 0; k < renderNode.transform.childCount; ++k)
        {
            Transform kChildNode = renderNode.transform.GetChild(k);
            if (kChildNode.name.Equals("Bip01"))
            {
                boneRoot = kChildNode.gameObject;
                break;
            }
        }

        mAnimController = renderNode.GetComponent <Animation>();
//		mAnimController.enabled = false;

        mMotionController         = this.gameObject.GetComponent <CharacterController>();
        mMotionController.enabled = false;

        mNavAgent         = this.gameObject.GetComponent <NavMeshAgent>();
        mNavAgent.enabled = false;

        mSelfAudioSource = this.gameObject.GetComponent <AudioSource>();
//		mSelfAudioSource.enabled = false;

        // 鍦烘櫙淇℃伅aa
        mMainCamera = sdGameLevel.instance.mainCamera.GetComponent <Camera>();
        mTuituLogic = sdGameLevel.instance.tuiTuLogic;

        // 鍔犺浇鎬?墿灞炴€ц〃(鍩虹?灞炴€﹁aa
        if (ActorType.AT_Pet == GetActorType())
        {
            Hashtable kTable = sdNewPetMgr.Instance.GetPetPropertyFromDBID(mDBID);
            Property = sdConfDataMgr.CloneHashTable(kTable);
        }
        else
        {
            Hashtable kMonsterProperty = sdConfDataMgr.Instance().GetTable("MonsterProperty");
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                if (!kMonsterProperty.ContainsKey(templateId))
                {
                    Debug.LogError("monster templateID error=" + templateId);
                }
            }
            Hashtable kTable = kMonsterProperty[templateId] as Hashtable;
            Property = sdConfDataMgr.CloneHashTable(kTable);

            //娣辨笂BOSS闇€瑕佺壒娈婂?鐞嗚?閲庬.
            if (isLapBoss && !sdGameLevel.instance.testMode)
            {
                if (sdActGameMgr.Instance.m_uuLapBossLastBlood > 0)
                {
                    Property["HP"] = (int)sdActGameMgr.Instance.m_uuLapBossLastBlood;
                }
                else
                {
                    Property["HP"] = (int)sdActGameMgr.Instance.m_uuWorldBossLastBlood;
                }
            }
            else
            {
                Property["HP"] = Property["MaxHP"];     //< 淇??琛€閲庣鍙?湁鎬?墿闇€瑕佷慨姝㈣aa
            }
        }

        Property["MaxSP"] = 100;                        //< 淇??鏈€楂樻硶鍔涘€糰a
        Property["SP"]    = Property["MaxSP"];          //< 淇??娉曞姏鍊糰a

        // 鍒濆?鍖栬?鑹叉秷澶辨椂闂碼a
        mDisappeared  = false;
        mDisapearTime = (int)Property["DisappearTime"] / 1000.0f;

        //
        m_summonInfo  = sdConfDataMgr.CloneHashTable(sdConfDataMgr.Instance().m_BaseSummon);
        m_SkillEffect = sdConfDataMgr.CloneHashTable(sdConfDataMgr.Instance().m_BaseSkillEffect);

        // 鍒濆?鍖栬?鏉?a
        LoadHPUI();

        // 鍒濆?鍖栭€変腑鐩?爣鐗规晥aa
        //if (GetActorType() == ActorType.AT_Pet)
        //	LoadTargetEffect();

        // 鍒涘缓鎶€鑳絘a
        CreateSkill_Action((ulong)templateId);

        // 鍒濆?鍖栦釜浣揂I鍙傛暟aa
        if (ActorType.AT_Pet == GetActorType())
        {
            if (mAnimController != null)
            {
                mAnimController.cullingType = AnimationCullingType.AlwaysAnimate;
            }

            PetAutoFight kPetAutoFight = new PetAutoFight();
            kPetAutoFight.FollowDistance       = ((int)Property["FollowDistance"]) / 1000.0f;
            kPetAutoFight.BattleFollowDistance = ((int)Property["BattleFollowDistance"]) / 1000.0f;
            kPetAutoFight.EyeDistance          = ((int)Property["EyeSize"]) / 1000.0f;
            kPetAutoFight.Enable = useAI;

            kPetAutoFight.AutoRetreat              = (int)(Property["Retreat"]) != 0;
            kPetAutoFight.RetreatDetectInterval    = ((int)Property["RetreatDetectInterval"]) / 1000.0f;
            kPetAutoFight.RetreatDetectMinDistance = ((int)Property["RetreatDetectMinDistance"]) / 1000.0f;
            kPetAutoFight.RetreatElapseTime        = ((int)Property["RetreatElapseTime"]) / 1000.0f;

            kPetAutoFight.NotifyChangeTarget += NotifyBattleSystemChangeTarget;

            sdSkill kSkill = skillTree.getSkill(1001);
            if (kSkill != null)
            {
                sdBaseState kState        = kSkill.actionStateList[0];
                int         iCastDistance = (int)kState.stateData["CastDistance"];
                kPetAutoFight.BattleDistance = (iCastDistance) * 0.001f;
            }

            mAutoFight = kPetAutoFight;
            mAutoFight.SetActor(this);
        }
        else
        {
            MonsterAutoFight kMonsterAutoFight = new MonsterAutoFight();
            kMonsterAutoFight.EyeDistance   = ((int)Property["EyeSize"]) / 1000.0f;
            kMonsterAutoFight.ChaseDistance = ((int)Property["ChaseSize"]) / 1000.0f;
            kMonsterAutoFight.Enable        = useAI;

            kMonsterAutoFight.NotifyChangeTarget += NotifyBattleSystemChangeTarget;

            sdSkill kSkill = skillTree.getSkill(1001);
            if (kSkill != null)
            {
                sdBaseState kState        = kSkill.actionStateList[0];
                int         iCastDistance = (int)kState.stateData["CastDistance"];
                kMonsterAutoFight.BattleDistance = (iCastDistance) * 0.001f;
            }

            mAutoFight = kMonsterAutoFight;
            mAutoFight.SetActor(this);
        }

        // 鍒濆?鍖栫兢浣揂I鍙傛暟aa
        if (ActorType.AT_Pet == GetActorType())
        {
            sdBehaviourNode kBehaviourNode = sdBehaviourManager.GetSingleton().GetBehaviourNode(1);
            if (kBehaviourNode != null)
            {
                kBehaviourNode.AddActor(this);
            }
        }

        //
        LoadShadow();
    }