示例#1
0
    static bool InitNpcWithDb(PeEntity entity, Mono.Data.SqliteClient.SqliteDataReader reader)
    {
        string strTemp = reader.GetString(reader.GetOrdinal("startpoint"));

        string[] pos = strTemp.Split(',');
        if (pos.Length < 3)
        {
            Debug.LogError("Npc's StartPoint is Error");
        }
        else
        {
            float   x    = System.Convert.ToSingle(pos[0]);
            float   y    = System.Convert.ToSingle(pos[1]);
            float   z    = System.Convert.ToSingle(pos[2]);
            PeTrans view = entity.peTrans;
            if (null != view)
            {
                view.position = new Vector3(x, y, z);
            }

            NpcCmpt cmpt = entity.NpcCmpt;
            if (null != cmpt)
            {
                cmpt.FixedPointPos = new Vector3(x, y, z);
            }
        }
        SetNpcMoney(entity, reader.GetString(reader.GetOrdinal("money")));
        AddWeaponItem(entity, reader.GetString(reader.GetOrdinal("weapon")), reader.GetString(reader.GetOrdinal("item")));
        SetNpcAbility(entity, reader.GetString(reader.GetOrdinal("speciality")));
        return(true);
    }
 public NpaTalkAgent(PeEntity entity)
 {
     _msgs       = new AgentInfo[(int)ENpcTalkType.Max];
     _romveCases = new List <AgentInfo>();
     m_npcCmpt   = entity.GetComponent <NpcCmpt>();
     //m_entityInfo = entity.GetComponent<EntityInfoCmpt>();
 }
 protected override void OnStart()
 {
     base.OnStart();
     //m_SelfEntity = GetComponent<PeEntity>();
     npc             = GetComponent <NpcCmpt>();
     operateDistance = GameConfig.NPCControlDistance;
 }
示例#4
0
//        public void OnEnable()
//        {
//            Excute();
//        }
//
//        public void OnDisable()
//        {
//            Stop();
//        }

        public override void Start()
        {
            base.Start();

            //m_View = GetComponent<ViewCmpt>();
            m_SkEntity = GetComponent <SkAliveEntity>();
            m_Request  = GetComponent <RequestCmpt>();
            m_Npc      = GetComponent <NpcCmpt>();

            if (m_SkEntity != null)
            {
                m_SkEntity.deathEvent  += OnDeath;
                m_SkEntity.reviveEvent += OnRevive;
            }

            m_BehaveID = BTLauncher.Instance.Instantiate(assetPath, this, false);

            InitAttacks();

            //添加m_Npc.hasAnyRequest 否则跟随任务读档传送无法继续进行
            if (PeGameMgr.IsSingle && m_Npc != null && (m_Npc.Type == ENpcType.Follower || m_Npc.Type == ENpcType.Base || m_Npc.hasAnyRequest))
            {
                Excute();
            }
        }
示例#5
0
            public static void SetBirthPos(this PeEntity entity, Vector3 pos)
            {
                NpcCmpt npccmpt = entity.GetCmpt <NpcCmpt>();

                if (null != npccmpt)
                {
                    npccmpt.FixedPointPos = pos;                    //NPCAI need
                }
            }
示例#6
0
        public override string ToString()
        {
            NpcCmpt f1 = GetServant(0);
            NpcCmpt f2 = GetServant(1);

            return(string.Format("leader:{0}, follower1:{1}, follower2:{2}"
                                 , Entity.Id
                                 , null == f1 ? -11 : f1.Entity.Id
                                 , null == f2 ? -11 : f2.Entity.Id));
        }
示例#7
0
        //未开始的行为使用
        public static bool CanDo(PeEntity entity, EThinkingType type)
        {
            NpcCmpt npc = entity.NpcCmpt;

            if (npc == null)
            {
                return(true);
            }

            return(npc.ThinkAgent.CanDo(type));
        }
示例#8
0
            public static void ExtSetVoiceType(this PeEntity entity, int voiceType)
            {
                NpcCmpt info = entity.GetCmpt <NpcCmpt>();

                if (null == info)
                {
                    return;
                }

                info.voiceType = voiceType;
            }
示例#9
0
        //正在进行的行为使用
        //返回值 Ture 当前type可以执行
        public static bool CanDoing(PeEntity entity, EThinkingType _newtThink)
        {
            NpcCmpt npc = entity.NpcCmpt;

            if (npc == null)
            {
                return(true);
            }

            if (!npc.ThinkAgent.CanDo(_newtThink))
            {
                EThinkingType _curThinkType = npc.ThinkAgent.GetNowDo();
                //NpcThinking curthink = Get(_curThinkType);
                NpcThinking newthink = Get(_newtThink);

                //1:阻塞当前行为,执行新加入行为
                if (newthink.GetMask(_curThinkType) == EThinkingMask.Block)
                {
                    npc.ThinkAgent.RemoveThink(_curThinkType);
                    npc.ThinkAgent.RemoveThink(_newtThink);

                    npc.ThinkAgent.AddThink(_curThinkType);
                    npc.ThinkAgent.AddThink(_newtThink);
                    return(true);
                }

                //-1:阻塞新加入行为,执行当前行为
                if (newthink.GetMask(_curThinkType) == EThinkingMask.Blocked)
                {
                    npc.ThinkAgent.RemoveThink(_newtThink);
                    npc.ThinkAgent.RemoveThink(_curThinkType);

                    npc.ThinkAgent.AddThink(_newtThink);
                    npc.ThinkAgent.AddThink(_curThinkType);
                    return(false);
                }

                //接受新的行为,删除当前行为
                if (newthink.GetMask(_curThinkType) == EThinkingMask.Delete)
                {
                    npc.ThinkAgent.RemoveThink(_curThinkType);
                    npc.ThinkAgent.AddThink(_newtThink);
                    return(true);
                }
                //不接收新的
                if (newthink.GetMask(_curThinkType) == EThinkingMask.Deleted)
                {
                    //no noth
                    return(false);
                }
            }
            return(true);
        }
示例#10
0
        public void InitSleepInfo(NpcCmpt npc)
        {
            if (mSleepAction == null)
            {
                mSleepAction = Entity.motionMgr.GetAction <Action_Sleep>();
            }

            if (mSleepAction != null)
            {
                mSleepAction.startSleepEvt += npc.OnLeaderSleep;
                mSleepAction.endSleepEvt   += npc.OnLeaderEndSleep;
            }
        }
示例#11
0
        public static void RemoveNpoReq(PeEntity npc, EReqType type)
        {
            NpcCmpt npccmpt = npc.NpcCmpt;

            if (npccmpt != null)
            {
                npccmpt.Req_Remove(type);
            }
            else
            {
                // TODO: 移除 Monster 当前状态
            }
        }
示例#12
0
    public NpcCmpt GetNeedReviveServant()
    {
        ServantLeaderCmpt leader = GameUI.Instance.mMainPlayer.GetCmpt <ServantLeaderCmpt>();
        NpcCmpt           mNpc   = leader.GetServant((int)mCurrentIndex);

        if (mNpc == null)
        {
            return(null);
        }
        if (mNpc.Alive.isDead)
        {
            return(mNpc);
        }
        return(null);
    }
示例#13
0
    void GetServentCmpt()
    {
        if (leaderCmpt != null)
        {
            NpcCmpt cmpt = leaderCmpt.GetServant((int)mCurrentIndex);
            if (cmpt != null && cmpt != npcCmpt)
            {
                viewCmpt    = cmpt.Entity.biologyViewCmpt;
                commonCmpt  = cmpt.Entity.commonCmpt;
                packageCmpt = cmpt.GetComponent <NpcPackageCmpt>();
                GetNpcPakgeSlotList();
                entityInfoCmpt = cmpt.Entity.enityInfoCmpt;

                // register changeEvent
                if (equipmentCmpt != null)
                {
                    equipmentCmpt.changeEventor.Unsubscribe(EquipmentChangeEvent);
                }
                equipmentCmpt = cmpt.Entity.equipmentCmpt;
                equipmentCmpt.changeEventor.Subscribe(EquipmentChangeEvent);
            }
            npcCmpt = cmpt;
            CheckWhtherCanGet();
            servant = (npcCmpt != null) ? npcCmpt.Entity : null;
        }
        else
        {
            npcCmpt = null;
            CheckWhtherCanGet();
        }

        if (npcCmpt == null)
        {
            viewCmpt       = null;
            commonCmpt     = null;
            equipmentCmpt  = null;
            packageCmpt    = null;
            entityInfoCmpt = null;

            mInteractionPackage = null;
            mPrivatePakge       = null;

            mSprSex.spriteName = "null";
            ClearEqList();
            ClearNpcPackage();
        }
        mEqTex.enabled = (npcCmpt != null);
    }
