Example #1
0
 // Use this for initialization
 void Start()
 {
     tab = new RoomV2[xSize][];
     for (int i = 0; i < xSize; i++)
     {
         tab [i] = new RoomV2[ySize];
     }
 }
    void CreateRooms()
    {
        //setup
        rooms = new RoomV2[gridSizeX * 2, gridSizeY * 2];
        rooms[gridSizeX, gridSizeY] = new RoomV2(Vector2.zero, 1);
        takenPositions.Insert(0, Vector2.zero);
        Vector2 checkPos = Vector2.zero;
        //magic numbers
        float randomCompare = 0.2f, randomCompareStart = 0.2f, randomCompareEnd = 0.01f;

        //add rooms
        for (int i = 0; i < numberOfRooms - 1; i++)
        {
            float randomPerc = ((float)i) / (((float)numberOfRooms - 1));
            randomCompare = Mathf.Lerp(randomCompareStart, randomCompareEnd, randomPerc);
            //grab new position
            checkPos = NewPosition();
            //test new position
            if (NumberOfNeighbors(checkPos, takenPositions) > 1 && Random.value > randomCompare)
            {
                int iterations = 0;
                do
                {
                    checkPos = SelectiveNewPosition();
                    iterations++;
                } while (NumberOfNeighbors(checkPos, takenPositions) > 1 && iterations < 100);
                if (iterations >= 50)
                {
                    print("error: could not create with fewer neighbors than : " + NumberOfNeighbors(checkPos, takenPositions));
                }
            }
            //finalize position
            rooms[(int)checkPos.x + gridSizeX, (int)checkPos.y + gridSizeY] = new RoomV2(checkPos, 0);
            takenPositions.Insert(0, checkPos);
        }
    }
Example #3
0
 public static Ice.DispatchStatus LeaveRoom___(RoomV2 obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     inS__.istr().skipEmptyEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         obj__.LeaveRoom(current__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(Chat.IllegalChatSessionException ex__)
     {
         os__.writeUserException(ex__);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
Example #4
0
 public static Ice.DispatchStatus Say___(RoomV2 obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string message;
     message = is__.readString();
     long time;
     time = is__.readLong();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         obj__.Say(message, time, current__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(Chat.IllegalChatSessionException ex__)
     {
         os__.writeUserException(ex__);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
Example #5
0
 public static Ice.DispatchStatus GetRoomName___(RoomV2 obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Idempotent, current__.mode);
     inS__.istr().skipEmptyEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     string ret__ = obj__.GetRoomName(current__);
     os__.writeString(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }