Browse Source

Fixed Diagonal + added Wait

master
JoshuaReason 5 years ago
parent
commit
775e8b93ef
20 changed files with 157 additions and 25 deletions
  1. +2
    -2
      Assets/Data/Inventory/BaseInventory.asset
  2. +1
    -1
      Assets/Data/Logic Blocks/Diagonal L.asset
  3. +3
    -0
      Assets/Data/Logic Blocks/Rotate Half L.asset
  4. +8
    -0
      Assets/Data/Logic Blocks/Rotate Half L.asset.meta
  5. +3
    -0
      Assets/Data/Logic Blocks/Rotate Half R.asset
  6. +8
    -0
      Assets/Data/Logic Blocks/Rotate Half R.asset.meta
  7. +3
    -0
      Assets/Data/Logic Blocks/Wait.asset
  8. +8
    -0
      Assets/Data/Logic Blocks/Wait.asset.meta
  9. +1
    -1
      Assets/Models.meta
  10. +8
    -0
      Assets/Plugins.meta
  11. +8
    -0
      Assets/Plugins/IngameDebugConsole.meta
  12. +8
    -0
      Assets/Plugins/IngameDebugConsole/Android.meta
  13. +8
    -0
      Assets/Plugins/IngameDebugConsole/Prefabs.meta
  14. +8
    -0
      Assets/Plugins/IngameDebugConsole/Scripts.meta
  15. +8
    -0
      Assets/Plugins/IngameDebugConsole/Sprites.meta
  16. +8
    -0
      Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta
  17. +33
    -15
      Assets/Scripts/Character.cs
  18. +2
    -2
      Assets/Scripts/KeyboardInput.cs
  19. +21
    -4
      Assets/Scripts/Logic/Blocks/Rotate.cs
  20. +8
    -0
      Assets/Scripts/LogicBlocks.meta

+ 2
- 2
Assets/Data/Inventory/BaseInventory.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ffe4ea933ab9da92364324d81c2749faee272a1748758219ee2fa21b503e5044
size 1059
oid sha256:07fcd4acc0a169da62bb9e580f52c4c1002bb75840e34c8f645646d3101be1c7
size 1186

+ 1
- 1
Assets/Data/Logic Blocks/Diagonal L.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8ab0be1c04b5733f302cf6294b114f646c748d72a57b95620f0e4476e557d576
oid sha256:35b10cb1265be2f97a08ddbe4c1142651c6b98a2fcfe480b9ca91a5593a550bc
size 871

+ 3
- 0
Assets/Data/Logic Blocks/Rotate Half L.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ef1cf0fb60605b274187de1b9550192ca070e6dfce03cafaec0ad84292a0bebf
size 583

+ 8
- 0
Assets/Data/Logic Blocks/Rotate Half L.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 087b44b5a4243a04ca6cc76601a56c93
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/Data/Logic Blocks/Rotate Half R.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cb3ab44d98fbeb03c9b7e1d11c86619f2db347f2831c0014ebd5c048bc3f55b9
size 583

+ 8
- 0
Assets/Data/Logic Blocks/Rotate Half R.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 73853329caa830f4ca424d96ce58d589
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/Data/Logic Blocks/Wait.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6475a06eeda44fd342624dfe1b8a353fcbb2e3fe56665c4747e00928f3d2f670
size 574

+ 8
- 0
Assets/Data/Logic Blocks/Wait.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7efcab7b8763f334ebf47148baaf4f0c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Assets/Scripts/Components.meta → Assets/Models.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8d7394d70ec233849a60a26da5f23b75
guid: 296bd90e667df1f4697823a0aa45acf0
folderAsset: yes
DefaultImporter:
externalObjects: {}

+ 8
- 0
Assets/Plugins.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eb6762a6d45772b43a77849ba46f89db
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f8eae876be4b03438375a82d2c69b4d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole/Android.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3d7d7a61a5341904eb3c65af025b1d86
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole/Prefabs.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7dbc36665bc0d684db9a4447e27a7a4b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole/Scripts.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 860c08388401a6d4e858fe4910ea9337
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole/Sprites.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cb5d7b23a9e684a41a6a5d4f300eb1e6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f6caae32d463529478f2186f47c2e3fe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 33
- 15
Assets/Scripts/Character.cs View File

