예제 #1
0
        public NpcPlayer GetClosestNpc(Neptune.Relationship npcType)
        {
            Actor localPlayer = Game.GetInstance().GetLocalPlayer();

            if (localPlayer != null && localPlayer.transform != null)
            {
                Vector3   localPlayerPos = localPlayer.transform.position;
                float     minDistance    = float.MaxValue;
                NpcPlayer closestNpc     = null;
                foreach (var mono in mNpcs.Values)
                {
                    var npc = (mono.BindActor as NpcPlayer);

                    if (npc == null)
                    {
                        continue;
                    }

                    if (npc.NpcData.Relationship == npcType)
                    {
                        float distance = (localPlayerPos - npc.transform.position).sqrMagnitude;
                        if (distance < minDistance)
                        {
                            minDistance = distance;
                            closestNpc  = npc;
                        }
                    }
                }
                return(closestNpc);
            }

            return(null);
        }
예제 #2
0
        private void CheckPlayVoice(DBDialogContent.DialogContentInfo dialogContentInfo)
        {
            if (mDialogInfo == null || mDialogInfo.mType != DBDialog.EDialogType.IST_DialogBox)
            {
                return;
            }

            if (dialogContentInfo == null || dialogContentInfo.mObjectType != DBDialogContent.EDialogObjectType.DOT_Other)
            {
                return;
            }

            if (mDialogInfo.mId == mPlayingVoiceDialogId)
            {
                return;
            }

            if (mOtherPlayer == null || !mOtherPlayer.IsNpc())
            {
                return;
            }

            NpcPlayer npc = (NpcPlayer)mOtherPlayer;

            if (npc != null)
            {
                mPlayingVoiceDialogId = mDialogInfo.mId;
                npc.PlayRandomVoice();
            }
        }
예제 #3
0
        static int _m_GetNpcRelatedTasks_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    NpcPlayer npcPlayer = (NpcPlayer)translator.GetObject(L, 1, typeof(NpcPlayer));
                    System.Collections.Generic.List <xc.Task> needDoTasks;
                    System.Collections.Generic.List <xc.Task> needAcceptAndSubmitTasks;

                    bool __cl_gen_ret = xc.TaskHelper.GetNpcRelatedTasks(npcPlayer, out needDoTasks, out needAcceptAndSubmitTasks);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);
                    translator.Push(L, needDoTasks);

                    translator.Push(L, needAcceptAndSubmitTasks);



                    return(3);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #4
0
        public virtual string NpcWholeName(NpcPlayer actor)
        {
            string funcName = "";

            if (actor.Define != null)
            {
                funcName = actor.Define.ConstTitle;
            }
            string name = string.Empty;

            if (!string.IsNullOrEmpty(funcName))
            {
                name = string.Format("<color=#68e0fa>{0}</color>\n<color=#fbbd65>{1}</color>", funcName, actor.Name);
            }
            else
            {
                name = string.Format("<color=#fbbd65>{0}</color>", actor.Name);
            }

            // 护送NPC的名字要加上"XXX的"
            if (actor.Define != null && actor.IsEscortNPC == true)
            {
                if (actor.ParentActor != null)
                {
                    name = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_40"), actor.ParentActor.UserName, name);
                }
            }

            return(name);
        }
