Exemple #1
0
        public override void CreateActualModel()
        {
            AvatarModelData data = AvatarModelData.dataMap.GetValueOrDefault(m_monsterData.model, null);
            if (data == null)
            {
                LoggerHelper.Error("Model not found: " + m_monsterData.model);
                return;
            }
            LoggerHelper.Debug("monster create:" + ID + ",name:" + data.prefabName);
            SubAssetCacheMgr.GetCharacterInstance(data.prefabName,
                (prefab, guid, gameObject) =>
                {
                    if (this.Actor)
                        this.Actor.Release();
                    if (Transform)
                        AssetCacheMgr.ReleaseLocalInstance(Transform.gameObject);
                    GameObject = (gameObject as GameObject);

                    Transform = GameObject.transform;
                    Transform.localScale = scale;
                    if (data.scale > 0)
                    {
                        Transform.localScale = new Vector3(data.scale, data.scale, data.scale);
                    }
                    Transform.tag = "Monster";
                    Transform.gameObject.layer = 11;
                    sfxHandler = GameObject.AddComponent<SfxHandler>();
                    motor = GameObject.AddComponent<MogoMotorServer>();

                    audioSource = GameObject.AddComponent<AudioSource>();
                    audioSource.rolloffMode = AudioRolloffMode.Custom;

                    CharacterController controller = GameObject.GetComponent<CharacterController>();
                    controller.radius = m_monsterData.scaleRadius / 100f;
                    controller.height = EntityColiderHeight;
                    float centerY = (controller.height > controller.radius * 2) ? (controller.height * 0.5f) : (controller.radius);
                    controller.center = new Vector3(0, centerY, 0);

                    animator = GameObject.GetComponent<Animator>();
                    ActorDummy ap = GameObject.AddComponent<ActorDummy>();
                    ap.theEntity = this;
                    this.Actor = ap;
                    UpdatePosition();
                    if (data.originalRotation != null && data.originalRotation.Count == 3)
                    {
                        Transform.eulerAngles = new Vector3(data.originalRotation[0], data.originalRotation[1], data.originalRotation[2]);
                    }
                    else
                    {
                        if (MogoWorld.thePlayer != null && MogoWorld.thePlayer.Transform != null)
                        {
                            Vector3 targetToLookAt = MogoWorld.thePlayer.Transform.position;
                            Transform.LookAt(new Vector3(targetToLookAt.x, Transform.position.y, targetToLookAt.z));
                        }
                    }
                    if (NotTurn())
                    {
                        motor.canTurn = false;
                    }
                    hp = (uint)m_monsterData.hpBase;
                    #region Shader
                    if (ShaderData.dataMap.ContainsKey(m_monsterData.shader)
                        && GameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true) != null)
                    {
                        MogoFXManager.Instance.SetObjShader(GameObject, ShaderData.dataMap[m_monsterData.shader].name, ShaderData.dataMap[m_monsterData.shader].color);
                        MogoFXManager.Instance.AlphaFadeIn(GameObject, fadeInTime);
                    }
                    #endregion

                    base.CreateModel();

                    MogoFXManager.Instance.AddEnemyInScreen(Transform.gameObject, ID);

                    motor.SetAngularSpeed(240f);
                    motor.acceleration = 2f;

                    //GameObject.AddComponent<MogoObjOpt>().ObjType = MogoObjType.Dummy;
                    //if (GameObject.GetComponent<Animation>() != null)
                    //{
                    //    GameObject.GetComponent<Animation>().enabled = false;
                    //} //鸟人动作带位移
                    try
                    {
                        if (m_monsterData != null && m_monsterData.bornFx != null)
                            foreach (var item in m_monsterData.bornFx)
                            {
                                sfxHandler.HandleFx(item);
                            }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Except(ex);
                    }

                    //开始执行出生流程
                    m_bModelBuilded = true;
                    m_aiRoot = AIContainer.container.Get((uint)m_monsterData.aiId);

                    uint waitTime = (uint)m_monsterData.bornTime;
                    if (waitTime <= 1)//容错
                        waitTime = 3000;
                    if (blackBoard.timeoutId > 0)
                        TimerHeap.DelTimer(blackBoard.timeoutId);

                    //LoggerHelper.Error("RebornAnimationDelay" + waitTime);
                    m_currentSee = m_monsterData.see;
                    blackBoard.ChangeState(Mogo.AI.AIState.THINK_STATE);
                    blackBoard.timeoutId = TimerHeap.AddTimer(waitTime, 0, RebornAnimationDelay);
                    TimerHeap.AddTimer(waitTime, 0, BornedHandler);
                    Actor.ActChangeHandle = ActionChange;
                }
            );
        }
Exemple #2
0
 public void UpdateAutoFightInfo()
 {
     if (MogoWorld.canAutoFight)
     {
         int weaponType = GetEquipSubType();
         m_iNormalAttackCastSkillId = 0;
         if (weaponType != 0)
         {
             int normalOneSkillId = (this.skillManager as PlayerSkillManager).GetNormalOne();
             int reflectNormalComboSkillId = SkillIdReflectData.GetReflectSkillId(normalOneSkillId);
             m_iNormalAttackCastSkillId = reflectNormalComboSkillId;
             //LoggerHelper.Error("normalOneSkillId" + normalOneSkillId + " reflectNormalComboSkillId:" + m_iNormalAttackCastSkillId);
             switch (vocation)
             {
                 case Vocation.Warrior:
                     m_iAiId = 10001;
                     m_aiRoot = AIContainer.container.Get((uint)m_iAiId);
                     //m_iNormalAttackCastSkillId = (((int)WeaponSubType.CLAYMORE) == weaponType) ? 2001 : 2007;
                     break;
                 case Vocation.Assassin:
                     m_iAiId = 10002;
                     m_aiRoot = AIContainer.container.Get((uint)m_iAiId);
                     //m_iNormalAttackCastSkillId = (((int)WeaponSubType.SICKLE) == weaponType) ? 2057 : 2051;
                     break;
                 case Vocation.Archer:
                     m_iAiId = 10003;
                     m_aiRoot = AIContainer.container.Get((uint)m_iAiId);
                     //m_iNormalAttackCastSkillId = (((int)WeaponSubType.BOW) == weaponType) ? 2101 : 2107;
                     break;
                 case Vocation.Mage:
                     m_iAiId = 10004;
                     m_aiRoot = AIContainer.container.Get((uint)m_iAiId);
                     //m_iNormalAttackCastSkillId = (((int)WeaponSubType.STAFF) == weaponType) ? 2151 : 2157;
                     break;
                 default:
                     m_aiRoot = null;
                     //m_iNormalAttackCastSkillId = 0;
                     break;
             }
         }
     }
 }