Skip to content

Commit

Permalink
syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
ObsessiveNerd committed Oct 8, 2016
2 parents 8c99a45 + b1f9be2 commit 92402ac
Show file tree
Hide file tree
Showing 29 changed files with 104 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions Assets/BattlemageVR/Resources/Scripts/DespawnAtLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;

public class DespawnAtLocation : MonoBehaviour
{
public Vector3 TargetLocation = new Vector3(0, 0, 0);

// Update is called once per frame
void Update () {
if((transform.position - TargetLocation).magnitude < .0001f)
{
Destroy(gameObject);
}
}
}
62 changes: 62 additions & 0 deletions Assets/BattlemageVR/Resources/Scripts/EnemyProjectileSpawnZone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using UnityEngine;
using System.Collections;

public class EnemyProjectileSpawnZone : MonoBehaviour
{
public float SpawnRateInSeconds = 1;

private float _lastSpawnTime = 0;

// Update is called once per frame
void Update () {
if(Time.time - _lastSpawnTime > SpawnRateInSeconds)
{
_lastSpawnTime = Time.time;
SpawnRandomProjectile();
}
}

private void SpawnRandomProjectile()
{
var t = transform;
var extent = t.localScale / 2;
var topForwardRight = t.position + t.up * extent.y + t.right * extent.x + t.forward * extent.z;
var bottomBackLeft = t.position - t.up * extent.y - t.right * extent.x - t.forward * extent.z;
var randPosition = new Vector3(
RandRange(topForwardRight.x, bottomBackLeft.x),
RandRange(topForwardRight.y, bottomBackLeft.y),
RandRange(topForwardRight.z, bottomBackLeft.z));

var projectile = CreateProjectile(randPosition, new Vector3(0, 1, 0));
projectile.transform.SetParent(transform, true);
}

private static GameObject CreateProjectile(Vector3 position, Vector3 target)
{
var projectile = Instantiate(PrefabFactory.RedFireballPrefab);
projectile.transform.position = position;

var moveScript = projectile.AddComponent<MoveToLocation>();
moveScript.Speed = 1f;
moveScript.TargetPosition = target;

var despawnScript = projectile.AddComponent<DespawnAtLocation>();
despawnScript.TargetLocation = target;

return projectile;
}

private static float RandRange(float a, float b)
{
if(a < b)
return Random.Range(a, b);
return Random.Range(b, a);
}

// Draw the bounds of the spawn zone in edit mode
void OnDrawGizmos()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireCube(transform.position, transform.localScale);
}
}
20 changes: 20 additions & 0 deletions Assets/BattlemageVR/Resources/Scripts/MoveToLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;

public class MoveToLocation : MonoBehaviour {
public Vector3 TargetPosition = new Vector2();
public float Speed = 1;

// Update is called once per frame
void Update () {
var moveAmount = Speed * Time.deltaTime;
var direction = TargetPosition - transform.position;

if(moveAmount > direction.magnitude)
{
moveAmount = direction.magnitude;
}

transform.position += moveAmount * direction.normalized;
}
}
7 changes: 7 additions & 0 deletions Assets/BattlemageVR/Resources/Scripts/PrefabFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using UnityEngine;
using System.Collections;

public static class PrefabFactory
{
public static readonly GameObject RedFireballPrefab = (GameObject)Resources.Load("Prefabs/RedFireball");
}
Binary file added Assets/BattlemageVR/Scenes/Prefabs.unity
Binary file not shown.
Binary file modified Assets/BattlemageVR/Scenes/SandboxModels.unity
Binary file not shown.
Binary file added Assets/FloorTiles/Materials/dirtfloor00.mat
Binary file not shown.
Binary file added Assets/FloorTiles/Materials/rockfloor00.mat
Binary file not shown.
Binary file added Assets/FloorTiles/Materials/stonefloor00.mat
Binary file not shown.
Binary file added Assets/FloorTiles/Materials/stonefloor01.mat
Binary file not shown.
Binary file added Assets/FloorTiles/Materials/stonefloor02.mat
Binary file not shown.
Binary file added Assets/FloorTiles/Textures/dirtfloor00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/FloorTiles/Textures/rockfloor00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/FloorTiles/Textures/stonefloor00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/FloorTiles/Textures/stonefloor01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/FloorTiles/Textures/stonefloor02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/Material/StoneFloor01.mat
Binary file not shown.
Binary file added Assets/Textures Set 01/Material/StoneFloor02.mat
Binary file not shown.
Binary file added Assets/Textures Set 01/Material/StoneFloor03.mat
Binary file not shown.
Binary file added Assets/Textures Set 01/Material/StoneFloor04.mat
Binary file not shown.
Binary file added Assets/Textures Set 01/Material/StoneFloor05.mat
Binary file not shown.
Binary file added Assets/Textures Set 01/Texture/StoneFloor01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/Texture/StoneFloor02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/Texture/StoneFloor03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/Texture/StoneFloor04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/Texture/StoneFloor05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures Set 01/demo.unity
Binary file not shown.

0 comments on commit 92402ac

Please sign in to comment.