Ejemplo n.º 1
0
        public static void CreateEnemy(string name, string model_name, Vector3 pos, Quaternion qt, System.Action <EnemyController> fn)
        {
            CharacterModel modelToSpawn = CharacterCatalog.Instance.GetModel(model_name);

            if (model_name.Contains("NPC_Template"))
            {
                modelToSpawn = CharacterCatalog.Instance.GetModelTemplate();
                modelToSpawn.NPC_Template = model_name.Replace("_NPC_Template", "");
            }
            if (modelToSpawn == null)
            {
                EB.Debug.LogError("EnemySpawnLogic:: No model in CharacterModel for Name:{0}", model_name);
                fn(null);
                return;
            }

            EB.Assets.LoadAsync(RES_Enemy, typeof(GameObject), o =>
            {
                if (!o)
                {
                    return;
                }

                GameObject spawnedEnemy = Replication.Instantiate(o, pos, qt, RES_Enemy) as GameObject;
                if (spawnedEnemy == null)
                {
                    EB.Debug.LogError("EnemySpawnLogic::Trying to initialize null spawned enemy");
                    fn(null);
                }
                else
                {
                    EnemyController enemyController = spawnedEnemy.GetComponent <EnemyController>();
                    if (enemyController == null)
                    {
                        EB.Debug.LogError("EnemySpawnLogic::Update can't obtain EnemyController component from spawned enemy object");
                        fn(null);
                    }
                    else
                    {
                        Player.EnemyHotfixController ehc = enemyController.transform.GetMonoILRComponent <Player.EnemyHotfixController>();
                        ehc.ObjectName    = spawnedEnemy.name;
                        spawnedEnemy.name = name;
                        ehc.OnSpawn(modelToSpawn, -1, false, () => fn(enemyController));
                        //EventManager.instance.Raise(new SpawnEndedEvent(spawnedEnemy));
                        //fn(enemyController);
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public void NpcLocatorTriggerEnter(string locator, GameObject triggerOb)
        {
            EnemyController enemy = MainLandLogic.GetInstance().GetEnemyController(locator);

            if (enemy == null)
            {
                return;
            }
            Player.EnemyHotfixController ehc = enemy.HotfixController._ilrObject as Player.EnemyHotfixController;
            if (ehc.IsBodyActive())
            {
                return;
            }

            NpcTriggerAction(locator, triggerOb);
        }
Ejemplo n.º 3
0
        public void NpcTriggerAction(string locator, GameObject triggerOb)
        {
            // 执行触发逻辑
            //将玩家的目标点设置为触发器位罿
            Vector3 dest = new Vector3();

            dest.x = triggerOb.transform.localPosition.x;
            dest.y = triggerOb.transform.localPosition.y;
            dest.z = triggerOb.transform.localPosition.z;
            PlayerManager.LocalPlayerController().TargetingComponent.SetMovementTarget(Vector3.zero, true);
            EnemyController enemy = MainLandLogic.GetInstance().GetEnemyController(locator);

            if (enemy != null)
            {
                Player.EnemyHotfixController ehc = enemy.HotfixController._ilrObject as Player.EnemyHotfixController;
                ehc.DoAppearingWay();
            }
            NpcTriggerActionOver();
        }
Ejemplo n.º 4
0
        private bool IsWorldBoss(GameObject interactable)
        {
            if (null == interactable)
            {
                return(false);
            }
            EnemyController _enemyController = interactable.GetComponent <EnemyController>();

            if (null == _enemyController)
            {
                return(false);
            }
            Player.EnemyHotfixController ehc = _enemyController.HotfixController._ilrObject as Player.EnemyHotfixController;
            if (NPC_ROLE.WORLD_BOSS == ehc.Role)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        private bool IsAllianceMonster(GameObject interactable)
        {
            if (null == interactable)
            {
                return(false);
            }
            EnemyController _enemyController = interactable.GetComponent <EnemyController>();

            if (null == _enemyController)
            {
                return(false);
            }
            Player.EnemyHotfixController ehc = _enemyController.HotfixController._ilrObject as Player.EnemyHotfixController;
            if (NPC_ROLE.ALLIANCE_CAMPAIGN_ENEMY == ehc.Role || NPC_ROLE.ALLIANCE_CAMPAIGN_BOSS == ehc.Role)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 是否是主线任务怪
        /// </summary>
        /// <param name="interactable"></param>
        /// <returns></returns>
        private bool IsBeatMonster(GameObject interactable)
        {
            if (null == interactable)
            {
                return(false);
            }
            EnemyController _enemyController = interactable.GetComponent <EnemyController>();

            if (null == _enemyController)
            {
                return(false);
            }
            Player.EnemyHotfixController ehc = _enemyController.HotfixController._ilrObject as Player.EnemyHotfixController;
            if (NPC_ROLE.BEAT_MONSTER == ehc.Role)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        void Update()
        {
            FreshQueue();
            if (!m_IsCanShow)
            {
                return;
            }
            if (!GM.AssetManager.IsIdle)
            {
                return;
            }
            if (m_NpcQueue != null && m_NpcQueue.Count > 0)
            {
                NpcDelegate npcdata = m_NpcQueue.Dequeue();
                if (npcdata != null)
                {
                    if (npcdata.sceneid.Equals(m_CurrentSceneID) && m_ManagedNpcs != null && m_ManagedNpcs.ContainsKey(npcdata.locator))
                    {
                        Vector3    v3;
                        Quaternion rot;
                        switch (npcdata.role)
                        {
                        case NPC_ROLE.GHOST:
                            v3  = npcdata.pos;
                            rot = npcdata.quater;
                            break;

                        default:
                            GameObject locator_obj = LocatorManager.Instance.GetLocator(npcdata.locator);
                            if (locator_obj == null)
                            {
                                EB.Debug.LogWarning(string.Format("No available locator data for npc  at locator [{0}]", npcdata.locator));
                                return;
                            }
                            v3  = locator_obj.transform.position;
                            rot = locator_obj.transform.rotation;
                            break;
                        }

                        if (npcdata.key != null)
                        {
                            //夺宝奇兵等级未开放或该区服未开放判断
                            if (npcdata.role == NPC_ROLE.GHOST &&
                                (
                                    !Hotfix_LT.Data.FuncTemplateManager.Instance.GetFunc(10073).IsConditionOK() ||
                                    !Hotfix_LT.Data.EventTemplateManager.Instance.GetRealmIsOpen("main_land_ghost_start")))
                            {
                                EB.Debug.LogWarning("NPC_ROLE.GHOST Return! (10073).IsConditionOK()——{0}", Hotfix_LT.Data.FuncTemplateManager.Instance.GetFunc(10073).IsConditionOK() + ";GetRealmIsOpen——" + Hotfix_LT.Data.EventTemplateManager.Instance.GetRealmIsOpen("main_land_ghost_start"));
                                return;
                            }
                            else if (m_GroupCellManager != null && m_GroupCellManager.IsCellShowing(npcdata.key))
                            {
                                if (!npcdata.preloaded)
                                {
                                    if (m_CurrentSceneLogic != null)
                                    {
                                        m_CurrentSceneLogic.PreloadAsync(npcdata.modelname, (success) =>
                                        {
                                            npcdata.preloaded = success;
                                            m_NpcQueue.Enqueue(npcdata);
                                        });
                                    }
                                    else
                                    {
                                        EB.Debug.LogError("CurrentSceneLogic is Null");
                                    }
                                }
                                else if (m_ManagedNpcs != null && !m_ManagedNpcs[npcdata.locator].created)
                                {
                                    m_ManagedNpcs[npcdata.locator].created = true;
                                    if (m_CurrentSceneLogic != null)
                                    {
                                        #region 异步加载一个NPC
                                        m_CurrentSceneLogic.SpawnNpcAsync(npcdata.locator, npcdata.modelname, npcdata.role, v3, rot, ec =>
                                        {
                                            if (ec != null)
                                            {
                                                Player.EnemyHotfixController ehc = ec.transform.GetMonoILRComponent <Player.EnemyHotfixController>();
                                                ehc.SetBarHudState(eHeadBarHud.FightStateHud, null, m_ManagedNpcs[npcdata.locator].isfighting);
                                                ehc.Role = npcdata.role;
                                                ehc.Attr = npcdata.attr;
                                                ehc.SetNpcName(m_CurrentSceneLogic.CurrentSceneName);
                                            }
                                        });
                                        #endregion
                                    }
                                    else
                                    {
                                        EB.Debug.LogError("CurrentSceneLogic is Null");
                                    }
                                }
                            }
                        }
                        else if (m_GroupCellManager != null)
                        {
                            GroupCellKey key = m_GroupCellManager.ObjectIn(npcdata.locator, v3);
                            npcdata.key = key;
                            if (m_GroupCellManager.IsCellShowing(npcdata.key))
                            {
                                m_NpcQueue.Enqueue(npcdata);
                            }
                        }
                    }
                    else
                    {
                    }
                }
            }

            if (m_GroupCellManager != null)
            {
                var go = PlayerManager.LocalPlayerGameObject();
                m_GroupCellManager.Update(go != null ? go.transform : null);
            }
        }