Commit 016c357d authored by Ashley N Crouch's avatar Ashley N Crouch

Merge branch 'master' into 'movingWater'

# Conflicts:
#   ProjectSettings/ProjectVersion.txt
parents 351ccb29 0d90c74c
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class DoorSceneScript : DoorScript {
// Use this for initialization
public string nextScene;
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D coll)
{
base.OnCollisionEnter2D(coll);
if(state == State.open)
{
SceneManager.LoadScene(nextScene);
}
}
}
fileFormatVersion: 2
guid: f6bea97f02675a04ab7e41327c0eb915
timeCreated: 1478828866
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class DoorScript : MonoBehaviour {
public enum State
{
closed,
open,
locked
}
public KeyColor doorColor;
public State state;
private Collider2D collider;
void Start()
{
collider = GetComponent<Collider2D>();
}
// Update is called once per frame
void Update()
{
if(state == State.closed)
{
//change sprite to be a closed door sprite
collider.enabled = true;
}
if(state == State.locked)
{
//change sprite to be a locked door sprite
collider.enabled = true;
}
if(state == State.open)
{
//change sprite to be an open door sprite
collider.enabled = false;
}
}
void unlockDoor()
{
if(state == State.locked)
{
state = State.open;
}
Debug.Log("Door Unlocked");
}
public void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == "Player")
{
if (state == State.locked)
{
KeyScript[] keyScripts = coll.gameObject.GetComponents<KeyScript>();
foreach (KeyScript key in keyScripts)
{
if (key.color == doorColor)
{
unlockDoor();
break;
}
}
}
}
}
}
fileFormatVersion: 2
guid: 626a32dcf7a1f8346a8a675af9f9ecb3
timeCreated: 1478218850
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class KeyScript : MonoBehaviour {
public KeyColor color;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == "Player")
{
KeyScript ks = coll.gameObject.AddComponent<KeyScript>();
ks.color = this.color;
}
}
}
public enum KeyColor
{
red,
blue,
green,
purple,
yellow,
orange
}
fileFormatVersion: 2
guid: 1a3035633693fa445898879705a191ae
timeCreated: 1478825784
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a7980e3cc7ad39d4aa968cb9fe241a0a
folderAsset: yes
timeCreated: 1477613634
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9c9cc0aa126d8b84494ab110abe4d840
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9dbbd5fe69390d5489f18914e7f5f7ad
folderAsset: yes
timeCreated: 1477085342
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 98cacb8c64e9186478cfed1f1e585757
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class basic_slime_script : MonoBehaviour
{
private Vector3 player_position;
private Vector3 slime_position;
private GameObject player;
private float x_diff;
private float y_diff;
// Use this for initialization
void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
}
// Update is called once per frame
void Update()
{
//get position of player character
player_position = player.transform.position;
//get position of slime
slime_position = transform.position;
//compare to position of slime (self)
x_diff = player_position.x - slime_position.x;
y_diff = player_position.y - slime_position.y;
if (Mathf.Abs(x_diff) >= Mathf.Abs(y_diff))
{
//if move is valid, then move
if (x_diff < 0)
{
if (World.get((int)(slime_position.x - 1 + 0.5), (int)(slime_position.y + 0.5)).walkable == true)
transform.position += Vector3.left;
}
if (x_diff > 0)
{
if (World.get((int)(slime_position.x + 1 + 0.5), (int)(slime_position.y + 0.5)).walkable == true)
transform.position += Vector3.right;
}
}
else
{
//if move is valid, then move
if (y_diff < 0)
{
if(World.get((int)(slime_position.x + 0.5), (int)(slime_position.y - 1 + 0.5)).walkable == true)
transform.position += Vector3.down;
}
if (y_diff > 0)
{
if (World.get((int)(slime_position.x + 0.5), (int)(slime_position.y + 1 + 0.5)).walkable == true)
transform.position += Vector3.up;
}
}
}
}
fileFormatVersion: 2
guid: 91273c6ae51601d4caf154810604da16
folderAsset: yes
timeCreated: 1477613634
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0bc1ee29b443c744a879fae3a31be6e0
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 647a00acb440c0c4aa002d9f0ae2ffd5
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0aa7e9ee35c587c4e8c03208b88269cb
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class FloorSwitch : MonoBehaviour {
//Ignore sprite renderer in file and set image useing first place in list
public GameObject player;
public bool isSwitchOn = false;
public Sprite[] sprites;
public bool isSwitchBack = true;
private Collider2D pCol;
private bool charIsOn = false;
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start ()
{
//Sets sprite to first frame
pCol = player.GetComponent<Collider2D>();
spriteRenderer = GetComponent<Renderer>() as SpriteRenderer;
spriteRenderer.sprite = sprites[0];
}
void OnTriggerEnter2D(Collider2D col)
{
//Debug.Log(col.name);
if(col == pCol)
{
//Debug.Log("somthing moving on");
//Turns on bool and changes sprite
isSwitchOn = true;
spriteRenderer.sprite = sprites[1];
}
}
void OnTriggerExit2D(Collider2D colE)
{
if (colE == pCol && isSwitchBack == true)
{
//Debug.Log("somthing moving off");
//Turns off bool and changes sprite
isSwitchOn = false;
spriteRenderer.sprite = sprites[0];
}
}
}
fileFormatVersion: 2
guid: a25513e707cbe794aa471c196b40ee22
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
m_EditorVersion: 5.3.5f1
m_StandardAssetsVersion: 0
m_StandardAssetsVersion: 0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment