예제 #1
0
    public static void StopTraining(PeEntity npc)
    {
        CSMgCreator creator = null;

        if (PeGameMgr.IsMulti)
        {
            NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
            if (npcnet == null)
            {
                return;
            }
            creator = MultiColonyManager.GetCreator(npcnet.TeamId);
        }
        else
        {
            creator = s_MgCreator;
        }
        if (creator == null)
        {
            return;
        }
        //find npc
        if (creator.Assembly == null)
        {
            return;
        }
    }
예제 #2
0
//	void RPC_S2C_CLN_SetGuardPos(uLink.BitStream stream, uLink.NetworkMessageInfo info)
//	{
//        //--to do: wait
//        Vector3 guardPos = stream.Read<Vector3>();
//        //int playID = stream.Read<int>();
//        //if (playID == PlayerFactory.mMainPlayer.OwnerView.viewID.id)
//        //{
//            CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp);
//            if (creator != null)
//            {
//                CSPersonnel[] personnels = creator.GetNpcs();
//                foreach (CSPersonnel csp in personnels)
//                {
//                    if (csp != null && csp.m_Npc != null)
//                    {
//                        if (Id == csp.m_Npc.Id)
//                        {
//                            csp.SetGuardAttr(guardPos);
//                        }
//                    }
//                }
//            }
//        //}
//	}

    void RPC_S2C_CLN_PlantGetBack(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int objId = stream.Read <int> ();

        if (objId != -1)
        {
            FarmManager.Instance.RemovePlant(objId);
            DragArticleAgent.Destory(objId);
            ItemMgr.Instance.DestroyItem(objId);
        }
        else
        {
            FarmPlantLogic plant = stream.Read <FarmPlantLogic>();

            CSMgCreator creator = MultiColonyManager.GetCreator(TeamId);
            if (creator == null || creator.Assembly == null)
            {
                return;
            }
            CSFarm farm = creator.Assembly.Farm;
            if (farm == null)
            {
                return;
            }
            farm.RestoreWateringPlant(plant);
        }
    }
예제 #3
0
    public void CheckFinish(int npcId, List <CSTreatment> csts)
    {
        //CSMain.Instance.RemoveCounter(m_Counter);
        StopCounter();
        PeEntity npc = EntityMgr.Instance.Get(npcId);

        int         teamId  = _ColonyObj._Network.TeamId;
        CSMgCreator creator = MultiColonyManager.GetCreator(teamId);

        creator.RemoveNpcTreatment(npcId);
        if (csts != null && csts.Count > 0)
        {
            creator.AddTreatment(csts);
            npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchTreat;
        }
        else
        {
            npc.GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.Cure;
        }

        allPatients.RemoveAll(it => it.Id == npcId);
        Data.npcIds.Remove(npcId);
        isNpcReady = false;
        if (allPatients.Count >= 1)
        {
            SetPatientIcon(m_Creator.GetNpc(allPatients[0].Id));
            allPatients[0].GetCmpt <NpcCmpt>().MedicalState = ENpcMedicalState.SearchDiagnos;
        }
        else
        {
            SetPatientIcon(null);
        }
        RefreshTreatment();
    }
예제 #4
0
    void RPC_S2C_CLN_SetWorkMode(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        //--to do: wait
        int workMode = stream.Read <int>();
        //int playID = stream.Read<int>();
        //if(playID != PlayerFactory.mMainPlayer.OwnerView.viewID.id)
        //{
        CSCreator creator = MultiColonyManager.GetCreator(TeamId, false);

        if (creator != null)
        {
            CSPersonnel[] personnels = creator.GetNpcs();
            foreach (CSPersonnel csp in personnels)
            {
                if (csp != null && csp.m_Npc != null)
                {
                    if (Id == csp.m_Npc.Id)
                    {
                        csp.m_WorkMode = workMode;
                    }
                }
            }
        }
        //}
    }
