Skip to content

Commit

Permalink
Started routine to handle destruction of teleporters, but still in
Browse files Browse the repository at this point in the history
progress (trigger commented out)
  • Loading branch information
cguckelsberger committed Nov 28, 2014
1 parent f7a52e6 commit cb2e8a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions Assets/Scripts/Damageable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void kill()
{
//Try play death sound effect
EnemyAI_BasicCollider enemyScript = gameObject.GetComponent<EnemyAI_BasicCollider>();
TeleportCountdown teleportCountdown = gameObject.GetComponent<TeleportCountdown>();
GameObject go = GameObject.FindGameObjectWithTag ("GameLogic") as GameObject;
LevelGenerator levelGenerator = go.GetComponent<LevelGenerator>();

if((enemyScript != null) && (enemyScript.DeathNoise != null))
{
Expand All @@ -41,11 +42,11 @@ void kill()
newAudioPlayer.audio.PlayOneShot(enemyScript.DeathNoise);
Destroy(newAudioPlayer, enemyScript.DeathNoise.length + 1.0f);
}

if(teleportCountdown != null)
/*
if(gameObject.tag.Equals("Teleporter"))
{
teleportCountdown.removeTeleporter();
}
levelGenerator.recalcTeleportAreas(transform.position);
}*/

Destroy(gameObject);
}
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/LevelGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class LevelGenerator : MonoBehaviour
public Dictionary<int,Dictionary<List<Vector2>,Node>> teleportAreas {get; set;}
public Dictionary<int,List<GameObject>> teleportAreasObjects {get; set;}
public Dictionary<int,List<Vector2>> objectPositions;
public Dictionary<Vector2, int[]> teleporterMapping;
public Dictionary<Vector3, int[]> teleporterMapping;


private Delaunay.Voronoi v;
Expand Down Expand Up @@ -127,7 +127,7 @@ void Awake ()
} while(path==null);

//Create teleporters and calculate/highlight areas of influence
teleporterMapping = new Dictionary<Vector2, int[]> ();
teleporterMapping = new Dictionary<Vector3, int[]> ();
graphTele = createTeleporters (graphCells, path, v);
teleportAreas = new Dictionary<int,Dictionary<List<Vector2>,Node>> ();
teleportAreasObjects = new Dictionary<int,List<GameObject>> ();
Expand Down Expand Up @@ -450,7 +450,7 @@ public GameGraph createGameGraph(Delaunay.Voronoi v, Vector2 startCell, Vector2
return graphCells;
}

public void recalcTeleportAreas(Vector2 coords){
public void recalcTeleportAreas(Vector3 coords){

if (teleporterMapping.ContainsKey (coords)) {
int[] adjacent = teleporterMapping[coords];
Expand Down Expand Up @@ -663,7 +663,7 @@ private void createAlarmLights(){
private void createTeleporter(Vector2 p0, Vector2 p1, Node n0, Node n1){
Vector2 midpoint = (p0+p1)*0.5f;
Vector3 midpointCoords = new Vector3(midpoint.x-m_mapWidth/2,0.5f*m_wallHeight,midpoint.y-m_mapHeight/2);
teleporterMapping.Add(midpoint,new int[]{n0.id,n1.id});
teleporterMapping.Add(midpointCoords,new int[]{n0.id,n1.id});
float length = Vector2.Distance(p0,p1)*0.5f;
float angle = -Mathf.Atan2(p0.y - p1.y, p0.x - p1.x) * (180 / Mathf.PI) + 90;
GameObject teleporter = Instantiate(prefab_teleporter,midpointCoords,Quaternion.Euler(new Vector3(0.0f,angle,0.0f))) as GameObject;
Expand Down

0 comments on commit cb2e8a0

Please sign in to comment.