예제 #5
0
 public void DestroyNpc(NpcPlayer npc)
 {
     if (npc != null)
     {
         RemoveNpc(npc);
         ActorManager.Instance.DestroyActor(npc.UID);
     }
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Npc_Data_Message"/> class.
 /// </summary>
 public Npc_Data_Message(Device Device, Home NpcHome, NpcPlayer NpcPlayer, Player Visitor, int Timestamp, int SecondsSinceLastSave) : base(Device)
 {
     this.NpcHome              = NpcHome;
     this.NpcPlayer            = NpcPlayer;
     this.Visitor              = Visitor;
     this.Timestamp            = Timestamp;
     this.SecondsSinceLastSave = SecondsSinceLastSave;
 }
예제 #7
0
        public void Update()
        {
            if (mIsEnabled == false)
            {
                return;
            }

            Camera cam = Game.Instance.MainCamera;

            if (cam != null)
            {
                mNeatRect       = cam.pixelRect;
                mNeatRect.xMin -= 65f;
                mNeatRect.xMax += 65f;
                mNeatRect.yMin -= 65f;
                mNeatRect.yMax += 65f;

                //目前只处理NPC
                if (mIsEnableNpcModelCull == true)
                {
                    using (var enumerator = NpcManager.Instance.AllNpc.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            var       actorMono = enumerator.Current.Value;
                            NpcPlayer npcPlayer = actorMono.BindActor as NpcPlayer;
                            if (npcPlayer != null)
                            {
                                Vector3 pos = cam.WorldToScreenPoint(actorMono.transform.position);
                                // 在屏幕范围内
                                if (mNeatRect.Contains(pos))
                                {
                                    // 离主角一定距离外需要隐藏,主角骑上坐骑的一瞬间位置是0,所以要排除主角位置是0的情况
                                    Actor localPlayer = Game.Instance.GetLocalPlayer();
                                    if (localPlayer != null && localPlayer.ActorTrans.position.Equals(Vector3.zero) == false && (npcPlayer.ActorTrans.position - localPlayer.ActorTrans.position).sqrMagnitude >= mNpcMaxVisibleDistanceSquare)
                                    {
                                        npcPlayer.mAvatarCtrl.UnloadModel();
                                        npcPlayer.GetBehavior <ShadowBehavior>().HideFakeShadow = true;
                                        npcPlayer.ShowTextName(false);
                                    }
                                    else
                                    {
                                        npcPlayer.mAvatarCtrl.ReloadModel();
                                        npcPlayer.GetBehavior <ShadowBehavior>().HideFakeShadow = false;
                                        npcPlayer.ShowTextName(true);
                                    }
                                }
                                else
                                {
                                    npcPlayer.mAvatarCtrl.UnloadModel();
                                    npcPlayer.ShowTextName(false);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
 void UpdateNPCplayerList()
 {
     if (Network.connections.Length == 0)
     {
         Transform npcPlayer = GameObject.Find("NpcPlayer").transform;
         NpcPlayer npc       = npcPlayer.GetComponent <NpcPlayer>();
         npc.InitNPCTurn();
     }
 }
예제 #9
0
        /// <summary>
        /// 执行触碰结婚npc,是结婚npc则返回true
        /// </summary>
        public static bool ProcessTouchMarryNpc(NpcPlayer npcPlayer)
        {
            if (NpcHelper.NpcCanOpenMarryWin((uint)npcPlayer.NpcData.Id) == true)
            {
                ui.ugui.UIManager.Instance.ShowSysWindow("UIMarryNPCWindow");
                return(true);
            }

            return(false);
        }
예제 #10
0
        static int _s_set_CanClickNPC(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.CanClickNPC = LuaAPI.lua_toboolean(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
예제 #11
0
        static int _g_get_IsInNavigating(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.IsInNavigating);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
예제 #12
0
 /// <summary>
 /// 处理npc的功能,比RunNpcFunction更上一级
 /// </summary>
 public static void ProcessNpcFunction(NpcPlayer npcPlayer)
 {
     // 互动功能不需要打开对话框
     if (npcPlayer.Define.Function == NpcDefine.EFunction.INTERACTION)
     {
         // 有任务才能互动,所以这里要干掉
         //npcPlayer.StartInteract(null);
     }
     else
     {
         UIManager.GetInstance().ShowSysWindow("UINpcDialogWindow", npcPlayer.Define, npcPlayer);
     }
 }
예제 #13
0
        public void RemoveNpc(NpcPlayer npc)
        {
            if (npc == null)
            {
                return;
            }

            if (mNpcs.ContainsKey(npc.UID.obj_idx))
            {
                mNpcs.Remove(npc.UID.obj_idx);
            }
            if (mEscortNpcs.ContainsKey(npc.UID.obj_idx))
            {
                mEscortNpcs.Remove(npc.UID.obj_idx);
            }
        }
예제 #14
0
        public bool TriggerDialog(uint dialogId, System.Action finishedCallback, Transform source)
        {
            if (source != null)
            {
                ActorMono actMono = ActorHelper.GetActorMono(source);
                if (actMono != null)
                {
                    NpcPlayer sourceActor = actMono.BindActor as NpcPlayer;
                    if (sourceActor != null)
                    {
                        sourceActor.TurnToLocalPlayer();
                    }
                }
            }

            return(TriggerDialog(dialogId, finishedCallback));
        }
예제 #15
0
 void FadeIn()
 {
     showUI      = true;
     _textAlpha  = Mathf.Lerp(_textAlpha, 1, Time.deltaTime * 5);
     diffHeight += movingSpeed;
     if (_textAlpha >= 0.9f)
     {
         FadeInUI = false;
         //update npc movement
         if (updateInMove)
         {
             Transform npcPlayer = GameObject.Find("NpcPlayer").transform;
             NpcPlayer npc       = npcPlayer.GetComponent <NpcPlayer>();
             npc.InPause = true;
         }
     }
 }
예제 #16
0
        static int __CreateInstance(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    NpcPlayer __cl_gen_ret = new NpcPlayer();
                    translator.Push(L, __cl_gen_ret);
                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to NpcPlayer constructor!"));
        }
예제 #17
0
        public void AddNpc(NpcPlayer npc)
        {
            if (npc == null)
            {
                return;
            }

            mCreatings.Remove(npc.UID.obj_idx);

            if (npc.IsEscortNPC == false)
            {
                mNpcs[npc.UID.obj_idx] = npc.GetActorMono();
            }
            else
            {
                mEscortNpcs[npc.UID.obj_idx] = npc.GetActorMono();
            }
        }
예제 #18
0
        static int _m_CheckNpcAndActiveNpcFollowAI_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    NpcPlayer npcPlayer = (NpcPlayer)translator.GetObject(L, 1, typeof(NpcPlayer));

                    xc.TaskHelper.CheckNpcAndActiveNpcFollowAI(npcPlayer);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #19
0
        static int _m_UpdateBattleAttribute(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    __cl_gen_to_be_invoked.UpdateBattleAttribute(  );



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #20
0
        static int _m_ProcessNpcFunction_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    NpcPlayer npcPlayer = (NpcPlayer)translator.GetObject(L, 1, typeof(NpcPlayer));

                    xc.NpcHelper.ProcessNpcFunction(npcPlayer);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #21
0
        public static bool GetNpcPos(uint npcId, ref Vector3 result)
        {
            NpcPlayer npc = NpcManager.Instance.GetNpcByNpcId(npcId);

            if (npc != null)
            {
                result = npc.transform.position;
                return(true);
            }

            Neptune.NPC npcInfo = Neptune.DataManager.Instance.Data.GetNode <Neptune.NPC>((int)npcId);

            if (npcInfo != null)
            {
                result = npcInfo.Position;
                return(true);
            }

            return(false);
        }
예제 #22
0
        /// <summary>
        /// 获取该任务当前场景的跟随NpcPlayer
        /// </summary>
        public NpcPlayer GetFollowNpcPlayer()
        {
            if (FollowNpcs != null)
            {
                uint instanceId = SceneHelp.Instance.CurSceneID;
                foreach (NpcScenePosition npcScenePosition in FollowNpcs)
                {
                    if (instanceId == npcScenePosition.SceneId)
                    {
                        NpcPlayer npcPlayer = NpcManager.Instance.GetNpcByNpcId(npcScenePosition.NpcId);
                        if (npcPlayer != null)
                        {
                            return(npcPlayer);
                        }
                    }
                }
            }

            return(null);
        }
예제 #23
0
        static int _m_PlayRandomVoice(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    int __cl_gen_ret = __cl_gen_to_be_invoked.PlayRandomVoice(  );
                    LuaAPI.xlua_pushinteger(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #24
0
        static int _m_ProcessTouchTasksNpc_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    NpcPlayer npcPlayer = (NpcPlayer)translator.GetObject(L, 1, typeof(NpcPlayer));

                    bool __cl_gen_ret = xc.TaskHelper.ProcessTouchTasksNpc(npcPlayer);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #25
0
        static int _m_FireTouchEvent(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    bool __cl_gen_ret = __cl_gen_to_be_invoked.FireTouchEvent(  );
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #26
0
        static int _m_InitNPCData(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    Neptune.NPC data = (Neptune.NPC)translator.GetObject(L, 2, typeof(Neptune.NPC));

                    __cl_gen_to_be_invoked.InitNPCData(data);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #27
0
        static int _m_StartInteract(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    System.Action finishCallback = translator.GetDelegate <System.Action>(L, 2);

                    __cl_gen_to_be_invoked.StartInteract(finishCallback);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #28
0
    // Use this for initialization
    void Start()
    {
        roundCounter = 1;
        if (!SummonerLand)
        {
            playerA = GameObject.Find("pSummonerA").transform.GetChild(0).transform;
        }
        else
        {
            playerA = GameObject.Find("pSummonerA").transform;
        }
        if (!SummonerLand)
        {
            playerB = GameObject.Find("pSummonerB").transform.GetChild(0).transform;
        }
        else
        {
            playerB = GameObject.Find("pSummonerB").transform;
        }
        //AllChesses = new List<Transform>();
        //PlayerAChesses = new List<Transform>();
        //PlayerBChesses = new List<Transform>();
        PlayerATerritory = new List <Transform>();
        PlayerBTerritory = new List <Transform>();

        //PlayerATerritory.Add(GameObject.Find("unit_start_point_A").transform);
        PlayerATerritory.Add(GameObject.Find("red_tower").transform);
        //PlayerBTerritory.Add(GameObject.Find("unit_start_point_B").transform);
        PlayerBTerritory.Add(GameObject.Find("yellow_tower").transform);

        rUI        = transform.GetComponent <RoundUI>();
        mUI        = transform.GetComponent <MainUI>();
        infoUI     = transform.GetComponent <MainInfoUI>();
        currentSel = transform.GetComponent <selection>();

        CamOffest = MidObject.position - transform.position;

        npc = GameObject.Find("NpcPlayer").GetComponent <NpcPlayer>();
    }
예제 #29
0
        //--------------------------------------------------------
        //  客户端消息
        //--------------------------------------------------------
        private void OnNpcClicked(CEventBaseArgs args)
        {
            if (args == null || args.arg == null)
            {
                return;
            }

            if (UIInputEvent.TouchedUI() == true)
            {
                return;
            }

            GameObject npcObject = args.arg as GameObject;

            if (npcObject == null)
            {
                return;
            }

            var mono = ActorHelper.GetActorMono(npcObject.gameObject);

            if (mono == null)
            {
                return;
            }

            NpcPlayer targetNpc = mono.BindActor as NpcPlayer;

            if (targetNpc == null)
            {
                return;
            }

            // 点击npc后已经取消任务的导航了,所以要把导航任务清空
            TaskManager.Instance.NavigatingTask = null;

            //MissionManager.Instance.NotifyMetNpc((uint)targetNpc.NpcData.Id);
            targetNpc.OnClicked();
        }
예제 #30
0
        static int _m_PlayDialogVoice(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            NpcPlayer __cl_gen_to_be_invoked = (NpcPlayer)translator.FastGetCSObj(L, 1);


            try {
                {
                    uint voiceId = LuaAPI.xlua_touint(L, 2);

                    __cl_gen_to_be_invoked.PlayDialogVoice(voiceId);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }