private void TryGenerateNPCs() { foreach (var pair in Npcs) { var info = pair.Value; if (info.IsEmpty) { NpcData targetData = null; foreach (NpcData data in resourceService.npcList.Shuffled()) { if (UnityEngine.Random.value < data.prob) { targetData = data; break; } } if (targetData != null) { info.SetNpc(targetData); RavenhillEvents.OnNpcCreated(pair.Key, pair.Value); } } } if (ravenhillGameModeService.gameModeName == GameModeName.map) { CreateMapNpcs(); } }
public void AddBuff(BonusData data) { BuffInfo info = new BuffInfo(data); buffs[info.Id] = info; RavenhillEvents.OnBuffAdded(info); }
public override void RemoveView(RavenhillViewType viewType) { if (openedViews.ContainsKey(viewType)) { GameObject instance = openedViews[viewType]; openedViews.Remove(viewType); if (instance) { RavenhillBaseView baseView = instance.GetComponentInChildren <RavenhillBaseView>(); baseView?.OnViewWillBeClosed(); if (baseView) { baseView.FadeOut(); } else { GameObject.Destroy(instance); } lastViewRemovedTime = Time.time; RavenhillEvents.OnViewRemoved(viewType); } } }
public void StartSearch(int maxCount) { RavenhillEvents.OnSearchStarted(); int groupIndex = UnityEngine.Random.Range(0, searchGroups.Length); searchGroups[groupIndex].gameObject.SetActive(true); activeGroup = searchGroups[groupIndex]; currentSearchObjects = activeGroup.Activate(maxCount); RavenhillEvents.OnSearchProgressChanged(foundedSearchObjectCount, searchableObjectCount); var resourceService = engine.GetService <IResourceService>() as RavenhillResourceService; notFoundedObjects.Clear(); for (int i = 0; i < currentSearchObjects.Length; i++) { var searchObjectData = resourceService.GetSearchObjectData(currentSearchObjects[i].id); if (searchObjectData != null) { notFoundedObjects.Add(searchObjectData); } } numberToFind = notFoundedObjects.Count; Debug.Log($"Not Founded: {notFoundedObjects.Count}, Active: {activeObjects.Count}, Founded: {foundedObjects.Count}"); }
public override GameObject ShowView(RavenhillViewType type, object data = null) { GameObject resultObject = null; if (openedViews.ContainsKey(type)) { GameObject existingViewObj = openedViews[type]; if (existingViewObj) { existingViewObj.GetComponentInChildren <RavenhillBaseView>()?.Setup(data); resultObject = existingViewObj; } else { openedViews.Remove(type); resultObject = CreatePrefabAndAddToScreen(type, data); openedViews.Add(type, resultObject); } } else { resultObject = CreatePrefabAndAddToScreen(type, data); openedViews.Add(type, resultObject); } RavenhillEvents.OnViewAdded(type); return(resultObject); }
private bool AddRoomProgress(int count) { bool isLevelChanged = false; if (count > 0) { int oldRoomProgress = roomProgress; roomProgress += count; if (roomProgress >= 100) { if (roomLevel != RoomLevel.Hunter) { roomProgress = 0; isLevelChanged = true; } else { roomProgress = 100; } } RavenhillEvents.OnRoomProgressChanged(oldRoomProgress, roomProgress, this); } return(isLevelChanged); }
public BuffManager() { updateBuffsTimer.Setup(1, (delta) => { foreach (var pair in buffs) { pair.Value.Update(delta); } }); removeExpiredTimer.Setup(1, (delta) => { List <string> keys = new List <string>(); foreach (var pair in buffs) { if (!pair.Value.IsValid) { keys.Add(pair.Key); } } foreach (string key in keys) { BuffInfo buff = buffs[key]; buffs.Remove(key); //buff removed event RavenhillEvents.OnBuffRemoved(buff); } }); }
public override void Awake() { base.Awake(); if (s_IsCreated) { Destroy(gameObject); return; } else { DontDestroyOnLoad(gameObject); RegisterServices(); SetupServices(); SceneManager.sceneLoaded += (scene, mode) => { var gameModeService = GetService <IGameModeService>()?.Cast <RavenhillGameModeService>(); if (gameModeService != null) { var roomData = GetService <IResourceService>()?.Cast <RavenhillResourceService>()?.GetRoomDataBySceneName(scene.name, gameModeService.roomMode); if (roomData != null) { switch (roomData.roomType) { case Data.RoomType.hallway: { gameModeService.SetGameModeName(GameModeName.hallway); } break; case Data.RoomType.map: { gameModeService.SetGameModeName(GameModeName.map); } break; case Data.RoomType.search: { gameModeService.SetGameModeName(GameModeName.search); } break; } } } RavenhillEvents.OnSceneLoaded(scene.name); }; s_IsCreated = true; var resourceSerice = GetService <IResourceService>().Cast <RavenhillResourceService>(); var mapData = resourceSerice.GetRoomData(RoomType.map); if (mapData != null) { LoadScene(mapData.id); } } }
public void ResetSearchCounter() { if (searchCounter > 0) { searchCounter = 0; RavenhillEvents.OnSearchCounterChanged(searchCounter); } }
public void AddEntry(JournalEntryInfo entry) { if (!Contains(entry.Id)) { entries.Add(entry); RavenhillEvents.OnJournalEntryAdded(entry); } }
/// <summary> /// Dont call (only for debug) /// </summary> /// <param name="status"></param> /// <param name="time"></param> /// <param name="drops"></param> internal void OnEndSession(SearchStatus status, int time, List <InventoryItem> drops) { SetSearchStatus(status); SetSearchTime(time); roomDropList.Clear(); roomDropList.AddRange(drops); isStarted = false; RavenhillEvents.OnSearchSessionEnded(this); }
public void SetRoomLevel(RoomLevel newRoomLevel) { RoomLevel oldRoomLevel = roomLevel; roomLevel = newRoomLevel; if (oldRoomLevel != newRoomLevel) { RavenhillEvents.OnRoomLevelChanged(oldRoomLevel, roomLevel, this); } }
public void StartSession(RoomInfo roomInfo) { if (!isStarted) { SetRoomInfo(roomInfo); //roomDropList.Clear(); isStarted = true; RavenhillEvents.OnSearchSessionStarted(this); } }
public void AddItem(InventoryItem item) { if (item.type == InventoryItemType.None) { return; } AddItemImpl(item); RavenhillEvents.OnInventoryItemAdded(item.data.type, item.id, item.count); RavenhillEvents.OnInventoryChanged(item.data.type, item.id, item.count); }
public RoomModeSwitcher(float switchInterval, IRoomMode roomMode) { this.switchInterval = switchInterval; this.switchTimer = switchInterval; this.roomMode = roomMode; eventTimer = new UpdateTimer(); eventTimer.Setup(1.0f, (realDelay) => { RavenhillEvents.OnRoomModeSwitchTimerChanged(switchTimer, switchInterval); }); }
public bool Remove(InventoryItemData data) { bool success = collectables.Remove(data.id); if (success) { RavenhillEvents.OnRemovedFromWishlist(data); } return(success); }
public void SetSearchMode(SearchMode searchMode) { SearchMode oldSearchMode = this.searchMode; this.searchMode = searchMode; if (oldSearchMode != searchMode) { RavenhillEvents.OnSearchModeChanged(oldSearchMode, searchMode, this); } }
public void SetName(string newName) { string oldName = PlayerName; PlayerName = newName; if (oldName != PlayerName) { RavenhillEvents.OnPlayerNameChanged(oldName, PlayerName); } }
private void OnSearchSessionEnded(SearchSession session) { if (session.isSearchSuccessed) { searchCounter++; lastSearchRoomId = session.roomId; RavenhillEvents.OnSearchCounterChanged(searchCounter); } }
public void SetGold(int count) { int oldCount = gold; gold = count; if (oldCount != gold) { RavenhillEvents.OnPlayerGoldChanged(oldCount, gold); } }
public void SetAvatar(AvatarData avatar) { string oldAvatar = avatarId; avatarId = avatar.id; if (oldAvatar != avatarId) { RavenhillEvents.OnPlayerAvatarChanged(oldAvatar, avatarId); } }
public void Unlock(bool value) { bool oldIsUnlocked = isUnlocked; isUnlocked = value; if (isUnlocked != oldIsUnlocked) { RavenhillEvents.OnRoomUnlocked(this); } }
public void SetSilver(int count) { int oldCount = silver; silver = count; if (oldCount != silver) { RavenhillEvents.OnPlayerSilverChanged(oldCount, silver); } }
private void AddSilverImpl(int count) { int oldCount = silver; silver += count; if (oldCount != silver) { RavenhillEvents.OnPlayerSilverChanged(oldCount, silver); } }
public void SetRoomMode(RoomMode roomMode) { RoomMode oldRoomMode = this.roomMode; this.roomMode = roomMode; if (oldRoomMode != this.roomMode) { RavenhillEvents.OnRoomModeChanged(oldRoomMode, this.roomMode); } }
public void RemoveHealth(float count) { float oldCount = health; health -= Mathf.Abs(count); health = Mathf.Clamp(health, 0, maxHealth); if (!Mathf.Approximately(oldCount, health)) { RavenhillEvents.OnPlayerHealthChanged(oldCount, health); } }
public bool TrySetRecordTime(int time) { if (time < recordSearchTime) { int oldTime = recordSearchTime; recordSearchTime = time; RavenhillEvents.OnRoomRecordTimeChanged(oldTime, recordSearchTime, this); return(true); } return(false); }
public void RemoveSilver(int count) { if (silver >= count) { int oldSilver = silver; silver -= count; if (oldSilver != silver) { RavenhillEvents.OnPlayerSilverChanged(oldSilver, silver); } } }
public void CloseEndText(string id) { var entry = GetEntry(id); if (entry != null) { if (entry.CloseEndText()) { RavenhillEvents.OnJournalEntryEndTextClosed(entry); } } }
public void RemoveGold(int count) { if (gold >= count) { int oldCount = gold; gold -= count; if (oldCount != gold) { RavenhillEvents.OnPlayerGoldChanged(oldCount, gold); } } }