|
|
@ -69,9 +69,13 @@ public class Character : MonoBehaviour |
|
|
|
|
|
|
|
characterAnimator = GetComponentInChildren<Animator>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Update() |
|
|
|
{ |
|
|
|
if (lives < 1) |
|
|
|
{ |
|
|
|
this.enabled = false; |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion Unity Functions
|
|
|
|
|
|
|
|
#region Class Implementation
|
|
|
@ -305,7 +309,7 @@ public class Character : MonoBehaviour |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void conveyorMoveForward(Direction direction, float speed) |
|
|
|
public void conveyorMove(Direction direction, float speed) |
|
|
|
{ |
|
|
|
Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted
|
|
|
|
Block hit; //output of block detection
|
|
|
@ -318,43 +322,6 @@ public class Character : MonoBehaviour |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
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; |
|
|
@ -403,10 +370,10 @@ public class Character : MonoBehaviour |
|
|
|
Debug.Log("currentPos = " + currentPos.x + ", " + currentPos.y + ", " + currentPos.z); |
|
|
|
if (Block.isBlockAtPosition(currentPos, 1, ~Ignore, out currentBlock)) //Does a block exist here?
|
|
|
|
{ |
|
|
|
Debug.Log("Block exists"); |
|
|
|
//Debug.Log("Block exists");
|
|
|
|
if (currentBlock.isWalkable(~Ignore)) //If so, can we walk on it?
|
|
|
|
{ |
|
|
|
Debug.Log("Block is walkable"); |
|
|
|
//Debug.Log("Block is walkable");
|
|
|
|
//Don't yet have a check for whether it's occupied
|
|
|
|
break; //If it is, we stop here
|
|
|
|
} |
|
|
@ -417,10 +384,10 @@ public class Character : MonoBehaviour |
|
|
|
Debug.Log("currentPos = " + currentPos.x + ", " + currentPos.y + ", " + currentPos.z); |
|
|
|
if (Block.isBlockAtPosition(currentPos, 1, ~Ignore, out currentBlock)) //Does a block exist here?
|
|
|
|
{ |
|
|
|
Debug.Log("Block exists"); |
|
|
|
//Debug.Log("Block exists");
|
|
|
|
if (currentBlock.isWalkable(~Ignore)) //If so, can we walk on it?
|
|
|
|
{ |
|
|
|
Debug.Log("Block is walkable"); |
|
|
|
//Debug.Log("Block is walkable");
|
|
|
|
//Don't yet have a check for whether it's occupied
|
|
|
|
break; //If it is, we stop here
|
|
|
|
} |
|
|
@ -429,10 +396,10 @@ public class Character : MonoBehaviour |
|
|
|
Debug.Log("currentPos = " + currentPos.x + ", " + currentPos.y + ", " + currentPos.z); |
|
|
|
if (Block.isBlockAtPosition(currentPos, 1, ~Ignore, out currentBlock)) //Does a block exist here?
|
|
|
|
{ |
|
|
|
Debug.Log("Block exists"); |
|
|
|
//Debug.Log("Block exists");
|
|
|
|
if (currentBlock.isWalkable(~Ignore)) //If so, can we walk on it?
|
|
|
|
{ |
|
|
|
Debug.Log("Block is walkable"); |
|
|
|
//Debug.Log("Block is walkable");
|
|
|
|
//Don't yet have a check for whether it's occupied
|
|
|
|
break; //If it is, we stop here
|
|
|
|
} |
|
|
@ -448,11 +415,11 @@ public class Character : MonoBehaviour |
|
|
|
this.transform.position = currentBlock.VisualPosition; |
|
|
|
this.inPit = false; |
|
|
|
this._currentBlock = currentBlock; |
|
|
|
Debug.Log("Moved " + this.name + " to " |
|
|
|
/*Debug.Log("Moved " + this.name + " to " |
|
|
|
+ this.transform.position.x + ", " |
|
|
|
+ this.transform.position.y + ", " |
|
|
|
+ this.transform.position.z + ", " |
|
|
|
+ " inPit = " + inPit); |
|
|
|
+ " inPit = " + inPit);*/ |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|