Browse Source

start working on Derived block for water.

Josh_Dev_branch
JoshuaReason 5 years ago
parent
commit
c55b13be62
7 changed files with 101 additions and 19 deletions
  1. +8
    -8
      Assets/Animations/CharacterController.controller
  2. +2
    -2
      Assets/Data/Logic Blocks/Diagonal Left.asset
  3. +2
    -2
      Assets/Data/Logic Blocks/Diagonal Right.asset
  4. +2
    -2
      Assets/Scripts/Character.cs
  5. +11
    -5
      Assets/Scripts/KeyboardInput.cs
  6. +65
    -0
      Assets/Scripts/LevelBlocks/Water.cs
  7. +11
    -0
      Assets/Scripts/LevelBlocks/Water.cs.meta

+ 8
- 8
Assets/Animations/CharacterController.controller View File

@ -45,7 +45,7 @@ AnimatorController:
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 0}
- m_Name: SpeedMultiple
- m_Name: AnimationSpeed
m_Type: 1 m_Type: 1
m_DefaultFloat: 1 m_DefaultFloat: 1
m_DefaultInt: 0 m_DefaultInt: 0
@ -400,7 +400,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400016, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400016, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -427,7 +427,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400018, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400018, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -454,7 +454,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400004, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400004, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -481,7 +481,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400012, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400012, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -508,7 +508,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400008, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400008, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -564,7 +564,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400006, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400006, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
@ -591,7 +591,7 @@ AnimatorState:
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400010, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Motion: {fileID: 7400010, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3}
m_Tag: m_Tag:
m_SpeedParameter: SpeedMultiple
m_SpeedParameter: AnimationSpeed
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:

+ 2
- 2
Assets/Data/Logic Blocks/Diagonal Left.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:9ec63e7f90a7facdb5a834a6de80a1d3a24eefad4e66edf48da4beeea8997828
size 797
oid sha256:f0a05826b5823f5f159f5b67277de6e24551a7e1a5cde6113c13371a117fe7ad
size 798

+ 2
- 2
Assets/Data/Logic Blocks/Diagonal Right.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:6148522c50f0cd5dc7d6ca8ea8a6b0fd461d82fa7ca2b018633eebd8e5fd6577
size 798
oid sha256:edf4b3bd5a1f10ecf8721fe4410092ee3e909e1e07c25c66f2b0b87012db8569
size 799

+ 2
- 2
Assets/Scripts/Character.cs View File

@ -191,7 +191,7 @@ public class Character : MonoBehaviour
transform.position = _startPos + Vector3.up * heightOffset(1); transform.position = _startPos + Vector3.up * heightOffset(1);
} }
private void StartAnimation(Animation animation,float speed = 1)
public void StartAnimation(Animation animation,float speed = 1)
{ {
characterAnimator.SetFloat("AnimationSpeed", (1 / speed)); characterAnimator.SetFloat("AnimationSpeed", (1 / speed));
@ -220,7 +220,7 @@ public class Character : MonoBehaviour
} }
} }
private void StopAnimation(Animation animation)
public void StopAnimation(Animation animation)
{ {
characterAnimator.SetFloat("AnimationSpeed", 1f); characterAnimator.SetFloat("AnimationSpeed", 1f);
switch (animation) switch (animation)

+ 11
- 5
Assets/Scripts/KeyboardInput.cs View File

@ -25,19 +25,25 @@ public class KeyboardInput : MonoBehaviour
if (Input.GetKeyDown(KeyCode.LeftArrow)) if (Input.GetKeyDown(KeyCode.LeftArrow))
{ {
character.Rotate(Direction.Left, characterSpeed);
StartCoroutine(character.RotateToDirection(Direction.Left, Character.Animation.Jump, characterSpeed, true));
} }
if (Input.GetKeyDown(KeyCode.RightArrow)) if (Input.GetKeyDown(KeyCode.RightArrow))
{ {
character.Rotate(Direction.Right, characterSpeed);
StartCoroutine(character.RotateToDirection(Direction.Right, Character.Animation.Jump, characterSpeed, true));
} }
if (Input.GetKeyDown(KeyCode.UpArrow)) if (Input.GetKeyDown(KeyCode.UpArrow))
{ {
character.Move(Direction.Forward, characterSpeed);
float outTime;
Move move = (Move)ScriptableObject.CreateInstance(typeof(Move));
move.Run(character, characterSpeed, out outTime);
Destroy(move);
} }
if (Input.GetKeyDown(KeyCode.Space)) if (Input.GetKeyDown(KeyCode.Space))
{ {
character.Jump(Direction.Forward, characterSpeed);
float outTime;
Jump jump = (Jump)ScriptableObject.CreateInstance(typeof(Jump));
jump.Run(character, characterSpeed, out outTime);
Destroy(jump);
} }
} }
@ -49,4 +55,4 @@ public class KeyboardInput : MonoBehaviour
} }
#endregion Unity Functions #endregion Unity Functions
}
}

+ 65
- 0
Assets/Scripts/LevelBlocks/Water.cs View File

@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Water : ActiveBlock
{
[SerializeField]
[Tooltip("GameObject which appears when character respawns")]
private GameObject lillyPad;
[SerializeField]
[Tooltip("Distance character will be submerged into the water")]
private float FallDistance = 0.5f;
private Character trappedCharacter;
public override void OnWalkedOnByPlayer(PlayerData player)
{
base.OnWalkedOnByPlayer(player);
if (trappedCharacter == null)
{
player.character = trappedCharacter;
trappedCharacter.stuck = true;
trappedCharacter.StartAnimation(Character.Animation.Hit);
StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition + Vector3.down * FallDistance, 1));
}
}
public override void OnRoundEnd(PlayerData[] allPlayers)
{
base.OnRoundEnd(allPlayers);
if (trappedCharacter != null)
{
StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition, 1));
StartCoroutine(LerpToPosition(lillyPad.transform, VisualPosition, 1));
trappedCharacter.stuck = false;
}
}
private IEnumerator LerpToPosition(Transform target, Vector3 endPos, float time)
{
Vector3 _startPos = target.position;
float elapsedTime = 0;
while (elapsedTime / time < 1)
{
target.position = Vector3.Lerp(_startPos, endPos, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
target.position = endPos;
}
}

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

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

Loading…
Cancel
Save