예제 #1
0
        private RoomVO MakeRoom(params int[] coords)
        {
            int    len = coords.Length;
            RoomVO Room;
            RoomVO room = new RoomVO();

            int[] wallCoords;
            int[] wall;
            _rooms[room] = new List <RoomVO>();
            //room.Vertices = coords;
            for (int i = 0; i < len; i += 2)
            {
                wallCoords = new int[4];
                for (int j = 0; j < 4; j++)
                {
                    wallCoords[j] = coords[(i + j) % len];
                }
                wall = _walls.Keys.FirstOrDefault(w => CoordsEqual(w, wallCoords));
                if (wall == null)
                {
                    _walls.Add(wallCoords, new RoomVO[] { room, null });
                }
                else if (_walls[wall][0] != room)
                {
                    _walls[wall][1] = room;
                    Room            = _walls[wall][0];
                    _rooms[Room].Add(room);
                    _rooms[room].Add(Room);
                }
            }
            return(room);
        }
예제 #2
0
 public RoomVO(RoomVO room)
 {
     Name       = room.Name;
     Background = room.Background;
     Incident   = room.Incident ?? _incident?.GetIncident();
     Guests     = room.Guests == null ? null : new CharacterVO[room.NumGuests];
     for (int i = NumGuests - 1; i >= 0; i--)
     {
         Guests[i] = new CharacterVO(room.Guests[i]);
     }
     if (room.Actions != null)
     {
         Actions = new CommodityVO[room.Actions.Length];
         for (int i = Actions.Length - 1; i >= 0; i--)
         {
             Actions[i] = new CommodityVO(room.Actions[i]);
         }
     }
     if (room.Rewards != null)
     {
         Rewards = new CommodityVO[room.Rewards.Length];
         for (int i = Rewards.Length - 1; i >= 0; i--)
         {
             Rewards[i] = new CommodityVO(room.Rewards[i]);
         }
     }
 }
예제 #3
0
 private void HandleCurrentRoom(RoomVO currentRoom)
 {
     if (_room != null)
     {
         bool current  = _room == currentRoom;
         bool adjacent = _room.IsAdjacentTo(currentRoom);
         if (current || adjacent)
         {
             if (_room.Revealed) //Had to simplify this because the rooms weren't displaying a lot of their characteristics. This is because many things reveal the rooms without this void doing it
             {
                 DescriptionText.enabled = true;
                 DescriptionText.text    = _room.Name + "\n";
                 for (int i = _room.Difficulty - 1; i >= 0; i--)
                 {
                     DescriptionText.text += '\u2605';
                 }
                 Punchbowl.enabled = (Array.IndexOf(_room.Features, PartyConstants.PUNCHBOWL) >= 0);
                 Host.enabled      = (Array.IndexOf(_room.Features, PartyConstants.HOST) >= 0);
                 if (Host.enabled)
                 {
                     PartyVO party = AmbitionApp.GetModel <PartyModel>().Party;
                     Host.sprite = FactionIcons.GetSprite(party.Faction);
                 }
             }
             ColorBlock cb = _button.colors;
             cb.disabledColor = ColorConfig.GetColor(current ? "current" : "shown");
             _button.colors   = cb;
         }
         _button.interactable = adjacent;
     }
     else
     {
         _button.interactable = false;
     }
 }
예제 #4
0
        override public void Initialize()
        {
            MapModel model = AmbitionApp.GetModel <MapModel>();

            _room = Array.Find(model.Map.Rooms, r => r.HostHere);
            AmbitionApp.Subscribe(PartyMessages.SHOW_MAP, HandleMap);
            HandleMap();
        }
예제 #5
0
 private int GenerateMoveThroughChance(RoomVO room)
 {
     if (room.MoveThroughChance >= 0 && !room.Cleared)
     {
         return(room.MoveThroughChance);
     }
     return(90 - (room.Cleared ? 0 : room.Difficulty * 10));
 }
