public void ProjectSelectionOnProjectionSurface() { if (NumberOfSelectedObjects == 0) { return; } if (!ObjectOnSurfaceProjectSettings.ProjectOnGrid) { GameObject projectionSurface = ObjectOnSurfaceProjectSettings.ProjectionSurface; if (projectionSurface == null) { return; } Vector3 projectionDirection = ObjectOnSurfaceProjectSettings.GetProjectionDirectionVector(); GameObjectExtensions.EmbedAllObjectsInSurface(new List <GameObject>(_selectedObjects.HashSet), projectionDirection, projectionSurface); _objectSelectionGizmos.OnObjectSelectionUpdated(); } else { Vector3 projectionDirection = ObjectOnSurfaceProjectSettings.GetProjectionDirectionVector(); GameObjectExtensions.ProjectAllObjectsOnPlane(new List <GameObject>(_selectedObjects.HashSet), projectionDirection, ObjectSnapping.Get().XZSnapGrid.Plane); _objectSelectionGizmos.OnObjectSelectionUpdated(); } }
public static void DomainReset() { EventHandler.DomainReset(); GameObjectExtensions.DomainReset(); ObjectPoolBase.DomainReset(); SchedulerBase.DomainReset(); }
private void Rotate(float angle, Vector3 axis) { var selectedParents = GameObjectExtensions.GetParents(_selectedObjects.HashSet); GameObjectExtensions.RecordObjectTransformsForUndo(selectedParents); if (Settings.RotateAroundSelectionCenter) { Vector3 selectionCenter = GetWorldCenter(); foreach (var parent in selectedParents) { parent.RotateHierarchyBoxAroundPoint(angle, axis, selectionCenter); } } else { foreach (var parent in selectedParents) { Box worldAABB = parent.GetHierarchyWorldBox(); if (worldAABB.IsValid()) { parent.RotateHierarchyBoxAroundPoint(angle, axis, worldAABB.Center); } } } }
private GameObject CreateGameObject(string prefabPath) { GameObject gameObject = GameObjectExtensions.InstantiateFromResources(prefabPath); m_pathPools[prefabPath].Add(gameObject); return(gameObject); }
public override void OnEnter(StatedMono <LevelStateEnum> statedMono) { LevelSystem levelSystem = statedMono as LevelSystem; int currentScore = ServiceProvider.GetService <ScoreSystem>().GetScore(); PersistentDataSystem persistentDataSystem = ServiceProvider.GetService <PersistentDataSystem>(); ScoreSavedData scoreSavedData = persistentDataSystem.GetSavedData <ScoreSavedData>(); int bestScore = scoreSavedData.bestScore; if (bestScore < currentScore) { scoreSavedData.bestScore = currentScore; persistentDataSystem.SaveData(scoreSavedData); } ServiceProvider.GetService <ResultScreenView>().Show(currentScore, scoreSavedData.bestScore); IPausable[] pausables = GameObjectExtensions.FindObjectsOfTypeAll <IPausable>(true); for (int i = 0; i < pausables.Length; i++) { pausables[i].Pause(); //Awake all entities in the level } timer = levelSystem.clock.CurrentRenderTime + 5f; }
protected void Awake() { this.RectTm = base.GetComponent <RectTransform>(); Transform[] children = TransformExtensions.GetChildren(this.LockedContentRoot.transform, false); for (int i = 0; i < children.Length; i++) { TransformAnimation item = GameObjectExtensions.AddOrGetComponent <TransformAnimation>(children[i].gameObject); this.m_lockedContentTransformAnimations.Add(item); RectTransform transform = children[i].GetComponent <RectTransform>(); this.m_lockedContentRectTransforms.Add(item, transform); this.m_lockedContentOriginalAnchoredPositions.Add(item, transform.anchoredPosition); Image image = children[i].GetComponent <Image>(); MenuOverlay overlay = GameObjectExtensions.AddOrGetComponent <MenuOverlay>(children[i].gameObject); overlay.Image = image; this.m_lockedContentImages.Add(item, overlay); } this.m_dummyRectTmObj = new GameObject("DummyRectTm").AddComponent <RectTransform>(); this.m_dummyRectTmObj.sizeDelta = Vector2.zero; this.m_dummyRectTmObj.SetParent(this.LockedContentRoot.transform, false); this.m_dimmableImages.Clear(); Image component = this.BackgroundCanvas.GetComponent <Image>(); this.m_dimmableImages.Add(component); this.m_dimmableImageOriginalColors.Add(component, component.color); Image[] componentsInChildren = this.OpenContentRoot.GetComponentsInChildren <Image>(); for (int j = 0; j < componentsInChildren.Length; j++) { this.m_dimmableImages.Add(componentsInChildren[j]); this.m_dimmableImageOriginalColors.Add(componentsInChildren[j], componentsInChildren[j].color); } }
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); }
public static void AlignSelectionToAxis(Axis axis) { int axisIndex = (int)axis; List <GameObject> allSelectedObjects = ObjectSelection.Get().GetAllSelectedGameObjects(); List <GameObject> selectedParents = GameObjectExtensions.GetParents(allSelectedObjects); if (selectedParents.Count == 0) { return; } float average = 0.0f; foreach (var parent in selectedParents) { average += parent.transform.position[axisIndex]; } average /= selectedParents.Count; GameObjectExtensions.RecordObjectTransformsForUndo(selectedParents); foreach (var parent in selectedParents) { Transform parentTransform = parent.transform; Vector3 alignedPosition = parentTransform.position; alignedPosition[axisIndex] = average; parentTransform.position = alignedPosition; } }
public void Destroy() { GameObjectExtensions.Destroy(GameObject); GameObject = null; MeshFilter = null; MeshRenderer = null; }
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; } } } }
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; } } }
private void PlaceObjects() { if (CanPlaceObjectsOnHoveredSurface()) { var placementDataInstances = _objectPlacementDataCalculator.Calculate(RotationToApplyForStrokeAlignment); List <GameObject> placedHierarchyRoots = Octave3DScene.Get().InstantiateObjectHirarchiesFromPlacementDataCollection(placementDataInstances); for (int rootIndex = 0; rootIndex < placedHierarchyRoots.Count; ++rootIndex) { GameObject root = placedHierarchyRoots[rootIndex]; if (placementDataInstances[rootIndex].MustEmbedInSurface) { if (_strokeSurface.Type == DecorPaintStrokeSurfaceType.Terrain) { root.EmbedInSurfaceByVertex(-Vector3.up, _strokeSurface.SurfaceObject); } else if (_strokeSurface.Type == DecorPaintStrokeSurfaceType.Mesh) { root.EmbedInSurfaceByVertex(-_strokeSurface.Plane.normal, _strokeSurface.SurfaceObject); } } } List <GameObject> allPlacedObjects = GameObjectExtensions.GetAllObjectsInHierarchyCollection(placedHierarchyRoots); _objectsPlacedWhileDragging.AddRange(allPlacedObjects); DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask.Mask(allPlacedObjects); ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(placedHierarchyRoots, ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.ObjectPlacement); } RegisterPlacementPoint(); }
protected void Awake() { this.Tm = base.transform; this.SpriteRenderer = GameObjectExtensions.AddOrGetComponent <UnityEngine.SpriteRenderer>(base.gameObject); this.Tm.localRotation = Quaternion.Euler(90f, 0f, 0f); this.initialize(); }
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); }
public static void SetDirty(bool dirty) { GameObject levelObject = GameObjectExtensions.FindWithSubstring(LOADED_LEVEL_NAME + LOADED_LEVEL_DIRTY_DELIMITER); if (levelObject != null) { if (!dirty) { levelObject.name = string.Format("{0}|{1}", LOADED_LEVEL_NAME, LoadedLevelPath); return; } } else { levelObject = GameObjectExtensions.FindWithSubstring(LOADED_LEVEL_NAME); if (levelObject != null) { if (dirty) { levelObject.name = string.Format("{0}{1}|{2}", LOADED_LEVEL_NAME, LOADED_LEVEL_DIRTY_DELIMITER, LoadedLevelPath); return; } } else { Debug.LogError("Failed to find a loaded level object!"); } } }
/// <summary> /// Reset level to initial settings /// </summary> private void ResetLevel() { _score = 0f; StopEnemyFishSpawning(); StopPowerupsSpawning(); // reset player position _player.transform.position = new Vector3(0, 0, GameConstants.FISH_Z_VALUE); _player.transform.localScale = GameConstants.PLAYER_STARTING_SCALE; _player.GetComponent <Rigidbody2D>().velocity = Vector2.zero; // find all enemy fish game objects and destroy them var enemyFish = GameObject.FindGameObjectsWithTag("EnemyFish").ToList(); DestroyAll(enemyFish); // find all obstacle objects and destroy them var obstacles = GameObject.FindGameObjectsWithTag("Obstacle").ToList(); DestroyAll(obstacles); // find all active powerups and destroy them var powerUps = GameObjectExtensions.FindAllIngameObjectsWithTagPrefix("PowerUp").ToList(); DestroyAll(powerUps); // rest fish speed modifier FishEnemySpeedModifier = 1.0f; }
public virtual void CreateTransforms() { // remove any existing children GameObjectExtensions.DestroyAllChildren(gameObject); m_Transforms.Clear(); }
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 SetLayerRecursivelyNull() { Assert.Throws(typeof(System.ArgumentNullException), () => { GameObjectExtensions.SetLayerRecursively(null, waterLayer); }); }
public IEnumerator GetComponent_Passes() { var obj = new GameObject("test" , typeof(BoxCollider) , typeof(MeshFilter)); var boxCollider = obj.GetComponent <BoxCollider>(); var meshFilter = obj.GetComponent <MeshFilter>(); Assert.AreSame(boxCollider, GameObjectExtensions.GetComponent <BoxCollider>(obj)); Assert.AreSame(boxCollider, GameObjectExtensions.GetComponent <BoxCollider>(obj.transform)); Assert.AreSame(boxCollider, GameObjectExtensions.GetComponent <BoxCollider>(meshFilter)); // Not Attach Component Assert.IsNull(GameObjectExtensions.GetComponent <AudioListener>(obj)); // pass invalid target int n = 0; string s = ""; Assert.IsNull(GameObjectExtensions.GetComponent <BoxCollider>(null)); Assert.IsNull(GameObjectExtensions.GetComponent <BoxCollider>(n)); Assert.IsNull(GameObjectExtensions.GetComponent <BoxCollider>(s)); yield break; }
public void UpdatePlayerMovement(PlayerObjectState playerObjectState) { var playerObjectComponent = FindPlayerObjectComponent(playerObjectState.Id); if (playerObjectComponent == null) { return; } ApplyLookDirAnglesToPlayer(playerObjectComponent, playerObjectState.LookDirAngles); var isGrounded = IsPlayerGrounded(playerObjectComponent); if (isGrounded) { var relativeMoveDirection = GetRelativeMoveDirection(playerObjectState.Input); var playerYAngle = playerObjectComponent.transform.eulerAngles.y; var horizontalMoveDirection = Quaternion.Euler(new Vector3(0, playerYAngle, 0)) * relativeMoveDirection; var desiredHorizontalVelocity = OsFps.MaxPlayerMovementSpeed * horizontalMoveDirection; var currentHorizontalVelocity = GameObjectExtensions.GetHorizontalVelocity(playerObjectComponent.Rigidbody); var horizontalVelocityError = desiredHorizontalVelocity - currentHorizontalVelocity; playerObjectComponent.Rigidbody.AddForce(3000 * horizontalVelocityError); } }
private void CleanUpDefaultProgressIndicator() { if (progressIndicatorObject != null) { GameObjectExtensions.DestroyGameObject(progressIndicatorObject); } }
protected void Start() { Debug.LogError($"GetPrefabPath {GetPrefabPath()}"); GameObject gameObject = GameObjectExtensions.InstantiateFromResources(GetPrefabPath()); gameObject.transform.SetParent(base.transform, worldPositionStays: false); }
private static void DestroyAllChildren(MixedRealityToolkit instance) { Transform instanceTransform = instance.transform; childrenToDelete.Clear(); foreach (Transform child in instanceTransform.transform) { childrenToDelete.Add(child); } foreach (ServiceFacade facade in ServiceFacade.ActiveFacadeObjects) { if (!childrenToDelete.Contains(facade.transform)) { childrenToDelete.Add(facade.transform); } } foreach (Transform child in childrenToDelete) { GameObjectExtensions.DestroyGameObject(child.gameObject); } childrenToDelete.Clear(); }
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); } }
// Token: 0x06000056 RID: 86 RVA: 0x00004194 File Offset: 0x00002394 public void KnightPlacer(PlayerController owner) { try { AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("ec8ea75b557d4e7b8ceeaacdf6f8238c"); IntVector2 intVector = Vector2Extensions.ToIntVector2(owner.unadjustedAimPoint, (VectorConversions)2); RoomHandler absoluteRoomFromPosition = GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVector); bool flag = absoluteRoomFromPosition != null && absoluteRoomFromPosition == owner.CurrentRoom && owner.IsInCombat; if (flag) { AIActor aiactor = AIActor.Spawn(orLoadByGuid.aiActor, owner.CenterPosition, absoluteRoomFromPosition, true, (AIActor.AwakenAnimationType) 2, true); PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(aiactor.specRigidbody, null, false); aiactor.CanTargetEnemies = true; aiactor.CanTargetPlayers = false; aiactor.IsHarmlessEnemy = true; aiactor.CanDropCurrency = false; aiactor.IgnoreForRoomClear = true; aiactor.MovementSpeed = 5.95f; aiactor.CompanionOwner = owner; aiactor.IsBuffEnemy = true; aiactor.isPassable = true; aiactor.gameObject.AddComponent <KillOnRoomClear>(); aiactor.reinforceType = (AIActor.ReinforceType) 2; aiactor.HandleReinforcementFallIntoRoom(0.1f); //added this so the player doesn't collide with the nut when dodge rolling, he goes through companions aiactor.gameObject.AddComponent <CompanionController>(); CompanionController component = aiactor.gameObject.GetComponent <CompanionController>(); component.Initialize(owner); this.nut = aiactor; MindControlEffect orAddComponent = GameObjectExtensions.GetOrAddComponent <MindControlEffect>(aiactor.gameObject); orAddComponent.owner = (this.gun.CurrentOwner as PlayerController); // to make the nut invincible against the player effects or any other damage effects if (aiactor.healthHaver != null) { aiactor.healthHaver.PreventAllDamage = true; } // to prevent the attacks of the nut from damaging the player if (aiactor.bulletBank != null) { AIBulletBank bulletBank = aiactor.bulletBank; bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(bulletBank.OnProjectileCreated, new Action <Projectile>(CopperChariot.OnPostProcessProjectile)); } if (aiactor.aiShooter != null) { AIShooter aiShooter = aiactor.aiShooter; aiShooter.PostProcessProjectile = (Action <Projectile>)Delegate.Combine(aiShooter.PostProcessProjectile, new Action <Projectile>(CopperChariot.OnPostProcessProjectile)); } } } catch (Exception e) { Tools.Print("Copper KnightPlacer", "FFFFFF", true); Tools.PrintException(e); } }
void Start() { var go = GameObjectExtensions.FindParentByTag(gameObject, "Player"); player = go.GetComponent <Player>(); player.attack = attack; }
private void DestroyCursorInstance() { if (cursorInstance != null) { // Destroy correctly depending on if in play mode or edit mode GameObjectExtensions.DestroyGameObject(cursorInstance); } }
public void ChangeLayerOfChildren() { if (ParentContainer != null) { int value = LayerMaskToFind.value; GameObjectExtensions.ChangeLayersRecursively(layerOnly: (value != 0) ? ((int)Mathf.Log(value, 2f)) : (-1), trans: ParentContainer.transform, layer: (int)Mathf.Log(LayerMaskToSwitchTo.value, 2f)); } }
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); }