Browse Source

Merge branch 'master' of https://bitbucket.org/JoshuaReason/ggj2020

# Conflicts:
#	Assets/Scripts/Input/HerdController.cs
master
NickFowler 4 years ago
parent
commit
0812bb70f8
7 changed files with 192 additions and 16 deletions
  1. +77
    -0
      Assets/Materials/Temp3.mat
  2. +8
    -0
      Assets/Materials/Temp3.mat.meta
  3. +50
    -0
      Assets/Scripts/ExplosionTest.cs
  4. +11
    -0
      Assets/Scripts/ExplosionTest.cs.meta
  5. +3
    -0
      Assets/Scripts/Input/DynamicCamera.cs
  6. +15
    -5
      Assets/Scripts/Input/HerdController.cs
  7. +28
    -11
      Assets/Scripts/Input/PlayerController.cs

+ 77
- 0
Assets/Materials/Temp3.mat View File

@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Temp3
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

+ 8
- 0
Assets/Materials/Temp3.mat.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 459cd3e0ba7a5fa4490b1d19849b49e2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

+ 50
- 0
Assets/Scripts/ExplosionTest.cs View File

@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExplosionTest : MonoBehaviour
{
[SerializeField]
private float Force = 1;
[SerializeField]
private float speed;
[SerializeField]
private Vector3 direction;
Vector3 start;
float ratio;
private void Start()
{
start = transform.position;
}
private void Update()
{
ratio = Mathf.Sin(Time.time * speed);
transform.position = Vector3.Lerp(start, start + direction, (ratio+1)/2);
}
private void OnDrawGizmosSelected()
{
if (Application.isPlaying)
Gizmos.DrawWireSphere(start + direction, 10);
else
Gizmos.DrawWireSphere(transform.position + direction, 10);
}
private void OnTriggerStay(Collider other)
{
var horse = other.GetComponent<PlayerController>();
if (horse != null)
{
horse.AddForce((direction.normalized * Mathf.Cos(Time.time *speed) + Vector3.up) * Force);
Debug.DrawRay(horse.transform.position, (direction.normalized + Vector3.up) * Mathf.Cos(Time.time * speed) * Force, Color.red, 0.5f);
}
}
}

+ 11
- 0
Assets/Scripts/ExplosionTest.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d016e6d7dab5554bb245a972d9d3060
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/Scripts/Input/DynamicCamera.cs View File

@ -15,6 +15,9 @@ public class DynamicCamera : MonoBehaviour
void Follow() void Follow()
{ {
Vector3 tempDest = target.transform.position; Vector3 tempDest = target.transform.position;
camHeight = target.transform.localScale.magnitude;
tempDest -= transform.forward * camHeight; tempDest -= transform.forward * camHeight;
Vector3 destination = Vector3.Lerp(transform.position, tempDest, 10f * Time.deltaTime); Vector3 destination = Vector3.Lerp(transform.position, tempDest, 10f * Time.deltaTime);
transform.position = destination; transform.position = destination;

+ 15
- 5
Assets/Scripts/Input/HerdController.cs View File

@ -109,12 +109,22 @@ public class HerdController : MonoBehaviour
} }
if (Centre != null)
Centre.position = Herd.Aggregate(new Vector3(0, 0, 0), (s, v) => s + v.transform.position) / (float)Herd.Count;
if (Herd.Count.Equals(0))
GameState.LoseState();
if (Herd?.Count > 0)
{
Bounds bound = new Bounds(Herd[0].transform.position, Vector3.zero);
foreach (PlayerController horse in Herd)
{
if (horse.isGrounded || Time.time < 5)
bound.Encapsulate(horse.transform.position);
}
Centre.position = bound.center;
Centre.localScale = bound.size * 0.8f;
}
else
{
GameState.LoseState();
}
} }
public void RemoveHorse(PlayerController horse) public void RemoveHorse(PlayerController horse)