예제 #6
0
 private void DrawRoom(RoomVO room)
 {
     if (room != null)
     {
         GameObject mapButton  = Instantiate(roomButtonPrefab, gameObject.transform);
         RoomButton roomButton = mapButton.GetComponent <RoomButton>();
         mapButton.transform.SetAsFirstSibling();
         roomButton.Room = room;
         _buttons.Add(room, roomButton);
     }
 }
예제 #7
0
 private void HandleRoom(RoomVO room)
 {
     if (room != null)
     {
         if (room.Background == null)
         {
             Sprite[] sprites = BackgroundCollection.GetSpritesByTag("party");
             room.Background = Util.RNG.TakeRandom(sprites);
         }
         _background.sprite = room.Background;
     }
 }
예제 #8
0
 private void Recenter()
 {
     if (Map != null)
     {
         RoomVO  room   = _model.Room ?? Map.Entrance;
         int[]   bounds = room.Bounds;
         Vector3 vec    = transform.localPosition;
         _offset = new Vector3(
             (bounds[0] + bounds[2]) * -.5f,
             (bounds[1] + bounds[3]) * -.5f,
             0f);
         transform.localPosition = _offset * _model.MapScale;
         //StartCoroutine(RecenterMap(_model.Room ?? Map.Entrance));
     }
 }
예제 #9
0
        private void Awake()
        {
            MapModel map = AmbitionApp.GetModel <MapModel>();

            _room = Array.Find(map.Map.Rooms, r => r.Name == RoomName);
            if (_room != null)
            {
                gameObject.SetActive(false);
                AmbitionApp.Subscribe <RoomVO>(MapMessage.GO_TO_ROOM, HandleRoom);
                HandleRoom(map.Room);
            }
            else
            {
                Destroy(gameObject);
            }
        }
예제 #10
0
        IEnumerator RecenterMap(RoomVO room)
        {
            int[]   bounds = room.Bounds;
            Vector3 vec    = transform.localPosition;

            _offset = new Vector3(
                (bounds[0] + bounds[2]) * -.5f,
                (bounds[1] + bounds[3]) * -.5f,
                0f);
            for (float t = 0f; t < RECENTER_TIME; t += Time.deltaTime)
            {
                vec = (vec * _model.MapScale + transform.localPosition) * .5f;
                transform.localPosition = vec;
                yield return(null);
            }
            transform.localPosition = _offset * _model.MapScale;
        }
예제 #11
0
 private void HandleRoom(RoomVO room)
 {
     if (room != null)
     {
         Sprite spt = null;
         if (room.Background != null)
         {
             spt = BackgroundCollection.GetSprite(room.Background);
         }
         if (spt == null)
         {
             Sprite[] sprites = BackgroundCollection.GetSpritesByTag("party");
             spt             = sprites[UnityEngine.Random.Range(0, sprites.Length)];
             room.Background = BackgroundCollection.GetID(spt);
         }
         _background.sprite = spt;
     }
 }
        override public void OnEnterState()
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (controller != null)
            {
                MapModel map   = AmbitionApp.GetModel <MapModel>();
                GuestVO  guest = map.Room.Guests[controller.transform.GetSiblingIndex()];
                if (guest.Action != null && guest.Action.Tags != null && guest.Action.Tags.Length > 0)
                {
                    switch (guest.Action.Tags[0])
                    {
                    case "Map":
                        RoomVO[] rooms = Array.FindAll(map.Map.Rooms, r => !r.Revealed);
                        RoomVO   room  = rooms[Util.RNG.Generate(rooms.Length)];
                        room.Revealed = true;
                        AmbitionApp.SendMessage(room);
                        break;

                    case "Wine":
                        AmbitionApp.SendMessage(PartyMessages.REFILL_DRINK);
                        break;

                    case "Remarks":
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        break;

                    case "Accolade":
                        foreach (GuestVO g in map.Room.Guests)
                        {
                            g.Opinion += (g == guest ? 30 : 10);
                            if (g.Opinion >= 100)
                            {
                                g.Opinion   = 100;
                                guest.State = GuestState.Charmed;
                            }
                        }
                        break;
                    }
                }
            }
        }