예제 #5
0
    void RPC_S2C_CLN_SetDwellingsID(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        //--to do: wait
        int dwllingsID = stream.Read <int>();
        //int playID = stream.Read<int>();
        //if (playID != PlayerFactory.mMainPlayer.OwnerView.viewID.id)
        //{
        CSMgCreator creator = MultiColonyManager.GetCreator(TeamId, false);

        if (creator != null)
        {
            CSPersonnel[] personnels = creator.GetNpcs();
            foreach (CSPersonnel csp in personnels)
            {
                if (csp != null && csp.m_Npc != null)
                {
                    if (Id == csp.m_Npc.Id)
                    {
                        CSDwellings cd = creator.GetCommonEntity(dwllingsID) as CSDwellings;
                        cd.AddNpcs(csp);
                    }
                }
            }
        }
        //}
    }
예제 #6
0
    IEnumerator InitDataRoutine(CSPersonnelData cspd)
    {
        PeEntity npc = null;

        while (true)
        {
            npc = EntityMgr.Instance.Get(Id);
            if (npc == null)
            {
                yield return(new WaitForSeconds(0.5f));
            }
            else
            {
                break;
            }
        }


        CSCreator creator = null;

        while (true)
        {
            creator = MultiColonyManager.GetCreator(TeamId);
            if (creator == null)
            {
                yield return(new WaitForSeconds(0.5f));
            }
            else
            {
                break;
            }
        }
        ((CSMgCreator)creator).AddNpc(npc, cspd, true);
//		if (TeamId == PlayerNetwork.MainPlayer.TeamId)
//        {
//            CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp);
//            while (creator == null)
//            {
//                yield return new WaitForSeconds(0.5f);
//				creator = MultiColonyManager.GetCreator(CSConst.ciDefMgCamp);
//            }
//
//
//            ((CSMgCreator)creator).AddNpc(npc, cspd, true);
//        }
//        else
//        {
//            CSCreator creator = CSMain.GetCreator(TeamId);
//            while (creator == null)
//            {
//                yield return new WaitForSeconds(0.5f);
//                creator = MultiColonyManager.GetCreator(TeamId);
//            }
//
//            ((CSMgCreator)creator).AddNpc(npc, cspd, true);
//        }
        //m_PersonnelDatas.Add(cspd.ID, cspd);
    }
예제 #7
0
 public static CSMedicalTent FindMedicalTent(out bool isReady, PeEntity npc, out Sickbed sickBed)
 {
     isReady = false;
     sickBed = null;
     if (PeGameMgr.IsMulti)
     {
         NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
         if (npcnet == null)
         {
             return(null);
         }
         CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId);
         if (creator.Assembly == null)
         {
             return(null);
         }
         if (creator.Assembly.MedicalTent == null)
         {
             return(null);
         }
         CSMedicalTent tent = creator.Assembly.MedicalTent;
         if (!tent.IsRunning)
         {
             return(null);
         }
         sickBed = tent.CheckNpcBed(npc);
         if (sickBed == null)
         {
             tent._ColonyObj._Network.RPCServer(EPacketType.PT_CL_TET_FindMachine, npc.Id);
         }
         else
         {
             isReady = true;
         }
         return(tent);
     }
     else
     {
         if (s_MgCreator.Assembly == null)
         {
             return(null);
         }
         if (s_MgCreator.Assembly.MedicalTent == null)
         {
             return(null);
         }
         CSMedicalTent tent = s_MgCreator.Assembly.MedicalTent;
         if (!tent.IsRunning)
         {
             return(null);
         }
         isReady = tent.IsReady(npc, out sickBed);
         tent.AppointTent(npc);
         return(tent);
     }
 }
예제 #8
0
    void RPC_S2C_CLN_RemoveNpc(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        //int playID = stream.Read<int>();
        //if(playID == PlayerFactory.mMainPlayer.OwnerView.viewID.id)
        //{
        //}

        CSCreator mCreator  = MultiColonyManager.GetCreator(TeamId);
        PeEntity  npcEntity = EntityMgr.Instance.Get(Id);

        mCreator.RemoveNpc(npcEntity);
        npcEntity.Dismiss();
    }