示例#14
0
    public static void SetNpcStandRot(PeEntity npc, float rot, bool isStand)
    {
        if (npc == null)
        {
            return;
        }
        NpcCmpt npcCmpt = npc.GetCmpt <NpcCmpt>();

        if (npcCmpt != null)
        {
            npcCmpt.Req_Rotation(Quaternion.Euler(0, rot, 0));
            npcCmpt.StandRotate = rot;
//            if(isStand)
//                npcCmpt.Req_SetIdle("Idle");
        }
    }
示例#15
0
        public void AddForcedServant(NpcCmpt forcedServant, bool isMove = false)
        {
            PeEntity npc = forcedServant.GetComponent <PeEntity>();

            if (mForcedFollowers.Contains(forcedServant) || npc == null)
            {
                return;
            }
            mForcedFollowers.Add(forcedServant);
            if (isMove == true)
            {
                StroyManager.Instance.Translate(npc, EntityCreateMgr.Instance.GetPlayerTrans().position);
            }
            //StroyManager.Instance.FollowTarget(npc, EntityCreateMgr.Instance.GetPlayerTrans());
            StroyManager.Instance.FollowTarget(npc, PeCreature.Instance.mainPlayer.Id, Vector3.zero, 0, 0.0f);
        }
示例#16
0
        public override void Deserialize(System.IO.BinaryReader r)
        {
            base.Deserialize(r);

            if (PeEntity.CURRENT_VERSION >= PeEntity.VERSION_0001)
            {
                /*int version = */
                r.ReadInt32();
                int length = r.ReadInt32();
                //int forcedLength = r.ReadInt32();

                initReq = new List <NpcCmpt>();

                for (int i = 0; i < length; i++)
                {
                    int      npcID  = r.ReadInt32();
                    PeEntity entity = EntityMgr.Instance.Get(npcID);
                    if (entity != null)
                    {
                        NpcCmpt npc = entity.GetComponent <NpcCmpt>();
                        if (npc != null)
                        {
                            AddServant(npc);
                            //							if(mSenventsInfo == null)
                            //								mSenventsInfo = new AddServrntInfo();
                            //							mSenventsInfo.AddServrnt(npc);
                            initReq.Add(npc);
                        }
                    }
                }

                //for (int i = 0; i < forcedLength; i++)
                //{
                //    int npcID = r.ReadInt32();
                //    PeEntity entity = EntityMgr.Instance.Get(npcID);
                //    if(entity != null)
                //    {
                //        NpcCmpt npc = entity.GetComponent<NpcCmpt>();
                //        if(npc != null)
                //        {
                //            AddForcedServant(npc);
                //        }
                //    }
                //}
            }
        }
示例#17
0
    //luwei
    public void ShowServantRevive(NpcCmpt servant)
    {
        //return ;
        SkAliveEntity skAlive_player = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <SkAliveEntity>();

        if (skAlive_player.isDead)
        {
            return;
        }

        currentState  = ReivieState.Reivie_Servant;
        currentEntity = servant.Entity;
        SetServantReviveInfo(Pathea.PeEntityExt.PeEntityExt.ExtGetFaceTex(servant.Follwerentity),
                             Pathea.PeEntityExt.PeEntityExt.ExtGetName(currentEntity)
                             );
        mServantRevided = servant;
        Show();
    }
示例#18
0
        public override void Start()
        {
            base.Start();
            mSkEntity    = Entity.skEntity;
            mViewCmpt    = Entity.biologyViewCmpt;
            mNPC         = Entity.NpcCmpt;
            mMotionEquip = Entity.motionEquipment;
            if (null != m_InitItems && m_InitItems.Count > 0)
            {
                for (int i = 0; i < m_InitItems.Count; ++i)
                {
                    PutOnEquipment(m_InitItems[i]);
                }
                m_InitItems.Clear();
                Entity.lodCmpt.onConstruct += e => e.StartCoroutine(PreLoad());
            }
//			StartCoroutine(InitEquipment());
        }
