Пример #1
0
    public void DefenceBossCreate(EntityModel monsterDataModel)
    {
        if (!MonsterManager.Instance.IsBossStatusPanelInit())
        {
            GameObject bossStatusPanel = NGUITools.AddChild(TopRightPos, BossStatusForDefence);
            bossStatusPanel.transform.localPosition = Vector3.zero;
            bossStatusPanel.transform.localScale    = Vector3.one;
            //Edit by lee
            bossStatusPanel.transform.parent = UI.Battle.BattleUIManager.Instance.GetScreenTransform(UI.Battle.ScreenPositionType.TopRight);
            //赋值
            m_bossStatusForDefencePanel = bossStatusPanel.GetComponent <BossStatusForDefencePanel>();
            MonsterManager.Instance.SetBossStatusPanel(m_bossStatusForDefencePanel);

            SetMonsterLoopNum();

            m_bossStatusForDefencePanel.SetBloodNum(monsterDataModel);

            m_upTips      = m_bossStatusForDefencePanel.SpecProperty;
            m_upTipsLabel = m_upTips.GetComponentInChildren <UILabel>();
            m_upTips.SetActive(false);

            //初始路障都打叉,在路障刷出来的时候点亮
            for (int i = 0; i < m_bossStatusForDefencePanel.RoadblockDamagedIcon.Length; i++)
            {
                if (!RoadblockEntityModes.ContainsKey(i))
                {
                    m_bossStatusForDefencePanel.RoadblockDamagedIcon[i].SetActive(true);
                }
            }
        }
        else
        {
            BossStatusPanel_V3 bossStatusPanelScript = MonsterManager.Instance.GetBossStatusPanel();
            bossStatusPanelScript.SetDataModel(monsterDataModel);
        }
    }
