Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueIceshard committed Jun 30, 2018
2 parents cd5ea23 + 0337536 commit fcb17f3
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 69 deletions.
9 changes: 2 additions & 7 deletions Neonmania/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e68807ba205749440827fc5e71ba7c09, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1079610143 stripped
Transform:
m_PrefabParentObject: {fileID: 4798293186133000, guid: d1d07de129d15a74390304540206fded,
type: 2}
m_PrefabInternal: {fileID: 1811130874}
--- !u!1 &1148241113
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1123,7 +1118,7 @@ Prefab:
type: 2}
propertyPath: player
value:
objectReference: {fileID: 1079610143}
objectReference: {fileID: 1079610139}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: da9c70ea3ed54464b955c8fdd666b19d, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -1342,7 +1337,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
enemy: {fileID: 1683257992604568, guid: da9c70ea3ed54464b955c8fdd666b19d, type: 2}
spawnPlane: {fileID: 1323457083}
player: {fileID: 1079610143}
player: {fileID: 1079610139}
minionTypes:
- {fileID: 11400000, guid: d37f1f9f417523947adef0c72bd77ea3, type: 2}
- {fileID: 11400000, guid: 75edf39147a941649a58939134f2060b, type: 2}
Expand Down
122 changes: 65 additions & 57 deletions Neonmania/Assets/Scripts/EnemyController.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,68 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyController : MonoBehaviour {

public Transform player;

public float speed = 1f;
public float checkFrequency = 1f;

public float timeToDie = 1f;
private float timeDead = 0f;
private bool dead = false;

private float lastCheck = 0f;
private Vector3 direction;

// Use this for initialization
void Start () {
GetComponent<Renderer>().material.SetFloat(Shader.PropertyToID("Vector1_30FACB43"), (timeToDie - timeDead) / timeToDie);
Debug.Log(GetComponent<Renderer>().material.GetFloat(Shader.PropertyToID("Vector1_30FACB43")) );
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyController : MonoBehaviour {

public GameObject player;

public float speed = 1f;
public float checkFrequency = 1f;

public float timeToDie = 1f;
private float timeDead = 0f;
private bool dead = false;

private float lastCheck = 0f;
private Vector3 direction;
private Rigidbody rb;
private EnemyProperties enemy;

// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
enemy = GetComponent<EnemyPropertyController>().properties;
Debug.Log(GetComponent<Renderer>().material.GetFloat(Shader.PropertyToID("Vector1_30FACB43")));
}

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

if(dead) {

timeDead += Time.deltaTime;

GetComponent<Renderer>().material.SetFloat(Shader.PropertyToID("Vector1_30FACB43"), (timeToDie - timeDead) / timeToDie);

if(timeToDie - timeDead <= 0) {
Destroy(this.gameObject);
}

return;
}

lastCheck += Time.deltaTime;

if(lastCheck >= checkFrequency) {
lastCheck = 0;

UpdateEnemyPath();
}

transform.Translate(direction * speed * Time.deltaTime, Space.World);
}

void UpdateEnemyPath() {
direction = (player.position - transform.position).normalized;
}

public void OnDeath() {
dead = true;
}
}
void Update () {

if(dead) {

timeDead += Time.deltaTime;

GetComponent<Renderer>().material.SetFloat(Shader.PropertyToID("Vector1_30FACB43"), timeToDie - timeDead);

return;
}

lastCheck += Time.deltaTime;

if(lastCheck >= checkFrequency) {
lastCheck = 0;

UpdateEnemyPath();
}

transform.Translate(direction * speed * Time.deltaTime, Space.World);
}

private void OnCollisionEnter(Collision collision) {
if (collision.collider.CompareTag("Player")) {
rb.AddForce((player.transform.position - transform.position).normalized, ForceMode.Impulse);
player.GetComponent<PlayerControl>().AddDamage(enemy.attackDamage);
}
}

void UpdateEnemyPath() {
direction = (player.transform.position - transform.position).normalized;
}

public void OnDeath() {
dead = true;

Debug.Log("Dead");
}
}
12 changes: 12 additions & 0 deletions Neonmania/Assets/Scripts/PlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class PlayerControl : MonoBehaviour {
private Rigidbody rb;
private PlayerColorChanger colorChanger;
private ProjectileController projectileController;
private float damage = 0;

// Use this for initialization
void Start () {
Expand Do