예제 #13
0
        public void Execute()
        {
            RoomVO room = AmbitionApp.GetModel <MapModel>().Room;

            if (room != null && room.HostHere)
            {
/*				PartyModel model = AmbitionApp.GetModel<PartyModel>();
 *                              switch(model.Party.Host.State)
 *                              {
 *                                      case GuestState.Charmed:
 *                                      // YOU WIN!
 *                                              break;
 *
 *                                      case GuestState.PutOff:
 *                                      // YOU F****D UP!!
 *                                              break;
 *                              }
 */         }
        }
예제 #14
0
 private void HandleRoom(RoomVO room)
 {
     if (room == _room)
     {
         Destroy(gameObject);
     }
     else
     {
         bool active = _room.IsAdjacentTo(room);
         if (active)
         {
             AmbitionApp.Subscribe(GameMessages.FADE_IN, HandleReveal);
         }
         else
         {
             gameObject.SetActive(false);
             AmbitionApp.Unsubscribe(GameMessages.FADE_IN, HandleReveal);
         }
     }
 }
예제 #15
0
 public WallVO(int[] vertices, RoomVO room1 = null, RoomVO room2 = null)
 {
     Vertices = vertices;
     Rooms    = new RoomVO[] { room1, room2 };
 }
예제 #16
0
 private int GenerateMoveThroughChance(RoomVO room)
 {
     return(100);
     //if (room.MoveThroughChance >= 0 && !room.Cleared) return room.MoveThroughChance;
     //return 90 - (room.Cleared ? 0 : room.Difficulty * 10);
 }
예제 #17
0
파일: RoomVO.cs 프로젝트: rasmus-z/DeWinter
 public bool IsAdjacentTo(RoomVO room)
 {
     return(Array.IndexOf(Doors, room) >= 0);
 }
예제 #18
0
        public override void OnEnterState()
        {
            PartyModel        partyModel = AmbitionApp.GetModel <PartyModel>();
            ConversationModel model      = AmbitionApp.GetModel <ConversationModel>();
            RoomVO            room       = model.Room;
            GuestVO           guest;

            GuestVO[] guests = model.Guests;
            _phrases = AmbitionApp.GetModel <LocalizationModel>();

            // This ensures that previous guest formations stay consistent
            if (guests == null || guests.Length == 0)
            {
                // TODO: Determine how to vary this number
                guests = new GuestVO[4];
            }
            for (int i = guests.Length - 1; i >= 0; i--)
            {
                if (guests[i] == null)
                {
                    guest = new GuestVO();
                    if (RNG.Generate(2) == 0)
                    {
                        guest.Gender    = Gender.Female;
                        guest.Title     = GetRandomDescriptor("female_title");
                        guest.FirstName = GetRandomDescriptor("female_name");
                    }
                    else
                    {
                        guest.Gender    = Gender.Male;
                        guest.Title     = GetRandomDescriptor("male_title");
                        guest.FirstName = GetRandomDescriptor("male_name");
                    }
                    guest.LastName = GetRandomDescriptor("last_name");
                    guest.LastName = "aeiouAEIOU".Contains(guest.LastName.Substring(0, 1))
                        ? (" d'" + guest.LastName)
                        : (" de " + guest.LastName);
                    guests[i] = guest;
                }
            }

            if (!room.Cleared)
            {
                int likeIndex;
                GuestDifficultyVO stats     = partyModel.GuestDifficultyStats[room.Difficulty - 1];
                string[]          interests = partyModel.Interests;

                if (room.Actions != null)
                {
                    AmbitionApp.SendMessage(room.Actions);
                }

                foreach (GuestVO g in guests)
                {
                    g.Opinion = RNG.Generate(stats.Opinion[0], stats.Opinion[1]);
                    likeIndex = RNG.Generate(interests.Length);
                    g.Like    = interests[likeIndex];
                    g.Dislike = interests[(likeIndex + 1) % interests.Length];
                }
                // All Variety of Likes final check
                if (Array.TrueForAll(guests, g => g.Like == guests[0].Like))
                {
                    guest         = RNG.TakeRandom(guests);
                    likeIndex     = RNG.Generate(interests.Length);
                    guest.Like    = interests[likeIndex];
                    guest.Dislike = interests[(likeIndex + 1) % interests.Length];
                }
            }
            model.Guests            = guests;
            model.Round             = 0;
            model.Remark            = null;
            model.FreeRemarkCounter = partyModel.FreeRemarkCounter;
            model.Repartee          = false;
            model.RemarksBought     = 0;
        }
