public static void SetAsType(SceneObject sceneObj, PrimitiveType type) { Mesh mesh = GetPrimitiveMesh(type); sceneObj.GetComponent <MeshFilter>().sharedMesh = mesh; sceneObj.GetComponent <MeshCollider>().sharedMesh = mesh; }
public void OnAddExplotion(Vector3 position, string _name, string _explotionEffect, string _explotionGift, int force, Color color) { Data.Instance.events.OnSoundFX("FX explot00", -1); Vector3 newPos = position; newPos.y -= 4; SceneObject explotionNew = ObjectPool.instance.GetObjectForType(_name, true); if (explotionNew == null) { // Debug.LogError("No hay explosion"); return; } FXExplotion fxExplotion = explotionNew.GetComponent <FXExplotion> (); if (fxExplotion != null) { fxExplotion.SetSize(force); } // explotionNew.GetComponent<FXExplotion>()._scale = force; if (explotionNew) { Game.Instance.sceneObjectsManager.AddSceneObjectAndInitIt(explotionNew, newPos); explotionNew.GetComponent <FXExplotion> ().SetColor(color); //explotionNew.Restart (newPos); } if (_explotionEffect != "") { SceneObject explpotionEffect = ObjectPool.instance.GetObjectForType(_explotionEffect, true); if (explpotionEffect) { Game.Instance.sceneObjectsManager.AddSceneObject(explpotionEffect, newPos); // explpotionEffect.Restart(newPos); ParticlesSceneObject ps = explpotionEffect.GetComponent <ParticlesSceneObject>(); if (ps != null) { ps.SetColor(color); } } } if (Random.Range(0, 100) > 70 && Data.Instance.isArcadeMultiplayer) { Data.Instance.events.OnAddPowerUp(position); } else { AddHeartsByBreaking(position, 14, 470); } }
public void Set(SceneObject sceneObject) { SceneObject = sceneObject; _boundingBoxRenderer = sceneObject.GetComponent <BoundingBoxRenderer>(); if (_boundingBoxRenderer == null) { _boundingBoxRenderer = sceneObject.AddComponent <BoundingBoxRenderer>(); } _renderer = sceneObject.GetComponent <Renderer>(); }
public bool Apply() { BoosterFunc bF = SceneObject.GetComponent <BoosterFunc>(); return(bF.ActivateApply(this)); // return false; }
public IEnumerator BasicUsagePasses() { yield return(null); var root = new GameObject("root", typeof(BoxCollider)); var root2 = new GameObject("root2", typeof(BoxCollider)); var child = new GameObject("child1", typeof(BoxCollider)); child.transform.parent = root.transform; Assert.DoesNotThrow(() => { var childCollider = new SceneObject <BoxCollider>("root/child1"); Assert.IsNotNull(childCollider.Instance); Assert.AreSame(child, childCollider.GameObject); Assert.AreSame(child.transform, childCollider.Transform); Assert.AreSame(child.GetComponent <BoxCollider>(), childCollider.Instance); Assert.AreSame(child.GetComponent <BoxCollider>(), childCollider.GetComponent <BoxCollider>()); Assert.AreSame(root, new SceneObject <BoxCollider>("root").GameObject); Assert.AreSame(root2, new SceneObject <BoxCollider>("root2").GameObject); }); Assert.Throws <UnityEngine.Assertions.AssertionException>(() => { var childCollider = new SceneObject <BoxCollider>("___invalidPath/root/child1"); }); }
void OnAddPowerUp(Vector3 pos) { powerUpOn = true; SceneObject newSO = null; int rand = Random.Range(0, 10); if (rand < 50) { newSO = ObjectPool.instance.GetObjectForType(Missile.name, true); } else { newSO = ObjectPool.instance.GetObjectForType(Invencible.name, true); } if (newSO) { int force = 600; pos.y += 1.2f; newSO.Restart(pos); newSO.transform.localEulerAngles = Vector3.zero; Vector3 direction = ((newSO.transform.forward * force) + (Vector3.up * (force * 1.8f))); newSO.GetComponent <Rigidbody>().AddForce(direction, ForceMode.Acceleration); } Invoke("Reset", 5); }
public void PastSelection(Action <SceneObject> addCallback) { if (Copy != null) { var sceneObject = (SceneObject)Copy.Clone(); var previous = Copy; addCallback(sceneObject); Copy = previous; var x = Copy.Transform.Position.X; x += Copy.GetComponent <Renderer>().BoundingSphere.Radius * 2.0f; sceneObject.Transform.SetPosition(x, null, null); if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Control) { Copy = Selected; } Messenger.Notify(EditorEvent.SceneObjectAdded); } }
void OnAddPowerUp(Vector3 pos) { if (!CanBeThrown()) { return; } powerUpOn = true; SceneObject newSO = null; int rand = Random.Range(0, 10); // if(rand<70) newSO = ObjectPool.instance.GetObjectForType(Missile.name, true); // else // newSO = ObjectPool.instance.GetObjectForType(Invencible.name, true); if (newSO) { int force = 600; pos.y += 1.2f; Game.Instance.sceneObjectsManager.AddSceneObject(newSO, pos); // newSO.Restart(pos); newSO.transform.localEulerAngles = Vector3.zero; Vector3 direction = ((newSO.transform.forward * force) + (Vector3.up * (force * 1.8f))); newSO.GetComponent <Rigidbody>().AddForce(direction, ForceMode.Acceleration); } Invoke("Reset", 5); }
public override void OnAdd() { transformComp = SceneObject.GetComponent <TransformComponent>(); maxSpeed = SceneObject.AttributeManager[AttributeType.MaxSpeed]; sqlMaxSpeed = maxSpeed.Mul(maxSpeed); base.OnAdd(); }
private static void DrawGizmo(Animation animation) { SceneObject so = animation.SceneObject; Gizmos.Color = Color.Green; Gizmos.Transform = Matrix4.Identity; AABox bounds = new AABox(); bool useAnimBounds = animation.UseBounds; if (!useAnimBounds) { Renderable renderable = so.GetComponent <Renderable>(); if (renderable != null) { bounds = renderable.Bounds.Box; } else { useAnimBounds = true; } } if (useAnimBounds) { bounds = animation.Bounds; bounds.TransformAffine(so.WorldTransform); } Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f); }
public static void Main(string[] _) { //new Input().Initialize(Input.ReadConsole).OnKey += (c) => { System.Console.WriteLine(c); }; //camera.AddComponent(new Camera(60)); camera = new Camera(60, new ConsoleRenderer(), new Dimensions2(30, 20)).DefaultObject(); Scene scene = new Scene(camera.GetComponent <Camera>()); camera.GetComponent <Camera>().renderer.renderMode = RenderMode.Shaded; EngineLoop e = new EngineLoop(scene, 10); e.RenderEvent += OnUpdate; // Add the OnUpdate event for every time the camera renders cube1.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); // Add a cube geometry to cube1 cube1.GetComponent <Mesh>().color = new Color(1, 0, 1); // Set the color of cube1's mesh cube1.worldPosition += new Point3(0, 0, 3); // Change the worldPosition of cube1 scene.objects.Add(cube1); // Add cube1 to the scene camera.worldPosition = new Point3(0, -2, 0); camera.worldRotation = Quaternion.Euler(-30, 0, 0, Quaternion.AngleUnit.Degrees); //scene.light.color = Color.FromArgb(0, 255, 0); //cubeChild.parent = cube1; // Set the parent of cubeChild to be cube1 cubeChild.localScale = new Direction3(0.5, 0.5, 1); cubeChild.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); cubeChild.localPosition = new Point3(0, 0, 3); cubeChild.localRotation = Quaternion.Euler(145, 0, 0, Quaternion.AngleUnit.Degrees); cubeChild.GetComponent <Mesh>().color = new Color(0, 1, 1); SceneObject occ = new SceneObject(); //occ.parent = cubeChild; occ.AddComponent(new Mesh(BaseGeometry.CubeGeometry())); occ.localPosition = new Point3(0, 0, 3); occ.GetComponent <Mesh>().color = new Color(0, 1, 0); occ.worldScale = new Direction3(1, 1, 1); //Tweener.TweenTo(ref cube1._localworldPosition,new Point3(0,0,0),5000); //scene.objects.Add(occ); //c.parent = o;*/ //c.localworldPosition = new Point3(0, 0, 5); while (true) { } }
Tile AddGenericTile() { SceneObject so = Data.Instance.pool.AddObjectTo("TileGeneric", transform); if (so == null) { Debug.LogError("TileGeneric no Existe"); } return(so.GetComponent <Tile>()); }
void AddObject() { SceneObject so = null; int tileID = (int)transform.position.x; so = Data.Instance.pool.AddObjectTo("GenericObject", container); //if(so != null) so.GetComponent <GenericObject> ().Init(Data.Instance.playerData.level, tileID, (int)transform.position.z); }
public void ResetEveryaditionalComponent(SceneObject so) { TimelineAnimation timelineAnimation = so.GetComponent <TimelineAnimation> (); SceneObjectData sceneObjectData = so.GetComponent <SceneObjectData> (); FullRotation fullRotation = so.GetComponent <FullRotation> (); if (timelineAnimation != null) { timelineAnimation.OnComponentDisposed(); } if (sceneObjectData != null) { Destroy(sceneObjectData); } if (fullRotation != null) { fullRotation.OnComponentDisposed(); } }
private void OnReset() { if (impl != null) { impl.Destroy(); } Camera cam = SceneObject.GetComponent <Camera>(); impl = new ProfilerOverlayInternal(cam); }
private void UpdateSelectedSO(bool force) { SceneObject so = Selection.SceneObject; if (selectedSO != so || force) { if (selectedSO != null && so == null) { EditorInput.OnPointerPressed -= OnPointerPressed; EditorInput.OnPointerMoved -= OnPointerMoved; EditorInput.OnPointerReleased -= OnPointerReleased; EditorInput.OnButtonUp -= OnButtonUp; } else if (selectedSO == null && so != null) { EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; } zoomAmount = 0.0f; selectedSO = so; selectedFields.Clear(); clipInfo = null; RebuildGUI(); // Load existing clip if one exists if (selectedSO != null) { Animation animation = selectedSO.GetComponent <Animation>(); if (animation != null) { AnimationClip clip = animation.DefaultClip; if (clip != null) { LoadAnimClip(clip); } } } if (clipInfo == null) { clipInfo = new EditorAnimClipInfo(); } if (selectedSO != null) { UpdateDisplayedCurves(true); } } }
void OnFabricaActivate(SceneObject.types fabricaType, SceneObject.types soType) { string animName = "lose"; if (fabricaType == soType) { Events.OnCorrect(soType); animName = "win"; } else { Events.OnIncorrect(soType); } SceneObject so = GetFabrica(fabricaType); Animation anim = so.GetComponent <Animation>(); anim[animName].normalizedTime = 0; anim.Play(animName); so.GetComponent <SceneSfx>().Play(animName); }
void OnAddHeartsByBreaking(Vector3 position, Material[] mat, Vector3[] pos) { int force = 400; position.y += 0.7f; int NumOfParticles = mat.Length; for (int a = 0; a < NumOfParticles; a++) { SceneObject newSO = ObjectPool.instance.GetObjectForType(explotionGift.name, true); if (newSO) { newSO.Restart(pos[a]); newSO.transform.localEulerAngles = new Vector3(0, a * (360 / NumOfParticles), 0); Vector3 direction = ((newSO.transform.forward * force) + (Vector3.up * (force * 2))); newSO.GetComponent <Rigidbody>().AddForce(direction, ForceMode.Impulse); GrabbableItem gi = newSO.GetComponent <GrabbableItem> (); gi.SetMaterial(mat[a]); } } }
void AddHeartsByBreaking(Vector3 position, int NumOfParticles, int force = 400) { position.y += 0.7f; if (NumOfParticles > 20) { NumOfParticles = 20; } for (int a = 0; a < NumOfParticles; a++) { SceneObject newSO = ObjectPool.instance.GetObjectForType(explotionGift.name, true); if (newSO) { newSO.Restart(position); newSO.transform.localEulerAngles = new Vector3(0, a * (360 / NumOfParticles), 0); Vector3 direction = ((newSO.transform.forward * force) + (Vector3.up * (force * 3))); newSO.GetComponent <Rigidbody>().AddForce(direction, ForceMode.Impulse); GrabbableItem gi = newSO.GetComponent <GrabbableItem> (); gi.SetGroundMaterial(); } } }
public void OnSetFinalScore(int playerID, Vector3 position, int score) { if (position == Vector3.zero) { return; } SceneObject newSO = Instantiate(scoreSignal, position, Quaternion.identity) as SceneObject; newSO.Restart(position); newSO.GetComponent <ScoreSignal>().SetScore(playerID, score); Data.Instance.events.OnScoreOn(playerID, position, score); }
private void InternalAddSceneObject(SceneObject sceneObject) { var collider = sceneObject.GetComponent <Collider>(); if (collider != null) { collider.IsPickable = true; } Add(sceneObject, true); SelectObject(sceneObject); }
/// <summary> /// Finds all available bones for the animation the provided bone is a part of. /// </summary> /// <param name="bone">Bone for which to return the parent skeleton's bones.</param> /// <returns>List of bones if parent skeleton is found, or null.</returns> private string[] GetBoneNames(Bone bone) { Animation animParent = null; SceneObject currentSO = bone.SceneObject; while (currentSO != null) { animParent = currentSO.GetComponent <Animation>(); if (animParent != null) { break; } currentSO = currentSO.Parent; } if (animParent == null) { return(null); } Renderable renderable = animParent.SceneObject.GetComponent <Renderable>(); if (renderable == null) { return(null); } RRef <Mesh> mesh = renderable.Mesh; if (mesh == null) { return(null); } Skeleton skeleton = mesh.Value.Skeleton; if (skeleton == null) { return(null); } string[] boneNames = new string[skeleton.NumBones]; for (int i = 0; i < boneNames.Length; i++) { boneNames[i] = skeleton.GetBoneInfo(i).name; } return(boneNames); }
public void OnAddExplotion(Vector3 position, string _name, string _explotionEffect, string _explotionGift, int force, Color color) { Data.Instance.events.OnSoundFX("FX explot00", -1); Vector3 newPos = position; newPos.y -= 4; SceneObject explotionNew = ObjectPool.instance.GetObjectForType(_name, true); if (explotionNew == null) { // Debug.LogError("No hay explosion"); return; } explotionNew.GetComponent <FXExplotion>()._scale = force; if (explotionNew) { explotionNew.Restart(newPos); } if (_explotionEffect != "") { SceneObject explpotionEffect = ObjectPool.instance.GetObjectForType(_explotionEffect, true); if (explpotionEffect) { explpotionEffect.Restart(newPos); ParticlesSceneObject ps = explpotionEffect.GetComponent <ParticlesSceneObject>(); if (ps != null) { ps.SetColor(color); } } } if ((Data.Instance.playMode == Data.PlayModes.STORY && Data.Instance.missions.MissionActiveID < 7) || !powerupsManager.CanBeThrown() || Random.Range(0, 100) > 50 || charactersManager.getDistance() < 300 ) { AddHeartsByBreaking(position, 12, 450); } else { Data.Instance.events.OnAddPowerUp(position); } }
public void SetPanel(ITouchable objectInfo) { gameObject.SetActive(true); upgrade.interactable = true; slideAnim.Play(); sell.onClick.RemoveAllListeners(); lastTouched = (SceneObject)objectInfo; if (lastTouched.GetComponent <IUpgradable>() == null || lastTouched.lvl > 2) { upgrade.interactable = false; } objectInfo.TouchObject(GetComponent <HelpPanel>()); sell.onClick.AddListener(lastTouched.ConfirmSale); }
private void CreateSceneObject(Transform parent, RectTransform guiObject) { SceneObject = UnityEngine.Object.Instantiate(bData.prefab).gameObject; Vector3 wPos = Vector3.zero; if (guiObject != null) { wPos = guiObject.transform.position; //Coordinats.CanvasToWorld(guiObject.gameObject); } SceneObject.transform.position = wPos; SceneObject.transform.parent = parent; SpriteRenderer sr = SceneObject.GetOrAddComponent <SpriteRenderer>(); SceneObject.GetComponent <BoosterFunc>().SetToFront(false); }
private void OnReset() { camera = SceneObject.GetComponent <Camera>(); moveForwardBtn = new VirtualButton(MoveForwardBinding); moveLeftBtn = new VirtualButton(MoveLeftBinding); moveRightBtn = new VirtualButton(MoveRightBinding); moveBackwardBtn = new VirtualButton(MoveBackBinding); moveUpBtn = new VirtualButton(MoveUpBinding); moveDownBtn = new VirtualButton(MoveDownBinding); fastMoveBtn = new VirtualButton(FastMoveBinding); activeBtn = new VirtualButton(RotateBinding); panBtn = new VirtualButton(PanBinding); horizontalAxis = new VirtualAxis(HorizontalAxisBinding); verticalAxis = new VirtualAxis(VerticalAxisBinding); scrollAxis = new VirtualAxis(ScrollAxisBinding); }
private void GenerateHexaGrid() { SceneObject cache = null; var waterMaterial = _gridPrefab.Renderer.Material; var groundMaterial = new StandardMaterial(Scene.current); groundMaterial.Texture = Application.Content.Load <Texture2D>("Models/hexagone_green"); var montainMaterial = new StandardMaterial(Scene.current); montainMaterial.Texture = Application.Content.Load <Texture2D>("Models/hexagone_brown"); montainMaterial.DiffuseColor = Color.Red; int rand = 0; ModelRenderer mRenderer = null; for (int z = 0; z < GridDepth; z++) { for (int x = 0; x < GridWidth; x++) { rand = RandomHelper.Range(0, 10); cache = Scene.Instanciate(_gridPrefab); cache.Transform.Position = GetWorldCoordinate(x, z); cache.Transform.Parent = transform; mRenderer = cache.GetComponent <ModelRenderer>(); if (rand % 2 == 0) { mRenderer.Material = groundMaterial; cache.Transform.LocalScale += new Vector3(0, 0.5f, 0); } else if (rand % 5 == 0) { mRenderer.Material = montainMaterial; cache.Transform.LocalScale += new Vector3(0.0f, 1.5f, 0.0f); } cache.Transform.SetPosition(null, _gridPrefab.Renderer.BoundingSphere.Radius * cache.Transform.LocalScale.Y / 2, null); } } }
public void AddBorder(Transform t, bool front, bool back, bool right, bool left) { SceneObject sceneObject = Instantiate(Border_videogame_1) as SceneObject; sceneObject.transform.parent = Pool.Scene.transform; sceneObject.transform.rotation = t.transform.rotation; sceneObject.Restart(t.transform.position); BordersManager bordersManager = sceneObject.GetComponent <BordersManager> (); if (front) { foreach (WeakPlatform wp in bordersManager.front.GetComponentsInChildren <WeakPlatform>()) { wp.OnRestart(wp.transform.position); wp.transform.SetParent(sceneObject.transform.parent); } } if (back) { foreach (WeakPlatform wp in bordersManager.back.GetComponentsInChildren <WeakPlatform>()) { wp.OnRestart(wp.transform.position); wp.transform.SetParent(sceneObject.transform.parent); } } if (right) { foreach (WeakPlatform wp in bordersManager.right.GetComponentsInChildren <WeakPlatform>()) { wp.OnRestart(wp.transform.position); wp.transform.SetParent(sceneObject.transform.parent); } } if (left) { foreach (WeakPlatform wp in bordersManager.left.GetComponentsInChildren <WeakPlatform>()) { wp.OnRestart(wp.transform.position); wp.transform.SetParent(sceneObject.transform.parent); } } sceneObject.Pool(); }
protected override void OnStart() { base.OnStart(); _collider = this.SceneObject.AddComponent <SphereCollider>(); _collider.Radius = 0.1f; _pickerRenderer = this.SceneObject.AddComponent <MeshRenderable>(); _pickerRenderer.Mesh = Icosahedron.Create(0.02f, 1); _pickerRenderer.IsEnabled = false; _pickerRenderer.Material = new Material(MaterialType.FlatColor); _pickerRenderer.Material.Color = new Vector4(1, 1, 0, 1); _pickerRenderer.IsRaytracable = false; _selector = SceneObject.GetComponent <ObjectSelector>(); if (_selector != null) { _selector.Selected += ObjectSelected; } }
public void OnScoreOn(int playerID, Vector3 position, int score, ScoresManager.types type) { if ( type == ScoresManager.types.DESTROY_FLOOR || type == ScoresManager.types.DESTROY_WALL || type == ScoresManager.types.KILL || type == ScoresManager.types.BREAKING ) { if (position == Vector3.zero) { return; } SceneObject newSO = Instantiate(scoreSignal, position, Quaternion.identity) as SceneObject; Game.Instance.sceneObjectsManager.AddSceneObject(newSO, position); newSO.GetComponent <ScoreSignal> ().SetScore(playerID, score); } }
/// <summary> /// Checks if the currently selected object has changed, and rebuilds the GUI and loads the animation clip if needed. /// </summary> /// <param name="force">If true the GUI rebuild and animation clip load will be forced regardless if the active /// scene object changed.</param> private void UpdateSelectedSO(bool force) { SceneObject so = Selection.SceneObject; if (selectedSO != so || force) { if (selectedSO != null && so == null) { EditorInput.OnPointerPressed -= OnPointerPressed; EditorInput.OnPointerMoved -= OnPointerMoved; EditorInput.OnPointerReleased -= OnPointerReleased; EditorInput.OnButtonUp -= OnButtonUp; } else if (selectedSO == null && so != null) { EditorInput.OnPointerPressed += OnPointerPressed; EditorInput.OnPointerMoved += OnPointerMoved; EditorInput.OnPointerReleased += OnPointerReleased; EditorInput.OnButtonUp += OnButtonUp; } SwitchState(State.Empty); selectedSO = so; zoomAmount = 0.0f; selectedFields.Clear(); clipInfo = null; UndoRedo.Clear(); RebuildGUI(); // Load existing clip if one exists if (selectedSO != null) { Animation animation = selectedSO.GetComponent<Animation>(); if (animation != null) { AnimationClip clip = animation.DefaultClip; if (clip != null) LoadAnimClip(clip); } } if(clipInfo == null) clipInfo = new EditorAnimClipInfo(); SwitchState(State.Normal); currentClipState = CreateClipState(); if (selectedSO != null) { // Select first curve by default foreach (var KVP in clipInfo.curves) { SelectField(KVP.Key, false); break; } UpdateDisplayedCurves(true); } } }