@@ -17,6 +17,7 @@ public class GameController : MonoBehaviour {
public Color tile_color_bound_1;
public Color tile_color_bound_2;
public Armory armory;
public bool intro;

//reflex
public float reflex = 3.0f;
@@ -40,6 +41,7 @@ public enum LevelType {Lava, Snow, Marsh, Desert, Fields};
public GameObject tile;
public GameObject exit;
public GameObject enemyController;
public WeaponManager weaponManager;

//Meta Info
public int currentLevel;
@@ -81,32 +83,73 @@ public enum LevelMode {Arena, Quarters, Intro};
unitGrid = new Unit[0];
occupationGrid = new int[0];
tileGrid = new GameObject[0];
ChangeLevel (LevelType.Fields, levelWidth, levelHeight);
LoadPlayerProfile();
StartCoroutine(elevator.Lower(true));
//ChangeLevel(LevelType.Fields, levelWidth, levelHeight);
intro = true;
StartIntro();
//StartCoroutine(elevator.Lower(true));
}

void StartIntro()
{
//just dump reflex somewhere
StopReflex();
//create new grid
Destroy(GameObject.Find("Elevator"));
targetGrid = new int[levelWidth * levelHeight];
unitGrid = new Unit[levelWidth * levelHeight];
tileGrid = new GameObject[levelWidth * levelHeight];
occupationGrid = new int[levelWidth * levelHeight];

enemies = 0;
levelHeight = 31;
levelWidth = 1;

//spawn tiles
for (int y = 0; y < levelHeight; y++)
{
for (int x = 0; x < levelWidth; x++)
{
GameObject spawnedTile = Instantiate(tile, new Vector3(x - (levelWidth) / 2f, y - (levelHeight) / 2f, 0), Quaternion.identity) as GameObject;
spawnedTile.GetComponent<SpriteRenderer>().color = Color.Lerp(tile_color_bound_1, tile_color_bound_2, UnityEngine.Random.Range(0.0f, 1.0f));
Debug.Log(y * levelWidth + x);
tileGrid[y * levelWidth + x] = spawnedTile;
}
}
playerUnit.Teleport(0, 0, true);
playerUnit.GrantRandomWeapon();
}

void LoadPlayerProfile()
{
string profileString = System.IO.File.ReadAllText(PlayerPrefs.GetString("savePath") + PlayerPrefs.GetString("profile") + "/profile.json");
PlayerProfile playerProfile = JsonUtility.FromJson<PlayerProfile>(profileString);

GameSaver gs = new GameSaver();
PlayerProfile playerProfile = gs.LoadProfile();
playerUnit.SetColor(playerProfile.myUnit.myColor);
playerUnit.SetName(playerProfile.myUnit.name);
playerUnit.SetWish(playerProfile.myUnit.wish);
Debug.Log(profileString);
playerUnit.LoadWeapon(playerProfile.myUnit.weapon);
}
//dishes out weapons to everyone in the arena
void DishOutWeapons()
{
for(int i = 0; i<enemyControllers.Count; i++)
{
GameObject primary_weapon_object = GameObject.Find("WeaponManager").GetComponent<WeaponManager>().GetRandomWeapon();
enemyControllers[i].unit.primaryWeapon = GameObject.Instantiate(primary_weapon_object, new Vector3(enemyControllers[i].unit.transform.position.x, enemyControllers[i].unit.transform.position.y, -5), Quaternion.identity).GetComponent<Weapon>();
enemyControllers[i].unit.primaryWeapon.owner = enemyControllers[i].unit;
enemyControllers[i].unit.primaryWeapon.transform.parent = enemyControllers[i].unit.transform;
}
}
void Save()
{
SavePlayerProfile();
}
void SavePlayerProfile()
{
string saveFile = (PlayerPrefs.GetString("savePath") + PlayerPrefs.GetString("profile") + "/profile.json");
PlayerProfile playerProfile = new PlayerProfile(playerUnit, armory.GetWeaponCereals());
string newProfileString = JsonUtility.ToJson(playerProfile);
Debug.Log(saveFile);
Debug.Log(newProfileString);
System.IO.File.WriteAllText(saveFile, newProfileString);
Debug.Log("weapon type" + playerUnit.primaryWeapon.GetType());
GameSaver gs = new GameSaver();
gs.SaveProfile(playerProfile);
}

// Update is called once per frame
@@ -130,13 +173,15 @@ void SavePlayerProfile()
occupationGrid = new int[width * height];

