mirror of
https://github.com/ConjureETS/OuijaMTLGJ2016.git
synced 2026-03-24 02:01:06 +00:00
Fix
This commit is contained in:
parent
da8d5a0506
commit
fe98521b0d
@ -1,118 +1,118 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class Character : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
|
||||
public float MoveSpeed;
|
||||
public float TurnSpeed;
|
||||
public float DashForce;
|
||||
public float DashCooldown;
|
||||
public Color TrailColor;
|
||||
|
||||
private Rigidbody rb;
|
||||
private Quaternion targetRot = Quaternion.identity;
|
||||
|
||||
private float dashRemainingTime = 6f;
|
||||
private bool isDashing = false;
|
||||
|
||||
private int playerId;
|
||||
private SelectorWithBolts selector;
|
||||
|
||||
private Vector3 dashForward;
|
||||
|
||||
private ParticleSystem particleSys;
|
||||
|
||||
public int PlayerID
|
||||
{
|
||||
get { return playerId; }
|
||||
set { playerId = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
particleSys = GetComponent<ParticleSystem>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
selector = GameObject.FindObjectOfType<SelectorWithBolts>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (dashRemainingTime > 0)
|
||||
{
|
||||
dashRemainingTime = Mathf.Clamp(dashRemainingTime - Time.deltaTime, 0f, DashCooldown);
|
||||
}
|
||||
|
||||
if (isDashing)
|
||||
{
|
||||
rb.AddForce(dashForward * DashForce, ForceMode.VelocityChange);
|
||||
}
|
||||
else
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class Character : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
|
||||
public float MoveSpeed;
|
||||
public float TurnSpeed;
|
||||
public float DashForce;
|
||||
public float DashCooldown;
|
||||
public Color TrailColor;
|
||||
|
||||
private Rigidbody rb;
|
||||
private Quaternion targetRot = Quaternion.identity;
|
||||
|
||||
private float dashRemainingTime = 6f;
|
||||
private bool isDashing = false;
|
||||
|
||||
private int playerId;
|
||||
private SelectorWithBolts selector;
|
||||
|
||||
private Vector3 dashForward;
|
||||
|
||||
private ParticleSystem particleSys;
|
||||
|
||||
public int PlayerID
|
||||
{
|
||||
get { return playerId; }
|
||||
set { playerId = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
particleSys = GetComponent<ParticleSystem>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
selector = GameObject.FindObjectOfType<SelectorWithBolts>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (dashRemainingTime > 0)
|
||||
{
|
||||
rb.rotation = Quaternion.RotateTowards(rb.rotation, targetRot, TurnSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(float xValue, float zValue)
|
||||
{
|
||||
if (isDashing) return;
|
||||
|
||||
Vector3 forwardDir = Camera.main.transform.forward;
|
||||
Vector3 rightDir = Camera.main.transform.right;
|
||||
|
||||
forwardDir.y = 0f;
|
||||
forwardDir = forwardDir.normalized * zValue;
|
||||
|
||||
rightDir.y = 0f;
|
||||
rightDir = rightDir.normalized * xValue;
|
||||
|
||||
Vector3 newVelocity = (forwardDir + rightDir) * MoveSpeed;
|
||||
|
||||
if (newVelocity != Vector3.zero)
|
||||
{
|
||||
// We rotate to face the new direction
|
||||
targetRot = Quaternion.LookRotation(newVelocity.normalized);
|
||||
}
|
||||
|
||||
newVelocity.y = rb.velocity.y;
|
||||
|
||||
rb.velocity = newVelocity;
|
||||
animator.SetFloat("Walk", rb.velocity.magnitude);
|
||||
}
|
||||
|
||||
public bool Dash()
|
||||
{
|
||||
if (dashRemainingTime > 0f) return false;
|
||||
|
||||
selector.ReplenishPlayerDashMeter(playerId);
|
||||
|
||||
dashRemainingTime = DashCooldown;
|
||||
|
||||
//particleSys.Play();
|
||||
|
||||
StartCoroutine(DashCoroutine());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerator DashCoroutine()
|
||||
{
|
||||
isDashing = true;
|
||||
|
||||
dashForward = GetComponent<Transform>().forward;
|
||||
rb.velocity = Vector3.zero;
|
||||
|
||||
animator.SetTrigger("Dash");
|
||||
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
|
||||
isDashing = false;
|
||||
}
|
||||
}
|
||||
dashRemainingTime = Mathf.Clamp(dashRemainingTime - Time.deltaTime, 0f, DashCooldown);
|
||||
}
|
||||
|
||||
if (isDashing)
|
||||
{
|
||||
rb.AddForce(dashForward * DashForce, ForceMode.VelocityChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.rotation = Quaternion.RotateTowards(rb.rotation, targetRot, TurnSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(float xValue, float zValue)
|
||||
{
|
||||
if (isDashing) return;
|
||||
|
||||
Vector3 forwardDir = Camera.main.transform.forward;
|
||||
Vector3 rightDir = Camera.main.transform.right;
|
||||
|
||||
forwardDir.y = 0f;
|
||||
forwardDir = forwardDir.normalized * zValue;
|
||||
|
||||
rightDir.y = 0f;
|
||||
rightDir = rightDir.normalized * xValue;
|
||||
|
||||
Vector3 newVelocity = (forwardDir + rightDir) * MoveSpeed;
|
||||
|
||||
if (newVelocity != Vector3.zero)
|
||||
{
|
||||
// We rotate to face the new direction
|
||||
targetRot = Quaternion.LookRotation(newVelocity.normalized);
|
||||
}
|
||||
|
||||
newVelocity.y = rb.velocity.y;
|
||||
|
||||
rb.velocity = newVelocity;
|
||||
animator.SetFloat("Walk", rb.velocity.magnitude);
|
||||
}
|
||||
|
||||
public bool Dash()
|
||||
{
|
||||
if (dashRemainingTime > 0f) return false;
|
||||
|
||||
selector.ReplenishPlayerDashMeter(playerId);
|
||||
|
||||
dashRemainingTime = DashCooldown;
|
||||
|
||||
//particleSys.Play();
|
||||
|
||||
StartCoroutine(DashCoroutine());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerator DashCoroutine()
|
||||
{
|
||||
isDashing = true;
|
||||
|
||||
dashForward = GetComponent<Transform>().forward;
|
||||
rb.velocity = Vector3.zero;
|
||||
|
||||
animator.SetTrigger("Dash");
|
||||
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
|
||||
isDashing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,8 +72,12 @@ public class RuneBehaviour : MonoBehaviour {
|
||||
|
||||
while (ratio < 1f)
|
||||
{
|
||||
ratio += Time.deltaTime / LightTime;
|
||||
symbol.color = Color.Lerp(startColor, DefaultColor, ratio);
|
||||
// Hack
|
||||
if (enabled)
|
||||
{
|
||||
ratio += Time.deltaTime / LightTime;
|
||||
symbol.color = Color.Lerp(startColor, DefaultColor, ratio);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using XInputDotNetPure;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class SelectorWithBolts : MonoBehaviour
|
||||
@ -74,5 +75,26 @@ public class SelectorWithBolts : MonoBehaviour
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
StartCoroutine(VibrateController(playerId));
|
||||
}
|
||||
|
||||
private IEnumerator VibrateController(int playerId)
|
||||
{
|
||||
GamePad.SetVibration((PlayerIndex)playerId, 1f, 1f);
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
GamePad.SetVibration((PlayerIndex)playerId, 0f, 0f);
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
// In case the coroutine was still running when we closed the game
|
||||
|
||||
for (int i = 0; i < Bolts.Length; i++)
|
||||
{
|
||||
GamePad.SetVibration((PlayerIndex)i, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user