예제 #19
0
 //This is for room SFX, necessary if we have indoor and outdoor rooms that the player is traversing on the map
 private void HandleRoomSFX(RoomVO room)
 {
     AmbitionApp.SendMessage(AudioMessages.PLAY_AMBIENTSFX, AmbientSFXCollection.GetFMODEvent(room.Indoors, (int)partyModel.Party.Importance));
 }
예제 #20
0
        // TODO: Stop checking collinearity. Form a room graph and build the rooms around it.
        public bool AddRoom(RoomVO room)
        {
            Vector2 vec;

            int[] verts     = room.Vertices;
            int[] wallVerts = new int[4];
            int   len       = verts.Length;

            float[] scalars;
            for (int i = len - 2; i >= 0; i -= 2)
            {
                wallVerts[0] = verts[i];
                wallVerts[1] = verts[i + 1];
                wallVerts[2] = verts[(i + 2) % len];
                wallVerts[3] = verts[(i + 3) % len];
                vec          = Vectorize(wallVerts);
                if (IsCollinear(vec))
                {
                    if (verts[i] < verts[i + 2])
                    {
                        scalars = new float[] { (float)(verts[i] - _origin[0]) / _line[0], (float)(verts[i + 2] - _origin[0]) / _line[0] };
                    }
                    else
                    {
                        scalars = new float[] { (float)(verts[i + 2] - _origin[0]) / _line[0], (float)(verts[i] - _origin[0]) / _line[0] };
                    }
                    List <WallVO> walls = Walls.FindAll(w => w.Scalars[1] >= scalars[0] && w.Scalars[0] <= scalars[1]);
                    WallVO        wall  = new WallVO(wallVerts, room);
                    wall.Scalars = scalars;
                    walls.Sort();
                    if (walls[0].Scalars[0] < scalars[0])
                    {
                        wall.Scalars[0]     = walls[0].Scalars[1];
                        walls[0].Scalars[1] = scalars[0];

                        wall.Vertices[0]     = walls[0].Vertices[2];
                        wall.Vertices[1]     = walls[0].Vertices[3];
                        walls[0].Vertices[2] = wallVerts[0];
                        walls[1].Vertices[3] = wallVerts[1];

                        wall.Rooms[1] = walls[0].Rooms[0];

//						Walls.Insert(Walls.in, wall);
//						w.Scalars[1] = scalars[0];
//						w.Vertices[2] = (int)Math.Round(_origin[0] + _line[0]*w.Scalars[1]);
//						w.Vertices[3] = (int)Math.Round(_origin[1] + _line[1]*w.Scalars[1]);
//						index = Walls.IndexOf(w);
                    }
//					if (walls[walls.Length-1].Scalars[1] > scalars[1])
//					{
//						// Copy logic from above
//					}
//					for (int i=walls.Count-1; i>=0; i--)
//					{
//						w.Rooms[1] = room;
//					}
//					 = Walls.Find(w=>w.Scalars[0]==scalars[0]);
//					if (wall == null)
//					{
//						wall
//						index = Walls.FindIndex(w=>w.Scalars[0] > scalars[0]);
//						if (index < 0) Walls.Add(wall);
//						else Walls.Insert(index, wall);
//					}
                    return(true);
                }
            }
            return(false);
        }