示例#19
0
            public static bool SetFollower(this PeEntity entity, bool bFlag, int index = -1)
            {
                ServantLeaderCmpt masterCmpt = PeCreature.Instance.mainPlayer.GetCmpt <ServantLeaderCmpt>();
                NpcCmpt           npcCmpt    = entity.NpcCmpt;

                if (!bFlag)
                {
                    return(masterCmpt.RemoveServant(npcCmpt));
                }
                else
                {
                    //set floower succeed talk
                    entity.NpcCmpt.AddTalkInfo(ENpcTalkType.Conscribe_succeed, ENpcSpeakType.TopHead);
                    if (index == -1)
                    {
                        return(masterCmpt.AddServant(npcCmpt));
                    }
                    return(masterCmpt.AddServant(npcCmpt, index));
                }
            }
示例#20
0
        public bool RemoveServant(NpcCmpt follower)
        {
            for (int i = 0; i < mFollowers.Length; i++)
            {
                if (follower == mFollowers[i])
                {
                    follower.NpcControlCmdId = 1;
                    follower.SetServantLeader(null);
                    PeEntity npc = follower.GetComponent <PeEntity>();
                    if (UIMissionMgr.Instance != null)
                    {
                        UIMissionMgr.Instance.AddMission(npc);
                    }
                    MissionManager.Instance.m_PlayerMission.UpdateNpcMissionTex(npc);
                    return(RemoveServant(i));
                }
            }

            return(false);
        }
示例#21
0
    void OnGUI()
    {
        if (Pathea.EntityMgr.Instance == null || !Application.isEditor)
        {
            return;
        }

        if (GUI.Button(new Rect(300, 100, 90, 20), "AddServant"))
        {
            PeEntity entity = EntityMgr.Instance.Get(9008);
            if (entity == null)
            {
                Debug.Log("Get entity failed!");
                return;
            }
            NpcCmpt cmpt = entity.NpcCmpt;
            if (cmpt != null)
            {
                CSMain.SetNpcFollower(entity);
            }
        }
    }
示例#22
0
    public void ShowServantRevive()
    {
        if (UINPCfootManMgr.Instance == null)
        {
            return;
        }

        //if (UINPCfootManMgr.Instance.IsRevive())
        //{
        //    NpcCmpt servant = UINPCfootManMgr.Instance.GetDeadServant();
        //    if (servant != null)
        //    {
        //        ShowServantRevive(servant);
        //    }
        //}
        NpcCmpt _servant = GameUI.Instance.mServantWndCtrl.GetNeedReviveServant();

        if (_servant != null)
        {
            ShowServantRevive(_servant);
        }
    }
示例#23
0
    static void SetNpcAbility(PeEntity entity, string text)
    {
        if (string.IsNullOrEmpty(text) || text == "0")
        {
            return;
        }

        Ablities abilitys = new Ablities();

        string[] tmp1 = text.Split(',');
        for (int i = 0; i < tmp1.Length; i++)
        {
            abilitys.Add(Convert.ToInt32(tmp1[i]));
        }

        NpcCmpt npccmpt = entity.GetCmpt <NpcCmpt>();

        if (npccmpt != null)
        {
            npccmpt.SetAbilityIDs(abilitys);
        }
    }
示例#24
0
        public void RemoveForcedServant(NpcCmpt forcedServant)
        {
            if (mForcedFollowers.Contains(forcedServant))
            {
                mForcedFollowers.Remove(forcedServant);
            }
            else
            {
                return;
            }
            NpcMissionData missionData = forcedServant.Follwerentity.GetUserData() as NpcMissionData;

            missionData.mInFollowMission = false;
            if (forcedServant.GetComponent <PeEntity>() == null)
            {
                return;
            }
            if (!MissionManager.Instance.m_PlayerMission.followers.Contains(forcedServant))
            {
                StroyManager.Instance.RemoveReq(forcedServant.GetComponent <PeEntity>(), EReqType.FollowTarget);
            }
        }
