Commit 008e8a97 authored by Andrew Van Buren's avatar Andrew Van Buren

Merge branch 'master' of git.gmu.edu:gadig/four into character

# Conflicts:
#	Assets/Scripts/Boss.cs
#	Assets/Scripts/FireballMove.cs
#	Assets/Scripts/FireballMove.cs.meta
#	Assets/script/FireballMove.cs.meta
#	Assets/script/TurtleActions.cs.meta
parents 8b4dacbe 17ee1245
fileFormatVersion: 2
guid: 3f69cf60d3105914bacdd6f4714c0732
timeCreated: 1479601880
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7f22a116230fac449b0aba6f00875b4d
timeCreated: 1479601888
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 90809fca9c1d0eb44a3dbe384eaac91b
timeCreated: 1479601888
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d28e37e53d221f444ae4f505b4933f64
timeCreated: 1479601888
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class CodecPoint : MonoBehaviour {
public enum CommType { codec, burst };
public bool isOn;
public CommType thisCommType;
public string[] codecText;
public float[] codecWaitTimes;
public int[] codecSpeaker;
}
fileFormatVersion: 2
guid: 906231cf7d8afa14d8f725a179188852
timeCreated: 1479601881
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class EnemyProjectile : MonoBehaviour {
// TEMPORARY
// Does not damage player
void OnCollisionEnter2D(Collision2D col) {
Destroy(gameObject);
}
}
using UnityEngine;
using System.Collections;
public class EnemyProjectile : MonoBehaviour {
// TEMPORARY
// Does not damage player
void OnCollisionEnter2D(Collision2D col) {
Destroy(gameObject);
}
}
using UnityEngine;
using System.Collections;
public class FireballMove : MonoBehaviour {
public float speed;
private Rigidbody2D fireRB;
public Vector2 move;
// Use this for initialization
void Start () {
fireRB = GetComponent<Rigidbody2D> ();
fireRB.velocity = (move * speed);
}
void OnCollisionEnter2D(Collision2D c){
Destroy (gameObject);
}
}
fileFormatVersion: 2
guid: b245668d1f70fae43ba9905676a8f688
timeCreated: 1477616043
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class HeroMobility : MonoBehaviour {
public enum Footsteps {
GRASS,
WATER
}
public float playerSpeed = 1f;
private Rigidbody2D playerRB;
Animator anim;
private Vector2 lastPos;
public Vector2 deltaPos;
private float lastFootstep;
public float footStepDelay = 0.3f;
using UnityEngine;
using System.Collections;
public class HeroMobility : MonoBehaviour {
public enum Footsteps {
GRASS,
WATER
}
public float playerSpeed = 1f;
private Rigidbody2D playerRB;
Animator anim;
private Vector2 lastPos;
public Vector2 deltaPos;
private float lastFootstep;
public float footStepDelay = 0.3f;
public Footsteps footsetps = Footsteps.GRASS;
private AudioSource audioSource;
public AudioClip[] grassFootsteps;
public AudioClip[] waterFootsteps;
void Start () {
playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
audioSource = GetComponent<AudioSource>();
lastPos = playerRB.position;
}
// Update is called once per frame
void FixedUpdate () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input);
void Start () {
playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
audioSource = GetComponent<AudioSource>();
lastPos = playerRB.position;
}
// Update is called once per frame
void FixedUpdate () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input);
if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) {
lastFootstep += footStepDelay;
Footstep();
}
}
void playerMove (Vector2 input){
//Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position;
}
}
}
void playerMove (Vector2 input){
//Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position;
}
void Footstep() {
switch (footsetps) {
case Footsteps.GRASS:
......@@ -55,5 +55,5 @@ public class HeroMobility : MonoBehaviour {
audioSource.PlayOneShot(waterFootsteps[Random.Range(0, waterFootsteps.Length)]);
break;
}
}
}
}
}
fileFormatVersion: 2
guid: d82b991eb2507f84bb413aed23f404c7
guid: b6308e0fc687f1b42b73f82957f4e001
folderAsset: yes
timeCreated: 1475761198
timeCreated: 1479601880
licenseType: Free
DefaultImporter:
userData:
......
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
[System.Serializable]
public class goColor
{
public GameObject go;
public GameObject border;
public Color32 rgb;
public goColor(GameObject go, Color32 rgb, GameObject border = null)
{
this.go = go;
this.border = border;
this.rgb = rgb;
}
public goColor(GameObject go, byte r, byte g, byte b, GameObject border = null)
{
this.go = go;
this.border = border;
this.rgb = new Color32(r, g, b, 0);
}
}
[System.Serializable]
public class goAlpha
{
public GameObject go;
public int aPercent;
public goAlpha(GameObject go, int val)
{
this.go = go;
aPercent = val;
}
public static byte percentToByte(int val)
{
return BitConverter.GetBytes( Mathf.RoundToInt( 255 * ((float)(((((val < 100) ? val : 100) > 0) ? val : 0)) / 100)))[0];
}
public static int byteToPercent(byte val)
{
return val / 255 * 100;
}
}
public class EditorTileSelect : MonoBehaviour
{
public string levelName;
public goColor[] rgbMap;
public goAlpha[] aMap;
public void save()
{
string path = Application.dataPath + "/Resources/Levels/" + levelName + ".txt";
if (!File.Exists(path))
{
File.Create(path);
}
StreamWriter sw = new StreamWriter(path);
for (int i = 0; i < rgbMap.Length; i++) // Write RGB values
{
//Debug.Log(AssetDatabase.GetAssetPath(gos[i]));
sw.WriteLine(AssetDatabase.GetAssetPath(rgbMap[i].go));
if(rgbMap[i].border != null)
sw.WriteLine(AssetDatabase.GetAssetPath(rgbMap[i].border));
sw.WriteLine(rgbMap[i].rgb.r);
sw.WriteLine(rgbMap[i].rgb.g);
sw.WriteLine(rgbMap[i].rgb.b);
}
if(aMap.Length > 0)
{
sw.WriteLine(":");
for (int i = 0; i < aMap.Length; i++)
{
sw.WriteLine(AssetDatabase.GetAssetPath(aMap[i].go));
sw.WriteLine(goAlpha.percentToByte(aMap[i].aPercent));
}
}
sw.Close();
}
public void load()
{
List<goColor> colors = new List<goColor>();
List<goAlpha> alphas = new List<goAlpha>();
StreamReader sr;
string path = Application.dataPath + "/Resources/Levels/" + levelName + ".txt";
try
{
GameObject go;
GameObject border;
byte r, g, b;
string line;
bool doingAlphas = false;
sr = new StreamReader(path);
while (!sr.EndOfStream) // Read values until EOS
{
line = sr.ReadLine();
if (line == ":")
{
doingAlphas = true;
line = sr.ReadLine();
}
go = AssetDatabase.LoadAssetAtPath<GameObject>(line); // Load GameObject
line = sr.ReadLine();
if (!char.IsDigit(line[0])) // Has a border
{
border = AssetDatabase.LoadAssetAtPath<GameObject>(line);
line = sr.ReadLine();
}
else
border = null;
if (!doingAlphas) // Reading RGB values
{
byte.TryParse(line, out r); // Read red value
line = sr.ReadLine();
byte.TryParse(line, out g); // Read green value
line = sr.ReadLine();
byte.TryParse(line, out b); // Read blue value
//Debug.Log(r + ", " + g + ", " + b + " | " + go.name);
colors.Add(new goColor(go, r, g, b, border));
}else // Reading alpha values
{
byte.TryParse(line, out r); // Read alpha value (store in r because it wont be used any more)
//Debug.Log(r + " | " + go.name);
alphas.Add(new goAlpha(go, r));
}
}
sr.Close();
}
catch (System.Exception)
{
throw;
}
rgbMap = colors.ToArray();
aMap = alphas.ToArray();
}
}
[CustomEditor (typeof(EditorTileSelect))]
public class EditorTileSelectEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if(GUILayout.Button("Save"))
{
((EditorTileSelect)target).save();
}
if(GUILayout.Button("Load"))
{
((EditorTileSelect)target).load();
}
}
}
fileFormatVersion: 2
guid: 4b3cbce46332f5343a63d7723921a1f5
timeCreated: 1479601881
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: d8ef5b1b7ddcf1e46a43c91701e26700
timeCreated: 1479601881
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class MapLoad : MonoBehaviour {
public GameObject button;
private MapMaker mm;
void Start () {
mm = GameObject.Find ("Create").GetComponent<MapMaker> ();
}
public void CreateMapButtons () {
string[] maps = System.IO.Directory.GetFiles ("Assets\\Resources\\Maps\\", "*.txt");
for(int i = 0; i < maps.Length; i++){
string s = maps [i];
RectTransform rt = (RectTransform)(((GameObject)Instantiate(button)).transform);
rt.SetParent (GameObject.Find ("Canvas").transform);
rt.anchoredPosition = new Vector3 (0, -i * 30 + 75);
rt.localScale = new Vector3 (1, 1, 1);
s = s.Substring (s.LastIndexOf("\\") + 1, s.Length - 5 - s.LastIndexOf("\\"));
rt.FindChild ("Text").GetComponent<Text> ().text = s;
rt.GetComponent<Button>().onClick.AddListener(() => { LoadMap(s); });
}
}
void LoadMap (string file) {
GameObject[] buttons = GameObject.FindGameObjectsWithTag ("Button");
for (int i = 0; i < buttons.Length; i++) {
Destroy (buttons[i]);
}
string text = System.IO.File.ReadAllText ("Assets/Resources/Maps/" + file + ".txt");
string[] delim = { "\r\n" };
string[] lines = text.Split(delim, System.StringSplitOptions.None);
int x = int.Parse (lines [0] [0].ToString ());
int y = int.Parse (lines [0] [2].ToString ());
MapMakerTile[,] map = mm.GenerateEmptyTiles (x, y);
for (int i = 1; i < lines.Length - 1; i++) {
string[] args = lines [i].Split (',');
x = int.Parse (args [0]);
y = int.Parse (args [1]);
map [x, y].walkable = bool.Parse (args [2]);
map [x, y].weight = float.Parse (args [3]);
map [x, y].GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Tiles/" + args[4]);
for (int j = 0; j < args.Length; j++) {
//for later use (extra tile shit)
}
}
}
}
fileFormatVersion: 2
guid: 92d5e911fb5523e43bac0c60148eec87
timeCreated: 1477702685
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class MapLoader : MonoBehaviour {
public string fileName;
public GameObject emptyTile;
void Start () {
string text = System.IO.File.ReadAllText ("Assets\\Resources\\Maps\\" + fileName + ".txt");
string[] delim = { "\r\n" };
string[] lines = text.Split(delim, System.StringSplitOptions.None);
string[] coords = lines[0].Split(',');
int x = int.Parse (coords[0].ToString ());
int y = int.Parse (coords[1].ToString ());
Tile[,] map = new Tile[y, x];
float startx;
float starty;
for (int i = 1; i < lines.Length - 1; i++) {
string[] args = lines [i].Split (',');
x = int.Parse (args [0]);
y = int.Parse (args [1]);
map [x, y].walkable = bool.Parse (args [2]);
map [x, y].weight = float.Parse (args [3]);
map [x, y] = ((GameObject) Instantiate(Resources.Load<GameObject> ("Prefabs/" + args[4]))).GetComponent<Tile> ();
startx = (float)x - (float)map.GetLength(0) / 2f;
starty = (float)y - (float)map.GetLength(1) / 2f;
map [x, y].transform.position = new Vector3 (startx, starty, 0);
}
Map.map = map;
}
Tile[,] GenerateTiles (int rows, int cols) {
Tile[,] map = new Tile[cols, rows];
float startx = -(float)cols / 2f * emptyTile.transform.lossyScale.x;
float starty = (float)rows / 2f * emptyTile.transform.lossyScale.y;
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
map[x, y] = ((GameObject) Instantiate (emptyTile, new Vector2(startx + x * emptyTile.GetComponent<BoxCollider2D>().size.x,
starty - y * emptyTile.GetComponent<BoxCollider2D>().size.x), Quaternion.identity)).GetComponent<Tile> ();
map [x, y].x = x;
map [x, y].y = y;
}
}
return map;
}
}
fileFormatVersion: 2
guid: 00b82cb959770da48addbe5d69996c09
timeCreated: 1479593362
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class MapMaker : MonoBehaviour {
public GameObject emptyTile;
private Text rowsText;
private Text colsText;
private MapMakerTile[,] map;
private Vector2 previousMousePosition;
void Start () {
rowsText = GameObject.Find ("Rows").transform.FindChild("Text").GetComponent<Text> ();
colsText = GameObject.Find ("Cols").transform.FindChild("Text").GetComponent<Text> ();
}
void Update () {
if (Input.GetAxisRaw("Mouse ScrollWheel") != 0) {
Camera.main.orthographicSize += Input.GetAxisRaw("Mouse ScrollWheel") * -10;
}
if (Input.GetMouseButton(1)) {
Vector2 mouseDelta = (Vector2)(Camera.main.ScreenToWorldPoint (Input.mousePosition)) - previousMousePosition;
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x - mouseDelta.x, Camera.main.transform.position.y - mouseDelta.y, -10f);
}
previousMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
public void GenerateEmptyTiles () {
int rows = 0;
int cols = 0;
int.TryParse (rowsText.text, out rows);
int.TryParse (colsText.text, out cols);
if (rows > 0 && cols > 0) {
GenerateEmptyTiles (rows, cols);
}
}
public MapMakerTile[,] GenerateEmptyTiles (int rows, int cols) {
GameObject[] tiles = GameObject.FindGameObjectsWithTag ("Empty Tile");
for (int i = 0; i < tiles.Length; i++) {
Destroy (tiles [i]);
}
map = new MapMakerTile[cols, rows];
float startx = -(float)cols / 2f * emptyTile.transform.lossyScale.x;
float starty = (float)rows / 2f * emptyTile.transform.lossyScale.y;
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
map[x, y] = ((GameObject) Instantiate (emptyTile, new Vector2(startx + x * emptyTile.GetComponent<BoxCollider2D>().size.x,
starty - y * emptyTile.GetComponent<BoxCollider2D>().size.x), Quaternion.identity)).GetComponent<MapMakerTile> ();
map [x, y].x = x;
map [x, y].y = y;
}
}