//spawn player
LoadPlayerProfile();

playerUnit.GetComponent<Unit>().Move(width/2,height/2, false);

//spawn enemies
List<Vector2> coords = new List<Vector2> ();
for (int w = 0; w < width; w++) {
for (int h = 0; h < height; h++) {
if (w != width / 2 || h != height / 2) {
if (w != width / 2 || h != height / 2 && w !=( width / 2) + 1 && w != (width / 2) - 1 && h != (height / 2) + 1 && h != (height / 2) + - 1) {
coords.Add (new Vector2 (w, h));
}
}
@@ -155,8 +200,9 @@ void SavePlayerProfile()
for (int i = 0; i < enemies; i++) {
GameObject e = GameObject.Instantiate (enemyController, new Vector3 (0, 0, 0), Quaternion.identity);
enemyControllers.Add (e.GetComponent<EnemyController>());
enemyControllers[enemyControllers.Count-1].unit.Move ((int)coords [i].x, (int)coords [i].y, false);
}
enemyControllers[enemyControllers.Count - 1].unit.GrantRandomWeapon();
enemyControllers[enemyControllers.Count - 1].unit.Move((int)coords[i].x, (int)coords[i].y, false);
}

//spawn tiles
for (int y = 0; y < height; y++)
@@ -183,6 +229,12 @@ void SavePlayerProfile()
enemyControllers[i].TakeTurn();
playerInputController.EnableInput();
}

if (!playerUnit.alive)
{
SceneManager.LoadScene("DeathScene");
}

for (int i = 0; i < enemyControllers.Count; i++)
{
if (enemyControllers[i].unit.alive)
@@ -191,13 +243,13 @@ void SavePlayerProfile()
}
}

if (level_won && !elevator_called)
if (level_won && !elevator_called && !intro)
{
elevator_called = true;
StartCoroutine(elevator.Lower(false));
}

if(playerUnit.cordX == levelWidth/2 && playerUnit.cordY == levelHeight/2 && level_won && elevator.elevator_lowered)
if(playerUnit.cordX == levelWidth/2 && playerUnit.cordY == levelHeight/2 && level_won && elevator.elevator_lowered && !intro)
{
StartCoroutine(EndLevel());
}
@@ -277,6 +329,7 @@ public void StopReflex()
reflex_stopped = true;
reflex_bar.GetComponent<Image>().color = new Color(0, 0, 0, 0);
}


public void ResetReflex()
{
@@ -294,6 +347,6 @@ public GameObject GetTile(int x, int y)
}
public GameObject GetMiddleTile()
{
return tileGrid[levelWidth/2 * levelWidth + levelHeight/2];
return tileGrid[levelWidth/2 * levelHeight + levelHeight/2];
}
}
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameSaver {

public GameSaver() { }
public PlayerProfile LoadProfile()
{
string profileString = System.IO.File.ReadAllText(PlayerPrefs.GetString("savePath") + PlayerPrefs.GetString("profile") + "/profile.json");
PlayerProfile playerProfile = JsonUtility.FromJson<PlayerProfile>(profileString);
return playerProfile;
}

public void SaveProfile(PlayerProfile playerProfile)
{
string saveFile = (PlayerPrefs.GetString("savePath") + PlayerPrefs.GetString("profile") + "/profile.json");
string newProfileString = JsonUtility.ToJson(playerProfile);
System.IO.File.WriteAllText(saveFile, newProfileString);
}
}
@@ -75,18 +75,18 @@ void FillTargetPanel()
{
if (ScanForInput())
{
if (first_move)
if (first_move && !gameController.intro)
{
StartCoroutine(gameController.elevator.Raise(false));
first_move = false;
}
gameController.ResetReflex();
if (!gameController.intro) { gameController.ResetReflex(); }
StartCoroutine(gameController.RunTurn());
}
}
else if (ScanForAim() && ! first_move)
else if (ScanForAim() && ! first_move && !gameController.intro)
{ //we are aiming
gameController.ResetReflex();
if (!gameController.intro) { gameController.ResetReflex(); }
StartCoroutine(gameController.RunTurn());
playerUnit.aiming = false;
}
@@ -7,7 +7,8 @@ public class Spear : Weapon {
// Use this for initialization
void Start () {
base.Start();
}
myType = WeaponType.spear;
}