@ -134,17 +134,16 @@ public class Character : MonoBehaviour
public IEnumerator RotateToDirection(Direction direction, Animation animation, float time, bool isLocal = true)
public IEnumerator RotateInDirection(Direction direction,float angles, Animation animation, float time)
{
System.Func<float, float> yFunction = null;
if (animation == Animation.Jump)
yFunction = (t) => Mathf.Sin((Mathf.PI * t));
Vector3 _endDir = isLocal ? direction.ToVector(transform) : direction.ToVector();
StartAnimation(animation, time);
yield return StartCoroutine(LerpToRotation(_endDir, time * 0.8f, yFunction));
Debug.Log("Rotating by: " + angles);
yield return StartCoroutine(Rotate(direction,angles, time * 0.8f, yFunction));
StopAnimation(animation);
}
@ -158,6 +157,9 @@ public class Character : MonoBehaviour
Vector3 _newPos;
float elapsedTime = 0;
while (elapsedTime / time < 1)
{
@ -180,34 +182,50 @@ public class Character : MonoBehaviour
transform.position = _newPos;
}
private IEnumerator LerpToRotation(Vector3 target, float time, System.Func<float, float> heightOffset = null)
private IEnumerator Rotate(Direction direction, float angles, float time, System.Func<float, float> heightOffset = null)
{
Vector3 _startDir = transform.forward;
Vector3 _endDir = target;
int RotationDir = 0;
switch (direction)
{
case Direction.Forward:
RotationDir = 0;
break;
case Direction.Left:
RotationDir = -1;
break;
case Direction.Right:
RotationDir = 1;
break;
case Direction.Back:
RotationDir = 2;
break;
}
Vector3 _startPos = transform.position;
float elapsedTime = 0;
while (elapsedTime / time < 1)
{
float anglePerSecond = (angles * RotationDir) / time;
Vector3 _startPos = transform.position;
Vector3 startDirection = transform.forward;
transform.forward = Vector3.Slerp(_startDir, _endDir, (elapsedTime / time));
while (elapsedTime < time)
{
transform.Rotate(Vector3.up, anglePerSecond * Time.deltaTime);
if (heightOffset != null)
transform.position = _startPos + Vector3.up * heightOffset(elapsedTime / time);
transform.position = _startPos + Vector3.up * heightOffset(elapsedTime / time);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.forward = target;
transform.forward = Quaternion.AngleAxis(angles * RotationDir, Vector3.up) * startDirection;
if (heightOffset != null)
transform.position = _startPos + Vector3.up * heightOffset(1);
}
public IEnumerator AnimateToPosition(Vector3 position, Animation animation, float time)
{
System.Func<float, float> yFunction = null;

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

@ -25,11 +25,11 @@ public class KeyboardInput : MonoBehaviour
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
StartCoroutine(character.RotateToDirection(Direction.Left, Character.Animation.Jump, characterSpeed, true));
StartCoroutine(character.RotateInDirection(Direction.Left,90, Character.Animation.Jump, characterSpeed));
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
StartCoroutine(character.RotateToDirection(Direction.Right, Character.Animation.Jump, characterSpeed, true));
StartCoroutine(character.RotateInDirection(Direction.Right, 90, Character.Animation.Jump, characterSpeed));
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{

+ 21
- 4
Assets/Scripts/Logic/Blocks/Rotate.cs View File

@ -14,6 +14,10 @@ public class Rotate : LogicBlock
[Header("Rotate Settings")]
[Tooltip("Direction to rotate in")]
protected Direction direction;
[SerializeField]
[Tooltip("Angle in Degrees")]
protected int Angle = 90;
#endregion Inspector Fields
@ -27,7 +31,8 @@ public class Rotate : LogicBlock
{
//player.Rotate(direction, animationTime);
yield return player.StartCoroutine(player.RotateToDirection(direction, Character.Animation.Jump, animationTime, true));
Debug.Log("Rotating by: " + Angle);
yield return player.StartCoroutine(player.RotateInDirection(direction,Angle, Character.Animation.Jump, animationTime));
}
/// <summary>
@ -45,19 +50,31 @@ public class Rotate : LogicBlock
public override void CopyToken(BlockToken token)
{
base.CopyToken(token);
direction = ((DirectionToken)token).direction;
direction = ((RotateToken)token).direction;
Angle = ((RotateToken)token).angle;
}
public override BlockToken ToToken(BlockToken token = null)
{
if (token == null)
token = new DirectionToken(this);
token = new RotateToken(this);
DirectionToken retVal = (DirectionToken)base.ToToken(token);
RotateToken retVal = (RotateToken)base.ToToken(token);
retVal.direction = direction;
retVal.angle = Angle;
return retVal;
}
#endregion Class Functions
}
[System.Serializable]
public class RotateToken : BlockToken
{
public Direction direction;
public int angle;
public RotateToken(LogicBlock block) : base(block) { }
}

+ 8
- 0
Assets/Scripts/LogicBlocks.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8936b441d7647f74884c94f97bfb8931
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save