Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -87,10 +87,52 @@ NavMeshSettings:
cellSize: .166666672
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &294769734
GameObject:
m_PrefabParentObject: {fileID: 133474, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
m_PrefabInternal: {fileID: 2130569307}
--- !u!1001 &531787708
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 122942, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_Name
value: ShopUI
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
m_IsPrefabParent: 0
--- !u!1 &907037392
GameObject:
m_ObjectHideFlags: 0
@@ -175,61 +217,3 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &985638225
GameObject:
m_PrefabParentObject: {fileID: 178772, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
m_PrefabInternal: {fileID: 2130569307}
--- !u!1001 &2130569307
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 490178, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11466982, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: shop
value:
objectReference: {fileID: 985638225}
- target: {fileID: 11466982, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: creator
value:
objectReference: {fileID: 294769734}
- target: {fileID: 122942, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
propertyPath: m_Name
value: ShopUI
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ad4dbf0694a8b594d9d226d020f98bef, type: 2}
m_IsPrefabParent: 0
@@ -34,6 +34,7 @@ override public void Update ()
void Explode(){
foreach(EnemyBase enemy in dmgEnemies)
enemy.takeDamage(dmg);
Player.Instance.setHealth(-dmg);
}

void OnTriggerStay2D(Collider2D other) {
File renamed without changes.
@@ -12,12 +12,12 @@ public class EnemyBase : MonoBehaviour {
//moving
public float speed = 1.0f;
private float startTime;
private float journeyLength;
public float journeyLength;
public Vector3 endPosition;
public bool moving;
float xDistance;
float yDistance;
Vector2 moveDirection;
public Vector2 moveDirection;
public Vector3 initialPos;

//stats
@@ -28,19 +28,22 @@ public class EnemyBase : MonoBehaviour {
//step counters
public int doSteps;
public int stepsTaken;
public bool wait;
float waitInit;

// Use this for initialization
public virtual void Start () {
player = GameObject.FindWithTag("Player");
vars = (GameVariables) GameObject.FindWithTag("GameVariables").GetComponent("GameVariables");

awake = true;
awake = false;
moving = false;
//TO DO - remove
vars.TileSize = 1;
doSteps = 8;
doSteps = 20;
//------------
stepsTaken = 0;
wait = false;

//stats
maxHealth = 100;
@@ -57,33 +60,42 @@ public class EnemyBase : MonoBehaviour {
die ();
return;
}
if(wait && checkWait()){
return;
}
if(doSteps > 0 )
{
bool canHit = checkCanHit();
if (awake && !moving && !canHit)
{
Vector2 targetPos = player.transform.position;
xDistance = targetPos.x - transform.position.x;
yDistance = targetPos.y - transform.position.y;
startTime = Time.time;
initialPos = transform.position;
endPosition = initialPos;

/*
Vector2 targetPos = player.transform.position;
xDistance = targetPos.x - transform.position.x;
yDistance = targetPos.y - transform.position.y;
if(Mathf.Abs(xDistance) > Mathf.Abs(yDistance)){
if ( xDistance > 0 ){
moveDirection = new Vector2( 1, 0);
endPosition += new Vector3(1, 0, 0);
}else{
moveDirection = new Vector2( -1, 0);
moveDirection = new Vector2(-1, 0);
endPosition -= new Vector3(1, 0, 0);
}
}else {
if ( yDistance > 0 ){
moveDirection = new Vector2(0, 1);
endPosition += new Vector3(0, 1, 0);
}else
}else{
moveDirection = new Vector2( 0, -1);
endPosition -= new Vector3(0, 1, 0);
}
}
}*/
moveDirection = GridManager.Instance.getMoveDirection(gameObject);
endPosition += new Vector3(moveDirection.x, moveDirection.y, 0);
journeyLength = Vector3.Distance (initialPos, endPosition);
doSteps--;
stepsTaken++;
@@ -92,6 +104,7 @@ public class EnemyBase : MonoBehaviour {

}else{
if(canHit && !moving){
startWait();
faceMoveDirection();
attack();
doSteps--;
@@ -165,7 +178,7 @@ bool checkCanHit()

public virtual void attack()
{
//Debug.Log("DIE");
Player.Instance.setHealth(-dmg);
}

public void takeDamage(int damage)
@@ -178,5 +191,17 @@ void die()
Destroy(gameObject);
}

void startWait(){
waitInit = Time.time;
wait = true;
}
bool checkWait()
{
if(Time.time - waitInit >= 1)
wait = false;
return wait;
}


}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,6 +4,7 @@
public class GameVariables : MonoBehaviour {

public int TileSize;
public float stepTime = 1;

// Use this for initialization
void Start () {
@@ -0,0 +1,160 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GridManager : MonoBehaviour {

public RoomGenerator rg;
public int currentRoom;
public GameObject[,,] grid;
public int [,] distanceSteps;
public Queue <KeyValuePair<int,int>> nodes;
KeyValuePair<int,int> playerTile;

public static GridManager Instance;
void Awake()
{
if (Instance == null) Instance = this;
}
void Start () {
rg = (RoomGenerator)FindObjectOfType(typeof(RoomGenerator));
currentRoom = 0;
nodes = new Queue<KeyValuePair<int, int>>();
}

public void pathMove()
{
Debug.Log("PATHMOVE");
grid = rg.rooms.First.Value;
//Debug.Log(grid.GetLength(1));
distanceSteps = new int[grid.GetLength(0), grid.GetLength(1)] ;
for(int i = 0; i < (distanceSteps.GetLength(0));i++)
for(int j = 0; j < (distanceSteps.GetLength(1));j++)
{
distanceSteps[i,j] = -1;

}
GameObject player = GameObject.FindWithTag("Player");
playerTile = findPlayer(player);
if (playerTile.Key!= -1){
//Debug.Log("FOUIND");
setDistanceArray(playerTile);
}

}

public KeyValuePair<int, int> findPlayer(GameObject o){
for(int i = 0; i < (grid.GetLength(0));i++)
for(int j = 0; j < (grid.GetLength(1));j++)
if (grid[i,j,3] !=null && grid[i,j,3].CompareTag("Player"))
{
//Debug.Log(i);
return new KeyValuePair<int,int>(i,j);
}
return new KeyValuePair<int,int>(-1,-1);
}

public KeyValuePair<int, int> findObject(GameObject o){
for(int i = 0; i < (grid.GetLength(0));i++)
for(int j = 0; j < (grid.GetLength(1));j++)
if (grid[i,j,3] !=null && grid[i,j,3]==o)
{
//Debug.Log(i);
return new KeyValuePair<int,int>(i,j);
}
return new KeyValuePair<int,int>(-1,-1);
}

public void changePlayerTile(Vector2 a, GameObject o){
grid[playerTile.Key, playerTile.Value, 3] = null;
playerTile= new KeyValuePair<int, int>((int)(playerTile.Key + a.x), (int)(playerTile.Value - a.y));
grid[playerTile.Key, playerTile.Value, 3] = o;
}


public void setDistanceArray(KeyValuePair<int,int>temp)
{
KeyValuePair<int,int> origin = temp;
distanceSteps[origin.Key, origin.Value] = 0;
distancesAroundNode(origin.Key,origin.Value);
while(nodes.Count > 0){
origin = nodes.Dequeue();
distancesAroundNode(origin.Key,origin.Value);
}


}

public void distancesAroundNode(int x, int y){
int distance = distanceSteps[x,y] + 1;
setNode (x+1, y, distance);
setNode (x-1, y, distance);
setNode (x, y+1, distance);
setNode (x, y-1, distance);
}

public void setNode(int x, int y, int value)
{
if(x < distanceSteps.GetLength(0) && y < distanceSteps.GetLength(1) && x>=0 && y>=0 && walkable (x,y)){
if(distanceSteps[x,y] < 0){
distanceSteps[x,y] = value;
nodes.Enqueue(new KeyValuePair<int,int >(x,y));
}else{
if(distanceSteps[x,y] > value){
distanceSteps[x,y] = value;
nodes.Enqueue(new KeyValuePair<int,int >(x,y));
}
}
}
//Debug.Log (value);
}

public bool walkable(int x, int y)
{
if(grid[x,y,0] == null)
return false;
if(((GameObject)grid[x,y,0]).CompareTag("Wall"))
return false;
if(((GameObject)grid[x,y,0]).CompareTag("Enemy"))
return false;
return true;

}

public Vector2 getMoveDirection(GameObject o){
KeyValuePair<int, int> tile = findObject(o);
KeyValuePair<int, int> previous = tile;
tile = getClosestAdjecent(tile.Key, tile.Value);
grid[previous.Key + tile.Key, previous.Value - tile.Value, 3] = o;
grid[previous.Key, previous.Value, 3] = null;
return new Vector2( tile.Key, tile.Value);

}



public KeyValuePair<int, int> getClosestAdjecent(int x, int y){
int min = 900;
KeyValuePair<int, int> temp = new KeyValuePair<int,int >();
if (x > 1 && distanceSteps[x-1,y] >= 0 && distanceSteps[x-1,y] < min && walkable(x-1,y)){
min = distanceSteps[x-1,y];
temp = new KeyValuePair<int,int >(-1, 0);
}
if (x < distanceSteps.GetLength(0)-1 && distanceSteps[x+1,y] >= 0 && distanceSteps[x+1,y] < min && walkable(x+1,y)){
min = distanceSteps[x+1,y];
temp = new KeyValuePair<int,int >(1, 0);
}
if (y > 1 && distanceSteps[x,y-1] >= 0 && distanceSteps[x,y-1] < min && walkable(x,y-1)){
min = distanceSteps[x,y-1];
temp = new KeyValuePair<int,int >(0, 1);
}
if (y < distanceSteps.GetLength(1)-1 && distanceSteps[x,y+1] >= 0 && distanceSteps[x,y+1] < min && walkable(x,y+1)){
min = distanceSteps[x,y+1];
temp = new KeyValuePair<int,int >(0, -1);
}
Debug.Log (min);
return temp;


}
}
@@ -44,6 +44,9 @@ void Start()
stepReducers = stepReducersStart;
teleportersStart = PlayerPrefs.GetInt("teleportersStart");
teleporters = teleportersStart;
buff = true;
debuff1 = true;
debuff2 = true;
UI.Instance.init();
}

@@ -203,28 +206,32 @@ public void pickUpTeleporter()
}

public void drinkHealthPotion()
{
{
if(healthPotions > 0)
healthPotions--;
setHealth(2);
UI.Instance.healthPotionUpdate();
}

public void drinkIncreaser()
{
if (stepIncreasers > 0)
stepIncreasers--;
incrementSteps(5);
UI.Instance.stepIncreaserUpdate();
}

public void drinkReducer()
{
if (stepReducers > 0)
stepReducers--;
incrementSteps(-5);
UI.Instance.stepDecreaserUpdate();
}

public void drinkTeleporter()
{
if (teleporters > 0)
//call teleport
teleporters--;
UI.Instance.teleporterUpdate();

Large diffs are not rendered by default.

@@ -0,0 +1,22 @@
using UnityEngine;
using System.Collections;

public class StepManager : MonoBehaviour
{

public static StepManager Instance;
void Awake()
{
if (Instance == null) Instance = this;
}

// Use this for initialization
void Start ()
{

}
public void newStep(){
GridManager.Instance.pathMove ();
}
}

@@ -2,7 +2,10 @@
using System.Collections;

public class UseHealthPotion : MonoBehaviour {

void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1)) drink();
}
public void drink()
{
Player.Instance.drinkHealthPotion();
@@ -2,7 +2,10 @@
using System.Collections;

public class UseStepIncreaser : MonoBehaviour {

void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha2)) drinkStepIncreaser();
}
public void drinkStepIncreaser()
{
Player.Instance.drinkIncreaser();
@@ -2,7 +2,10 @@
using System.Collections;

public class UseStepReducer : MonoBehaviour {

void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha3)) drinkReducer();
}
public void drinkReducer()
{
Player.Instance.drinkReducer();
@@ -2,7 +2,10 @@
using System.Collections;

public class UseTeleporter : MonoBehaviour {

void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha4)) drinkTeleporter();
}
public void drinkTeleporter()
{
Player.Instance.drinkTeleporter();
@@ -7,12 +7,15 @@ public class characterControls : MonoBehaviour {

private Animator anim;
public float speed = 1.0f;
private int health = 20;
private int steps = 10;
private float startTime;
private float journeyLength;
private Vector3 startPosition;
private Vector3 endPosition;
private bool moving = false;
private bool attacking = false;
public ParticleSystem trace;

// Use this for initialization
void Start () {
@@ -21,6 +24,7 @@ public class characterControls : MonoBehaviour {

// Update is called once per frame
void Update () {
<<<<<<< HEAD
if (!moving && !attacking) {
if (Input.GetKey(KeyCode.W))
{
@@ -83,15 +87,95 @@ public class characterControls : MonoBehaviour {
anim.SetTrigger("attackS");
attacking = true;
}
=======
if (health <= 0) {
doKill();
}
if (steps == 0) {
doJump();
} else {
if (!moving && !attacking) {
if (Input.GetKey (KeyCode.W)) {
if (checkForCollisions(transform.position + new Vector3(0, 1, 0)))
return;
anim.SetTrigger ("iddleN");
startTime = Time.time;
startPosition = transform.position;
endPosition = startPosition;
endPosition += new Vector3 (0, 1, 0);
journeyLength = Vector3.Distance (startPosition, endPosition);
doStep();
moving = true;
>>>>>>> deaa9b7fee48fe0bdd579cf0b0e69d6911ce73c4
}
else if(diffY < 1 && diffY > 0){
if(diffX < -0.7 && diffX > -1.7){
anim.SetTrigger("attackE");
attacking = true;
}
else if(diffX > 0.7 && diffX < 1.7){
anim.SetTrigger("attackW");
attacking = true;
if (Input.GetKey (KeyCode.A)) {
if (checkForCollisions(transform.position - new Vector3(1, 0, 0)))
return;
anim.SetTrigger ("iddleE");
startTime = Time.time;
startPosition = transform.position;
endPosition = startPosition;
endPosition -= new Vector3 (1, 0, 0);
journeyLength = Vector3.Distance (startPosition, endPosition);
doStep();
moving = true;
}
if (Input.GetKey (KeyCode.S)) {
if (checkForCollisions(transform.position - new Vector3(0, 1, 0)))
return;
anim.SetTrigger ("iddleS");
startTime = Time.time;
startPosition = transform.position;
endPosition = startPosition;
endPosition -= new Vector3 (0, 1, 0);
journeyLength = Vector3.Distance (startPosition, endPosition);
doStep();
moving = true;
}
if (Input.GetKey (KeyCode.D)) {
if (checkForCollisions(transform.position + new Vector3(1, 0, 0)))
return;
anim.SetTrigger ("iddleW");
startTime = Time.time;
startPosition = transform.position;
endPosition = startPosition;
endPosition += new Vector3 (1, 0, 0);
journeyLength = Vector3.Distance (startPosition, endPosition);
doStep();
moving = true;
}
if (Input.GetMouseButtonDown (0)) {
Vector3 mousePoint = Camera.main.ScreenPointToRay (Input.mousePosition).origin;
float diffX = mousePoint.x - transform.position.x;
float diffY = mousePoint.y - transform.position.y;
if (diffX > -0.7 && diffX < 0.7) {
if (diffY > 1 && diffY < 2) {
anim.SetTrigger ("attackN");
doStep();
trace.transform.rotation = Quaternion.Euler(0,0,89f);
trace.Play();
attacking = true;
} else if (diffY < 0 && diffY > -1) {
anim.SetTrigger ("attackS");
doStep();
trace.transform.rotation = Quaternion.Euler(0,0,-91f);
trace.Play();
attacking = true;
}
} else if (diffY < 1 && diffY > 0) {
if (diffX < -0.7 && diffX > -1.7) {
anim.SetTrigger ("attackE");
doStep();
trace.transform.rotation = Quaternion.Euler(0,0,-179f);
trace.Play();
attacking = true;
} else if (diffX > 0.7 && diffX < 1.7) {
anim.SetTrigger ("attackW");
doStep();
trace.transform.rotation = Quaternion.Euler(0,0,-1f);
trace.Play();
attacking = true;
}
}
}
}
@@ -104,7 +188,16 @@ public class characterControls : MonoBehaviour {
}
}

<<<<<<< HEAD
private bool checkForCollisions(Vector3 startPoint, Vector3 endPoint)
=======
private void doStep(){
steps --;
// notify game mechanic of step performed by player
}

private bool checkForCollisions(Vector3 endPoint)
>>>>>>> deaa9b7fee48fe0bdd579cf0b0e69d6911ce73c4
{
Debug.DrawLine(transform.position, endPoint);
int layer = LayerMask.NameToLayer("RaycastLayer");
@@ -129,6 +222,30 @@ private bool checkForCollisions(Vector3 startPoint, Vector3 endPoint)
}

private void doAttack(){
attacking = false;
// TODO proper collision detection with enemies
//RaycastHit2D hit = Physics2D.Raycast (transform.position, Vector2.right, 5, <enemy layer>);
//if (hit.collider != null) {
//
//}
if (anim.GetCurrentAnimatorStateInfo (0).IsName ("iddleN") ||
anim.GetCurrentAnimatorStateInfo (0).IsName ("iddleS") ||
anim.GetCurrentAnimatorStateInfo (0).IsName ("iddleE") ||
anim.GetCurrentAnimatorStateInfo (0).IsName ("iddleW")) {
attacking = false;
}
}

private void doJump(){

}

private void doKill(){
if(!anim.GetCurrentAnimatorStateInfo(0).IsName("die")){
anim.SetTrigger ("kill");
}
}

public void doDammages(int dammages) {
health -= dammages;
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -4,13 +4,11 @@
TagManager:
serializedVersion: 2
tags:
- PlayerSpawn
- Wall
- Player
- Door
- Enemy
- Corner
- GameVariables
- Interactable
- PlayerSpawn
layers:
- Default
- TransparentFX
@@ -20,12 +18,8 @@ TagManager:
- UI
-
-
- Player
<<<<<<< HEAD
- RaycastLayer
=======
- Enemy
>>>>>>> origin/master
-
-
-
-
@@ -52,15 +46,15 @@ TagManager:
- name: Default
uniqueID: 0
locked: 0
- name: GroundStuff
uniqueID: 4294862691
- name: Walls
uniqueID: 3083086009
locked: 0
- name: Obstacles
uniqueID: 2480666031
uniqueID: 3013221327
locked: 0
- name: ObstructionLayer
uniqueID: 1381001665
- name: Obstructions
uniqueID: 2356594449
locked: 0
- name: FogOfWar
uniqueID: 615236271
- name: New Layer
uniqueID: 2590502289
locked: 0