场景设计
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 945383d2ff39ec546bc8fa5a396f9756
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed9d2c7cebcf9be4e9fa52a4b0479222
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6023463b97795b5439bf62bf9ec91ddc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace INab.Demo
|
||||
{
|
||||
public class FloatingCoin : MonoBehaviour
|
||||
{
|
||||
public float rotationSpeed = 100f;
|
||||
public float floatSpeed = 0.5f;
|
||||
public float floatHeight = 0.5f;
|
||||
|
||||
private Vector3 startPosition;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
startPosition = transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Rotate the coin
|
||||
transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime, Space.World);
|
||||
|
||||
// Float the coin up and down
|
||||
Vector3 newPosition = startPosition + new Vector3(0f, Mathf.Sin(Time.time * floatSpeed) * floatHeight, 0f);
|
||||
transform.position = newPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c024ef0b195e73f4b94131f86f3afb93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30134a1579d3b1341aaf9a62d53f086b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Highlighters
|
||||
{
|
||||
public class CameraManager : MonoBehaviour
|
||||
{
|
||||
public Transform target;
|
||||
|
||||
public Vector3 transformv;
|
||||
|
||||
public float xRot = 0f;
|
||||
public float RestartRotation = 0f;
|
||||
public float yRot = 0f;
|
||||
|
||||
public float distance = 5f;
|
||||
public float sensitivity = 10f;
|
||||
|
||||
//UI elements
|
||||
public Slider rotationSlider;
|
||||
public Slider distanceSlider;
|
||||
|
||||
//private members
|
||||
private bool m_Locked = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rotationSlider.onValueChanged.AddListener(delegate { RotationValueChange(); });
|
||||
distanceSlider.onValueChanged.AddListener(delegate { DistanceValueChange(); });
|
||||
}
|
||||
|
||||
public void RotationValueChange()
|
||||
{
|
||||
if (m_Locked)
|
||||
{
|
||||
yRot = rotationSlider.value;
|
||||
transform.position = target.position + transformv + Quaternion.Euler(xRot, yRot, 0f) * (distance * -Vector3.back);
|
||||
transform.LookAt(target.position + transformv, Vector3.up);
|
||||
}
|
||||
else
|
||||
{
|
||||
yRot = rotationSlider.value;
|
||||
}
|
||||
}
|
||||
|
||||
public void DistanceValueChange()
|
||||
{
|
||||
if (m_Locked)
|
||||
{
|
||||
distance = distanceSlider.value;
|
||||
transform.position = target.position + transformv + Quaternion.Euler(xRot, yRot, 0f) * (distance * -Vector3.back);
|
||||
transform.LookAt(target.position + transformv, Vector3.up);
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = distanceSlider.value;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
LockRotation();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
yRot = RestartRotation;
|
||||
}
|
||||
|
||||
if (m_Locked) return;
|
||||
|
||||
yRot += sensitivity * Time.deltaTime;
|
||||
|
||||
transform.position = target.position + transformv + Quaternion.Euler(xRot, yRot, 0f) * (distance * -Vector3.back);
|
||||
transform.LookAt(target.position + transformv, Vector3.up);
|
||||
|
||||
if (yRot >= 360) yRot = 0;
|
||||
|
||||
UiManager();
|
||||
|
||||
}
|
||||
|
||||
void UiManager()
|
||||
{
|
||||
rotationSlider.value = yRot;
|
||||
}
|
||||
|
||||
public void LockRotation()
|
||||
{
|
||||
m_Locked = !m_Locked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71f20312f3223b54780a73928fb64c11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,136 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Highlighters
|
||||
{
|
||||
public class Camera_Controller : MonoBehaviour
|
||||
{
|
||||
public float Normal_Speed = 25.0f; //Normal movement speed
|
||||
|
||||
public float Shift_Speed = 54.0f; //multiplies movement speed by how long shift is held down.
|
||||
|
||||
public float Speed_Cap = 54.0f; //Max cap for speed when shift is held down
|
||||
|
||||
public float Camera_Sensitivity = 0.6f; //How sensitive it with mouse
|
||||
|
||||
private Vector3 Mouse_Location = new Vector3(255, 255, 255); //Mouse location on screen during play (Set to near the middle of the screen)
|
||||
|
||||
private float Total_Speed = 1.0f; //Total speed variable for shift
|
||||
|
||||
public bool freeze = false;
|
||||
public bool freezeMouse = true;
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (Input.GetKey(KeyCode.Escape))
|
||||
{
|
||||
freeze = !freeze;
|
||||
}
|
||||
if (freeze) return;
|
||||
|
||||
if (Input.GetKey(KeyCode.M))
|
||||
{
|
||||
freezeMouse = !freezeMouse;
|
||||
}
|
||||
if (!freezeMouse)
|
||||
{
|
||||
|
||||
//Camera angles based on mouse position
|
||||
Mouse_Location = Input.mousePosition - Mouse_Location;
|
||||
|
||||
Mouse_Location = new Vector3(-Mouse_Location.y * Camera_Sensitivity, Mouse_Location.x * Camera_Sensitivity, 0);
|
||||
|
||||
Mouse_Location = new Vector3(transform.eulerAngles.x + Mouse_Location.x, transform.eulerAngles.y + Mouse_Location.y, 0);
|
||||
|
||||
transform.eulerAngles = Mouse_Location;
|
||||
|
||||
Mouse_Location = Input.mousePosition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Keyboard controls
|
||||
|
||||
Vector3 Cam = GetBaseInput();
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
|
||||
|
||||
Total_Speed += Time.deltaTime;
|
||||
|
||||
Cam = Cam * Total_Speed * Shift_Speed;
|
||||
|
||||
Cam.x = Mathf.Clamp(Cam.x, -Speed_Cap, Speed_Cap);
|
||||
|
||||
Cam.y = Mathf.Clamp(Cam.y, -Speed_Cap, Speed_Cap);
|
||||
|
||||
Cam.z = Mathf.Clamp(Cam.z, -Speed_Cap, Speed_Cap);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
Total_Speed = Mathf.Clamp(Total_Speed * 0.5f, 1f, 1000f);
|
||||
|
||||
Cam = Cam * Normal_Speed;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Cam = Cam * Time.deltaTime;
|
||||
|
||||
Vector3 newPosition = transform.position;
|
||||
|
||||
if (Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
|
||||
|
||||
//If the player wants to move on X and Z axis only by pressing space (good for re-adjusting angle shots)
|
||||
transform.Translate(Cam);
|
||||
newPosition.x = transform.position.x;
|
||||
newPosition.z = transform.position.z;
|
||||
transform.position = newPosition;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
transform.Translate(Cam);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Vector3 GetBaseInput()
|
||||
{
|
||||
|
||||
|
||||
Vector3 Camera_Velocity = new Vector3();
|
||||
|
||||
float HorizontalInput = Input.GetAxis("Horizontal"); //Input for horizontal movement
|
||||
|
||||
float VerticalInput = Input.GetAxis("Vertical"); //Input for Vertical movement
|
||||
|
||||
|
||||
|
||||
Camera_Velocity += new Vector3(HorizontalInput, 0, 0);
|
||||
|
||||
Camera_Velocity += new Vector3(0, 0, VerticalInput);
|
||||
|
||||
return Camera_Velocity;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42dd1a894d85db548a183bdc6a398828
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace Highlighters
|
||||
{
|
||||
public class FloatingObject : MonoBehaviour
|
||||
{
|
||||
// The amplitude of the coin's oscillation
|
||||
public float amplitude = 0.5f;
|
||||
|
||||
// The frequency of the coin's oscillation
|
||||
public float frequency = 1.0f;
|
||||
|
||||
// The starting position of the coin
|
||||
private Vector3 startPos;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Store the starting position of the coin
|
||||
startPos = transform.position;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Calculate the coin's new position based on a sinusoidal oscillation
|
||||
float newYPos = amplitude * Mathf.Sin(Time.time * frequency);
|
||||
transform.position = startPos + new Vector3(0, newYPos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853b5bbbb4a669445bf3ad34ab46319a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Highlighters
|
||||
{
|
||||
public class ObjectOscilate : MonoBehaviour
|
||||
{
|
||||
public float minX;
|
||||
public float maxX;
|
||||
public float speed = 1.0f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Calculate oscillation value using ping-pong function
|
||||
float oscillation = Mathf.PingPong(Time.time * speed, 1.0f);
|
||||
|
||||
// Calculate X position for the object
|
||||
float posX = Mathf.Lerp(minX, maxX, oscillation);
|
||||
|
||||
// Set position of game object based on oscillation value
|
||||
transform.localPosition = new Vector3(posX, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3673f63a6b49dc4c9ebcb2cf0f2d6b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Highlighters
|
||||
{
|
||||
public class TestSceneManager : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> objectsToShow = new List<GameObject>();
|
||||
|
||||
public Text text;
|
||||
|
||||
private int currentObjectActiveID = 0;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
foreach (var obj in objectsToShow)
|
||||
{
|
||||
obj.SetActive(false);
|
||||
}
|
||||
|
||||
if (objectsToShow.Count > 0) objectsToShow[0].SetActive(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (objectsToShow.Count < 1) return;
|
||||
|
||||
if (text != null) text.text = (currentObjectActiveID + 1).ToString() + " / " + objectsToShow.Count.ToString();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
||||
{
|
||||
Previous();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.RightArrow))
|
||||
{
|
||||
Next();
|
||||
}
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
foreach (var item in objectsToShow)
|
||||
{
|
||||
item.SetActive(false);
|
||||
}
|
||||
|
||||
//objectsToShow[currentObjectActiveID].SetActive(false);
|
||||
currentObjectActiveID++;
|
||||
currentObjectActiveID = currentObjectActiveID % objectsToShow.Count;
|
||||
|
||||
objectsToShow[currentObjectActiveID].SetActive(true);
|
||||
}
|
||||
|
||||
public void Previous()
|
||||
{
|
||||
foreach (var item in objectsToShow)
|
||||
{
|
||||
item.SetActive(false);
|
||||
}
|
||||
|
||||
//objectsToShow[currentObjectActiveID].SetActive(false);
|
||||
currentObjectActiveID--;
|
||||
if (currentObjectActiveID < 0) currentObjectActiveID = objectsToShow.Count - 1;
|
||||
|
||||
objectsToShow[currentObjectActiveID].SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f8f5864b1fe3a945864e1bef3f537ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user