Browse Source

Fixed cannon so we aren't waiting for it. Started to add hook shot.

master
Joshua Reason 4 years ago
parent
commit
186a1dd634
21 changed files with 4419 additions and 1735 deletions
  1. +3
    -0
      Assets/Data/Logic Blocks/Hook Shot.asset
  2. +3
    -3
      Assets/Data/Logic Blocks/Hook Shot.asset.meta
  3. +0
    -8
      Assets/Plugins/IngameDebugConsole/Scripts.meta
  4. +0
    -8
      Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta
  5. +2
    -0
      Assets/Prefabs/Blocks/Cube_Water.prefab
  6. +15
    -15
      Assets/Prefabs/Map Sections/Map Section Template.prefab
  7. +3925
    -1181
      Assets/Prefabs/Map Sections/Start 4-player.prefab
  8. +8
    -1
      Assets/Prefabs/Traps/ShootingCannon.prefab
  9. +46
    -0
      Assets/Resources/Cube_Air.prefab
  10. +2
    -3
      Assets/Resources/Cube_Air.prefab.meta
  11. +58
    -423
      Assets/Scripts/Character.cs
  12. +1
    -1
      Assets/Scripts/Components.meta
  13. +64
    -0
      Assets/Scripts/LevelBlocks/Air.cs
  14. +11
    -0
      Assets/Scripts/LevelBlocks/Air.cs.meta
  15. +18
    -0
      Assets/Scripts/LevelBlocks/Block.cs
  16. +100
    -0
      Assets/Scripts/Logic/Blocks/Lasso.cs
  17. +11
    -0
      Assets/Scripts/Logic/Blocks/Lasso.cs.meta
  18. +0
    -8
      Assets/Scripts/LogicBlocks.meta
  19. +4
    -1
      Assets/Scripts/Managers/GameManager.cs
  20. +74
    -74
      Assets/Scripts/Traps/CannonShot.cs
  21. +74
    -9
      Assets/Scripts/Traps/ShootingCannon.cs

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

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

Assets/Plugins/IngameDebugConsole/Prefabs.meta → Assets/Data/Logic Blocks/Hook Shot.asset.meta View File

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

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

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

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

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

+ 2
- 0
Assets/Prefabs/Blocks/Cube_Water.prefab View File

@ -173,6 +173,8 @@ MonoBehaviour:
is_Walkable: 1
isWater: 0
isPit: 0
isCrystals: 0
isRock: 0
isSpawnable: 0
SpawnDirection: 2
lillyPad: {fileID: 530235143574139110}

+ 15
- 15
Assets/Prefabs/Map Sections/Map Section Template.prefab View File

@ -795,6 +795,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3264658026752372929}
m_Modifications:
- target: {fileID: 6179448856766749154, guid: 72b0336b2f8509045b92eadaecbc885b,
type: 3}
propertyPath: m_Name
value: ShootingCannon + Block
objectReference: {fileID: 0}
- target: {fileID: 6179448856766749153, guid: 72b0336b2f8509045b92eadaecbc885b,
type: 3}
propertyPath: m_LocalPosition.x
@ -850,11 +855,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6179448856766749154, guid: 72b0336b2f8509045b92eadaecbc885b,
type: 3}
propertyPath: m_Name
value: ShootingCannon + Block
objectReference: {fileID: 0}
- target: {fileID: 7559508468311915790, guid: 72b0336b2f8509045b92eadaecbc885b,
type: 3}
propertyPath: m_Mesh
@ -885,6 +885,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 7525176871745234139}
m_Modifications:
- target: {fileID: 6745622317302131141, guid: 26e034cbe9690f14a87e8365ee7734f1,
type: 3}
propertyPath: m_Name
value: CrushingBoulder
objectReference: {fileID: 0}
- target: {fileID: 6745622317302131140, guid: 26e034cbe9690f14a87e8365ee7734f1,
type: 3}
propertyPath: m_LocalPosition.x
@ -940,11 +945,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6745622317302131141, guid: 26e034cbe9690f14a87e8365ee7734f1,
type: 3}
propertyPath: m_Name
value: CrushingBoulder
objectReference: {fileID: 0}
- target: {fileID: 6745622315908332753, guid: 26e034cbe9690f14a87e8365ee7734f1,
type: 3}
propertyPath: m_Mesh
@ -975,6 +975,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 3733143707459234553}
m_Modifications:
- target: {fileID: 9119206199061355249, guid: 9c7fae64659c0ef42ad2fe9b386e8ef9,
type: 3}
propertyPath: m_Name
value: CubeWithCrystals
objectReference: {fileID: 0}
- target: {fileID: 9119206199061355250, guid: 9c7fae64659c0ef42ad2fe9b386e8ef9,
type: 3}
propertyPath: m_LocalPosition.x
@ -1030,11 +1035,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9119206199061355249, guid: 9c7fae64659c0ef42ad2fe9b386e8ef9,
type: 3}
propertyPath: m_Name
value: CubeWithCrystals
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9c7fae64659c0ef42ad2fe9b386e8ef9, type: 3}
--- !u!4 &968667811583345056 stripped

