Exemple #1
0
        public void AddOneRoom(string roomname)
        {
            var roomgo   = new GameObject(roomname);
            var roomcomp = roomgo.AddComponent <BldRoom>();

            roomcomp.Initialize(this, roomname, roomname);
            var roompt = this.transform.position;

            if (lc.IsNodeName(roomname))
            {
                var lpt = lc.GetNode(roomname);
                roompt = lpt.pt;
            }
            var alignang = defAngAlign;
            var pcap     = defPeoplePerRoom;
            var area     = defRoomArea;

            roomcomp.SetStatsArea(roompt, pcap, alignang, area, true);
            roomdict[roomname] = roomcomp;
            bm.RegisterRoom(roomname, roomcomp);
            roomgo.transform.parent = roomlistgo.transform;
        }
Exemple #2
0
        public Journey AddInterBuildingJourney(Person pers, BldRoom broom, int roomslot)
        {
            //Debug.Log("Adding Interbuilding Journey for " + pers.personName + " to " + broom.name);
            CheckFastMode();
            var frbroom = pers.GetCurrentRoom();

            if (!frbroom)
            {
                Debug.LogWarning(pers.personName + " is not in a room so can't do interbuilding journey - placeRoom:" + pers.placeRoom);
                return(null);
            }
            if (broom == frbroom)
            {
                if (journeyMessages)
                {
                    Debug.LogWarning(pers.personName + " starting journey to same room - no journey - room:" + broom.roomFullName);
                }
                broom.UnReserveRoomSlot(roomslot); // same room - no journey
                return(null);
            }
            //else
            //{
            //    Debug.Log("Clearly room " + broom.name + " is not the same as " + frbroom.name);
            //}


            var bld1 = frbroom.bld;
            var bld2 = broom.bld;

            if (!(bld1.name == bld2.name))
            {
                Debug.LogWarning("Not the same building - no journey frbroom:" + frbroom.roomFullName + "  broom:" + broom.roomFullName);
                broom.UnReserveRoomSlot(roomslot);// not in same building
                return(null);
            }

            var perform = pers.avatarName;

            try
            {
                var jsnode = pers.placeNode;

                Leg leg = new Leg
                {
                    snode    = jsnode,
                    enode    = "",
                    form     = BirdFormE.person,
                    capneed  = LcCapType.walk,
                    formname = perform,
                    vel      = 2 * lvelfak
                };
                var spos = linkctrl.GetNode(jsnode).pt;

                leg.enode = broom.roomNodeName;
                if (!NodeExists(leg.enode))
                {
                    return(null);
                }

                pers.PersonStateStartWaitingToTravel();
                var msg = (pers.personName + " interbuiding leg.snode:" + leg.snode + " enode:" + leg.enode);
                if (journeyMessages)
                {
                    Debug.Log(msg);
                }
                var stardelay     = GraphAlgos.GraphUtil.GetRanFloat(0.5f, 5f);
                var jgo           = new GameObject();
                var jny           = jgo.AddComponent <Journey>();
                var findelaysecs  = 2f;
                var stardelaysecs = GraphAlgos.GraphUtil.GetRanFloat(0, 15);
                jny.InitJourney(this, pers, null, frbroom, broom, msg, findelaysecs, stardelaysecs, jorg: "interbld");
                jny.AddLeg(leg);
                AddJ(jny);
                return(jny);
            }
            catch (UnityException ex)
            {
                Debug.LogWarning("Could not add interbuilding journey for " + pers.personName + " from" + frbroom.name + " to " + broom.name + " " + ex.Message);
                broom.UnReserveRoomSlot(roomslot);
                return(null);
            }
        }