예제 #1
0
    public void RemoveManFromRoom(Guid manId)
    {
        ManScript ManScript = _ManList[manId].ManScript;

        if (RoomManager.Ref.IsRoomExisting(ManScript.ManData.AssignedRoom) == false)
        {
            return;
        }

        RoomScript RoomScript = RoomManager.Ref.GetRoomData(ManScript.ManData.AssignedRoom).RoomScript;

        RoomScript.RemoveManFromRoomSlot(manId);
        ManScript.AssignToRoom(Guid.Empty, 0);
    }
예제 #2
0
    public void MoveManToNewRoom(Guid manId, Guid newRoomId)
    {
        if (RoomManager.Ref.IsRoomExisting(newRoomId) == false)
        {
            return;
        }
        if (IsManExisting(manId) == false)
        {
            return;
        }

        ManScript  ManScript     = _ManList[manId].ManScript;
        RoomScript NewRoomScript = RoomManager.Ref.GetRoomData(newRoomId).RoomScript;

        //NPC is Overworld only trying to travel to Underworld
        if (ManScript.ManData.ManType > 0 && NewRoomScript.RoomData.RoomOverUnder < 0)
        {
            GuiManager.Ref.Initiate_UserInfoSmall("Sorry, can't assign to this room!");
            return;
        }

        //NPC is Underworld only trying to travel to Overworld
        if (ManScript.ManData.ManType < 0 && NewRoomScript.RoomData.RoomOverUnder > 0)
        {
            GuiManager.Ref.Initiate_UserInfoSmall("Sorry, can't assign to this room!");
            return;
        }


        if (NewRoomScript.RoomContainsMan(manId))
        {
            GuiManager.Ref.Initiate_UserInfoSmall("Already assigned to this room!");
            return;
        }

        if ((ManScript.IsAssignedToAnyRoom() == false) && (NewRoomScript.RoomHasFreeManSlots() == false))
        {
            GuiManager.Ref.Initiate_UserInfoSmall("Sorry, can't assign to this room!");
            return;
        }

        if ((ManScript.IsAssignedToAnyRoom() == false) && (NewRoomScript.RoomHasFreeManSlots() == true))
        {
            int ManSlotIndex = NewRoomScript.GetFreeManSlotIndex();
            ManScript.AssignToRoom(newRoomId, ManSlotIndex);
            NewRoomScript.AssignManToRoomSlot(manId, ManSlotIndex);
            SetManPathFromEntrance(manId, newRoomId, ManSlotIndex);
            StateManager.Ref.SetWaitingMan(Guid.Empty);
            return;
        }

        Guid       OldRoomGuid   = ManScript.ManData.AssignedRoom;
        RoomScript OldRoomScript = RoomManager.Ref.GetRoomData(OldRoomGuid).RoomScript;

        if (NewRoomScript.RoomHasFreeManSlots() == true)
        {
            int NewManSlotIndex = NewRoomScript.GetFreeManSlotIndex();
            int OldManSlotIndex = ManScript.ManData.AssignedRoomSlot;
            ManScript.AssignToRoom(newRoomId, NewManSlotIndex);
            OldRoomScript.RemoveManFromRoomSlot(manId);
            NewRoomScript.AssignManToRoomSlot(manId, NewManSlotIndex);
            SetManPath(manId, OldRoomGuid, OldManSlotIndex, newRoomId, NewManSlotIndex);
        }
        else
        {
            Guid      OtherManGuid   = NewRoomScript.RoomData.ManSlotsAssignments[0];
            ManScript OtherManScript = _ManList[OtherManGuid].ManScript;
            OldRoomScript.RemoveManFromRoomSlot(manId);
            NewRoomScript.RemoveManFromRoomSlot(OtherManGuid);

            int NewManSlotIndex1 = NewRoomScript.GetFreeManSlotIndex();
            int OldManSlotIndex1 = ManScript.ManData.AssignedRoomSlot;
            ManScript.AssignToRoom(newRoomId, NewManSlotIndex1);
            NewRoomScript.AssignManToRoomSlot(manId, NewManSlotIndex1);
            SetManPath(manId, OldRoomGuid, OldManSlotIndex1, newRoomId, NewManSlotIndex1);

            int NewManSlotIndex2 = OldRoomScript.GetFreeManSlotIndex();
            int OldManSlotIndex2 = OtherManScript.ManData.AssignedRoomSlot;
            OtherManScript.AssignToRoom(OldRoomGuid, NewManSlotIndex2);
            OldRoomScript.AssignManToRoomSlot(OtherManGuid, NewManSlotIndex2);
            SetManPath(OtherManGuid, newRoomId, OldManSlotIndex2, OldRoomGuid, NewManSlotIndex2);
        }
    }