+ 3925
- 1181
Assets/Prefabs/Map Sections/Start 4-player.prefab
File diff suppressed because it is too large
View File


+ 8
- 1
Assets/Prefabs/Traps/ShootingCannon.prefab View File

@ -253,8 +253,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 44366bd8a25270844bdd9a5db9f2b0e0, type: 3}
m_Name:
m_EditorClassIdentifier:
VisualOffset: {x: 0, y: 0, z: 0}
is_Walkable: 1
isWater: 0
isPit: 0
isCrystals: 0
isRock: 0
isSpawnable: 0
SpawnDirection: 2
shootingRight: 1
triggeranimate: 0
shootingObject: {fileID: 3506936643819969965, guid: e8cf547bc36bd094f860f652fbe08047,
type: 3}
spawnLocation: {fileID: 4411312180479633393}

+ 46
- 0
Assets/Resources/Cube_Air.prefab View File

@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1999421548732318256
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 47964057}
- component: {fileID: 6650162365135615188}
m_Layer: 0
m_Name: Cube_Air
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &47964057
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1999421548732318256}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -12, y: -0.5, z: 1.9999998}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &6650162365135615188
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1999421548732318256}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}

Assets/Plugins/IngameDebugConsole/Android.meta → Assets/Resources/Cube_Air.prefab.meta View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 3d7d7a61a5341904eb3c65af025b1d86
folderAsset: yes
DefaultImporter:
guid: b80ae9361b2fa0247bc25856d48b2c3d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:

+ 58
- 423
Assets/Scripts/Character.cs View File

