Permalink
Browse files

Holy hell it finally works

  • Loading branch information...
brendon-ai committed Jan 13, 2018
1 parent ea2bb08 commit 18fbf3e596dbbf18e135e600f83a2211ba17a775
@@ -38,7 +38,7 @@ GameObject:
- component: {fileID: 4941366499880692}
- component: {fileID: 54579768767235348}
- component: {fileID: 136855803810738378}
- component: {fileID: 114959412768523980}
- component: {fileID: 114479740433136154}
m_Layer: 0
m_Name: Bullet
m_TagString: Untagged
@@ -129,7 +129,7 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
--- !u!114 &114959412768523980
--- !u!114 &114479740433136154
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
@@ -52,9 +52,11 @@ GameObject:
serializedVersion: 5
m_Component:
- component: {fileID: 4107564328578448}
- component: {fileID: 114582393048724692}
- component: {fileID: 135401636332952394}
m_Layer: 0
m_Name: NormalHunterTower
m_TagString: Untagged
m_TagString: Tower
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -96,7 +98,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1404443622890868}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.055429667, y: -0.3399347, z: 1.5568571}
m_LocalPosition: {x: -0.51, y: -2.3449402, z: 2.34}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_Children:
- {fileID: 4740683730690628}
@@ -213,6 +215,19 @@ MeshFilter:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1070652682262262}
m_Mesh: {fileID: 4300000, guid: 53c3d9d29c8ea4b8da6d5a86f5a34de7, type: 3}
--- !u!114 &114582393048724692
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1404443622890868}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 478d525a05f554c5a9f0126da5559f07, type: 3}
m_Name:
m_EditorClassIdentifier:
successor: {fileID: 0}
bullet: {fileID: 1560192737533736, guid: 140389824e072400fb19223eae8cb5d3, type: 2}
--- !u!114 &114651997114369308
MonoBehaviour:
m_ObjectHideFlags: 1
@@ -226,3 +241,15 @@ MonoBehaviour:
m_EditorClassIdentifier:
successor: {fileID: 0}
bullet: {fileID: 1560192737533736, guid: 140389824e072400fb19223eae8cb5d3, type: 2}
--- !u!135 &135401636332952394
SphereCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1404443622890868}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 10
m_Center: {x: 2.5, y: 10.5, z: -12.5}
View
@@ -191,6 +191,7 @@ Camera:
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
@@ -238,7 +239,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 51665d6a7881f44bea39393fd3204577, type: 3}
m_Name:
m_EditorClassIdentifier:
tower: {fileID: 1790076028583340, guid: b77122004b9bc410085f5ece76c0b01f, type: 2}
tower: {fileID: 1404443622890868, guid: ed873b434404a4794bf58fc0ef3de712, type: 2}
money: 100
--- !u!1 &16
GameObject:
m_ObjectHideFlags: 0
@@ -644,90 +646,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &828172663
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 828172667}
- component: {fileID: 828172666}
- component: {fileID: 828172665}
- component: {fileID: 828172664}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &828172664
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 828172663}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &828172665
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 828172663}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &828172666
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 828172663}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &828172667
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 828172663}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.5, y: 0.8, z: 1}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &836632443
@@ -805,7 +723,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 836632446}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 578805324}
m_MethodName: Shoot
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &836632446
View
@@ -4,11 +4,36 @@
public class Bullet : MonoBehaviour
{
private bool isTower;
public void SetIsTower(bool isTowerIn)
{
isTower = isTowerIn;
print(isTower);
}
void OnTriggerEnter(Collider other)
{
print(isTower);
print(other.tag);
if (other.tag != "Tower")
{
Destroy(gameObject);
Invoke("Terminate", 0.1f);
}
else if (!isTower)
{
other.GetComponent<Tower>().HitByPlayer();
}
}
void Terminate()
{
Destroy(gameObject);
}
public enum Sender
{
PLAYER,
TOWER
}
}
@@ -6,6 +6,7 @@ public class CreateTower : MonoBehaviour
{
public GameObject tower;
public int money = 100;
Camera cam;
int towerCount = 0;
int towerLimit = 10;
@@ -2,15 +2,19 @@
using System.Collections.Generic;
using UnityEngine;
public class PlayerShoot : MonoBehaviour {
public class PlayerShoot : MonoBehaviour
{
public GameObject projectile;
public GameObject projectile;
public void Shoot(){
var ray = Camera.main.transform.rotation * Vector3.forward;
var proj = Instantiate(projectile);
proj.transform.position = Camera.main.transform.position;
proj.GetComponent<Rigidbody>().AddForce(ray * 100f);
Destroy (proj, 4);
}
public void Shoot()
{
var ray = Camera.main.transform.rotation * Vector3.forward;
var proj = Instantiate(projectile);
proj.transform.position = Camera.main.transform.position;
proj.transform.rotation = Quaternion.LookRotation(ray);
proj.GetComponent<Bullet>().SetIsTower(false);
proj.GetComponent<Rigidbody>().AddForce(ray * 100f);
Destroy(proj, 4);
}
}
@@ -14,12 +14,18 @@ public override void Shoot(Vector3 position)
var force = delta.normalized * bulletSpeed;
var bul = Instantiate(bullet);
bul.transform.position = transform.position;
//bul.transform.rotation = Quaternion.LookRotation(delta);
bul.transform.rotation = Quaternion.LookRotation(delta);
bul.GetComponent<Bullet>().SetIsTower(true);
bul.GetComponent<Rigidbody>().AddForce(force);
}
public override float GetFiringDelay()
{
return 0.4f;
}
public override int GetCost()
{
return 20;
}
}
@@ -7,9 +7,12 @@ public abstract class Tower : MonoBehaviour
public abstract void Shoot(Vector3 position);
public abstract float GetFiringDelay();
public abstract int GetCost();
public GameObject successor;
private int hitsByPlayerBeforeSale = 3;
void Start()
{
StartCoroutine(ShootLoop());
@@ -38,4 +41,14 @@ IEnumerator ShootLoop()
yield return new WaitForSeconds(GetFiringDelay());
}
}
public void HitByPlayer()
{
hitsByPlayerBeforeSale--;
if (hitsByPlayerBeforeSale <= 0)
{
Camera.main.GetComponent<CreateTower>().money += GetCost();
Destroy(gameObject);
}
}
}

0 comments on commit 18fbf3e

Please sign in to comment.