// Update is called once per frame
void Update () {
@@ -7,6 +7,7 @@ public class Sword : Weapon {
// Use this for initialization
void Start () {
base.Start();
myType = WeaponType.sword;
}
// Update is called once per frame

@@ -29,11 +29,6 @@ public class Unit : MonoBehaviour {
aiming = false;
weaponObject = Resources.Load("Prefabs/Weapon") as GameObject;
age = Random.Range (15, 60);

GameObject primary_weapon_object = GameObject.Find("WeaponManager").GetComponent<WeaponManager>().GetRandomWeapon();
primaryWeapon = GameObject.Instantiate (primary_weapon_object, new Vector3(transform.position.x, transform.position.y, -5), Quaternion.identity).GetComponent<Weapon> ();
primaryWeapon.owner = this;
primaryWeapon.transform.parent = transform;
my_color = new Color (Random.Range (.2f, 1f), Random.Range (.2f, 1f), Random.Range (.2f, 1f));
GetComponent<SpriteRenderer> ().color = my_color;
}
@@ -44,6 +39,16 @@ public class Unit : MonoBehaviour {
gameController.unitList.Add (this);
}

public void GrantRandomWeapon()
{
GameObject primary_weapon_object = GameObject.Find("WeaponManager").GetComponent<WeaponManager>().GetRandomWeapon();
primaryWeapon = GameObject.Instantiate (primary_weapon_object, new Vector3(transform.position.x, transform.position.y, -5), Quaternion.identity).GetComponent<Weapon> ();


primaryWeapon.owner = this;
primaryWeapon.transform.parent = transform;
}

// Update is called once per frame
void Update () {

@@ -86,7 +91,31 @@ public void SetWish(string w)
return false;
}

public void TakeDamage(int d){
public bool Teleport(int x, int y, bool moveCamera)
{
if (x < gameController.GetLevelWidth() && y < gameController.GetLevelHeight() && x >= 0 && y >= 0 && gameController.occupationGrid[y * gameController.GetLevelWidth() + x] == 0)
{
gameController.unitGrid[cordY * gameController.GetLevelWidth() + cordX] = null;
gameController.SetOccupation(cordX, cordY, 0);
cordX = x;
cordY = y;
gameController.SetOccupation(cordX, cordY, 1);
gameController.unitGrid[cordY * gameController.GetLevelWidth() + cordX] = this;

Vector3 movePosition = new Vector3((x - gameController.GetLevelWidth() / 2) - .5f, (y - gameController.GetLevelHeight() / 2) - .5f, transform.position.z);
transform.position = movePosition;
if (moveCamera)
{
movePosition = new Vector3((x - gameController.GetLevelWidth() / 2) - .5f, (y - gameController.GetLevelHeight() / 2) - .5f, GameObject.Find("Main Camera").transform.position.z);
StartCoroutine(MoveToPosition(GameObject.Find("Main Camera").transform, movePosition, .2f));
}
return true;
}
return false;
}


public void TakeDamage(int d){
hp -= d;
if (hp < 1) {
Die ();
@@ -157,4 +186,26 @@ public IEnumerator MoveToPosition(Transform transform, Vector3 position, float t
}
moving = false;
}
public void LoadWeapon(WeaponCereal wc)
{
GameObject primary_weapon_object;
switch (wc.myType)
{
case Weapon.WeaponType.sword:
primary_weapon_object = GameObject.Find("WeaponManager").GetComponent<WeaponManager>().GetSword();
Destroy(primaryWeapon);
primaryWeapon = GameObject.Instantiate(primary_weapon_object, new Vector3(transform.position.x, transform.position.y, -5), Quaternion.identity).GetComponent<Sword>();
break;
case Weapon.WeaponType.spear:
primary_weapon_object = GameObject.Find("WeaponManager").GetComponent<WeaponManager>().GetSpear();
Destroy(primaryWeapon);
primaryWeapon = GameObject.Instantiate(primary_weapon_object, new Vector3(transform.position.x, transform.position.y, -5), Quaternion.identity).GetComponent<Spear>();
break;
default:
Debug.Log("invalid weapon type");
break;
}
primaryWeapon.owner = this;
primaryWeapon.transform.parent = transform;
}
}
@@ -4,16 +4,16 @@

public class Weapon : MonoBehaviour {
public Color myColor;
int damage = 1;
public int damage = 1;
public GameObject reticleObject;

public float attack_time = .1f;

//reticle
public Reticle reticle;
public List<Reticle> reticles;
public enum WeaponType{other, sword, spear };
WeaponType myType = WeaponType.other;
public enum WeaponType{sword, spear, other};
protected WeaponType myType = WeaponType.other;
//range this is a problem for later
//public Sprite range_sprite;

@@ -90,6 +90,8 @@ public void MakeVisible()
}
public WeaponType GetMyType()
{
Debug.Log("getting type...");
Debug.Log(myType);
return myType;
}
private void AutoAim()
@@ -292,4 +294,5 @@ public void TuckItIn()
public bool MoveReticleWest(){
return MoveReticle(reticle.cordX - 1, reticle.cordY);
}

}
@@ -6,19 +6,27 @@
public class WeaponCereal {
public Weapon.WeaponType myType;
public string name;
public int range;
public int damage;

public WeaponCereal() {
myType = 0;
name = "weapon";
name = "sword";
range = 1;
damage = 1;
}
public WeaponCereal(Weapon w)
{
myType = w.GetMyType();
name = w.name;
range = w.range;
damage = w.damage;
}
public void Convert(Weapon w)
{
myType = w.GetMyType();
name = w.name;
range = w.range;
damage = w.damage;
}
}
@@ -18,6 +18,16 @@ public GameObject GetRandomWeapon()
GameObject weapon = weapon_prefabs[Random.Range(0, weapon_prefabs.Count)];
return weapon;
}
public GameObject GetSpear()
{
GameObject weapon = weapon_prefabs[1];
return weapon;
}
public GameObject GetSword()
{
GameObject weapon = weapon_prefabs[0];
return weapon;
}


}
BIN +0 Bytes (100%) Assets/StartMenu.unity
Binary file not shown.
@@ -83,8 +83,8 @@ public void StartGame()
void CreateProfile()
{
PlayerProfile newProfile = new PlayerProfile();
newProfile.myUnit.name = wishText.text;
newProfile.myUnit.wish = nameText.text;
newProfile.myUnit.name = nameText.text;
newProfile.myUnit.wish = wishText.text;
newProfile.myUnit.myColor = myColor;
PlayerPrefs.SetString("profile", nameText.text);
savePath = PlayerPrefs.GetString("savePath") + PlayerPrefs.GetString("profile");
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StoryBitController : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StoryPlayerController : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}
@@ -2,20 +2,44 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class WeaponButtonList : MonoBehaviour {
PlayerProfile playerProfile;

int current_index;
public List<WeaponCereal> weaponCereals;
List<WeaponCereal> weaponCereals;
public GameObject elementGrid;
public GameObject weaponSelectButtonObject;
public int selection_index = 0;

// Use this for initialization
void Start () {
//Display info
public Text weaponDamage;
public Text weaponRange;
public Text weaponName;

public Text myWeaponDamage;
public Text myWeaponRange;
public Text myWeaponName;

int view;
int selection;

// Use this for initialization
void Awake () {
view = 0;
current_index = 0;
weaponCereals = new List<WeaponCereal>();
}
string profileString = System.IO.File.ReadAllText(PlayerPrefs.GetString("profilePath"));
playerProfile = JsonUtility.FromJson<PlayerProfile>(profileString);
//AddWeaponButton(playerProfile.myUnit.weapon);
for (int i = 0; i < playerProfile.litter.Count; i++)
{
AddWeaponButton(playerProfile.litter[i]);
}
DisplayWeaponInfo(0);
PickupWeapon();
}

// Update is called once per frame
void Update () {
@@ -36,12 +60,38 @@ public void AddWeaponButton(WeaponCereal wc)
switch (wc.myType)
{
case (Weapon.WeaponType.sword):
Debug.Log("wow");
//sprites
break;
case (Weapon.WeaponType.spear):
//sprites
default:
Debug.Log("nada");
//Debug.Log("nada");
break;
}
}

public void DisplayWeaponInfo(int i)
{
Debug.Log(i);
Debug.Log(weaponCereals.Count);
weaponName.text = weaponCereals[i].name;
weaponDamage.text = weaponCereals[i].damage.ToString();
weaponRange.text = weaponCereals[i].range.ToString();
view = i;
}
public void PickupWeapon()
{
myWeaponName.text = weaponCereals[view].name;
myWeaponDamage.text = weaponCereals[view].damage.ToString();
myWeaponRange.text = weaponCereals[view].range.ToString();
selection = view;
}
public void FinalizeSelection()
{
playerProfile.myUnit.weapon = weaponCereals[selection];
playerProfile.litter = new List<WeaponCereal>();
GameSaver gs = new GameSaver();
gs.SaveProfile(playerProfile);
SceneManager.LoadScene("Arena");
}
}
@@ -7,12 +7,18 @@
public class WeaponSelectButton : MonoBehaviour {
public int index;
public Image weaponImage;
// Use this for initialization
void Start () {

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {

}

public void DisplayWeaponInfo()
{
GameObject.Find("WeaponButtonList").GetComponent<WeaponButtonList>().DisplayWeaponInfo(index);
}
}

Large diffs are not rendered by default.

Binary file not shown.
BIN +3.18 KB (110%) Library/LastBuild.buildreport
Binary file not shown.
@@ -1,4 +1,4 @@
sceneSetups:
- path: Assets/Quarters.unity
- path: Assets/Arena.unity
isLoaded: 1
isActive: 1
Binary file not shown.
Binary file not shown.
BIN +3.59 KB (100%) Library/assetDatabase3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
@@ -84,6 +84,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\DeathManager.cs" />
<Compile Include="Assets\QuartersManager.cs" />
<Compile Include="Assets\Scripts\Armory.cs" />
<Compile Include="Assets\Scripts\Bolo.cs" />
@@ -92,6 +93,7 @@
<Compile Include="Assets\Scripts\Elevator.cs" />
<Compile Include="Assets\Scripts\EnemyController.cs" />
<Compile Include="Assets\Scripts\GameController.cs" />
<Compile Include="Assets\Scripts\GameSaver.cs" />
<Compile Include="Assets\Scripts\LineDrawer.cs" />
<Compile Include="Assets\Scripts\MainCamera.cs" />
<Compile Include="Assets\Scripts\NameWizard.cs" />
@@ -107,6 +109,8 @@
<Compile Include="Assets\Scripts\WeaponCereal.cs" />
<Compile Include="Assets\Scripts\WeaponManager.cs" />
<Compile Include="Assets\StartMenuManager.cs" />
<Compile Include="Assets\StoryBitController.cs" />
<Compile Include="Assets\StoryPlayerController.cs" />
<Compile Include="Assets\WeaponButtonList.cs" />
<Compile Include="Assets\WeaponSelectButton.cs" />
</ItemGroup>
@@ -1,13 +1,11 @@
<Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/EnemyController.cs">
<Properties StartupItem="Rue.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Scripts\GameController.cs">
<Files>
<File FileName="Assets/Scripts/Weapon.cs" Line="54" Column="14" />
<File FileName="Assets/Scripts/GameController.cs" Line="124" Column="7" />
<File FileName="Assets/Scripts/PlayerInputController.cs" Line="99" Column="16" />
<File FileName="Assets/Scripts/EnemyController.cs" Line="9" Column="20" />
<File FileName="Assets/Scripts/Reticle.cs" Line="22" Column="1" />
<File FileName="Assets/Bolo.cs" Line="5" Column="19" />
<File FileName="Assets\Scripts\Weapon.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\GameController.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\PlayerInputController.cs" Line="85" Column="5" />
<File FileName="Assets\Scripts\WeaponCereal.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Binary file not shown.
@@ -0,0 +1 @@
{"level":0,"myUnit":{"name":"a","wish":"a","age":51,"myColor":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"weapon":{"myType":1,"name":"Spear","range":2,"damage":1}},"litter":[]}
@@ -0,0 +1 @@
{"level":0,"myUnit":{"name":"p","wish":"p","age":0,"myColor":{"r":1.0,"g":1.0,"b":1.0,"a":1.0},"weapon":{"myType":0,"name":"sword","range":1,"damage":1}},"litter":[]}

This file was deleted.

BIN +1.89 KB (110%) Test_Data/globalgamemanagers
Binary file not shown.
BIN +472 Bytes (100%) Test_Data/globalgamemanagers.assets
Binary file not shown.
BIN +0 Bytes (100%) Test_Data/level0
Binary file not shown.
BIN -2.68 KB (80%) Test_Data/level1
Binary file not shown.
BIN +21.1 KB Test_Data/level2
Binary file not shown.
BIN +7.32 KB Test_Data/level3
Binary file not shown.

Large diffs are not rendered by default.

BIN +3.78 KB (100%) Test_Data/resources.assets
Binary file not shown.
BIN -47.2 KB (42%) Test_Data/sharedassets0.assets
Binary file not shown.
BIN -24 Bytes (99%) Test_Data/sharedassets1.assets
Binary file not shown.
Binary file not shown.
Binary file not shown.