@ -151,83 +151,7 @@ public class Character : MonoBehaviour
StopAnimation(animation);
}
private IEnumerator LerpToBlock(Vector3 target, float time, System.Func<float, float> heightOffset = null)
{
Vector3 _startPos = transform.position;
Vector3 _endPos = target;
Vector3 _newPos;
float elapsedTime = 0;
while (elapsedTime / time < 1)
{
_newPos = Vector3.Lerp(_startPos, _endPos, (elapsedTime / time));
if (heightOffset != null)
_newPos.y += heightOffset(elapsedTime / time);
transform.position = _newPos;
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
_newPos = _endPos;
if (heightOffset != null)
_newPos.y += heightOffset(1);
transform.position = _newPos;
}
private IEnumerator Rotate(Direction direction, float angles, float time, System.Func<float, float> heightOffset = null)
{
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;
}
lastRotation = angles * RotationDir;
float elapsedTime = 0;
float anglePerSecond = (angles * RotationDir) / time;
Vector3 _startPos = transform.position;
Vector3 startDirection = transform.forward;
while (elapsedTime < time)
{
transform.Rotate(Vector3.up, anglePerSecond * Time.deltaTime);
if (heightOffset != null)
transform.position = _startPos + Vector3.up * heightOffset(elapsedTime / time);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
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)
@ -289,8 +213,12 @@ public class Character : MonoBehaviour
}
}
public void respawnCharacter()
{
respawnCharacter(CurrentBlock.position);
}
public void respawnCharacter(Vector3 respawnPosition)
{
/* Will introduce more complex criteria for choosing where to respawn the player in future
* For now: if the square one back (x =- 1) from the pit is walkable and unoccupied, then put them there
@ -299,7 +227,7 @@ public class Character : MonoBehaviour
Block currentBlock = null;
//We start from the position of our pit, at ground level
Vector3 currentPos = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
Vector3 currentPos = respawnPosition;
Debug.Log("Commencing respawn");
@ -395,386 +323,93 @@ public class Character : MonoBehaviour
}
}
/// <summary>
/// Rotates to point in specific direction based on current direction
/// </summary>
/// <param name="direction">Local direction to point</param>
public void Rotate(Direction direction, float speed)
{
StartCoroutine(rotateCoroutine(direction, transform, speed, 0.15f));
//transform.forward = direction.ToVector(transform);
}
public void RotateHalf(Direction direction, float speed)
{
StartCoroutine(rotateHalfCoroutine(direction, transform, speed, 0.15f));
//transform.forward = direction.ToVector(transform);
}
/// <summary>
/// Jumps in specefied direction, picks between Long Jump and Jumping up
/// </summary>
/// <param name="direction">Direction to Jump</param>
public void Jump(Direction direction, float speed)
{
//if there is a block infront JumpUp else LongJump
if (Block.isBlockAtPosition(_currentBlock.position + direction.ToVector(transform) + Vector3.up, 1, ~Ignore))
JumpUp(direction, speed);
else
JumpLong(direction, speed);
}
#endregion Class Implementation
#region Private Functions
/// <summary>
/// Jumps up obstacle of specific height. Jumps as high as possible
/// </summary>
/// <param name="direction">Direction of obstacle</param>
/// <param name="height">max height</param>
private void JumpUp(Direction direction, float speed, int height = 1)
private IEnumerator LerpToBlock(Vector3 target, float time, System.Func<float, float> heightOffset = null)
{
//setting up variables
Vector3 position; // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
//Check blocks in going up then move to the heighest walkable one
for (int i = 0; i <= height; i++)
{
//next position up the tower
position = _currentBlock.position + direction.ToVector(transform) + (Vector3.up * i);
//if block is walkable set it to last known position
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
moveTo = hit;
}
//set current block && move
_currentBlock = moveTo;
StartCoroutine(JumpCoroutine(_currentBlock, transform, speed, 0.5f));
//transform.position = CurrentBlock.VisualPosition;
}
Vector3 _startPos = transform.position;
Vector3 _endPos = target;
/// <summary>
/// Long jumps forward a specified distance. Can Jump gaps. Stops at obstruction
/// </summary>
/// <param name="direction">Direction to Jump</param>
/// <param name="Distance">Max distance</param>
private void JumpLong(Direction direction, float speed, int Distance = 2)
{
//setting up variables
Vector3 position; // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
Vector3 _newPos;
//Check blocks in front until we hit an obstruction or went the distance
for (int i = 1; i <= Distance; i++)
{
//Next position to MoveTo
position = _currentBlock.position + (direction.ToVector(transform) * i);
float elapsedTime = 0;
//if jump is obstructed, stop and go to last known block
if (Block.isBlockAtPosition(position + Vector3.up, 1, ~Ignore))
break;
//If block at Position is walkable set it to last known position
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
moveTo = hit;
//else if block down one is walkable
else if (Block.isBlockAtPosition(position + Vector3.down, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
moveTo = hit;
while (elapsedTime / time < 1)
{
}//end for
_newPos = Vector3.Lerp(_startPos, _endPos, (elapsedTime / time));
//Set Current Block and move
_currentBlock = moveTo;
StartCoroutine(JumpCoroutine(_currentBlock, transform, speed, 0.5f));
//transform.position = CurrentBlock.VisualPosition;
}
if (heightOffset != null)
_newPos.y += heightOffset(elapsedTime / time);
#endregion Private Functions
transform.position = _newPos;
#region Depricated
IEnumerator JumpCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
time *= 0.8f;
characterAnimator.Play("Jump Inplace");
yield return new WaitForSeconds(0.15f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, Target.VisualPosition, (elapsedTime / time));
//transform.position += yValue((elapsedTime / time), heightMax);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = Target.VisualPosition;
}
IEnumerator MoveCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
time *= 0.8f;
characterAnimator.Play("Walk");
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, Target.VisualPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = Target.VisualPosition;
}
IEnumerator MoveConveyorForwardCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 charEndPosition = new Vector3(Current.position.x + 1.0f, Current.position.y, Current.position.z);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, charEndPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = charEndPosition;
}
IEnumerator MoveConveyorBackwardCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 charEndPosition = new Vector3(Current.position.x - 1.0f, Current.position.y, Current.position.z);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, charEndPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = charEndPosition;
}
IEnumerator MoveConveyorLeftCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 charEndPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, charEndPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = charEndPosition;
}
IEnumerator MoveConveyorRightCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
Vector3 charEndPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, charEndPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = charEndPosition;
}
IEnumerator PushLeftCoroutine(Transform Current, float time)
{
float elapsedTime = 0;
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = endPosition;
}
IEnumerator PushRightCoroutine(Transform Current, float time)
{
float elapsedTime = 0;
Vector3 startPosition = Current.transform.position;
Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
Current.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
Current.position = endPosition;
}
IEnumerator MoveDownCoroutine(Block Target, Transform Current, float time, float heightMax)
{
float elapsedTime = 0;
Vector3 startPosition = Current.position;
time *= 0.8f;
characterAnimator.Play("Walk");
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, Target.VisualPosition, (elapsedTime / time));
//transform.position += yValue((elapsedTime / time), heightMax);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = Target.VisualPosition;
_newPos = _endPos;
if (heightOffset != null)
_newPos.y += heightOffset(1);
transform.position = _newPos;
}
IEnumerator rotateCoroutine(Direction direction, Transform Current, float time, float heightMax)
private IEnumerator Rotate(Direction direction, float angles, float time, System.Func<float, float> heightOffset = null)
{
float elapsedTime = 0;
time *= 0.8f;
Vector3 endDirection = direction.ToVector(Current);
Vector3 startDirection = Current.forward;
while (elapsedTime < time)
int RotationDir = 0;
switch (direction)
{
characterAnimator.Play("Jump");
transform.forward = Vector3.Slerp(startDirection, endDirection, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
case Direction.Forward:
RotationDir = 0;
break;
case Direction.Left:
RotationDir = -1;
break;
case Direction.Right:
RotationDir = 1;
break;
case Direction.Back:
RotationDir = 2;
break;
}
transform.forward = endDirection;
}
IEnumerator rotateHalfCoroutine(Direction direction, Transform Current, float time, float heightMax)
{
lastRotation = angles * RotationDir;
float elapsedTime = 0;
time *= 0.8f;
Vector3 endDirection = (direction.ToVector(Current) + Current.forward).normalized;
Vector3 startDirection = Current.forward;
float anglePerSecond = (angles * RotationDir) / time;
Vector3 _startPos = transform.position;
Vector3 startDirection = transform.forward;
while (elapsedTime < time)
{
characterAnimator.Play("Jump");
transform.forward = Vector3.Slerp(startDirection, endDirection, (elapsedTime / time));
transform.Rotate(Vector3.up, anglePerSecond * Time.deltaTime);
if (heightOffset != null)
transform.position = _startPos + Vector3.up * heightOffset(elapsedTime / time);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.forward = endDirection;
}
/// <summary>
/// Moves one block in specefied direction, Can walk off obstacles
/// </summary>
/// <param name="direction">direction to walk</param>
/// <remarks>Technically is same as JumpLong(1) but kept seperate to avoid confusion</remarks>
public void Move(Direction direction, float speed)
{
//setting up variables
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
//if move is obstucted no where to move
if (Block.isBlockAtPosition(position + Vector3.up, 1, ~Ignore))
return;
//If block at Position is walkable set it to moveTo
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveCoroutine(_currentBlock, transform, speed, 0.3f));
}
//else if block down one is walkable
else if (Block.isBlockAtPosition(position + Vector3.down, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveDownCoroutine(_currentBlock, transform, speed, 0.3f));
}
transform.forward = Quaternion.AngleAxis(angles * RotationDir, Vector3.up) * startDirection;
if (heightOffset != null)
transform.position = _startPos + Vector3.up * heightOffset(1);
}
public void conveyorMoveForward(Direction direction, float speed)
{
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorForwardCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveBackward(Direction direction, float speed)
{
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorBackwardCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveLeft(Direction direction, float speed)
{
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorLeftCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void conveyorMoveRight(Direction direction, float speed)
{
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(MoveConveyorRightCoroutine(_currentBlock, transform, speed, 0.3f));
}
}
public void CannonRMove(float speed)
{
Direction direction = Direction.Right;
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(PushRightCoroutine(transform, speed));
}
}
public void CannonLMove(float speed)
{
Direction direction = Direction.Left;
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
Block hit; //output of block detection
Block moveTo = _currentBlock; //block we'll actually move to
if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
{
moveTo = hit;
_currentBlock = moveTo;
StartCoroutine(PushLeftCoroutine(transform, speed));
}
}
#endregion Private Functions
#endregion Depricated
}

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

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

+ 64
- 0
Assets/Scripts/LevelBlocks/Air.cs View File

@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Air : ActiveBlock
{
private List<Character> FallenPlayers = new List<Character>();
public override int GetInitative()
{
return -1;
}
public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
{
player.stuck = true;
FallenPlayers.Add(player);
StartCoroutine(player.AnimateToPosition(transform.position + Vector3.down * 10,Character.Animation.Hit, 1));
StartCoroutine(LerpScale(player.transform, Vector3.zero, 1));
yield return new WaitForSeconds(1);
player.gameObject.SetActive(false);
player.transform.localScale = Vector3.one;
isFinished = true;
}
public override IEnumerator OnRoundEnd(PlayerData[] allPlayers)
{
foreach (Character player in FallenPlayers)
{
player.gameObject.SetActive(true);
player.respawnCharacter(transform.position);
}
FallenPlayers.Clear();
isFinished = true;
Destroy(gameObject);
yield break;
}
private IEnumerator LerpScale(Transform target, Vector3 endScale, float time)
{
Vector3 startScale = target.localScale;
float elapsedTime = 0;
while(elapsedTime < time)
{
target.localScale = Vector3.Slerp(startScale, endScale, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
target.localScale = endScale;
}
}

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

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

+ 18
- 0
Assets/Scripts/LevelBlocks/Block.cs View File

@ -229,6 +229,24 @@ public class Block : MonoBehaviour
return (isBlockAtPosition(position, scale, layerMask, out hit));
}
/// <summary>
/// Gets the block at a position or creates an airblock if there isn't one there
/// </summary>
/// <param name="position">position to get block at</param>
/// <param name="Scale">Scale of block. (should be 1)</param>
/// <param name="layerMask">Layers to check on</param>
/// <returns>block at position</returns>
public static Block GetOrCreateBlockAtPosition(Vector3 position, float Scale, LayerMask layerMask)
{
Block retVal;
if (isBlockAtPosition(position, Scale, layerMask, out retVal))
return retVal;
GameObject newBlock = Resources.Load<GameObject>("Cube_Air");
newBlock.transform.position = position;
return newBlock.GetComponent<Air>();
}
#endregion
}

+ 100
- 0
Assets/Scripts/Logic/Blocks/Lasso.cs View File

@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Major Project/Pick Ups/Lasso Block")]
[System.Serializable]
public class Lasso : LogicBlock
{
[SerializeField]
[Header("Max distance checked before returning")]
private int MaxDistance = 30;
[SerializeField]
[Header("Direction to shoot in")]
private Direction Direction;
[SerializeField]
private GameObject ShotPrefab;
[SerializeField]
private float ShotSpeed = 1;
public override Block GetEndBlock(Block startBlock, Transform transform, LayerMask layerMask)
{
//setting up variables
Vector3 position; // position wanted
Block hit; //output of block detection
Block retVal = startBlock; //block we'll actually move to
//Check blocks in front until we hit an obstruction or went the distance
for (int i = 1; i <= MaxDistance; i++)
{
//Next position to MoveTo
position = startBlock.position + (Direction.ToVector(transform) * i);
//if hit player return block they are standing on
if (Block.isBlockAtPosition(position, 1, layerMask, out hit)) {
if (hit.CurrentPlayer != null)
return hit;
}
//if block block paths return block infront of it
if (Block.isBlockAtPosition(position + Vector3.up,1,layerMask))
{
return Block.GetOrCreateBlockAtPosition(position - Direction.ToVector(transform), 1, layerMask);
}
}
return retVal;
}
protected override IEnumerator BlockLogic(Character player, float animationTime, bool useBlockDirection = false)
{
Block hitBlock = GetEndBlock(player.CurrentBlock, player.transform, ~player.Ignore);
Debug.Log("hookshot: " + hitBlock.position, hitBlock.gameObject);
if (hitBlock == player.CurrentBlock)
yield break;
Debug.Log("Instantiating shot");
GameObject shot = GameObject.CreatePrimitive(PrimitiveType.Sphere);
shot.transform.localScale = Vector3.one * 0.33f;
yield return player.StartCoroutine(lerpShot(shot.transform, player.transform.position, hitBlock.VisualPosition,ShotSpeed));
Destroy(shot);
if (hitBlock.CurrentPlayer != null)
{
Block pullBlock = Block.GetOrCreateBlockAtPosition(player.CurrentBlock.position + Direction.ToVector(player.transform), 1, ~player.Ignore);
yield return player.StartCoroutine(hitBlock.CurrentPlayer.MoveToBlock(pullBlock, Character.Animation.Hit, ShotSpeed));
}
else
{
yield return player.StartCoroutine(player.MoveToBlock(hitBlock, Character.Animation.Jump, ShotSpeed));
}
}
private IEnumerator lerpShot(Transform target, Vector3 startPosition,Vector3 endPosition, float time)
{
float elapsedTime = 0;
while (elapsedTime < time)
{
target.transform.position = Vector3.Lerp(startPosition, endPosition, elapsedTime / time);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
target.position = endPosition;
}
}

+ 11
- 0
Assets/Scripts/Logic/Blocks/Lasso.cs.meta View File

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

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

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

+ 4
- 1
Assets/Scripts/Managers/GameManager.cs View File

@ -142,7 +142,10 @@ public class GameManager : MonoBehaviour
//Let Gamemode know all players have moved
gameMode.AllPlayersMoved(playerDataAsArray);
//I hate having to do this
EnvironmentBlocks = FindObjectsOfType<ActiveBlock>();
//Let the environment take a turn
yield return StartCoroutine(EnvironmentTurn());
gameMode.EnvironmentTurn(playerDataAsArray);

+ 74
- 74
Assets/Scripts/Traps/CannonShot.cs View File

@ -3,77 +3,77 @@ using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
public class CannonShot : MonoBehaviour
{
public bool shootingRight;
public ConnectedClients clientData;
GameObject player;
string charname;
public List<string> Names;
Rigidbody rb;
private void Start()
{
rb = this.gameObject.GetComponent<Rigidbody>();
for (int i = 0; i < clientData.AllClients.Count; i++)
{
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
}
}
IEnumerator PushLeftCoroutine(float time)
{
float elapsedTime = 0;
Vector3 startPosition = transform.position;
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = endPosition;
Destroy(gameObject);
}
IEnumerator PushRightCoroutine(float time)
{
float elapsedTime = 0;
Vector3 startPosition = transform.position;
Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f);
time *= 0.8f;
yield return new WaitForSeconds(0.05f);
while (elapsedTime < time)
{
transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = endPosition;
Destroy(gameObject);
}
void OnTriggerEnter(Collider other)
{
foreach (string name in Names)
{
if (other.gameObject.name == name)
{
rb.velocity = Vector3.zero;
player = GameObject.Find(charname);
Rigidbody playerRB = player.GetComponent<Rigidbody>();
if (shootingRight == true)
{
StartCoroutine(PushRightCoroutine(0.5f));
player.GetComponent<Character>().CannonRMove(0.5f);
}
else
{
StartCoroutine(PushLeftCoroutine(0.5f));
player.GetComponent<Character>().CannonLMove(0.5f);
}
}
}
}
}
//public class CannonShot : MonoBehaviour
//{
// public bool shootingRight;
// public ConnectedClients clientData;
// GameObject player;
// string charname;
// public List<string> Names;
// Rigidbody rb;
//
// private void Start()
// {
// rb = this.gameObject.GetComponent<Rigidbody>();
// for (int i = 0; i < clientData.AllClients.Count; i++)
// {
// Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
// }
// }
//
// IEnumerator PushLeftCoroutine(float time)
// {
// float elapsedTime = 0;
// Vector3 startPosition = transform.position;
// Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f);
// time *= 0.8f;
// yield return new WaitForSeconds(0.05f);
// while (elapsedTime < time)
// {
// transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
// yield return new WaitForEndOfFrame();
// elapsedTime += Time.deltaTime;
// }
// transform.position = endPosition;
// Destroy(gameObject);
// }
// IEnumerator PushRightCoroutine(float time)
// {
// float elapsedTime = 0;
// Vector3 startPosition = transform.position;
// Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f);
// time *= 0.8f;
// yield return new WaitForSeconds(0.05f);
// while (elapsedTime < time)
// {
// transform.position = Vector3.Lerp(startPosition, endPosition, (elapsedTime / time));
// yield return new WaitForEndOfFrame();
// elapsedTime += Time.deltaTime;
// }
// transform.position = endPosition;
// Destroy(gameObject);
// }
//
// void OnTriggerEnter(Collider other)
// {
// foreach (string name in Names)
// {
// if (other.gameObject.name == name)
// {
// rb.velocity = Vector3.zero;
// player = GameObject.Find(charname);
// Rigidbody playerRB = player.GetComponent<Rigidbody>();
// if (shootingRight == true)
// {
// StartCoroutine(PushRightCoroutine(0.5f));
// player.GetComponent<Character>().CannonRMove(0.5f);
// }
// else
// {
// StartCoroutine(PushLeftCoroutine(0.5f));
// player.GetComponent<Character>().CannonLMove(0.5f);
// }
// }
// }
// }
//}

+ 74
- 9
Assets/Scripts/Traps/ShootingCannon.cs View File

@ -6,6 +6,7 @@ using UnityEngine;
public class ShootingCannon : ActiveBlock
{
[Header("Cannon Settings")]
public bool shootingRight;
public GameObject shootingObject;
public Transform spawnLocation;
@ -30,18 +31,82 @@ public class ShootingCannon : ActiveBlock
public override IEnumerator OnEnvironmentTurn(PlayerData[] allPlayers)
{
countdown--;
if (countdown == 0)
if (countdown > 0)
{
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity);
if (shootingRight == true){
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500);
}else{
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500);
}
countdown = countdowntimer;
countdown--;
isFinished = true;
yield break;
}
countdown = countdowntimer;
Vector3 bulletPosition;
Character[] hitPlayers = getHitPlayers(out bulletPosition);
foreach (Character player in hitPlayers)
{
Vector3 moveToPosition = player.CurrentBlock.position + transform.forward;
Block moveToBlock = Block.GetOrCreateBlockAtPosition(moveToPosition, 1, ~0);
StartCoroutine(player.MoveToBlock(moveToBlock, Character.Animation.Hit, 1));
}
StartCoroutine(lerpShot(bulletPosition, Vector3.Distance(spawnLocation.position,bulletPosition)/15));
if (hitPlayers.Length > 0)
yield return new WaitForSeconds(1.5f);
isFinished = true;
yield break;
}
private Character[] getHitPlayers(out Vector3 endPosition)
{
Vector3 curPos;
List<Character> retVal = new List<Character>();
Block hit;
endPosition = position + Vector3.up;
for (int i = 1; i < 50; i++)
{
curPos = position + (transform.forward * i);
endPosition = curPos + Vector3.one; //position which bullet will stop at
if (Block.isBlockAtPosition(curPos, 1, ~0, out hit))
{
if (hit.CurrentPlayer != null)
retVal.Add(hit.CurrentPlayer);
}
//this will stop the bullet
if (Block.isBlockAtPosition(curPos + Vector3.up, 1, ~0))
break;
}//end forloop
return retVal.ToArray();
}
private IEnumerator lerpShot(Vector3 endPosition, float time)
{
GameObject shot = Instantiate(shootingObject, spawnLocation.position, spawnLocation.rotation);
Vector3 startPosition = spawnLocation.position;
float elapsedTime = 0;
while(elapsedTime < time)
{
shot.transform.position = Vector3.Lerp(startPosition, endPosition, elapsedTime / time);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
//reset
Destroy(shot);
}
}

Loading…
Cancel
Save