+ 28
- 11
Assets/Scripts/Input/PlayerController.cs View File

@ -21,13 +21,16 @@ public class PlayerController : MonoBehaviour
private Vector3 moveDirection = Vector3.zero; private Vector3 moveDirection = Vector3.zero;
private float moveDelta; private float moveDelta;
private float lastMoveTime; private float lastMoveTime;
private bool isRagdoll = false;
public bool isGrounded { get { return (cController != null) ? cController.isGrounded : false; } }
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
speedMulitplier = UnityEngine.Random.Range(0.8f, 1.2f); speedMulitplier = UnityEngine.Random.Range(0.8f, 1.2f);
cController = GetComponent<CharacterController>(); cController = GetComponent<CharacterController>();
randomizer = UnityEngine.Random.Range(0,10);
randomizer = UnityEngine.Random.Range(0, 10);
cam = FindObjectOfType<Camera>(); cam = FindObjectOfType<Camera>();
herd = FindObjectOfType<HerdController>(); herd = FindObjectOfType<HerdController>();
} }
@ -36,7 +39,7 @@ public class PlayerController : MonoBehaviour
{ {
receivedInput = input; receivedInput = input;
} }
public void UpdatePosition() public void UpdatePosition()
{ {
moveDelta = Time.time - lastMoveTime; moveDelta = Time.time - lastMoveTime;
@ -59,15 +62,21 @@ public class PlayerController : MonoBehaviour
if (cController.isGrounded) if (cController.isGrounded)
{ {
moveDirection = new Vector3(HorseX, 0, HorseZ);
moveDirection *= walkSpeed * speedMulitplier;
if (!isRagdoll)
{
moveDirection = Vector3.zero;
moveDirection += new Vector3(HorseX, 0, HorseZ) * (walkSpeed * (1 + speedMulitplier));
}
} }
moveDirection.y -= gravity * Time.deltaTime; moveDirection.y -= gravity * Time.deltaTime;
cController.Move(moveDirection * Time.deltaTime); cController.Move(moveDirection * Time.deltaTime);
if (cController.isGrounded)
isRagdoll = false;
//float rotateTo = RotateObject(HorseX, HorseZ); //float rotateTo = RotateObject(HorseX, HorseZ);
@ -117,11 +126,12 @@ public class PlayerController : MonoBehaviour
public IEnumerator RandomWait(float wait) public IEnumerator RandomWait(float wait)
{ {
yield return new WaitForSeconds(UnityEngine.Random.Range(0, wait/2));
Vector3 input = receivedInput;
yield return new WaitForSeconds(UnityEngine.Random.Range(0, wait / 2));
if (cController.isGrounded)
if (/*cController.isGrounded*/ true)
{ {
Vector3 rotateDir = new Vector3(90 * Math.Sign(receivedInput.y), 0, -90 * Math.Sign(receivedInput.x));
Vector3 rotateDir = new Vector3(90 * Math.Sign(input.y), 0, -90 * Math.Sign(input.x));
model.transform.Rotate(rotateDir, Space.World); model.transform.Rotate(rotateDir, Space.World);
} }
} }
@ -136,9 +146,16 @@ public class PlayerController : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
speedMulitplier = (Mathf.Sin(Time.time * UnityEngine.Random.Range(0.9f,1.1f) + randomizer) + 2);
directionRandmoizer = Mathf.Cos(Time.time + randomizer / 2) * 0.3f;
speedMulitplier = ((Mathf.Sin(Time.time * UnityEngine.Random.Range(0.95f, 1.05f) + randomizer) + 2) * 0.25f);
directionRandmoizer = Mathf.Cos(Time.time + randomizer / 2) * 0.0f;
UpdatePosition(); UpdatePosition();
DestroyOffCamera(); DestroyOffCamera();
} }
public void AddForce(Vector3 direction)
{
moveDirection += direction;
isRagdoll = true;
}
} }

Loading…
Cancel
Save