コード例 #1
0
ファイル: NpcService.cs プロジェクト: OlegGelezcov/Casual
        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();
            }
        }
コード例 #2
0
        public void AddBuff(BonusData data)
        {
            BuffInfo info = new BuffInfo(data);

            buffs[info.Id] = info;
            RavenhillEvents.OnBuffAdded(info);
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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}");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: RoomInfo.cs プロジェクト: OlegGelezcov/Casual
        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);
        }
コード例 #7
0
        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);
                }
            });
        }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
0
 public void ResetSearchCounter()
 {
     if (searchCounter > 0)
     {
         searchCounter = 0;
         RavenhillEvents.OnSearchCounterChanged(searchCounter);
     }
 }
コード例 #10
0
ファイル: JournalService.cs プロジェクト: OlegGelezcov/Casual
 public void AddEntry(JournalEntryInfo entry)
 {
     if (!Contains(entry.Id))
     {
         entries.Add(entry);
         RavenhillEvents.OnJournalEntryAdded(entry);
     }
 }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
ファイル: RoomInfo.cs プロジェクト: OlegGelezcov/Casual
        public void SetRoomLevel(RoomLevel newRoomLevel)
        {
            RoomLevel oldRoomLevel = roomLevel;

            roomLevel = newRoomLevel;
            if (oldRoomLevel != newRoomLevel)
            {
                RavenhillEvents.OnRoomLevelChanged(oldRoomLevel, roomLevel, this);
            }
        }
コード例 #13
0
 public void StartSession(RoomInfo roomInfo)
 {
     if (!isStarted)
     {
         SetRoomInfo(roomInfo);
         //roomDropList.Clear();
         isStarted = true;
         RavenhillEvents.OnSearchSessionStarted(this);
     }
 }
コード例 #14
0
ファイル: Inventory.cs プロジェクト: OlegGelezcov/Casual
 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);
 }
コード例 #15
0
 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);
     });
 }
コード例 #16
0
        public bool Remove(InventoryItemData data)
        {
            bool success = collectables.Remove(data.id);

            if (success)
            {
                RavenhillEvents.OnRemovedFromWishlist(data);
            }
            return(success);
        }
コード例 #17
0
ファイル: RoomInfo.cs プロジェクト: OlegGelezcov/Casual
        public void SetSearchMode(SearchMode searchMode)
        {
            SearchMode oldSearchMode = this.searchMode;

            this.searchMode = searchMode;
            if (oldSearchMode != searchMode)
            {
                RavenhillEvents.OnSearchModeChanged(oldSearchMode, searchMode, this);
            }
        }
コード例 #18
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        public void SetName(string newName)
        {
            string oldName = PlayerName;

            PlayerName = newName;
            if (oldName != PlayerName)
            {
                RavenhillEvents.OnPlayerNameChanged(oldName, PlayerName);
            }
        }
コード例 #19
0
        private void OnSearchSessionEnded(SearchSession session)
        {
            if (session.isSearchSuccessed)
            {
                searchCounter++;
                lastSearchRoomId = session.roomId;

                RavenhillEvents.OnSearchCounterChanged(searchCounter);
            }
        }
コード例 #20
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        public void SetGold(int count)
        {
            int oldCount = gold;

            gold = count;
            if (oldCount != gold)
            {
                RavenhillEvents.OnPlayerGoldChanged(oldCount, gold);
            }
        }
コード例 #21
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        public void SetAvatar(AvatarData avatar)
        {
            string oldAvatar = avatarId;

            avatarId = avatar.id;
            if (oldAvatar != avatarId)
            {
                RavenhillEvents.OnPlayerAvatarChanged(oldAvatar, avatarId);
            }
        }
コード例 #22
0
ファイル: RoomInfo.cs プロジェクト: OlegGelezcov/Casual
        public void Unlock(bool value)
        {
            bool oldIsUnlocked = isUnlocked;

            isUnlocked = value;
            if (isUnlocked != oldIsUnlocked)
            {
                RavenhillEvents.OnRoomUnlocked(this);
            }
        }
コード例 #23
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        public void SetSilver(int count)
        {
            int oldCount = silver;

            silver = count;
            if (oldCount != silver)
            {
                RavenhillEvents.OnPlayerSilverChanged(oldCount, silver);
            }
        }
コード例 #24
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        private void AddSilverImpl(int count)
        {
            int oldCount = silver;

            silver += count;
            if (oldCount != silver)
            {
                RavenhillEvents.OnPlayerSilverChanged(oldCount, silver);
            }
        }
コード例 #25
0
        public void SetRoomMode(RoomMode roomMode)
        {
            RoomMode oldRoomMode = this.roomMode;

            this.roomMode = roomMode;

            if (oldRoomMode != this.roomMode)
            {
                RavenhillEvents.OnRoomModeChanged(oldRoomMode, this.roomMode);
            }
        }
コード例 #26
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
        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);
            }
        }
コード例 #27
0
ファイル: RoomInfo.cs プロジェクト: OlegGelezcov/Casual
 public bool TrySetRecordTime(int time)
 {
     if (time < recordSearchTime)
     {
         int oldTime = recordSearchTime;
         recordSearchTime = time;
         RavenhillEvents.OnRoomRecordTimeChanged(oldTime, recordSearchTime, this);
         return(true);
     }
     return(false);
 }
コード例 #28
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
 public void RemoveSilver(int count)
 {
     if (silver >= count)
     {
         int oldSilver = silver;
         silver -= count;
         if (oldSilver != silver)
         {
             RavenhillEvents.OnPlayerSilverChanged(oldSilver, silver);
         }
     }
 }
コード例 #29
0
ファイル: JournalService.cs プロジェクト: OlegGelezcov/Casual
        public void CloseEndText(string id)
        {
            var entry = GetEntry(id);

            if (entry != null)
            {
                if (entry.CloseEndText())
                {
                    RavenhillEvents.OnJournalEntryEndTextClosed(entry);
                }
            }
        }
コード例 #30
0
ファイル: PlayerService.cs プロジェクト: OlegGelezcov/Casual
 public void RemoveGold(int count)
 {
     if (gold >= count)
     {
         int oldCount = gold;
         gold -= count;
         if (oldCount != gold)
         {
             RavenhillEvents.OnPlayerGoldChanged(oldCount, gold);
         }
     }
 }