示例#25
0
        public static void SetNpoReqDialogue(PeEntity npc, string RqAction = "", object npoidOrVecter3 = null)
        {
            NpcCmpt npccmpt = npc.NpcCmpt;

            if (npccmpt != null)
            {
                if (npoidOrVecter3 != null)
                {
                    if (npoidOrVecter3 is int)
                    {
                        if ((int)npoidOrVecter3 == 0 || EntityMgr.Instance.Get((int)npoidOrVecter3) == null)
                        {
                            npccmpt.Req_Dialogue(RqAction, null);
                        }
                        else
                        {
                            PeTrans trans = EntityMgr.Instance.Get((int)npoidOrVecter3).peTrans;
                            if (trans != null)
                            {
                                npccmpt.Req_Dialogue(RqAction, trans);
                            }
                        }
                    }
                    else if (npoidOrVecter3 is Vector3)
                    {
                        npccmpt.Req_Dialogue(RqAction, (Vector3)npoidOrVecter3);
                    }
                }
                else
                {
                    npccmpt.Req_Dialogue(RqAction);
                }
            }
            else
            {
                // TODO: 设置 Monster 对话 状态
            }
        }
示例#26
0
        public bool AddServant(NpcCmpt follower)
        {
            if (ContainsServant(follower))
            {
                return(false);
            }

            for (int i = 0; i < mFollowers.Length; i++)
            {
                if (null == mFollowers[i])
                {
                    mFollowers[i] = follower;

                    if (UINPCfootManMgr.Instance != null)
                    {
                        UINPCfootManMgr.Instance.GetFollowerAlive();
                    }
                    //DoFollow(follower.Entity.GetCmpt<FollowCmpt>());
                    follower.SetServantLeader(this);
                    follower.NpcControlCmdId = 19;
                    PeEntityCreator.RecruitRandomNpc(follower.Entity);
                    InitSleepInfo(mFollowers[i]);
                    if (UIMissionMgr.Instance != null)
                    {
                        UIMissionMgr.Instance.DeleteMission(follower.Entity);
                    }
                    changeEventor.Dispatch(new ServantChanged(true, follower.Entity));

                    //lz-2016.08.22 玩家召一个仆从
                    InGameAidData.CheckGetServant(follower.Entity.Id);
                    //lw:完成成就同生共死
                    SteamAchievementsSystem.Instance.OnGameStateChange(Eachievement.Eleven);
                    return(true);
                }
            }

            return(false);
        }
示例#27
0
    // Update is called once per frame
    void Update()
    {
        NpcCmpt npcCmpt = PeCreature.Instance.mainPlayer.GetCmpt <ServantLeaderCmpt>().GetServant(m_HeroIndex);

        if (npcCmpt != null)
        {
            PeEntity npcRd = npcCmpt.Entity;
            if (npcRd != m_CurNpc)
            {
                //m_NameLbUI.text = npcCmpt.name;
                m_NameLbUI.text = npcCmpt.Entity.enityInfoCmpt.characterName.ToString();
                m_ServantShowingUI.SetNpc(npcRd);
                m_CurNpc = npcRd;
            }

            m_Cancel  = false;
            m_Replace = false;
            if (HandlePerson != null)
            {
                if (HandlePerson.m_Npc == m_CurNpc)
                {
                    m_BtnLbUI.text    = "Cancel";
                    m_Cancel          = true;
                    m_Replace         = false;
                    m_BtnUI.isEnabled = m_Active;
                }
                else if (HandlePerson.NPC.IsFollower())
                {
                    m_BtnUI.isEnabled = false;
                    m_BtnLbUI.text    = "Replace";
                }
                else
                {
                    m_BtnLbUI.text    = "Replace";
                    m_Replace         = true;
                    m_BtnUI.isEnabled = m_Active;
                }
            }
            else
            {
                m_BtnUI.isEnabled = m_Active;
            }
        }
        else
        {
            m_CurNpc        = null;
            m_NameLbUI.text = "";
            m_ServantShowingUI.SetNpc(null);
            m_BtnLbUI.text = "Set";
            m_Cancel       = false;

            if (HandlePerson != null)
            {
                if (HandlePerson.NPC.IsFollower())
                {
                    m_BtnUI.isEnabled = false;
                }
                else
                {
                    //lz-2016.06.01 这里不能直接设置为为true,还要考虑基地是否存在和有电
                    m_BtnUI.isEnabled = m_Active;
                }
            }
        }
    }
