This commit is contained in:
Patrice Vignola 2015-08-22 21:48:57 -04:00
commit 9bf9b5aaef
14 changed files with 78 additions and 99 deletions

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 9264b7464f0b2a04d951cf9fbfef3019
folderAsset: yes
timeCreated: 1440262930
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a982ca76f16291a469a3532007a4cb13
timeCreated: 1440262931
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -1,55 +0,0 @@
fileFormatVersion: 2
guid: d8eead0b348e6814d877c5d98b8fb4fa
timeCreated: 1440264201
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 1
externalNormalMap: 1
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 2
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: 1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 11cc80c6443f5ea4190c0041d3858a7e
timeCreated: 1440263521
guid: cffa81ba5df21ac4f8d31f5bed357ce1
timeCreated: 1440275417
licenseType: Free
NativeFormatImporter:
userData:

Binary file not shown.

Binary file not shown.

View File

@ -2,52 +2,89 @@
using System.Collections;
using System.Collections.Generic;
public class AutoTarget : MonoBehaviour {
public class AutoTarget : MonoBehaviour
{
private List<Transform> targets;
public float minAngleRange = 60f;
// Use this for initialization
void Start () {
void Start ()
{
targets = new List<Transform>();
GameObject[] gos = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject go in gos) {
if( !go.Equals(gameObject) ){
foreach (GameObject go in gos)
{
if(!go.Equals(gameObject))
{
targets.Add(go.transform);
}
}
}
// Update is called once per frame
void Update () {
void Update ()
{
}
public Transform GetTarget(Vector3 lookingAngle) {
public Transform GetTarget(float screenX, float screenZ)
{
//Translate into looking angles
Vector3 forwardDir = Camera.main.transform.forward;
Vector3 rightDir = Camera.main.transform.right;
forwardDir.y = 0f;
forwardDir = forwardDir.normalized * screenZ;
rightDir.y = 0f;
rightDir = rightDir.normalized * screenX;
Vector3 movement = forwardDir + rightDir;
return GetTarget(movement);
}
public Transform GetTarget(Vector3 lookingAngle)
{
Transform closest = null;
float minAngle = minAngleRange;
Debug.Log("looking direction:" + lookingAngle);
//Debug.Log("looking direction:" + lookingAngle);
Debug.DrawRay(transform.position, lookingAngle * 2);
foreach (Transform t in targets) {
foreach (Transform t in targets)
{
Vector3 targetDirection = t.transform.position - transform.position;
float realAngle = Mathf.Atan2(targetDirection.z, targetDirection.x) * Mathf.Rad2Deg;
Debug.Log("real angle:" + realAngle);
float lookAngle = Mathf.Atan2(lookingAngle.z, lookingAngle.x) * Mathf.Rad2Deg;
Debug.Log("look angle:" + lookAngle);
//Debug.Log("look angle:" + lookAngle);
float angle = (lookAngle - realAngle + 5*360) % 360;
if (angle > 180)
angle -= 360;
//float angle = lookAngle - realAngle;
if (Mathf.Abs(lookAngle - realAngle) < minAngle) {
minAngle = lookAngle;
if (Input.GetKeyDown(KeyCode.D))
Debug.Log("Angle: " + angle + "Looking - " + lookAngle + "\nReal - " + realAngle);
//Debug.Log("real angle:" + realAngle);
if (Mathf.Abs(angle) < minAngle)
{
minAngle = angle;
closest = t;
}
}
if (closest != null)
{
Debug.DrawRay(transform.position, closest.transform.position - transform.position, Color.blue);
}
return closest;
}
}

View File

@ -75,7 +75,8 @@ public class ChildController : MonoBehaviour
}
if (xLookingValue != 0 || zLookingValue != 0) {
Transform target = _autoTarget.GetTarget(new Vector3(xLookingValue, 0, zLookingValue));
//Transform target = _autoTarget.GetTarget(new Vector3(xLookingValue, 0, zLookingValue));
Transform target = _autoTarget.GetTarget(xLookingValue, zLookingValue);
_child.target = target;
if (_child.target != null) {
@ -87,7 +88,6 @@ public class ChildController : MonoBehaviour
Mathf.Atan2(xLookingValue, zLookingValue) * Mathf.Rad2Deg,
transform.eulerAngles.z);
}
}
}

View File

@ -5,14 +5,28 @@ using System.Collections;
public class LightOnOff : MonoBehaviour {
private Light light;
private float intensity;
private float flicker;
// Use this for initialization
void Start () {
light = GetComponent<Light>();
intensity = light.intensity;
}
// Update is called once per frame
void Update () {
flicker -= Time.deltaTime;
if (flicker <= 0)
{
light.intensity = intensity * 0.8f;
if (Random.value <= 0.3f)
flicker = Random.Range(0.4f, 1.5f);
}
else
light.intensity = intensity;
if(Input.GetKeyDown(KeyCode.Space))
light.enabled = !light.enabled;
}