예제 #9
0
 public static CSMedicalCheck FindMedicalCheck(out bool isReady, PeEntity npc)
 {
     isReady = false;
     if (PeGameMgr.IsMulti)
     {
         NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
         if (npcnet == null)
         {
             return(null);
         }
         CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId);
         if (creator.Assembly == null)
         {
             return(null);
         }
         if (creator.Assembly.MedicalCheck == null)
         {
             return(null);
         }
         CSMedicalCheck check = creator.Assembly.MedicalCheck;
         if (!check.IsRunning)
         {
             return(null);
         }
         isReady = check.IsReady(npc);
         if (npc.GetCmpt <NpcCmpt>().illAbnormals != null && npc.GetCmpt <NpcCmpt>().illAbnormals.Count > 0)
         {
             check._ColonyObj._Network.RPCServer(EPacketType.PT_CL_CHK_FindMachine, npc.Id);
         }
         return(check);
     }
     else
     {
         if (s_MgCreator.Assembly == null)
         {
             return(null);
         }
         if (s_MgCreator.Assembly.MedicalCheck == null)
         {
             return(null);
         }
         CSMedicalCheck detector = s_MgCreator.Assembly.MedicalCheck;
         if (!detector.IsRunning)
         {
             return(null);
         }
         isReady = detector.IsReady(npc);
         detector.AppointCheck(npc);
         return(detector);
     }
 }
예제 #10
0
 public static CSMedicalTreat FindMedicalTreat(out bool isReady, PeEntity npc)
 {
     isReady = false;
     if (PeGameMgr.IsMulti)
     {
         NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
         if (npcnet == null)
         {
             return(null);
         }
         CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId);
         if (creator.Assembly == null)
         {
             return(null);
         }
         if (creator.Assembly.MedicalTreat == null)
         {
             return(null);
         }
         CSMedicalTreat treat = creator.Assembly.MedicalTreat;
         if (!treat.IsRunning)
         {
             return(null);
         }
         isReady = treat.IsReady(npc);
         treat._ColonyObj._Network.RPCServer(EPacketType.PT_CL_TRT_FindMachine, npc.Id);
         return(treat);
     }
     else
     {
         if (s_MgCreator.Assembly == null)
         {
             return(null);
         }
         if (s_MgCreator.Assembly.MedicalTreat == null)
         {
             return(null);
         }
         CSMedicalTreat lab = s_MgCreator.Assembly.MedicalTreat;
         if (!lab.IsRunning)
         {
             return(null);
         }
         isReady = lab.IsReady(npc);
         lab.AppointTreat(npc);
         return(lab);
     }
     //--to do: inform player need treat
     //return null;
 }
예제 #11
0
    void RPC_S2C_CLN_PlantClean(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        /*int farmId = */ stream.Read <int>();
        FarmPlantLogic plant = stream.Read <FarmPlantLogic>();

        CSMgCreator creator = MultiColonyManager.GetCreator(TeamId);

        if (creator == null || creator.Assembly == null)
        {
            return;
        }
        CSFarm farm = creator.Assembly.Farm;

        farm.RestoreCleaningPlant(plant);
    }
예제 #12
0
    public static void KickOutFromHospital(PeEntity npc)
    {
        CSMgCreator creator = null;

        if (PeGameMgr.IsMulti)
        {
            if (PeGameMgr.IsCustom)
            {
                return;
            }

            NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
            if (npcnet == null)
            {
                return;
            }
            creator = MultiColonyManager.GetCreator(npcnet.TeamId);
        }
        else
        {
            creator = s_MgCreator;
        }
        if (creator == null)
        {
            return;
        }
        //find npc
        if (creator.Assembly == null)
        {
            return;
        }

        if (creator.Assembly.MedicalCheck != null && creator.Assembly.MedicalCheck.IsRunning)
        {
            creator.Assembly.MedicalCheck.RemoveDeadPatient(npc.Id);
        }
        if (creator.Assembly.MedicalTreat != null && creator.Assembly.MedicalTreat.IsRunning)
        {
            creator.Assembly.MedicalTreat.RemoveDeadPatient(npc.Id);
        }
        if (creator.Assembly.MedicalTent != null && creator.Assembly.MedicalTent.IsRunning)
        {
            creator.Assembly.MedicalTent.RemoveDeadPatient(npc.Id);
        }
        creator.m_TreatmentList.RemoveAll(it => it.npcId == npc.Id);
    }
