private void OnParticleCollision(GameObject other) { ParticlePhysicsExtensions.GetCollisionEvents(splatParticles, other, collisionEvents); int count = collisionEvents.Count; //Debug.Log("---------------- PARTICLE COLLISIONS " + count); for (int i = 0; i < count; i++) { float create = Random.Range(0f, 100f); if (create < 50f) { //Debug.Log("Skip splat -----------------------------------------"); return; } List <PooledObject> activeObjects = GameManager.Instance.objectPools.GetActiveObjectsWithinArea(collisionEvents[i].intersection, 0.5f); //Debug.Log(activeObjects.Count + " found nearby"); if (activeObjects.Count > 75) { return; } ObjectPoolManager.PoolRequestInfo info = ObjectPoolManager.CreatePoolInfo( poolType, GameManager.Instance.splatHolder, collisionEvents[i].intersection, null, true, false ); PooledObject pooledSplat = GameManager.GetPooledObject(info); if (pooledSplat == null) { //Debug.LogError("Out of Splats"); return; } Splat splat = pooledSplat as Splat; splat.SetSplatVisualLayer(Splat.SplatLoacation.Foreground); //GameObject splat = Instantiate(splatPrefab, collisionEvents[i].intersection, Quaternion.identity) as GameObject; //splat.transform.SetParent(GameManager.Instance.splatHolder, true); //Splat splatScript = splat.GetComponent<Splat>(); //splatScript.Initialize(Splat.SplatLoacation.Foreground); //Debug.Log("Creations : " + GameManager.splatCreations + " ---------------------------------------"); } }
public void CastSplat(Vector3 position) { Ray ray = Camera.main.ScreenPointToRay(transform.position); RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity, layerMask); if (hit.collider != null) { GameObject splat = Instantiate(splatPrefab, position, Quaternion.identity) as GameObject; splat.transform.SetParent(splatHolder, true); Splat splatScript = splat.GetComponent <Splat>(); ParticleSystem particle = Instantiate(splatParticles, position, Quaternion.identity); //particle.Play(); Debug.DrawRay(position, hit.point, Color.red, 5f); if (hit.collider.gameObject.tag == "Background") { splatScript.Initialize(Splat.SplatLocation.Background); } else { splatScript.Initialize(Splat.SplatLocation.Foreground); } } Destroy(gameObject, 5f); }
public Texture Bake(LODTerrainData terrainData, int size = 2048) { this.size = size; this.CreateObjects(); this.UpdateCameraModes(); SplatsNormalmap.quads[this.key].SetActive(true); this.rttCamera.gameObject.SetActive(true); this.rttCamera.enabled = true; TerrainConfig terrainConfig = GameScene.mainScene.terrainConfig; this.sntMat.SetTexture("_Control", terrainData.splatsmapTex); for (int i = 0; i < terrainData.spaltsmapLayers; i++) { Splat splat = terrainData.splats[i]; if (splat != null) { this.sntMat.SetTexture("_Splat" + i, splat.normalMap); this.sntMat.SetTextureScale("_Splat" + i, new Vector2(splat.tilingOffset.x, splat.tilingOffset.y)); this.sntMat.SetTextureOffset("_Splat" + i, Vector2.zero); } else { splat = terrainData.splats[0]; this.sntMat.SetTexture("_Splat" + i, terrainConfig.baseSplat.normalMap); this.sntMat.SetTextureScale("_Splat" + i, new Vector2(splat.tilingOffset.x, splat.tilingOffset.y)); this.sntMat.SetTextureOffset("_Splat" + i, Vector2.zero); } } this.rttCamera.targetTexture = this.rtt; RenderTexture.active = this.rtt; this.tex.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0); this.tex.Apply(); return(this.tex); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); w = GraphicsDevice.Viewport.Bounds.Width; h = GraphicsDevice.Viewport.Bounds.Height; data = new uint[w * h]; sw = GraphicsDevice.Viewport.Bounds.Width; sh = GraphicsDevice.Viewport.Bounds.Height; // texture = new Texture2D(GraphicsDevice, w, h); textureFade = new Texture2D(GraphicsDevice, 1, 1); textureFade.SetData(new uint[] { 0x0f000000 }); textureWhite = new Texture2D(GraphicsDevice, 1, 1); textureWhite.SetData(new uint[] { 0xFFFFFFFF }); // Setup our BasicEffect for drawing the quad worldMatrix = Matrix.CreateScale(w / (float)h, 1, 1); display = Content.Load <Effect>("basic"); depthEffect = Content.Load <Effect>("depth"); Matrix projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); display.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection); depthEffect.Parameters["MatrixTransform"].SetValue(halfPixelOffset * projection); // Create a vertex declaration vertexDeclaration = new VertexDeclaration( new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) }); velocity = new RenderTargetDouble(GraphicsDevice, w, h); density = new RenderTargetDouble(GraphicsDevice, w, h); velocityDivergence = new RenderTargetDouble(GraphicsDevice, w, h); velocityVorticity = new RenderTargetDouble(GraphicsDevice, w, h); pressure = new RenderTargetDouble(GraphicsDevice, w, h); advect = new Advect(w, h, timestep, Content); boundary = new Boundary(w, h, Content); diffuse = new Jacobi(Content.Load <Effect>("jacobivector"), w, h); divergence = new Divergence(w, h, Content); poissonPressureEq = new Jacobi(Content.Load <Effect>("jacobiscalar"), w, h); gradient = new Gradient(w, h, Content); splat = new Splat(w, h, Content); vorticity = new Vorticity(w, h, Content); vorticityConfinement = new VorticityConfinement(Content.Load <Effect>("vorticityforce"), w, h, timestep); // this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); this.depthFrameReader = this.kinectSensor.DepthFrameSource.OpenReader(); this.kinectSensor.Open(); // this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived; this.depthFrameReader.FrameArrived += DepthFrameReader_FrameArrived; }
public void CmdSplatCommand(Splat newSplat) { if (!ValidateSplat(newSplat)) { return; } SplatManagerSystem.instance.AddSplat(newSplat); RpcAddSplat(newSplat); }
private void CastRay() { GameObject splat = Instantiate(splatPrefab, player.transform.position, Quaternion.identity); splat.transform.SetParent(splatHolder, true); Splat splatScript = splat.GetComponent <Splat>(); splatParticles.transform.position = player.transform.position; splatParticles.Play(); splatScript.Initialized(Splat.SplatLocation.Background); }
public void SlingProjectile(GameObject projectile) { if (projectile == null) { curProjectile = null; return; } curProjectile = projectile.GetComponent <Splat> (); lr.material = curProjectile.slingMat; audio.PlayOneShot(stretch); }
void SplatOnTheWall(Vector2 pos) { GameObject splat = Instantiate(splatPrefab, pos, Quaternion.identity); if (splatHolder != null) { splat.transform.SetParent(splatHolder); } Splat splatScript = splat.GetComponent <Splat>(); splatScript.CreateSplat(Splat.SplatLocation.Background); }
public void AddSplat(int id, Splat splat) { // Debug.Log ("Adding Splat::"+ id + " ,Splat::"+ splat.splatMatrix + ",scaleBias::" + splat.scaleBias ); if (m_SplatDict.ContainsKey(id)) { m_SplatDict[id].Add(splat); } else { m_SplatDict.Add(id, new List <Splat>()); m_SplatDict[id].Add(splat); } }
private void OnParticleCollision(GameObject other) { ParticlePhysicsExtensions.GetCollisionEvents(splatParticles, other, collisionEvents); int count = collisionEvents.Count; for (int i = 0; i < count; i++) { GameObject splat = Instantiate(splatPrefab, collisionEvents[i].intersection, Quaternion.identity) as GameObject; //splat.transform.SetParent(splatHolder, true); Splat splatScript = splat.GetComponent <Splat>(); splatScript.Initialized(Splat.SplatLocation.Foreground); } }
public virtual void RecieveDamage(HitInfo hitInfo) { Splat.Create(3, this.transform.position); hitSource.Play(); Health -= hitInfo.damage; if (Health <= 0 && !dead) { StartCoroutine(Die()); } }
public void Write(string message, Splat.LogLevel logLevel) { lock (_mutex) { using (var stream = new FileStream(_path, FileMode.Open, System.Security.AccessControl.FileSystemRights.AppendData, FileShare.Write, 4096, FileOptions.None)) using (var writer = new StreamWriter(stream)) { writer.WriteLine("{0}: {1}", logLevel.ToString().ToUpperInvariant(), message); writer.Flush(); } } }
public void TrySplat(Splat newSplat) { if (!isServer) { CmdSplatCommand(newSplat); } else { if (!ValidateSplat(newSplat)) { return; } RpcAddSplat(newSplat); } }
/// <summary> /// 根据水体数据创建水体相关使用材质,这里似乎只有光照贴图材质??? 跟水体要毛关系啊?????? /// </summary> /// <param name="waterData"></param> public void BuildMaterial(WaterData waterData = null) { if (LightmapSettings.lightmaps.Length > 0 || GameScene.isPlaying) //有光照贴图 { if (!this.terrainConfig.enablePointLight) { this.matrial = new Material(this.terrainMobileShader); } else { this.matrial = new Material(this.terrainMobileWithPointLightShader); } } else //否则启用实时光照??? { this.matrial = new Material(this.realLightShader); } Texture2D texture; if (GameScene.isPlaying) { texture = AssetLibrary.Load(this.splatsMapPath, AssetType.Texture2D, LoadType.Type_Auto).texture2D; } else { texture = this.terrainData.splatsmapTex; } this.matrial.SetTexture("_Control", texture); for (int i = 0; i < this.terrainData.spaltsmapLayers; i++) //如果有splatmap,则添加 { Splat splat = this.terrainData.splats[i]; if (splat != null) { this.matrial.SetTexture("_Splat" + i, splat.texture); this.matrial.SetTextureScale("_Splat" + i, new Vector2(splat.tilingOffset.x, splat.tilingOffset.y)); this.matrial.SetTextureOffset("_Splat" + i, Vector2.zero); } else { splat = this.terrainData.splats[0]; this.matrial.SetTexture("_Splat" + i, this.terrainConfig.baseSplat.texture); this.matrial.SetTextureScale("_Splat" + i, new Vector2(splat.tilingOffset.x, splat.tilingOffset.y)); this.matrial.SetTextureOffset("_Splat" + i, Vector2.zero); } } base.renderer.material = this.matrial; //给渲染器赋予材质 }
private void OnParticleCollision(GameObject other) { ParticlePhysicsExtensions.GetCollisionEvents(splatSystem, other, collisionEvents); for (int i = 0; i < collisionEvents.Count; i++) { Vector2 pos = collisionEvents[i].intersection; GameObject splat = Instantiate(splatPrefab, new Vector2(pos.x, pos.y - Random.Range(0.0f, 0.5f)), Quaternion.identity); if (splatHolder != null) { splat.transform.SetParent(splatHolder); } Splat splatScript = splat.GetComponent <Splat>(); splatScript.CreateSplat(Splat.SplatLocation.Foreground); } }
private void Update() { if (Input.GetMouseButton(0)) { RaycastHit hitInfo; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo)) { if (hitInfo.collider != null) { Splat s = hitInfo.collider.GetComponent <Splat>(); if (s != null) { //Debug.Log(hitInfo.textureCoord); s.SplatInk(hitInfo.textureCoord, splatTexture, splatColor); } } } } }
public void Save(ref WorldSerialization blob) { if (!HasValidTerrain()) { return; } blob.world.size = (uint)Terrain.terrainData.size.x; byte[] byteArray = ArrayUtils.FloatToByteArray(Terrain.terrainData.GetHeights(0, 0, Terrain.terrainData.heightmapWidth, Terrain.terrainData.heightmapHeight)); blob.AddMap("terrain", byteArray); blob.AddMap("height", byteArray); blob.AddMap("water", Water.GetBytes()); blob.AddMap("splat", Splat.GetBytes()); blob.AddMap("alpha", Alpha.GetBytes()); blob.AddMap("biome", Biome.GetBytes()); blob.AddMap("topology", Topology.GetBytes()); }
// Use this for initialization void Awake() { GameObject splatTest = new GameObject("splatTest"); Splat splt = splatTest.AddComponent <Splat>(); instance = this; GameObject[] tempBlocks = GameObject.FindGameObjectsWithTag("Walkable"); GameObject[] tempPass = GameObject.FindGameObjectsWithTag("PassThrough"); blocks = new GameObject[tempBlocks.Length + tempPass.Length]; List <GameObject> listTempBlocks = new List <GameObject>(); List <GameObject> toBeRemoved = new List <GameObject>(); for (int i = 0; i < tempBlocks.Length; i++) { listTempBlocks.Add(tempBlocks[i]); if (tempBlocks[i].name.Contains("ItemBlock") || tempBlocks[i].transform.position.y > 2.0f) { toBeRemoved.Add(tempBlocks[i]); } } for (int i = 0; i < tempPass.Length; i++) { listTempBlocks.Add(tempPass[i]); } for (int i = listTempBlocks.Count - 1; i >= 0; i--) { if (listTempBlocks.Find(x => Mathf.Abs(x.transform.position.x - listTempBlocks[i].transform.position.x) < 0.1f && x.transform.position.y > listTempBlocks[i].transform.position.y && x.transform.position.y - listTempBlocks[i].transform.position.y < 0.5f) != null) { toBeRemoved.Add(listTempBlocks[i]); } } for (int i = toBeRemoved.Count - 1; i >= 0; i--) { //if(toBeRemoved[i] != null) // toBeRemoved[i].transform.position = new Vector2(999, 999); //to visually show which blocks cannot be spawned on listTempBlocks.Remove(toBeRemoved[i]); } blocks = listTempBlocks.ToArray(); NetworkBase b = new NetworkBase(new System.Net.Sockets.UdpClient()); }
IEnumerator Die() { dead = true; agent.Stop(); GetComponent <Rigidbody2D>().velocity = Vector2.zero; GetComponent <Rigidbody2D>().angularVelocity = 0; GetComponent <Collider2D>().enabled = false; animator.SetTrigger("die"); SpeechBubble.Create(GameManager.instance.GetRandomDeathText(), this.gameObject); // Squeeel yield return(deathDelay); deadSource.Play(); Splat.Create(10, this.transform.position, 75f); this.enabled = false; }
void Start() { instance = this; LoadSprites(); transform.localPosition = new Vector2(-3.36f, -0.16f); _spriteRenderer = gameObject.AddComponent <SpriteRenderer>(); _bakeTexture = new Texture2D(_bakeTextureWidth, _bakeTextureHeight); Color[] pixels = _bakeTexture.GetPixels(); Color fillColor = new Color(0, 0, 0, 0.01f); for (int i = 0; i < pixels.Length; i++) { pixels[i] = fillColor; } _bakeTexture.SetPixels(pixels); _bakeTexture.Apply(); //_spriteRenderer.sprite.texture = _bakeTexture; _spriteRenderer.sprite = Sprite.Create(_bakeTexture, new Rect(Vector2.zero, new Vector2(_bakeTextureWidth, _bakeTextureHeight)), Vector2.zero, 50); _bakeTexture = _spriteRenderer.sprite.texture; }
public void Refresh() { splat.Clear(); splat = new Splat(this); KPrefabID component = GetComponent <KPrefabID>(); bool flag = component.HasTag(RoomConstraints.ConstraintTags.Decor20); bool flag2 = decor.GetTotalValue() >= 20f; if (flag != flag2) { if (flag2) { component.AddTag(RoomConstraints.ConstraintTags.Decor20, false); } else { component.RemoveTag(RoomConstraints.ConstraintTags.Decor20); } Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(this), true); } }
protected void StoreCurrentAlphaMaps() { switch (PaintMode) { case PaintType.Splat: Splat.UpdateFromTerrain(Terrain); break; case PaintType.Biome: Biome.UpdateFromTerrain(Terrain); break; case PaintType.Alpha: Alpha.UpdateFromTerrain(Terrain); break; case PaintType.Topology: Topology.UpdateFromTerrain(SelectedTopology, Terrain); return; } }
private static NLog.LogLevel NLogLogLevelToSplatLogLevel(Splat.LogLevel logLevel) { switch (logLevel) { case LogLevel.Debug: return NLog.LogLevel.Debug; case LogLevel.Error: return NLog.LogLevel.Error; case LogLevel.Fatal: return NLog.LogLevel.Fatal; case LogLevel.Info: return NLog.LogLevel.Info; case LogLevel.Warn: return NLog.LogLevel.Warn; } throw new NotImplementedException("LogLevel isn't implemented"); }
private static NLog.LogLevel NLogLogLevelToSplatLogLevel(Splat.LogLevel logLevel) { switch (logLevel) { case LogLevel.Debug: return NLog.LogLevel.Debug; case LogLevel.Info: return NLog.LogLevel.Info; case LogLevel.Warn: return NLog.LogLevel.Warn; case LogLevel.Error: return NLog.LogLevel.Error; case LogLevel.Fatal: return NLog.LogLevel.Fatal; default: throw new ArgumentOutOfRangeException("logLevel", logLevel, "This Splat.LogLevel isn't implemented!"); } }
IEnumerator Die() { dead = true; deadSource.Play(); GetComponent <Rigidbody2D>().velocity = Vector2.zero; GetComponent <Rigidbody2D>().angularVelocity = 0; animator.SetTrigger("die"); CameraManager.instance.Zoom(3); // Squeeel yield return(deathDelay); Splat.Create(10, this.transform.position, 75f); yield return(deathDelay); // restart SceneManager.LoadScene("DeathScene"); }
public bool ValidateSplat(Splat newSplat) { Debug.Log("Seeing if peeing?"); foreach (Splatter s in splatters.Keys) { if (newSplat.channelMask != SplatChannel.MAN && s.channelMask == newSplat.channelMask) { Drinker d = s.gameObject.GetComponent <Drinker> (); Debug.Log("Found me to pee"); if (!d.CanPee()) { Debug.Log("Can't pee"); return(false); } else { Debug.Log("Peeing"); d.Pee(); } } else if (newSplat.channelMask == SplatChannel.MAN && s.channelMask == newSplat.channelMask) { Grabber g = s.gameObject.GetComponent <Grabber> (); if (g.hasMop) { Debug.Log("Man is splatting"); return(true); } else { Debug.Log("Man is not splatting"); return(false); } } } return(true); }
public void Write(string message, Splat.LogLevel logLevel) { switch (logLevel) { case Splat.LogLevel.Debug: _Logger.Debug(message); break; case Splat.LogLevel.Error: _Logger.Error(message); break; case Splat.LogLevel.Fatal: _Logger.Fatal(message); break; case Splat.LogLevel.Info: _Logger.Information(message); break; case Splat.LogLevel.Warn: _Logger.Warning(message); break; default: _Logger.Information(message); break; } }
public void RpcAddSplat(Splat s) { SplatManagerSystem.instance.AddSplat(s); }
public void PaintSplatsmap(LODTerrain terrain, Vector3 worldPos, Splat splat, int insertIndex = -1) { this.terrain = terrain; int num = -1; for (int i = 0; i < this.terrain.terrainData.splats.Length; i++) { if (this.terrain.terrainData.splats[i] == null) { this.terrain.terrainData.splats[i] = splat; num = i; break; } if (this.terrain.terrainData.splats[i].key == splat.key) { this.terrain.terrainData.splats[i] = splat; num = i; break; } } if (num < 0 && insertIndex >= 0) { if (insertIndex > this.terrain.terrainData.splats.Length - 1) { insertIndex = this.terrain.terrainData.splats.Length - 1; } this.terrain.terrainData.splats[insertIndex] = splat; } if (num < 0) { return; } if (num < this.terrain.terrainData.spaltsmapLayers) { int num2 = (int)(terrain.transform.position.x - worldPos.x) + 16; int num3 = (int)(terrain.transform.position.z - worldPos.z) + 16; int num4 = this.size / 2; float[,,] splatsmap = this.terrain.terrainData.splatsmap; for (int j = 0; j < 32; j++) { for (int k = 0; k < 32; k++) { int num5 = num2 - (31 - k) + num4; int num6 = num3 - j + num4; if (num5 >= 0 && num5 < this.size) { if (num6 >= 0 && num6 < this.size) { float num7 = this.GetStrength(num5, num6); float num8 = this.ApplyBrush(splatsmap[j, k, num], num7 * this.strengthen); splatsmap[j, k, num] = num8; this.Normalize(k, j, num, splatsmap); } } } } this.terrain.terrainData.SetSplasmap(0, 0, splatsmap); } else { LogSystem.Log(new object[] { "超出纹理层级。" }); } }
// Use this for initialization void Start() { eg = GameObject.Find("EnemySpawner").GetComponent <EnemyGenerator>(); s = GameObject.Find("score").GetComponent <Score>(); spl = GameObject.Find("splatter").GetComponent <Splat>(); }
/// <summary> /// Position of Current Spell Indicator or Mouse Ray if unavailable /// </summary> public Vector3 GetSpellCursorPosition() { return(CurrentSpellIndicator != null ? CurrentSpellIndicator.transform.position : Splat.Get3DMousePosition()); }
public void Write(string message, Splat.LogLevel logLevel) { if (logLevel < Level) { return; } lock (gate) inner.WriteLine(message); }
public void AddSplat(Splat splat) { //Debug.Log ("Adding Splat"); m_Splats.Add(splat); }
void Start() { splat = GetComponent <Splat>(); }
public void AddSplat(Splat splat) { m_Splats.Add(splat); }