예제 #21
0
 private void HandleRoom(RoomVO room)
 {
     _titleText.text = room.Name;
     HandleStarToggles(room.Difficulty);
 }
예제 #22
0
        // TODO: Stop checking collinearity. Form a room graph and build the rooms around it.
        public bool AddRoom(RoomVO room)
        {
/*			Vector2 vec;
 *                      int[] verts = room.Vertices;
 *                      int[] wallVerts = new int[4];
 *                      int len = verts.Length;
 *                      float[] scalars;
 *          for (int i=len-2; i>=0; i-=2)
 *          {
 *                              wallVerts[0] = verts[i];
 *                              wallVerts[1] = verts[i+1];
 *                              wallVerts[2] = verts[(i+2)%len];
 *                              wallVerts[3] = verts[(i+3)%len];
 *                              vec = Vectorize(wallVerts);
 *                              if (IsCollinear(vec))
 *                              {
 *                                      if (verts[i] < verts[i+2])
 *                                      {
 *                                              scalars = new float[]{(float)(verts[i]-_origin[0])/_line[0], (float)(verts[i+2]-_origin[0])/_line[0]};
 *                                      }
 *                                      else
 *                                      {
 *                                              scalars = new float[]{(float)(verts[i+2]-_origin[0])/_line[0], (float)(verts[i]-_origin[0])/_line[0]};
 *                                      }
 *                                      List<WallVO> walls = Walls.FindAll(w=>w.Scalars[1] >= scalars[0] && w.Scalars[0] <= scalars[1]);
 *                                      WallVO wall=new WallVO(wallVerts,room);
 *                                      wall.Scalars = scalars;
 *                                      walls.Sort();
 *                                      if (walls[0].Scalars[0] < scalars[0])
 *                                      {
 *                                              wall.Scalars[0] = walls[0].Scalars[1];
 *                                              walls[0].Scalars[1] = scalars[0];
 *
 *                                              wall.Vertices[0] = walls[0].Vertices[2];
 *                                              wall.Vertices[1] = walls[0].Vertices[3];
 *                                              walls[0].Vertices[2] = wallVerts[0];
 *                                              walls[1].Vertices[3] = wallVerts[1];
 *
 *                                              wall.Rooms[1] = walls[0].Rooms[0];
 *
 *                                              Walls.Insert(Walls.in, wall);
 *                                              w.Scalars[1] = scalars[0];
 *                                              w.Vertices[2] = (int)Math.Round(_origin[0] + _line[0]*w.Scalars[1]);
 *                                              w.Vertices[3] = (int)Math.Round(_origin[1] + _line[1]*w.Scalars[1]);
 *                                              index = Walls.IndexOf(w);
 *                                      }
 *                                      if (walls[walls.Length-1].Scalars[1] > scalars[1])
 *                                      {
 *                                              // Copy logic from above
 *                                      }
 *                                      for (int i=walls.Count-1; i>=0; i--)
 *                                      {
 *                                              w.Rooms[1] = room;
 *                                      }
 *                                       = Walls.Find(w=>w.Scalars[0]==scalars[0]);
 *                                      if (wall == null)
 *                                      {
 *                                              wall
 *                                              index = Walls.FindIndex(w=>w.Scalars[0] > scalars[0]);
 *                                              if (index < 0) Walls.Add(wall);
 *                                              else Walls.Insert(index, wall);
 *                                      }
 *                                      return true;
 *                              }
 *                      }
 */         return(false);
        }
예제 #23
0
 private void HandleRoom(RoomVO room) => Activate();
예제 #24
0
 //This is for room SFX, necessary if we have indoor and outdoor rooms that the player is traversing on the map
 private void HandleRoomSFX(RoomVO room)
 {
     AmbitionApp.SendMessage(AudioMessages.PLAY_AMBIENT, AmbientSFXCollection.GetFMODEvent(/*room.Indoors*/ true, (int)partyModel.Party.Size));
 }