111
This commit is contained in:
338
Assets/ThirdParty/BruteForce/Scripts/BF_AddSnow.cs
vendored
Normal file
338
Assets/ThirdParty/BruteForce/Scripts/BF_AddSnow.cs
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class BF_AddSnow : MonoBehaviour
|
||||
{
|
||||
public Material snowMaterial;
|
||||
public float angle = 80f;
|
||||
public bool isAuto = false;
|
||||
public float intersectionOffset = 0.25f;
|
||||
public bool useIntersection = false;
|
||||
public bool useUpdatedRotation = false;
|
||||
|
||||
private Mesh originalMesh;
|
||||
private MeshFilter meshFilter;
|
||||
private Mesh newMesh;
|
||||
private GameObject newGO;
|
||||
private float yIntersection = 0f;
|
||||
private Quaternion ySlope = Quaternion.identity;
|
||||
private float zNormal = 0;
|
||||
private Vector3 normalHit = Vector3.zero;
|
||||
private float oldyIntersection = -1f;
|
||||
|
||||
private int[] oldTri;
|
||||
private Vector3[] oldVert;
|
||||
private Vector3[] oldNorm;
|
||||
private Vector3[] oldNormWorld;
|
||||
private Vector2[] oldUV;
|
||||
private Color[] oldCol;
|
||||
|
||||
private List<int> triangles = new List<int>();
|
||||
private List<Vector3> vertexs = new List<Vector3>();
|
||||
private List<Vector2> uvs = new List<Vector2>();
|
||||
private List<Color> cols = new List<Color>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
CheckValues();
|
||||
BuildInitialGeometry();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (useIntersection)
|
||||
{
|
||||
CheckIntersection();
|
||||
}
|
||||
|
||||
if (useUpdatedRotation)
|
||||
{
|
||||
UpdateVertexColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CheckValues()
|
||||
{
|
||||
meshFilter = gameObject.GetComponent<MeshFilter>();
|
||||
originalMesh = meshFilter.mesh;
|
||||
oldTri = originalMesh.triangles;
|
||||
oldVert = originalMesh.vertices;
|
||||
oldNorm = originalMesh.normals;
|
||||
oldNormWorld = oldNorm;
|
||||
|
||||
if (isAuto)
|
||||
{
|
||||
int k = 0;
|
||||
foreach (Vector3 norm in oldNorm)
|
||||
{
|
||||
oldNormWorld[k] = this.transform.localToWorldMatrix.MultiplyVector(norm).normalized;
|
||||
k++;
|
||||
}
|
||||
oldCol = new Color[oldVert.Length];
|
||||
}
|
||||
else
|
||||
{
|
||||
oldCol = originalMesh.colors;
|
||||
}
|
||||
oldUV = originalMesh.uv;
|
||||
}
|
||||
|
||||
private void CheckIntersection()
|
||||
{
|
||||
int layerMask = 1 << 0 | 1 << 4;
|
||||
RaycastHit hit;
|
||||
RaycastHit hitIfHit;
|
||||
|
||||
if (Physics.Raycast(transform.position + Vector3.up*5f, Vector3.down, out hit, 200, layerMask))
|
||||
{
|
||||
if (hit.transform != this.transform)
|
||||
{
|
||||
yIntersection = hit.point.y + intersectionOffset;
|
||||
//Vector3 tangent = Vector3.ProjectOnPlane(Vector3.down, hit.normal).normalized;
|
||||
|
||||
ySlope = Quaternion.LookRotation(hit.normal, Vector3.forward);
|
||||
|
||||
zNormal = ((hit.normal.normalized.z) + 1f) / 2f;
|
||||
normalHit = hit.normal.normalized;
|
||||
|
||||
if (yIntersection != oldyIntersection)
|
||||
{
|
||||
UpdateSlopeColor();
|
||||
}
|
||||
oldyIntersection = yIntersection;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Physics.Raycast(hit.point + Vector3.up * -0.05f, Vector3.down, out hitIfHit, 200, layerMask))
|
||||
{
|
||||
if (hitIfHit.transform != this.transform)
|
||||
{
|
||||
yIntersection = hitIfHit.point.y + intersectionOffset;
|
||||
//Vector3 tangent = Vector3.ProjectOnPlane(Vector3.down, hitIfHit.normal).normalized;
|
||||
|
||||
ySlope = Quaternion.LookRotation(hitIfHit.normal, Vector3.forward);
|
||||
zNormal = ((hitIfHit.normal.normalized.z) + 1f) / 2f;
|
||||
normalHit = hitIfHit.normal.normalized;
|
||||
|
||||
if (yIntersection != oldyIntersection)
|
||||
{
|
||||
UpdateSlopeColor();
|
||||
}
|
||||
oldyIntersection = yIntersection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearGeometry()
|
||||
{
|
||||
triangles.Clear();
|
||||
triangles.TrimExcess();
|
||||
vertexs.Clear();
|
||||
vertexs.TrimExcess();
|
||||
uvs.Clear();
|
||||
uvs.TrimExcess();
|
||||
cols.Clear();
|
||||
cols.TrimExcess();
|
||||
}
|
||||
|
||||
private void BuildInitialGeometry()
|
||||
{
|
||||
if (meshFilter == null)
|
||||
{
|
||||
meshFilter = gameObject.GetComponent<MeshFilter>();
|
||||
}
|
||||
newMesh = new Mesh();
|
||||
newGO = new GameObject();
|
||||
MeshFilter mF = newGO.AddComponent<MeshFilter>();
|
||||
MeshRenderer mR = newGO.AddComponent<MeshRenderer>();
|
||||
mF.mesh = newMesh;
|
||||
mR.material = snowMaterial;
|
||||
|
||||
snowMaterial.SetFloat("_ISADD", 1);
|
||||
snowMaterial.EnableKeyword("IS_ADD");
|
||||
if (useIntersection)
|
||||
{
|
||||
if (snowMaterial.GetFloat("_USEINTER") == 0)
|
||||
{
|
||||
snowMaterial.SetFloat("_USEINTER", 1);
|
||||
snowMaterial.EnableKeyword("USE_INTER");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snowMaterial.GetFloat("_USEINTER") == 1)
|
||||
{
|
||||
snowMaterial.SetFloat("_USEINTER", 0);
|
||||
snowMaterial.DisableKeyword("USE_INTER");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
newGO.transform.parent = this.transform;
|
||||
newGO.transform.localPosition = Vector3.zero;
|
||||
newGO.transform.localScale = Vector3.one;
|
||||
newGO.transform.localRotation = Quaternion.identity;
|
||||
|
||||
int indexNewV = 0;
|
||||
foreach (Vector3 v in oldVert)
|
||||
{
|
||||
vertexs.Add(v + new Vector3(0,0,0));
|
||||
uvs.Add(oldUV[indexNewV]);
|
||||
|
||||
indexNewV++;
|
||||
}
|
||||
indexNewV = 0;
|
||||
foreach (int innt in oldTri)
|
||||
{
|
||||
triangles.Add(oldTri[indexNewV]);
|
||||
|
||||
indexNewV++;
|
||||
}
|
||||
|
||||
if (isAuto)
|
||||
{
|
||||
int j = 0;
|
||||
foreach (Vector3 norm in oldNormWorld)
|
||||
{
|
||||
if(j>= oldCol.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
oldCol[j] = Color.red;
|
||||
float theAngle = Vector3.Angle(Vector3.up, norm);
|
||||
if (theAngle < (angle+10f))
|
||||
{
|
||||
Color lerpedColor = Color.Lerp(Color.white, Color.red, Mathf.Max(0f,theAngle- angle/2f) / (angle / 2f));
|
||||
oldCol[j] = lerpedColor;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
cols = oldCol.ToList();
|
||||
newMesh.vertices = vertexs.ToArray();
|
||||
newMesh.triangles = triangles.ToArray();
|
||||
newMesh.uv = uvs.ToArray();
|
||||
newMesh.colors = cols.ToArray();
|
||||
|
||||
newMesh.normals = originalMesh.normals;
|
||||
|
||||
RecalculateNormalsSeamless(newMesh);
|
||||
newMesh.RecalculateBounds();
|
||||
newMesh.Optimize();
|
||||
}
|
||||
|
||||
private void UpdateVertexColor()
|
||||
{
|
||||
Color[] updatedColors = newMesh.colors;
|
||||
Vector3[] newNormWorld = newMesh.normals;
|
||||
|
||||
if (isAuto)
|
||||
{
|
||||
int k = 0;
|
||||
foreach (Vector3 norm in newMesh.normals)
|
||||
{
|
||||
newNormWorld[k] = this.transform.localToWorldMatrix.MultiplyVector(norm).normalized;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isAuto)
|
||||
{
|
||||
int j = 0;
|
||||
foreach (Vector3 norm in newNormWorld)
|
||||
{
|
||||
if (j >= updatedColors.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
float theAngle = Vector3.Angle(Vector3.up, norm);
|
||||
if (theAngle < (angle + 10f))
|
||||
{
|
||||
Color lerpedColor = Color.Lerp(new Color(1,1,1, updatedColors[j].a), new Color(1, 0, 0, updatedColors[j].a), Mathf.Max(0f, theAngle - angle / 2f) / (angle / 2f));
|
||||
updatedColors[j].r = lerpedColor.r;
|
||||
updatedColors[j].g = lerpedColor.g;
|
||||
updatedColors[j].b = lerpedColor.b;
|
||||
updatedColors[j].a = lerpedColor.a;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
newMesh.colors = updatedColors;
|
||||
}
|
||||
|
||||
private void UpdateSlopeColor()
|
||||
{
|
||||
// This is not perfect for now but gets the job done... //
|
||||
int j = 0;
|
||||
|
||||
Color[] updatedColors = newMesh.colors;
|
||||
Vector2[] updatedUV4 = new Vector2[updatedColors.Count()];
|
||||
Vector2[] updatedUV5 = new Vector2[updatedColors.Count()];
|
||||
Vector2[] updatedUV6 = new Vector2[updatedColors.Count()];
|
||||
Vector2[] updatedUV7 = new Vector2[updatedColors.Count()];
|
||||
foreach (Color norm in newMesh.colors)
|
||||
{
|
||||
updatedColors[j].a = yIntersection;
|
||||
updatedUV4[j] = new Vector2(normalHit.x, normalHit.y);
|
||||
updatedUV5[j] = new Vector2(zNormal, normalHit.z);
|
||||
updatedUV6[j] = new Vector2(ySlope.x, ySlope.y);
|
||||
updatedUV7[j] = new Vector2(ySlope.z, ySlope.w);
|
||||
j++;
|
||||
}
|
||||
|
||||
newMesh.colors = updatedColors;
|
||||
newMesh.uv4 = updatedUV4;
|
||||
newMesh.uv5 = updatedUV5;
|
||||
newMesh.uv6 = updatedUV6;
|
||||
newMesh.uv7 = updatedUV7;
|
||||
}
|
||||
|
||||
private void RecalculateNormalsSeamless(Mesh mesh)
|
||||
{
|
||||
var trianglesOriginal = mesh.triangles;
|
||||
var triangles = trianglesOriginal.ToArray();
|
||||
|
||||
var vertices = mesh.vertices;
|
||||
|
||||
var mergeIndices = new Dictionary<int, int>();
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vertexHash = vertices[i].GetHashCode();
|
||||
|
||||
if (mergeIndices.TryGetValue(vertexHash, out var index))
|
||||
{
|
||||
for (int j = 0; j < triangles.Length; j++)
|
||||
if (triangles[j] == i)
|
||||
triangles[j] = index;
|
||||
}
|
||||
else
|
||||
mergeIndices.Add(vertexHash, i);
|
||||
}
|
||||
|
||||
mesh.triangles = triangles;
|
||||
|
||||
var normals = new Vector3[vertices.Length];
|
||||
|
||||
mesh.RecalculateNormals();
|
||||
var newNormals = mesh.normals;
|
||||
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
if (mergeIndices.TryGetValue(vertices[i].GetHashCode(), out var index))
|
||||
normals[i] = newNormals[index];
|
||||
|
||||
mesh.triangles = trianglesOriginal;
|
||||
mesh.normals = normals;
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_AddSnow.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_AddSnow.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 384d5b78126338848a3f397c6c80dc55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/ThirdParty/BruteForce/Scripts/BF_FPS.cs
vendored
Normal file
46
Assets/ThirdParty/BruteForce/Scripts/BF_FPS.cs
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class BF_FPS : MonoBehaviour
|
||||
{
|
||||
float deltaTime = 0.0f;
|
||||
|
||||
private GUIStyle style = null;
|
||||
|
||||
private bool ShowFps = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ShowFps = true;
|
||||
style = new GUIStyle();
|
||||
style.alignment = TextAnchor.UpperLeft;
|
||||
style.normal.textColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Alpha2))
|
||||
{
|
||||
ShowFps = !ShowFps;
|
||||
}
|
||||
|
||||
if(ShowFps)
|
||||
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (ShowFps)
|
||||
{
|
||||
int w = Screen.width, h = Screen.height;
|
||||
|
||||
style.fontSize = h * 4 / 100;
|
||||
|
||||
Rect rect = new Rect(0, 0, w, h * 2 / 100);
|
||||
|
||||
float msec = deltaTime * 1000.0f;
|
||||
float fps = 1.0f / deltaTime;
|
||||
GUI.Label(rect, string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps), style);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_FPS.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_FPS.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a87ad753b0ceaed4285ff052cf561fbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
133
Assets/ThirdParty/BruteForce/Scripts/BF_FxMouse.cs
vendored
Normal file
133
Assets/ThirdParty/BruteForce/Scripts/BF_FxMouse.cs
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
public class BF_FxMouse : MonoBehaviour
|
||||
{
|
||||
private Camera mainCam;
|
||||
public ParticleSystem ps;
|
||||
public ParticleSystem psRightClick;
|
||||
public ParticleSystem psMiddleClick;
|
||||
private float raycastSize = 200f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
mainCam = this.GetComponent<Camera>();
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
mainCam = this.GetComponent<Camera>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
|
||||
Debug.DrawRay(this.transform.position, ray.direction);
|
||||
if (Physics.Raycast(ray, out hit, raycastSize))
|
||||
{
|
||||
if (!ps.isEmitting)
|
||||
{
|
||||
ps.Play();
|
||||
}
|
||||
ps.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.Stop();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
|
||||
Debug.DrawRay(this.transform.position, ray.direction);
|
||||
if (Physics.Raycast(ray, out hit, raycastSize))
|
||||
{
|
||||
if (!psRightClick.isEmitting)
|
||||
{
|
||||
psRightClick.Play();
|
||||
}
|
||||
psRightClick.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psRightClick.Stop();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(2))
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
|
||||
Debug.DrawRay(this.transform.position, ray.direction);
|
||||
if (Physics.Raycast(ray, out hit, raycastSize))
|
||||
{
|
||||
if (!psMiddleClick.isEmitting)
|
||||
{
|
||||
psMiddleClick.Play();
|
||||
}
|
||||
psMiddleClick.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psMiddleClick.Stop();
|
||||
}
|
||||
#else
|
||||
if (Mouse.current.leftButton.isPressed)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = mainCam.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||
Debug.DrawRay(this.transform.position, ray.direction);
|
||||
if (Physics.Raycast(ray, out hit, raycastSize))
|
||||
{
|
||||
if (!ps.isEmitting)
|
||||
{
|
||||
ps.Play();
|
||||
}
|
||||
ps.transform.position = hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ps.Stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ps.Stop();
|
||||
}
|
||||
|
||||
if (Mouse.current.rightButton.isPressed)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = mainCam.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||
Debug.DrawRay(this.transform.position, ray.direction);
|
||||
if (Physics.Raycast(ray, out hit, raycastSize))
|
||||
{
|
||||
if (!psRightClick.isEmitting)
|
||||
{
|
||||
psRightClick.Play();
|
||||
}
|
||||
psRightClick.transform.position = hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ps.Stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
psRightClick.Stop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_FxMouse.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_FxMouse.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 417e02b765d08944c98436fe98c91bda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/ThirdParty/BruteForce/Scripts/BF_InputSystemSwitcher.cs
vendored
Normal file
31
Assets/ThirdParty/BruteForce/Scripts/BF_InputSystemSwitcher.cs
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.UI;
|
||||
#endif
|
||||
|
||||
public class BF_InputSystemSwitcher : MonoBehaviour
|
||||
{
|
||||
public GameObject eventS;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (eventS.GetComponent<InputSystemUIInputModule>() == null)
|
||||
{
|
||||
if(eventS.GetComponent<StandaloneInputModule>() != null)
|
||||
{
|
||||
Destroy(eventS.GetComponent<StandaloneInputModule>());
|
||||
}
|
||||
InputSystemUIInputModule inputSystem = eventS.AddComponent<InputSystemUIInputModule>();
|
||||
inputSystem.enabled = false;
|
||||
inputSystem.enabled = true;
|
||||
inputSystem.UpdateModule();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_InputSystemSwitcher.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_InputSystemSwitcher.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04d2879101b9eea479cb0d2f2754514d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffects.cs
vendored
Normal file
74
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffects.cs
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class BF_InteractiveEffects : MonoBehaviour
|
||||
{
|
||||
public Transform transformToFollow;
|
||||
public RenderTexture rt;
|
||||
public string GlobalTexName = "_GlobalEffectRT";
|
||||
public string GlobalOrthoName = "_OrthographicCamSize";
|
||||
public bool isPaced = false;
|
||||
|
||||
private float orthoMem = 0;
|
||||
private Coroutine waitPace;
|
||||
private bool paceRunning = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
orthoMem = GetComponent<Camera>().orthographicSize;
|
||||
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
|
||||
Shader.SetGlobalTexture(GlobalTexName, rt);
|
||||
Shader.SetGlobalFloat("_HasRT", 1);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
orthoMem = GetComponent<Camera>().orthographicSize;
|
||||
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
|
||||
Shader.SetGlobalTexture(GlobalTexName, rt);
|
||||
Shader.SetGlobalFloat("_HasRT", 1);
|
||||
}
|
||||
private void MoveCamera()
|
||||
{
|
||||
if (transformToFollow != null)
|
||||
{
|
||||
transform.position = new Vector3(transformToFollow.position.x, transformToFollow.position.y + 20, transformToFollow.position.z);
|
||||
}
|
||||
Shader.SetGlobalVector("_Position", transform.position);
|
||||
transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0));
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if(isPaced)
|
||||
{
|
||||
if(!paceRunning)
|
||||
{
|
||||
waitPace = StartCoroutine(WaitPace());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (paceRunning)
|
||||
{
|
||||
paceRunning = false;
|
||||
StopCoroutine(WaitPace());
|
||||
}
|
||||
|
||||
MoveCamera();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitPace()
|
||||
{
|
||||
for(; ;)
|
||||
{
|
||||
paceRunning = true;
|
||||
|
||||
MoveCamera();
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffects.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffects.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3213c75ba5401eb42aee936e4b61a69f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffectsAdditional.cs
vendored
Normal file
79
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffectsAdditional.cs
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class BF_InteractiveEffectsAdditional : MonoBehaviour
|
||||
{
|
||||
public Transform mainCamera;
|
||||
public RenderTexture rt;
|
||||
public string GlobalTexName = "_GlobalEffectRTAdditional";
|
||||
public string GlobalOrthoName = "_OrthographicCamSizeAdditional";
|
||||
public bool isPaced = false;
|
||||
|
||||
private float orthoMem = 0;
|
||||
private Vector3 camDir;
|
||||
private Coroutine waitPace;
|
||||
private bool paceRunning = false;
|
||||
private void Awake()
|
||||
{
|
||||
orthoMem = GetComponent<Camera>().orthographicSize;
|
||||
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
|
||||
Shader.SetGlobalTexture(GlobalTexName, rt);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
orthoMem = GetComponent<Camera>().orthographicSize;
|
||||
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
|
||||
Shader.SetGlobalTexture(GlobalTexName, rt);
|
||||
}
|
||||
|
||||
private void MoveCamera()
|
||||
{
|
||||
if (mainCamera != null)
|
||||
{
|
||||
camDir = Vector3.ProjectOnPlane(mainCamera.forward, Vector3.up).normalized;
|
||||
camDir.y = 0f;
|
||||
|
||||
if (mainCamera != null)
|
||||
{
|
||||
float YView = Vector3.Angle(Vector3.down, mainCamera.forward);
|
||||
transform.position = new Vector3(mainCamera.position.x, mainCamera.position.y + 20, mainCamera.position.z) + camDir.normalized * Mathf.Max(0f, orthoMem - 20f) * Mathf.Clamp01(((YView - 35) * 3) / 35);
|
||||
}
|
||||
}
|
||||
Shader.SetGlobalVector("_PositionAdd", transform.position);
|
||||
transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isPaced)
|
||||
{
|
||||
if (!paceRunning)
|
||||
{
|
||||
waitPace = StartCoroutine(WaitPace());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paceRunning)
|
||||
{
|
||||
paceRunning = false;
|
||||
StopCoroutine(WaitPace());
|
||||
}
|
||||
|
||||
MoveCamera();
|
||||
}
|
||||
}
|
||||
private IEnumerator WaitPace()
|
||||
{
|
||||
for (; ; )
|
||||
{
|
||||
paceRunning = true;
|
||||
|
||||
MoveCamera();
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffectsAdditional.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_InteractiveEffectsAdditional.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7329b255050ede64f96bc899973e510f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/ThirdParty/BruteForce/Scripts/BF_LightSwitch.cs
vendored
Normal file
30
Assets/ThirdParty/BruteForce/Scripts/BF_LightSwitch.cs
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BF_LightSwitch : MonoBehaviour
|
||||
{
|
||||
public GameObject lightScene;
|
||||
public Material skyboxScene;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if(lightScene != null)
|
||||
{
|
||||
lightScene.SetActive(true);
|
||||
}
|
||||
if(skyboxScene != null)
|
||||
{
|
||||
RenderSettings.skybox = skyboxScene;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (lightScene != null)
|
||||
{
|
||||
lightScene.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_LightSwitch.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_LightSwitch.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 500e34ee2d18f3c43be45c3ec1c393ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
84
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerMovement.cs
vendored
Normal file
84
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerMovement.cs
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
public class BF_PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public Camera cam;
|
||||
private Rigidbody rb;
|
||||
private Quaternion camRot;
|
||||
private Vector3 moveDirection;
|
||||
private Vector3 inputDirection;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
rb = this.GetComponent<Rigidbody>();
|
||||
if(cam == null)
|
||||
{
|
||||
cam = Camera.main;
|
||||
}
|
||||
} // Start is called before the first frame update
|
||||
void OnEnable()
|
||||
{
|
||||
rb = this.GetComponent<Rigidbody>();
|
||||
if(cam == null)
|
||||
{
|
||||
cam = Camera.main;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
inputDirection = Vector3.zero;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (Keyboard.current.qKey.isPressed || Keyboard.current.aKey.isPressed)
|
||||
{
|
||||
inputDirection += new Vector3(0, 0, 1);
|
||||
}
|
||||
if (Keyboard.current.dKey.isPressed)
|
||||
{
|
||||
inputDirection += new Vector3(0, 0, -1);
|
||||
}
|
||||
if (Keyboard.current.wKey.isPressed || Keyboard.current.zKey.isPressed)
|
||||
{
|
||||
inputDirection += new Vector3(1, 0, 0);
|
||||
}
|
||||
if (Keyboard.current.sKey.isPressed)
|
||||
{
|
||||
inputDirection += new Vector3(-1, 0, 0);
|
||||
}
|
||||
#else
|
||||
if (Input.GetKey(KeyCode.Q)|| Input.GetKey(KeyCode.A))
|
||||
{
|
||||
inputDirection += new Vector3(0, 0, 1);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
{
|
||||
inputDirection += new Vector3(0, 0, -1);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.W))
|
||||
{
|
||||
inputDirection += new Vector3(1, 0, 0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
{
|
||||
inputDirection += new Vector3(-1, 0, 0);
|
||||
}
|
||||
#endif
|
||||
MoveBall();
|
||||
}
|
||||
|
||||
private void MoveBall()
|
||||
{
|
||||
camRot = Quaternion.LookRotation(cam.transform.forward, Vector3.up);
|
||||
moveDirection = camRot * new Vector3(Mathf.Clamp(inputDirection.x * 2, -1, 1), 0, Mathf.Clamp(inputDirection.z * 2, -1, 1));
|
||||
rb.AddTorque(moveDirection*22.5f);
|
||||
rb.AddForce(moveDirection*15f,ForceMode.Force);
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerMovement.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerMovement.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0c540651fd7ade458bcf18adb77a455
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerReset.cs
vendored
Normal file
19
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerReset.cs
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BF_PlayerReset : MonoBehaviour
|
||||
{
|
||||
public GameObject player;
|
||||
public Transform playerPos;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
player.transform.position = playerPos.position;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
player.transform.position = playerPos.position;
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerReset.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerReset.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02f858f19ebff6c469275aa024a241f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
156
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerSnow.cs
vendored
Normal file
156
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerSnow.cs
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BF_PlayerSnow : MonoBehaviour
|
||||
{
|
||||
public Collider playerCollider;
|
||||
public ParticleSystem particleSys;
|
||||
|
||||
public PhysicsMaterial playerMatDefault;
|
||||
public PhysicsMaterial playerMatSnow;
|
||||
public PhysicsMaterial playerMatIce;
|
||||
|
||||
private Rigidbody rB;
|
||||
private float speedMult = 1;
|
||||
private float lerpIce = 0;
|
||||
private MeshCollider oldMC = null;
|
||||
private Mesh mesh = null;
|
||||
private ParticleSystem.MainModule pSMain;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
oldMC = null;
|
||||
mesh = null;
|
||||
rB = this.GetComponent<Rigidbody>();
|
||||
pSMain = particleSys.main;
|
||||
}
|
||||
|
||||
private void CheckIceCols(float snowCol)
|
||||
{
|
||||
lerpIce = snowCol / 255f;
|
||||
|
||||
if (snowCol == -1)
|
||||
{
|
||||
if (playerCollider.material != playerMatDefault)
|
||||
{
|
||||
playerCollider.material = playerMatDefault;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lerpIce <= 0.925f && playerCollider.material != playerMatIce)
|
||||
{
|
||||
playerCollider.material = playerMatIce;
|
||||
rB.angularDamping = 0.25f;
|
||||
}
|
||||
else if(lerpIce >= 0.925f && playerCollider.material != playerMatSnow)
|
||||
{
|
||||
playerCollider.material = playerMatSnow;
|
||||
rB.angularDamping = 5f;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionStay(Collision collision)
|
||||
{
|
||||
if (lerpIce >= 0.925f && collision.collider.gameObject.layer == 4)
|
||||
{
|
||||
AddSnow(1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSnow(0.05f);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if(collision.impulse.magnitude>10)
|
||||
{
|
||||
// RemoveSnow(20);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSnow(float multiplier)
|
||||
{
|
||||
if (playerCollider.transform.localScale.x < 7f)
|
||||
{
|
||||
speedMult = Mathf.Clamp(rB.linearVelocity.magnitude * 0.02f,0,1);
|
||||
playerCollider.transform.localScale += Vector3.zero + Vector3.one * 0.0035f * 2 * multiplier* speedMult;
|
||||
playerCollider.transform.localScale += Vector3.zero + Vector3.one * 0.005f * 2 * multiplier * speedMult;
|
||||
}
|
||||
}
|
||||
private void RemoveSnow(float multiplier)
|
||||
{
|
||||
if (playerCollider.transform.localScale.x >= 1.1f)
|
||||
{
|
||||
if (!playerCollider.transform.gameObject.activeInHierarchy)
|
||||
{
|
||||
// SnowPlayer.gameObject.SetActive(true);
|
||||
}
|
||||
playerCollider.transform.localScale -= Vector3.zero + Vector3.one * 0.0035f * 4 * multiplier;
|
||||
playerCollider.transform.localScale -= Vector3.zero + Vector3.one * 0.005f * 4 * multiplier;
|
||||
}
|
||||
if (playerCollider.transform.localScale.x < 1.1f)
|
||||
{
|
||||
if (playerCollider.transform.gameObject.activeInHierarchy)
|
||||
{
|
||||
// SnowPlayer.gameObject.SetActive(false);
|
||||
}
|
||||
playerCollider.transform.localScale = Vector3.one * 1.1f;
|
||||
playerCollider.transform.localScale = Vector3.one * 1.1f;
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
ChangePlayerMass();
|
||||
CheckSnowUnderneath();
|
||||
}
|
||||
|
||||
private void CheckSnowUnderneath()
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
int layerMask = 1 << 4;
|
||||
if (Physics.Raycast(transform.position+(Vector3.down*(playerCollider.transform.localScale.x/2)+Vector3.up*0.5f), Vector3.down, out hit, 5, layerMask,QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
MeshCollider meshCollider = hit.collider as MeshCollider;
|
||||
if (oldMC != meshCollider || mesh == null)
|
||||
{
|
||||
mesh = meshCollider.GetComponent<MeshFilter>().sharedMesh;
|
||||
}
|
||||
oldMC = meshCollider;
|
||||
if (meshCollider == null || meshCollider.sharedMesh == null)
|
||||
{
|
||||
CheckIceCols(255f);
|
||||
return;
|
||||
}
|
||||
|
||||
//Mesh mesh = meshCollider.sharedMesh;
|
||||
|
||||
int[] triangles = mesh.triangles;
|
||||
Color32[] colorArray;
|
||||
colorArray = mesh.colors32;
|
||||
|
||||
var vertIndex1 = triangles[hit.triangleIndex * 3 + 0];
|
||||
CheckIceCols(((float)colorArray[vertIndex1].g) / 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerCollider.material != playerMatDefault)
|
||||
{
|
||||
playerCollider.material = playerMatDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangePlayerMass()
|
||||
{
|
||||
rB.mass = Mathf.Lerp(1.95f, 2.5f, (playerCollider.transform.localScale.x-1.2f) / 7);
|
||||
pSMain.startSize = playerCollider.transform.localScale.x+0.5f;
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerSnow.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_PlayerSnow.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb1cf2caeea15a641a9b68e147daa302
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/ThirdParty/BruteForce/Scripts/BF_Rotator.cs
vendored
Normal file
12
Assets/ThirdParty/BruteForce/Scripts/BF_Rotator.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BF_Rotator : MonoBehaviour
|
||||
{
|
||||
public float RotSpeed = 1;
|
||||
void Update()
|
||||
{
|
||||
this.transform.Rotate(new Vector3(0, RotSpeed*Time.deltaTime, 0), Space.World);
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_Rotator.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_Rotator.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53088f735d92cd94fa9c9c91525485b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
122
Assets/ThirdParty/BruteForce/Scripts/BF_SnowAssetManager.cs
vendored
Normal file
122
Assets/ThirdParty/BruteForce/Scripts/BF_SnowAssetManager.cs
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
public class BF_SnowAssetManager : MonoBehaviour
|
||||
{
|
||||
public GameObject UIText;
|
||||
public int showcaseIndex = 0;
|
||||
[HideInInspector] public int subShowcaseIndex = 0;
|
||||
public List<GameObject> showcasesGO;
|
||||
public List<GameObject> cameras;
|
||||
public List<GameObject> lights;
|
||||
public List<Material> skyboxes;
|
||||
[Space]
|
||||
public GameObject specialCamera;
|
||||
public GameObject specialButton;
|
||||
public GameObject specialInfo;
|
||||
private int maxIndex = 4;
|
||||
[HideInInspector] public int maxSubIndex = 3;
|
||||
|
||||
[HideInInspector] public UnityEvent m_ShowcaseChange = new UnityEvent();
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
maxIndex = showcasesGO.Count - 1;
|
||||
SwitchShowcase(0);
|
||||
SwitchSubShowcase(0);
|
||||
RenderSettings.fog = true;
|
||||
RenderSettings.fogDensity = 0.00f;
|
||||
UIText.SetActive(false);
|
||||
specialCamera.SetActive(false);
|
||||
specialButton.SetActive(true);
|
||||
specialInfo.SetActive(true);
|
||||
}
|
||||
|
||||
public void SwitchShowcase(int addIndex)
|
||||
{
|
||||
for (int i = 0; i <= maxIndex; i++)
|
||||
{
|
||||
showcasesGO[i].SetActive(false);
|
||||
cameras[i].SetActive(false);
|
||||
lights[i].SetActive(false);
|
||||
}
|
||||
showcaseIndex += addIndex;
|
||||
if (showcaseIndex <= -1)
|
||||
{
|
||||
showcaseIndex = maxIndex;
|
||||
}
|
||||
else if (showcaseIndex == maxIndex + 1)
|
||||
{
|
||||
showcaseIndex = 0;
|
||||
}
|
||||
showcasesGO[showcaseIndex].SetActive(true);
|
||||
cameras[showcaseIndex].SetActive(true);
|
||||
lights[showcaseIndex].SetActive(true);
|
||||
RenderSettings.skybox = skyboxes[showcaseIndex];
|
||||
subShowcaseIndex = 0;
|
||||
m_ShowcaseChange.Invoke();
|
||||
|
||||
if(showcaseIndex != 0)
|
||||
{
|
||||
RenderSettings.fogDensity = 0.001f;
|
||||
specialCamera.SetActive(false);
|
||||
specialButton.SetActive(false);
|
||||
specialInfo.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
specialCamera.SetActive(false);
|
||||
RenderSettings.fogDensity = 0.00f;
|
||||
specialButton.SetActive(true);
|
||||
specialInfo.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchSubShowcase(int addIndex)
|
||||
{
|
||||
subShowcaseIndex += addIndex;
|
||||
if (subShowcaseIndex <= -1)
|
||||
{
|
||||
subShowcaseIndex = maxSubIndex;
|
||||
}
|
||||
else if (subShowcaseIndex == maxSubIndex + 1)
|
||||
{
|
||||
subShowcaseIndex = 0;
|
||||
}
|
||||
m_ShowcaseChange.Invoke();
|
||||
}
|
||||
|
||||
public void ActivateSpecialCamera()
|
||||
{
|
||||
specialCamera.SetActive(!specialCamera.activeInHierarchy);
|
||||
cameras[0].SetActive(!cameras[0].activeInHierarchy);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
SwitchSubShowcase(-1);
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Alpha2))
|
||||
{
|
||||
SwitchSubShowcase(1);
|
||||
}
|
||||
#else
|
||||
if (Keyboard.current.digit1Key.wasPressedThisFrame)
|
||||
{
|
||||
SwitchSubShowcase(-1);
|
||||
}
|
||||
if (Keyboard.current.digit2Key.wasPressedThisFrame)
|
||||
{
|
||||
SwitchSubShowcase(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowAssetManager.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowAssetManager.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86e6ab644acef394f9a3498ddeb8e3dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/ThirdParty/BruteForce/Scripts/BF_SnowSubShowcase.cs
vendored
Normal file
55
Assets/ThirdParty/BruteForce/Scripts/BF_SnowSubShowcase.cs
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class BF_SnowSubShowcase : MonoBehaviour
|
||||
{
|
||||
public BF_SnowAssetManager aM;
|
||||
public Text uiText;
|
||||
public List<GameObject> subShowcases;
|
||||
public List<string> nameSubs;
|
||||
private int oldIndex = -1;
|
||||
|
||||
private UnityAction showcaseChange;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void OnEnable()
|
||||
{
|
||||
aM.maxSubIndex = subShowcases.Count-1;
|
||||
aM.m_ShowcaseChange.AddListener(ChangeIndex);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
aM.m_ShowcaseChange.RemoveListener(ChangeIndex);
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
/*
|
||||
if(aM.subShowcaseIndex != oldIndex)
|
||||
{
|
||||
oldIndex = aM.subShowcaseIndex;
|
||||
foreach(GameObject GO in subShowcases)
|
||||
{
|
||||
GO.SetActive(false);
|
||||
}
|
||||
subShowcases[oldIndex].SetActive(true);
|
||||
uiText.text = nameSubs[oldIndex];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void ChangeIndex()
|
||||
{
|
||||
oldIndex = aM.subShowcaseIndex;
|
||||
|
||||
foreach (GameObject GO in subShowcases)
|
||||
{
|
||||
GO.SetActive(false);
|
||||
}
|
||||
subShowcases[oldIndex].SetActive(true);
|
||||
uiText.text = nameSubs[oldIndex];
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowSubShowcase.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowSubShowcase.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08e6d17c1c9ea7d4189ee556f2049d88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
204
Assets/ThirdParty/BruteForce/Scripts/BF_SnowTerrain.cs
vendored
Normal file
204
Assets/ThirdParty/BruteForce/Scripts/BF_SnowTerrain.cs
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class BF_SnowTerrain : MonoBehaviour
|
||||
{
|
||||
public Terrain terrainToCopy;
|
||||
public bool avoidCulling = false;
|
||||
|
||||
private Terrain terrainAsset;
|
||||
private TerrainData terrainData;
|
||||
private TerrainData terrainDataOld = null;
|
||||
private Vector3 sizeOld = Vector3.one * 100f;
|
||||
private float[,] terrainHeightOld = null;
|
||||
private int heightRezOld = 0;
|
||||
private Vector3 posOld = Vector3.zero;
|
||||
private Material terrainMaterial;
|
||||
private GameObject selectGO;
|
||||
private bool isSynced = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
UpdateTerrainData();
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
UpdateTerrainData();
|
||||
}
|
||||
|
||||
private void StoreTerrainData()
|
||||
{
|
||||
if (terrainDataOld == null)
|
||||
{
|
||||
terrainDataOld = terrainAsset.terrainData;
|
||||
terrainHeightOld = terrainAsset.terrainData.GetHeights(0, 0, terrainAsset.terrainData.heightmapResolution, terrainAsset.terrainData.heightmapResolution);
|
||||
sizeOld = terrainAsset.terrainData.size;
|
||||
heightRezOld = terrainAsset.terrainData.heightmapResolution;
|
||||
posOld = terrainAsset.transform.position;
|
||||
}
|
||||
}
|
||||
private void ClearTerrainData()
|
||||
{
|
||||
terrainDataOld = null;
|
||||
terrainHeightOld = null;
|
||||
isSynced = false;
|
||||
sizeOld = Vector3.one*100f;
|
||||
}
|
||||
|
||||
private void UpdateTerrainData()
|
||||
{
|
||||
terrainAsset = this.GetComponent<Terrain>();
|
||||
if (avoidCulling)
|
||||
{
|
||||
terrainAsset.patchBoundsMultiplier = Vector3.one * 2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
terrainAsset.patchBoundsMultiplier = Vector3.one;
|
||||
}
|
||||
terrainData = terrainAsset.terrainData;
|
||||
|
||||
terrainMaterial = terrainAsset.materialTemplate;
|
||||
terrainMaterial.SetTexture("_Control0", terrainData.GetAlphamapTexture(0));
|
||||
terrainMaterial.SetTexture("_Control1", terrainData.GetAlphamapTexture(1));
|
||||
terrainMaterial.SetVector("_TerrainScale", terrainData.size);
|
||||
|
||||
|
||||
terrainMaterial.SetFloat("_IST", 1);
|
||||
terrainMaterial.EnableKeyword("IS_T");
|
||||
|
||||
if (terrainData.terrainLayers.Length <= 4)
|
||||
{
|
||||
terrainMaterial.DisableKeyword("USE_COMPLEX_T");
|
||||
}
|
||||
|
||||
if (terrainData.terrainLayers.Length > 4)
|
||||
{
|
||||
terrainMaterial.EnableKeyword("USE_COMPLEX_T");
|
||||
terrainMaterial.SetTexture("_Normal4", terrainData.terrainLayers[4].normalMapTexture);
|
||||
terrainMaterial.SetFloat("_NormalScale4", terrainData.terrainLayers[4].normalScale);
|
||||
terrainMaterial.SetTexture("_Splat4", terrainData.terrainLayers[4].diffuseTexture);
|
||||
terrainMaterial.SetVector("_Splat4_STn", new Vector4(terrainData.terrainLayers[4].tileSize.x, terrainData.terrainLayers[4].tileSize.y, terrainData.terrainLayers[4].tileOffset.x, terrainData.terrainLayers[4].tileOffset.y));
|
||||
terrainMaterial.SetColor("_Specular4", terrainData.terrainLayers[4].specular);
|
||||
terrainMaterial.SetFloat("_Metallic4", terrainData.terrainLayers[4].metallic);
|
||||
terrainMaterial.SetTexture("_Mask4", terrainData.terrainLayers[4].maskMapTexture);
|
||||
}
|
||||
if (terrainData.terrainLayers.Length > 5)
|
||||
{
|
||||
terrainMaterial.SetTexture("_Normal5", terrainData.terrainLayers[5].normalMapTexture);
|
||||
terrainMaterial.SetFloat("_NormalScale5", terrainData.terrainLayers[5].normalScale);
|
||||
terrainMaterial.SetTexture("_Splat5", terrainData.terrainLayers[5].diffuseTexture);
|
||||
terrainMaterial.SetVector("_Splat5_STn", new Vector4(terrainData.terrainLayers[5].tileSize.x, terrainData.terrainLayers[5].tileSize.y, terrainData.terrainLayers[5].tileOffset.x, terrainData.terrainLayers[5].tileOffset.y));
|
||||
terrainMaterial.SetColor("_Specular5", terrainData.terrainLayers[5].specular);
|
||||
terrainMaterial.SetFloat("_Metallic5", terrainData.terrainLayers[5].metallic);
|
||||
terrainMaterial.SetTexture("_Mask5", terrainData.terrainLayers[5].maskMapTexture);
|
||||
}
|
||||
if (terrainData.terrainLayers.Length > 6)
|
||||
{
|
||||
terrainMaterial.SetTexture("_Normal6", terrainData.terrainLayers[6].normalMapTexture);
|
||||
terrainMaterial.SetFloat("_NormalScale6", terrainData.terrainLayers[6].normalScale);
|
||||
terrainMaterial.SetTexture("_Splat6", terrainData.terrainLayers[6].diffuseTexture);
|
||||
terrainMaterial.SetVector("_Splat6_STn", new Vector4(terrainData.terrainLayers[6].tileSize.x, terrainData.terrainLayers[6].tileSize.y, terrainData.terrainLayers[6].tileOffset.x, terrainData.terrainLayers[6].tileOffset.y));
|
||||
terrainMaterial.SetColor("_Specular6", terrainData.terrainLayers[6].specular);
|
||||
terrainMaterial.SetFloat("_Metallic6", terrainData.terrainLayers[6].metallic);
|
||||
terrainMaterial.SetTexture("_Mask6", terrainData.terrainLayers[6].maskMapTexture);
|
||||
}
|
||||
if (terrainData.terrainLayers.Length > 7)
|
||||
{
|
||||
terrainMaterial.SetTexture("_Normal7", terrainData.terrainLayers[7].normalMapTexture);
|
||||
terrainMaterial.SetFloat("_NormalScale7", terrainData.terrainLayers[7].normalScale);
|
||||
terrainMaterial.SetTexture("_Splat7", terrainData.terrainLayers[7].diffuseTexture);
|
||||
terrainMaterial.SetVector("_Splat7_STn", new Vector4(terrainData.terrainLayers[7].tileSize.x, terrainData.terrainLayers[7].tileSize.y, terrainData.terrainLayers[7].tileOffset.x, terrainData.terrainLayers[7].tileOffset.y));
|
||||
terrainMaterial.SetColor("_Specular7", terrainData.terrainLayers[7].specular);
|
||||
terrainMaterial.SetFloat("_Metallic7", terrainData.terrainLayers[7].metallic);
|
||||
terrainMaterial.SetTexture("_Mask7", terrainData.terrainLayers[7].maskMapTexture);
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTerrainData()
|
||||
{
|
||||
if(terrainToCopy != null && terrainToCopy != terrainAsset)
|
||||
{
|
||||
StoreTerrainData();
|
||||
|
||||
terrainAsset.terrainData.heightmapResolution = terrainToCopy.terrainData.heightmapResolution;
|
||||
terrainAsset.terrainData.SetHeights(0, 0, terrainToCopy.terrainData.GetHeights(0, 0, terrainToCopy.terrainData.heightmapResolution, terrainToCopy.terrainData.heightmapResolution));
|
||||
terrainAsset.terrainData.size = terrainToCopy.terrainData.size;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTerrainSync()
|
||||
{
|
||||
if (terrainToCopy != null && terrainToCopy != terrainAsset)
|
||||
{
|
||||
isSynced = true;
|
||||
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.up * 0.01f;
|
||||
//terrainMaterial.SetFloat("_GrassCut", 1);
|
||||
terrainAsset.terrainData.heightmapResolution = terrainToCopy.terrainData.heightmapResolution;
|
||||
terrainAsset.terrainData.baseMapResolution = terrainToCopy.terrainData.baseMapResolution;
|
||||
terrainAsset.terrainData.alphamapResolution = terrainToCopy.terrainData.alphamapResolution;
|
||||
|
||||
terrainMaterial.SetFloat("_ISADD", 1);
|
||||
terrainMaterial.EnableKeyword("IS_ADD");
|
||||
}
|
||||
else
|
||||
{
|
||||
//terrainMaterial.SetFloat("_GrassCut", 0);
|
||||
terrainMaterial.SetFloat("_ISADD", 0);
|
||||
terrainMaterial.DisableKeyword("IS_ADD");
|
||||
}
|
||||
}
|
||||
public void RevertTerrainData()
|
||||
{
|
||||
if (terrainDataOld != null)
|
||||
{
|
||||
terrainToCopy = null;
|
||||
terrainAsset.terrainData = terrainDataOld;
|
||||
terrainAsset.terrainData.heightmapResolution = heightRezOld;
|
||||
terrainAsset.terrainData.size = sizeOld;
|
||||
terrainAsset.terrainData.SetHeights(0, 0, terrainHeightOld);
|
||||
//terrainMaterial.SetFloat("_GrassCut", 0);
|
||||
terrainMaterial.SetFloat("_ISADD", 0);
|
||||
terrainMaterial.DisableKeyword("IS_ADD");
|
||||
terrainAsset.transform.position = posOld;
|
||||
ClearTerrainData();
|
||||
}
|
||||
}
|
||||
|
||||
void OnRenderObject()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if ((Application.isEditor && !Application.isPlaying)&& terrainToCopy!=null && isSynced)
|
||||
{
|
||||
if (Selection.activeGameObject == this.gameObject && selectGO != this.gameObject)
|
||||
{
|
||||
selectGO = Selection.activeGameObject;
|
||||
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.up * 0.01f;
|
||||
}
|
||||
else if (Selection.activeGameObject == terrainToCopy.gameObject && selectGO != terrainToCopy.gameObject)
|
||||
{
|
||||
selectGO = Selection.activeGameObject;
|
||||
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.down * 0.01f;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (Application.isEditor && !Application.isPlaying)
|
||||
{
|
||||
UpdateTerrainData();
|
||||
if (isSynced && terrainToCopy != null && terrainToCopy.terrainData.GetHeights(0, 0, terrainToCopy.terrainData.heightmapResolution, terrainToCopy.terrainData.heightmapResolution) != terrainAsset.terrainData.GetHeights(0, 0, terrainAsset.terrainData.heightmapResolution, terrainAsset.terrainData.heightmapResolution))
|
||||
{
|
||||
CopyTerrainData();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowTerrain.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_SnowTerrain.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41c94d07ab70d5b4e881198d094c5d0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/ThirdParty/BruteForce/Scripts/BF_SquareBanding.cs
vendored
Normal file
15
Assets/ThirdParty/BruteForce/Scripts/BF_SquareBanding.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class BF_SquareBanding : MonoBehaviour
|
||||
{
|
||||
public Material cinematicBandsFX = null;
|
||||
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
Graphics.Blit(source, destination, cinematicBandsFX);
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BruteForce/Scripts/BF_SquareBanding.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BruteForce/Scripts/BF_SquareBanding.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8293a710c5345854cb7d5039e78a596d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user