示例#28
0
 void OnSetBtn()
 {
     if (!m_Cancel)
     {// add/replace follower
         if (HandlePerson != null)
         {
             if (m_Replace)
             {   // follower
                 if (PeGameMgr.IsMulti)
                 {
                     if (m_CurNpc != null)
                     {
                         ServantLeaderCmpt masterCmpt = PeCreature.Instance.mainPlayer.GetCmpt <ServantLeaderCmpt>();
                         NpcCmpt           npcCmpt    = m_CurNpc.GetComponent <NpcCmpt>();
                         if (masterCmpt == npcCmpt.Master)
                         {
                             if (null != PlayerNetwork.mainPlayer)
                             {
                                 PlayerNetwork.RequestDismissNpc(m_CurNpc.Id);
                                 PlayerNetwork.RequestNpcRecruit(HandlePerson.ID);
                             }
                         }
                         else
                         {
                             //--to do: log
                         }
                     }
                 }
                 else
                 {
                     if (m_CurNpc != null)
                     {
                         m_CurNpc.SetFollower(false);
                     }
                     HandlePerson.FollowMe(m_HeroIndex);
                 }
             }
             else
             {
                 //check if can add person
                 if (PeGameMgr.IsMulti)
                 {
                     if (null != PlayerNetwork.mainPlayer)
                     {
                         PlayerNetwork.RequestNpcRecruit(HandlePerson.ID);
                     }
                 }
                 else
                 {
                     HandlePerson.FollowMe(m_HeroIndex);
                 }
             }
         }
     }
     else
     {// remove follower
         if (m_CurNpc != null)
         {
             if (PeGameMgr.IsMulti)
             {
                 if (null != PlayerNetwork.mainPlayer)
                 {
                     PlayerNetwork.RequestDismissNpc(m_CurNpc.Id);
                 }
             }
             else
             {
                 m_CurNpc.SetFollower(false);
             }
         }
     }
 }
示例#29
0
        public bool AddServant(NpcCmpt follower, int index)
        {
            if (ContainsServant(follower))
            {
                return(false);
            }

            bool isFull = true;

            for (int i = 0; i < mFollowers.Length; i++)
            {
                if (mFollowers[i] == null)
                {
                    isFull = false;
                    break;
                }
            }
            if (isFull)
            {
                return(false);
            }

            for (int i = 0; i < mFollowers.Length; i++)
            {
                if (i == index)
                {
                    if (mFollowers[i] != null)
                    {
                        List <NpcCmpt> fList = mFollowers.Where(a => a != null).ToList();
                        fList.Insert(i, follower);
                        if (fList.Count < MaxFollower)
                        {
                            for (int j = 0; j < MaxFollower - fList.Count; j++)
                            {
                                fList.Add(null);
                            }
                        }
                        mFollowers = fList.ToArray();
                    }
                    else
                    {
                        mFollowers[i] = follower;
                    }

                    if (UINPCfootManMgr.Instance != null)
                    {
                        UINPCfootManMgr.Instance.GetFollowerAlive();
                    }


                    //log: lz-2016.05.11  这里移除一个仆从的时候进行排序,让前面不要空出位置
                    mFollowers = mFollowers.OrderBy(a => a == null).ToArray();
                    //DoFollow(follower.Entity.GetCmpt<FollowCmpt>());
                    follower.SetServantLeader(this);
                    follower.NpcControlCmdId = 19;
                    PeEntityCreator.RecruitRandomNpc(follower.Entity);
                    InitSleepInfo(follower);
                    changeEventor.Dispatch(new ServantChanged(false, follower.Entity));
                    return(true);
                }
            }

            return(false);
        }
示例#30
0
 public bool ContainsServant(NpcCmpt follower)
 {
     return(new List <NpcCmpt>(mFollowers).Contains(follower));
 }