Пример #2
0
    private void CreateMonster(IEntityDataStruct entityDataStruct)
    {
        EntityModel monsterDataModel = MonsterManager.Instance.GetEntityMode(entityDataStruct.SMsg_Header.uidEntity);

        if (monsterDataModel == null)
        {
            Debug.LogError("monster uid : " + entityDataStruct.SMsg_Header.uidEntity.ToString() + " cant find");
        }
        var sMsgPropCreateEntity_SC_Monster = (SMsgPropCreateEntity_SC_Monster)monsterDataModel.EntityDataStruct;

        int monsterId = sMsgPropCreateEntity_SC_Monster.BaseObjectValues.OBJECT_FIELD_ENTRY_ID;
        //TraceUtil.Log("==>创建怪物ID: " + monsterId);
        var monsterData = BattleConfigManager.Instance.GetMonsterData(monsterId);

        if (monsterData == null)
        {
            Debug.LogWarning("找不到怪物配置");
            return;
        }
        var pos = Vector3.zero;

        pos = pos.GetFromServer(sMsgPropCreateEntity_SC_Monster.MonsterX, sMsgPropCreateEntity_SC_Monster.MonsterY);
        GameObject monsterPrefab = MapResManager.Instance.GetMapMonsterPrefab(monsterId);
        float      angle         = sMsgPropCreateEntity_SC_Monster.MonsterUnitValues.UNIT_FIELD_DIR / 1000f + 90;
        var        monster       = (GameObject)GameObject.Instantiate(monsterPrefab, pos, Quaternion.Euler(0, angle, 0));

        #region edit by lee

        var monsterBehaviour = monster.GetComponent <MonsterBehaviour>();

        if (monsterBehaviour == null)
        {
            Debug.LogWarning("怪物" + monsterId.ToString() + "未挂载脚本");
            monsterBehaviour = monster.AddComponent <MonsterBehaviour>();
        }

        //cache hurt point
        monsterBehaviour.CacheHurtPoint();
        //怪物生成特效
        if (monsterData._bornEffects != "0")
        {
            GameObject bornEffectPrefab = MapResManager.Instance.GetMapEffectPrefab(monsterData._bornEffects);
            if (bornEffectPrefab != null)
            {
                GameObject bornEffect = GameObjectPool.Instance.AcquireLocal(bornEffectPrefab, Vector3.zero, bornEffectPrefab.transform.rotation);
                bornEffect.AddComponent <DestroySelf>();
                bornEffect.transform.position = monster.transform.position;
            }
        }
        //怪物对白
        if (false == BattleManager.Instance.IsHeroFirstDead)
        {
//            if (monsterData._dialogPortrait != "0")
//            {
//                var resData = MapResManager.Instance.GetMapEffectPrefab(monsterData._dialogPortrait);
//                if (resData != null)
//                {
//                    GameObject IconPrefab = CreatObjectToNGUI.InstantiateObj(MonsterDialogPrefab, BattleUIManager.Instance.GetScreenTransform(ScreenPositionType.Center));
//                    IconPrefab.transform.localPosition = new Vector3(-240, 160, 10);//避免和任务指引面板重叠
//                    SirenDialogEctypeBehaviour sirenDialogEctypeBehaviour = IconPrefab.GetComponent<SirenDialogEctypeBehaviour>();
//
//                    sirenDialogEctypeBehaviour.Init(resData, LanguageTextManager.GetString(monsterData._bornDialogue), LanguageTextManager.GetString(monsterData._dialogMonsterName));
//                    if (monsterData._bornSound != "0")
//                    {
//                        SoundManager.Instance.PlaySoundEffect(monsterData._bornSound);
//                    }
//                    IconPrefab.AddComponent<DestroySelf>();
//                }
//            }
            if (monsterData._BornDialogueFulls[0].Portrait != "0")
            {
                GameObject IconPrefab = CreatObjectToNGUI.InstantiateObj(MonsterDialogPrefab, BattleUIManager.Instance.GetScreenTransform(ScreenPositionType.Center));
                SirenDialogEctypeBehaviour sirenDialogEctypeBehaviour = IconPrefab.GetComponent <SirenDialogEctypeBehaviour>();
                sirenDialogEctypeBehaviour.Init(MonsterDialogPrefab, monsterData._BornDialogueFulls);
                if (monsterData._bornSound != "0")
                {
                    SoundManager.Instance.PlaySoundEffect(monsterData._bornSound);
                }
            }
        }

        //特殊镜头
        if (monsterData._cameraFix_pos != Vector3.zero)
        {
            //BattleManager.Instance.FollowCamera.SetFixed(monsterData._cameraFix_pos, monsterData._cameraFix_time);
            BattleManager.Instance.FollowCamera.BeginMoveToPosAndGoBack(monsterData._cameraFix_pos, monsterData._cameraFix_time, monsterData._cameraStay_time, monsterData._cameraBack_time, monsterData._blockPlayerToIdle);
        }

        #endregion


        //TypeID type;
        //EntityModel monsterDataModel = monsterBehaviour.EntityModel = EntityController.Instance.GetEntityModel( entityDataStruct.SMsg_Header.uidEntity, out type);
        //monsterBehaviour.EntityModel.GO = monsterBehaviour.gameObject;
        //monsterBehaviour.EntityModel.Behaviour = monsterBehaviour;


        monsterDataModel.GO        = monster;
        monsterDataModel.Behaviour = monsterBehaviour;
        //monsterDataModel.EntityDataStruct = sMsgPropCreateEntity_SC_Monster;

        monsterBehaviour.EntityModel = monsterDataModel;
        monsterBehaviour.SetMonsterConfigData(monsterData);

        monsterBehaviour.InitFSM();
        //MonsterManager.Instance.Init();

        //出生是否隐藏
        if (sMsgPropCreateEntity_SC_Monster.MonsterValues.MONSTER_FIELD_ISSHOW == 0)
        {
            SetCildLayer(monsterDataModel.GO.transform, 21);           //21=hide
        }

        //血条
        Transform bloodBarMP;
        monster.transform.RecursiveFindObject("BloodBarMP", out bloodBarMP);
        if (null != bloodBarMP)
        {
            GameObject bloodBarPrefab = null;
            switch (sMsgPropCreateEntity_SC_Monster.MonsterValues.MONSTER_FIELD_TYPE)
            {
            case 0:
                bloodBarPrefab = MonsterFactory.Instance.BloobBarPrefab_normal;
                break;

            case 1:
                bloodBarPrefab = MonsterFactory.Instance.BloobBarPrefab;
                break;

            case 2:
                bloodBarPrefab = MonsterFactory.Instance.BloobBarPrefab_boss;
                break;

            case 3:
                bloodBarPrefab = MonsterFactory.Instance.BloobBarPrefab_normal;
                break;

            default:
                break;
            }
            if (bloodBarPrefab != null)
            {
                BloodBarManager.Instance.AttachBarToTarget(sMsgPropCreateEntity_SC_Monster.SMsg_Header.uidEntity, bloodBarMP, bloodBarPrefab);
            }
        }
        //发UI事件,参数 EntityModel
        UIEventManager.Instance.TriggerUIEvent(UIEventType.CreatMoster, monsterData);

        //如果是boss,激活boss状态栏
        if (MonsterManager.Instance.IsMonsterBossType(monsterId))
        {
            if (DefencePanel.Instance.ISDefenceEctype)
            {
                DefencePanel.Instance.DefenceBossCreate(monsterDataModel);
            }
            else
            {
                if (!MonsterManager.Instance.IsBossStatusPanelInit())
                {
                    GameObject bossStatusPanel = (GameObject)Instantiate(BossStatusPanelPrefab);
                    //bossStatusPanel.transform.parent = PopupObjManager.Instance.UICamera.transform;
                    bossStatusPanel.transform.parent        = UI.Battle.BattleUIManager.Instance.GetScreenTransform(UI.Battle.ScreenPositionType.TopRight);
                    bossStatusPanel.transform.localPosition = Vector3.zero;
                    bossStatusPanel.transform.localScale    = Vector3.one;
                    //赋值
                    BossStatusPanel_V3 bossStatusPanelScript = bossStatusPanel.GetComponent <BossStatusPanel_V3>();
                    MonsterManager.Instance.SetBossStatusPanel(bossStatusPanelScript);

                    bossStatusPanelScript.SetBloodNum(monsterDataModel);
                }
                else
                {
                    //第二个boss
                    GameObject secondBossStatusPanel = (GameObject)Instantiate(BattleResManager.Instance.SecondBossStatusPanelPrefab);
                    secondBossStatusPanel.transform.parent        = UI.Battle.BattleUIManager.Instance.GetScreenTransform(UI.Battle.ScreenPositionType.TopRight);
                    secondBossStatusPanel.transform.localPosition = Vector3.zero;
                    secondBossStatusPanel.transform.localScale    = Vector3.one;
                    BossStatusPanel_V3 secondBossPanelScript = secondBossStatusPanel.GetComponent <BossStatusPanel_V3>();
                    secondBossPanelScript.SetBloodNum(monsterDataModel);
                    MonsterManager.Instance.IsDoubleBoss = true;
                    //BossStatusPanel_V3 bossStatusPanelScript = MonsterManager.Instance.GetBossStatusPanel();
                    //bossStatusPanelScript.SetDataModel(monsterDataModel);
                }
                //bossStatusPanelScript.SetBloodNum();
            }
            //如果是普通副本,boss出场,播特效//
            SMSGEctypeInitialize_SC sMSGEctypeInitialize_SC = (SMSGEctypeInitialize_SC)GameDataManager.Instance.PeekData(DataType.InitializeEctype);
            EctypeContainerData     m_ectypeData            = EctypeConfigManager.Instance.EctypeContainerConfigList[sMSGEctypeInitialize_SC.dwEctypeContainerId];
            if (m_ectypeData.lEctypeType == 0 || m_ectypeData.lEctypeType == 9)
            {
                UIEventManager.Instance.TriggerUIEvent(UIEventType.OnBossShowEvent, null);
                SoundManager.Instance.PlaySoundEffect("Sound_UIEff_BossAppear");
            }
        }
        else
        {
            //加入箭头挂载脚本
#if !UNITY_EDITOR
            if (sMsgPropCreateEntity_SC_Monster.MonsterUnitValues.UNIT_FIELD_FIGHT_HOSTILITY !=
                PlayerManager.Instance.FindHeroDataModel().UnitValues.sMsgPropCreateEntity_SC_UnitVisibleValue.UNIT_FIELD_FIGHT_HOSTILITY)
            {
                if (monster.GetComponent <MonsterBehaviour>().m_MonsterConfigData._isShowGuideArrow == 1)
                {
                    ArrowManager.Instance.AddMonsterArrowt(monster);
                }
            }
#endif
        }
        //jamfing//
        //if(DefencePanel.Instance.ISDefenceEctype)
        {
            DefencePanel.Instance.DefenceMonsterCreated(monsterDataModel, monsterData);
        }
        //EntityController.Instance.RegisteEntity(entityDataStruct.SMsg_Header.uidEntity, monsterDataModel);
    }