private void GenerateBlocks(Vector3 pos) { if (Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index < 20 && PlayerData.Instance.LifetimePrestiges.Value <= 0) { string chunkPrefabPath = GetChunkPrefabPath(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index); GameObject gameObject = GameObjectExtensions.InstantiateFromResources(chunkPrefabPath, pos, Quaternion.identity); ChunkGenerator.GenerateFromPlaceholders(gameObject, BindingManager.Instance.BlockContainer); UnityEngine.Object.DestroyImmediate(gameObject); CalculateBlocksAndGoldBlocks(); } else if (PersistentSingleton <ARService> .Instance.ARLevel.Value != null && (Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index % 5 == 2 || PersistentSingleton <ARService> .Instance.ShowCustomLevel.Value)) { CustomLevel.Value = true; ChunkGenerator.GenerateFromCustomLevel(PersistentSingleton <ARService> .Instance.ARLevel.Value, pos, BindingManager.Instance.BlockContainer); PersistentSingleton <ARService> .Instance.ShowCustomLevel.Value = false; } else { CustomLevel.Value = false; ChunkGenerator.GenerateFromConfig(pos, Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, PlayerData.Instance.LifetimePrestiges.Value, PlayerData.Instance.RetryLevelNumber.Value, BindingManager.Instance.BlockContainer, bossFight: false); } (from moving in Singleton <CameraMoveRunner> .Instance.IsCameraMoving where !moving select moving).Take(1).Subscribe(delegate { CalculateChunkHealth(); }).AddTo(SceneLoader.Instance); }
private GameObject CreateGameObject(string prefabPath) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(prefabPath); m_pathPools[prefabPath].Add(gameObject); return(gameObject); }
public GameObject InstantiateFromResources(string path, Vector3 position, Quaternion rotation, Dictionary <string, object> parameters) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(path, position, rotation); InstallContexts(gameObject.transform, parameters); return(gameObject); }
protected void Start() { IEnumerator enumerator = base.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { Transform transform = (Transform)enumerator.Current; UnityEngine.Object.DestroyImmediate(transform.gameObject); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } Debug.LogError($"GetPrefabPath {GetPrefabPath()}"); GameObject gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath()); gameObject.transform.SetParent(base.transform, worldPositionStays: false); }
public void LoadARLevel() { if (File.Exists(PersistentDataPath.Get() + "/ARLevel.idl")) { string cipherText = File.ReadAllText(PersistentDataPath.Get() + "/ARLevel.idl"); string str = Encryptor.Decrypt(cipherText); JSONObject jSONObject = new JSONObject(str); if (jSONObject.HasField("Blocks")) { Transform blockContainer = ARBindingManager.Instance.BlockContainer; blockContainer.DestroyChildrenImmediate(); List <JSONObject> list = jSONObject.GetField("Blocks").list; foreach (JSONObject item in list) { string text = item.asString("Type", () => string.Empty); int num = item.asInt("Size", () => 0); Vector3 localPosition = new Vector3(item.asFloat("X", () => 0f), item.asFloat("Y", () => 0f), item.asFloat("Z", () => 0f)); Quaternion rotation = ARBindingManager.Instance.World.transform.rotation; GameObject gameObject = GameObjectExtensions.InstantiateFromResources("Blocks/AR/" + text + "Cube_" + num + "x" + num, Vector3.zero, rotation); Transform transform = gameObject.transform; Vector3 one = Vector3.one; Vector3 localScale = ARBindingManager.Instance.World.transform.localScale; transform.localScale = one * localScale.x; gameObject.transform.SetParent(blockContainer); gameObject.transform.localPosition = localPosition; } } } }
private void SpawnCollectableReward() { spots = BindingManager.Instance.UI.gameObject.GetComponentsInChildren <CollectableSpot>(includeInactive: true); if (spawnedRewards > 6) { return; } spawnedRewards++; List <CollectableSpot> list = new List <CollectableSpot>(); if (spots.Length <= 0) { return; } CollectableSpot[] array = spots; foreach (CollectableSpot collectableSpot in array) { if (collectableSpot.transform.childCount == 0) { list.Add(collectableSpot); } } if (list.Count > 0) { Transform transform = list[UnityEngine.Random.Range(0, list.Count)].transform; GameObject gameObject = GameObjectExtensions.InstantiateFromResources("Collectables/StationaryReward_0"); gameObject.transform.SetParent(transform, worldPositionStays: false); } }
protected void Start() { Debug.LogError($"GetPrefabPath {GetPrefabPath()}"); GameObject gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath()); gameObject.transform.SetParent(base.transform, worldPositionStays: false); }
public void CreateNearbyMaterialObservers(BindingManager bind) { int i; for (i = 0; i < 5; i++) { if (observers[i] != null) { observers[i].Dispose(); } BlockType mat = (BlockType)i; int chunkIndex = PersistentSingleton <Economies> .Instance.ChunkGeneratings.Find((ChunkGeneratingConfig x) => x.Materials[i].Weight > 0f).Chunk; chunkIndex = Math.Max(1, chunkIndex); if (PlayerData.Instance.LifetimeBlocksDestroyed[i].Value > 0) { IDisposable disposable = (from chunk in Singleton <WorldRunner> .Instance.CurrentChunk where chunk.Index == chunkIndex select chunk).Take(1).Subscribe(delegate { GameObject gameObject = GameObjectExtensions.InstantiateFromResources("UI/NearbyMaterialsProfiles/NearbyMaterial_" + mat); gameObject.transform.SetParent(bind.NearbyMaterial, worldPositionStays: false); }).AddTo(bind); observers[i] = disposable; } } }
public GameObject InstantiateFromResourcesSetParent(string path, Vector3 position, Quaternion rotation, Dictionary <string, object> parameters, Transform parent) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(path, position, rotation); gameObject.transform.SetParent(parent, worldPositionStays: false); InstallContexts(gameObject.transform, parameters); return(gameObject); }
protected void OnEnable() { base.transform.DestroyChildrenImmediate(); m_gameObject = null; int value = Singleton <BossIndexRunner> .Instance.CurrentBossIndex.Value; if (value != -1) { m_gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath(value), Vector3.zero, Quaternion.identity); m_gameObject.transform.SetParent(base.transform, worldPositionStays: false); StartCoroutine(RenderQueueRoutine()); } }
protected void Start() { string prefabPath = GetPrefabPath(); if (prefabPath != null) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(prefabPath); if (gameObject != null) { gameObject.transform.SetParent(base.transform, worldPositionStays: false); } } }
private void OnEnable() { base.transform.DestroyChildrenImmediate(); if (m_whichTrophy == Trophy.Next && PlayerData.Instance.Trophies.Value < 3) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath(PlayerData.Instance.Trophies.Value + 1), Vector3.zero, Quaternion.identity); gameObject.transform.SetParent(base.transform, worldPositionStays: false); } else if (m_whichTrophy == Trophy.Current) { GameObject gameObject2 = GameObjectExtensions.InstantiateFromResources(GetPrefabPath(PlayerData.Instance.Trophies.Value), Vector3.zero, Quaternion.identity); gameObject2.transform.SetParent(base.transform, worldPositionStays: false); } }
private void ShowPerkUnlock(int hero, int perk) { if (PlayerData.Instance.HeroStates[hero].Level.Value >= PlayerData.Instance.HeroStates[hero].LifetimeLevel.Value) { base.gameObject.SetActive(value: true); BonusMultConfig bonusMultConfig = PersistentSingleton <Economies> .Instance.PerkMilestoneConfigs[hero].Items[perk]; m_perkParent.transform.DestroyChildrenImmediate(); GameObject gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath(bonusMultConfig)); gameObject.transform.SetParent(m_perkParent.transform, worldPositionStays: false); m_perkName.text = PersistentSingleton <LocalizationService> .Instance.Text("Perk." + bonusMultConfig.BonusType + ".Title"); m_perkAttribute.text = BonusTypeHelper.GetAttributeText(bonusMultConfig.BonusType, bonusMultConfig.Amount); } }
protected void OnEnable() { base.transform.DestroyChildrenImmediate(); int value = Singleton <BossIndexRunner> .Instance.CurrentBossIndex.Value; if (value == -1) { m_gameObject = GameObjectExtensions.InstantiateFromResources("Trapped/TrappedCoins", Vector3.zero, Quaternion.identity); } else { m_gameObject = GameObjectExtensions.InstantiateFromResources("Trapped/TrappedCompanion", Vector3.zero, Quaternion.identity); } m_gameObject.transform.SetParent(base.transform, worldPositionStays: false); }
public MaterialNotificationRunner() { Singleton <PropertyManager> .Instance.AddRootContext(this); SceneLoader instance = SceneLoader.Instance; BindingManager bind = BindingManager.Instance; for (int i = 0; i < PlayerData.Instance.LifetimeBlocksDestroyed.Count; i++) { BlockType mat = (BlockType)i; if (mat != BlockType.Gold && PlayerData.Instance.LifetimeBlocksDestroyed[i].Value == 0) { (from amount in PlayerData.Instance.LifetimeBlocksDestroyed[i] where amount > 0 select amount).Take(1).Subscribe(delegate { GameObject gameObject = GameObjectExtensions.InstantiateFromResources("UI/NewMaterialFoundProfiles/MaterialFound_" + mat); gameObject.transform.SetParent(bind.NewMaterialFound, worldPositionStays: false); }).AddTo(instance); } } PlayerData.Instance.LifetimePrestiges.Subscribe(delegate { CreateNearbyMaterialObservers(bind); }).AddTo(instance); (from berries in PlayerData.Instance.LifetimeBerries.Pairwise() where berries.Current > 0 && berries.Previous == 0 select berries).Subscribe(delegate { bind.BerryTutorialParent.ShowInfo(); }).AddTo(instance); (from keys in PlayerData.Instance.LifetimeKeys.Pairwise() where keys.Current > 0 && keys.Previous == 0 select keys).Subscribe(delegate { bind.KeyTutorialParent.ShowInfo(); }).AddTo(instance); GrassFound = CreateMaterialProperty(0); DirtFound = CreateMaterialProperty(1); WoodFound = CreateMaterialProperty(2); StoneFound = CreateMaterialProperty(3); MetalFound = CreateMaterialProperty(4); RelicFound = PlayerData.Instance.BlocksInBackpack[6].CombineLatest(PlayerData.Instance.LifetimeRelics, (long bp, long lt) => bp > 0 || lt > 0).TakeUntilDestroy(instance).ToReactiveProperty(); }
public void LoadFromJSON(JSONObject json) { if (json.HasField("Blocks")) { Transform blockContainer = ARBindingManager.Instance.BlockContainer; blockContainer.DestroyChildrenImmediate(); List <JSONObject> list = json.GetField("Blocks").list; foreach (JSONObject item in list) { string text = item.asString("Type", () => string.Empty); int num = item.asInt("Size", () => 0); Vector3 localPosition = new Vector3(item.asFloat("X", () => 0f), item.asFloat("Y", () => 0f), item.asFloat("Z", () => 0f)); Quaternion rotation = ARBindingManager.Instance.World.transform.rotation; GameObject gameObject = GameObjectExtensions.InstantiateFromResources("Blocks/AR/" + text + "Cube_" + num + "x" + num, Vector3.zero, rotation); Transform transform = gameObject.transform; Vector3 one = Vector3.one; Vector3 localScale = ARBindingManager.Instance.World.transform.localScale; transform.localScale = one * localScale.x; gameObject.transform.SetParent(blockContainer); gameObject.transform.localPosition = localPosition; } } }
private void CheckAndSpawn(Vector3 pos, float halfScale) { Quaternion rotation = ARBindingManager.Instance.World.transform.rotation; if (!Physics.CheckSphere(pos, (float)m_prefabSize * halfScale * 0.95f)) { if (ARInstaller.Instance.RestrictedMode) { JSONObject item = ARInstaller.Instance.SaveARLevel(); RestrSteps.Add(item); } string path = "Blocks/AR/" + m_prefabType.ToString() + "Cube_" + m_prefabSize + "x" + m_prefabSize; GameObject gameObject = GameObjectExtensions.InstantiateFromResources(path, pos, rotation); gameObject.transform.localScale = Vector3.one * halfScale * 20f; gameObject.transform.SetParent(ARBindingManager.Instance.BlockContainer); BlocksPlaced.Value++; AudioController.Instance.QueueEvent(new AudioEvent(BlockAudioClip, AUDIOEVENTACTION.Play)); if (!ARInstaller.Instance.RestrictedMode) { Steps.Add(new EditStep(gameObject, activate: true)); } } }