diff --git a/Assets/Scripts/Components.meta b/Assets/Models.meta
similarity index 77%
rename from Assets/Scripts/Components.meta
rename to Assets/Models.meta
index 5a95b09..5346456 100644
--- a/Assets/Scripts/Components.meta
+++ b/Assets/Models.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 8d7394d70ec233849a60a26da5f23b75
+guid: 296bd90e667df1f4697823a0aa45acf0
folderAsset: yes
DefaultImporter:
externalObjects: {}
diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Plugins/IngameDebugConsole/Android.meta
new file mode 100644
index 0000000..12049b6
--- /dev/null
+++ b/Assets/Plugins/IngameDebugConsole/Android.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3d7d7a61a5341904eb3c65af025b1d86
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta
new file mode 100644
index 0000000..6aa8bf2
--- /dev/null
+++ b/Assets/Plugins/IngameDebugConsole/Prefabs.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7dbc36665bc0d684db9a4447e27a7a4b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta
new file mode 100644
index 0000000..72dcaac
--- /dev/null
+++ b/Assets/Plugins/IngameDebugConsole/Scripts.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 860c08388401a6d4e858fe4910ea9337
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta
new file mode 100644
index 0000000..f3769b1
--- /dev/null
+++ b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f6caae32d463529478f2186f47c2e3fe
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs
index 8943cee..7156348 100644
--- a/Assets/Scripts/Character.cs
+++ b/Assets/Scripts/Character.cs
@@ -103,7 +103,7 @@ public class Character : MonoBehaviour
public IEnumerator MoveToBlock(Block target, Animation animation, float time)
{
- Block oldBlock = _currentBlock;
+ Vector3 moveDirection = Vector3.ProjectOnPlane(target.position - _currentBlock.position, Vector3.up).normalized;
_currentBlock.OnLeftByPlayer(this);
@@ -116,10 +116,7 @@ public class Character : MonoBehaviour
yield return StartCoroutine(LerpToBlock(target.VisualPosition, time, yFunction));
_currentBlock= target;
- _currentBlock.OnWalkedOnByPlayer(this);
-
- yield return StartCoroutine(DoPush(oldBlock,_currentBlock, time));
-
+ yield return StartCoroutine (_currentBlock.OnWalkedOnByPlayer(this,moveDirection));
StopAnimation(animation);
}
@@ -197,49 +194,6 @@ public class Character : MonoBehaviour
transform.position = _startPos + Vector3.up * heightOffset(1);
}
- public IEnumerator DoPush(Block lastBlock, Block currentBlock, float animationTime)
- {
- //Direction player moved in ignoring Y value
- Vector3 pushDirection = Vector3.ProjectOnPlane(currentBlock.position - lastBlock.position, Vector3.up).normalized;
-
- foreach(Character character in _currentBlock.GetPushablePlayers())
- {
- if (character == this)
- continue;
-
- yield return StartCoroutine(character.GetPushed(pushDirection));
- }
- }
-
- public IEnumerator GetPushed(Vector3 direction)
- {
- yield return null;
- }
-
- private Block getPushLocation(Vector3 pushDirection)
- {
- //setting up variables
- Vector3 position = _currentBlock.position + pushDirection; // position wanted
- Block hit; //output of block detection
-
- //if move is obstucted no where to move
- if (Block.isBlockAtPosition(position + Vector3.up, 1, ~Ignore))
- return _currentBlock;
-
-
- //If block at Position is walkable set it to moveTo
- if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
- {
- return hit;
- }
- //else if block down one is walkable
- else if (Block.isBlockAtPosition(position + Vector3.down, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore))
- {
- return hit;
- }
- return _currentBlock;
- }
-
public void StartAnimation(Animation animation,float speed = 1)
{
characterAnimator.SetFloat("AnimationSpeed", (1 / speed));
diff --git a/Assets/Scripts/LevelBlocks/Block.cs b/Assets/Scripts/LevelBlocks/Block.cs
index 1d1c834..5e3d4c7 100644
--- a/Assets/Scripts/LevelBlocks/Block.cs
+++ b/Assets/Scripts/LevelBlocks/Block.cs
@@ -37,7 +37,7 @@ public class Block : MonoBehaviour
///
/// List of current players on this block
///
- protected List currentPlayers = new List();
+ protected Character currentPlayer;
#endregion Private Functions
#region ReadOnly Properties
@@ -71,9 +71,10 @@ public class Block : MonoBehaviour
/// Should be implemented by a derived class
///
/// Player which moved on to block
- public virtual void OnWalkedOnByPlayer(Character player)
+ ///The direction the player moved to get to this block
+ public virtual IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
{
- currentPlayers.Add(player);
+ yield return StartCoroutine(DoPush(player, moveDirection));
}
///
@@ -84,22 +85,69 @@ public class Block : MonoBehaviour
/// Player which moved on to block
public virtual void OnLeftByPlayer(Character player)
{
- currentPlayers.Remove(player);
+ currentPlayer = null;
}
///
- /// Returns an array of players who can be pushed off this block
+ /// Called to deal with players colliding on this block
///
- /// array of players who can be pushed off this block
- public virtual Character[] GetPushablePlayers()
+ /// Player which is moving into this block
+ /// The direction the player moved to get to this block
+ public virtual IEnumerator DoPush(Character newPlayer, Vector3 moveDirection)
{
- return currentPlayers.ToArray();
- }
+ if (currentPlayer == null)
+ {
+ currentPlayer = newPlayer;
+ yield break;
+ }
+ Block pushBlock = GetPushLocation(moveDirection, ~currentPlayer.Ignore);
+ if (pushBlock != this)
+ {
+ Character oldPlayer = currentPlayer;
+ currentPlayer = newPlayer;
+ yield return StartCoroutine(oldPlayer.MoveToBlock(pushBlock, Character.Animation.Hit, 1));
+ }
+ else
+ {
+ Block returnBlock = GetPushLocation(-moveDirection, ~newPlayer.Ignore);
+
+ if (returnBlock != this)
+ yield return StartCoroutine(newPlayer.MoveToBlock(returnBlock, Character.Animation.Hit, 1));
+ }
+ }
#endregion Public Functions
+ #region Protected Functions
+
+ protected Block GetPushLocation(Vector3 pushDirection, LayerMask ignoreMask)
+ {
+ //setting up variables
+ Vector3 newPosition = position + pushDirection; // position wanted
+ Block hit; //output of block detection
+
+ //if move is obstucted no where to move
+ if (Block.isBlockAtPosition(newPosition + Vector3.up, 1, ignoreMask))
+ return this;
+
+
+ //If block at Position is walkable set it to moveTo
+ if (Block.isBlockAtPosition(newPosition, 1, ignoreMask, out hit) && hit.isWalkable(ignoreMask))
+ {
+ return hit;
+ }
+ //else if block down one is walkable
+ else if (Block.isBlockAtPosition(newPosition + Vector3.down, 1, ignoreMask, out hit) && hit.isWalkable(ignoreMask))
+ {
+ return hit;
+ }
+ return this;
+ }
+
+ #endregion Protected Functions
+
#region Editor Functions
private void OnDrawGizmos()
{
diff --git a/Assets/Scripts/LevelBlocks/Water.cs b/Assets/Scripts/LevelBlocks/Water.cs
index 2a2f046..54796ed 100644
--- a/Assets/Scripts/LevelBlocks/Water.cs
+++ b/Assets/Scripts/LevelBlocks/Water.cs
@@ -16,17 +16,17 @@ public class Water : ActiveBlock
private Character trappedCharacter;
- public override void OnWalkedOnByPlayer(PlayerData player)
+ public override IEnumerator OnWalkedOnByPlayer(Character player, Vector3 moveDirection)
{
- base.OnWalkedOnByPlayer(player);
+ base.OnWalkedOnByPlayer(player, moveDirection);
if (trappedCharacter == null)
{
- player.character = trappedCharacter;
+ player = trappedCharacter;
trappedCharacter.stuck = true;
trappedCharacter.StartAnimation(Character.Animation.Hit);
- StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition + Vector3.down * FallDistance, 1));
+ yield return StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition + Vector3.down * FallDistance, 1));
}
}
diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta
new file mode 100644
index 0000000..98af9d1
--- /dev/null
+++ b/Assets/Scripts/LogicBlocks.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8936b441d7647f74884c94f97bfb8931
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant: