Skip to content

Commit

Permalink
Merge pull request #21 from OUVirtualReality/noah_z
Browse files Browse the repository at this point in the history
(Mostly) Finished GameSetup Script
  • Loading branch information
jallendev committed Nov 6, 2017
2 parents 45e69f3 + f66f9c5 commit b16fce0
Showing 1 changed file with 79 additions and 13 deletions.
92 changes: 79 additions & 13 deletions Assets/Scripts/GameSetup.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,90 @@
//Developer: Joseph Allen
//Developer: Noah Zemlin
//Script: GameSetup
//Version: 0.1
//Purpose: This script randomly sets up all GameObjects on the grid given by PlaySurfaceScanner
//Version: 1.0
//Purpose: This script spawns the game objects onto the map as well as checking for win conditions

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameSetup : MonoBehaviour {
private float[][] gridPositions;

void Start () {

}

void Update () {

}
public class GameSetup : MonoBehaviour
{

void InitializeGrid() {
private Dictionary<Goal, bool> goals;
private bool mapMade = false;

private bool won = false;

public LaserEmitter laserPrefab;
public LaserRefractor beaconPrefab;
public Goal goalPrefab;

public GameSetup()
{
goals = new Dictionary<Goal, bool>();
}

public void SetVictory(Goal g, bool victory)
{
if (goals.ContainsKey(g))
goals[g] = victory;
}

//Spawns all the game objecst
//This may need to be set to public if some other script is going to setup the world
private void SetupWorld()
{
if (laserPrefab != null && beaconPrefab != null && goalPrefab != null)
{
//spawn the map
mapMade = true;

//example spawn stuff (will come from json in future)
Vector3 pos1 = PlaySurfaceScanner.GetWorldPosition(1, 1, 1);
Vector3 pos2 = PlaySurfaceScanner.GetWorldPosition(1, 3, 1);
Vector3 pos3 = PlaySurfaceScanner.GetWorldPosition(1, 1, 3);

Instantiate(laserPrefab, pos1, Quaternion.Euler(0, 0, 0));
Instantiate(beaconPrefab, pos2, Quaternion.Euler(0, 0, 0));
Goal goal = Instantiate<Goal>(goalPrefab, pos3, Quaternion.Euler(0, 0, 0));
goals.Add(goal, false);

}
else
{
Debug.LogError("The GameSetup prefabs must be set!");
}
}

private void Update()
{
//if the map exists, assume game is in play
if (mapMade)
{
won = true;

//find any unsatisfied win conditions
foreach (bool goalVictory in goals.Values)
{
if (!goalVictory)
{
won = false;
break;
}
}

if (won)
{
Debug.Log("You won! Wow! Amazing! Nice shot!");
}
}
//if the PSS is done, then we can make the map using it's grid
else if (PlaySurfaceScanner.checkInitializationComplete())
{
//we can make the map
SetupWorld();
}
}

}

0 comments on commit b16fce0

Please sign in to comment.