예제 #13
0
 public static bool TryGetCheck(PeEntity npc)
 {
     if (PeGameMgr.IsMulti)
     {
         NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
         if (npcnet == null)
         {
             return(false);
         }
         CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId);
         if (creator.Assembly == null)
         {
             return(false);
         }
         if (creator.Assembly.MedicalCheck == null)
         {
             return(false);
         }
         CSMedicalCheck detector = creator.Assembly.MedicalCheck;
         if (!detector.IsRunning)
         {
             return(false);
         }
         detector._ColonyObj._Network.RPCServer(EPacketType.PT_CL_CHK_TryStart, npc.Id);
     }
     else
     {
         if (s_MgCreator.Assembly == null)
         {
             return(false);
         }
         if (s_MgCreator.Assembly.MedicalCheck == null)
         {
             return(false);
         }
         CSMedicalCheck detector = s_MgCreator.Assembly.MedicalCheck;
         if (!detector.IsRunning)
         {
             return(false);
         }
         //--to do : check npc detector
         return(detector.StartCheck(npc));
     }
     return(false);
 }
예제 #14
0
 public static bool TryGetTent(PeEntity npc)
 {
     if (PeGameMgr.IsMulti)
     {
         NetworkInterface npcnet = AiAdNpcNetwork.Get(npc.Id);
         if (npcnet == null)
         {
             return(false);
         }
         CSMgCreator creator = MultiColonyManager.GetCreator(npcnet.TeamId);
         if (creator.Assembly == null)
         {
             return(false);
         }
         if (creator.Assembly.MedicalTent == null)
         {
             return(false);
         }
         CSMedicalTent tent = creator.Assembly.MedicalTent;
         if (!tent.IsRunning)
         {
             return(false);
         }
         tent._ColonyObj._Network.RPCServer(EPacketType.PT_CL_TET_TryStart, npc.Id);
     }
     else
     {
         if (s_MgCreator.Assembly == null)
         {
             return(false);
         }
         if (s_MgCreator.Assembly.MedicalTent == null)
         {
             return(false);
         }
         CSMedicalTent tent = s_MgCreator.Assembly.MedicalTent;
         if (!tent.IsRunning)
         {
             return(false);
         }
         return(tent.StartTent(npc));
     }
     return(false);
 }
예제 #15
0
    void RPC_S2C_CLN_SetIsProcessing(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        bool        isProcessing = stream.Read <bool>();
        CSMgCreator creator      = MultiColonyManager.GetCreator(TeamId, false);

        if (creator != null)
        {
            CSPersonnel[] personnels = creator.GetNpcs();
            foreach (CSPersonnel csp in personnels)
            {
                if (csp != null && csp.m_Npc != null)
                {
                    if (Id == csp.m_Npc.Id)
                    {
                        csp.IsProcessing = isProcessing;
                    }
                }
            }
        }
    }
예제 #16
0
    void RPC_S2C_CLN_SetWorkRoomID(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        //--to do: wait
        int workRoomID = stream.Read <int>();
        //int playID = stream.Read<int>();
        //if (playID != PlayerFactory.mMainPlayer.OwnerView.viewID.id)
        //{
        CSCreator creator = MultiColonyManager.GetCreator(TeamId, false);

        if (creator != null)
        {
            CSPersonnel[] personnels = creator.GetNpcs();
            foreach (CSPersonnel csp in personnels)
            {
                if (csp != null && csp.m_Npc != null)
                {
                    if (Id == csp.m_Npc.Id)
                    {
                        if (workRoomID == 0)
                        {
                            csp.WorkRoom = null;
                            return;
                        }
                        Dictionary <int, CSCommon> commons = creator.GetCommonEntities();
                        foreach (KeyValuePair <int, CSCommon> kvp in commons)
                        {
                            if (kvp.Value.Assembly != null && kvp.Value.WorkerMaxCount > 0 && kvp.Value.m_Type != CSConst.etFarm)
                            {
                                if (kvp.Value.ID == workRoomID)
                                {
                                    csp.WorkRoom = kvp.Value;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        //}
    }