Commit 158637e4 by Tim Reiter

added turret button

parent a756f861
fileFormatVersion: 2
guid: ac2a3874793993e4ea958e1d9f235d5a
timeCreated: 1433457882
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -3,13 +3,10 @@ using System.Collections; ...@@ -3,13 +3,10 @@ using System.Collections;
public class Turret : MonoBehaviour { public class Turret : MonoBehaviour {
public Transform target;
public GameObject rocketPrefab; public GameObject rocketPrefab;
private Transform target;
private Rocket currentRocket;
// Use this for initialization
void Start () {
InvokeRepeating("shoot", 1.0f, 2.0f);
}
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
...@@ -26,7 +23,9 @@ public class Turret : MonoBehaviour { ...@@ -26,7 +23,9 @@ public class Turret : MonoBehaviour {
public void shoot() public void shoot()
{ {
Rocket newRocket = (GameObject.Instantiate(rocketPrefab, transform.position, transform.rotation) as GameObject).GetComponent<Rocket>(); if (currentRocket) return; // do not shoot another rocket when there is one already flying.
newRocket.setTarget(target);
currentRocket = (GameObject.Instantiate(rocketPrefab, transform.position, transform.rotation) as GameObject).GetComponent<Rocket>();
currentRocket.setTarget(target);
} }
} }
using UnityEngine;
using System.Collections;
public class TurretButton : MonoBehaviour {
public Turret cannon; // die entsprechende turret-cannon.
void OnCollisionEnter2D(Collision2D coll)
{
//soll nur von oben ausloesen:
if (coll.gameObject.tag == "Player" && coll.relativeVelocity.x<0.001f && coll.relativeVelocity.y>0.2f)
{
cannon.setTarget(coll.gameObject.transform);
cannon.shoot();
}
}
}
fileFormatVersion: 2
guid: 429169020cca7914692a6ae37225ac6a
timeCreated: 1433457512
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ae75b45fc60e1fd4da52c66d8f8716e2
timeCreated: 1433457314
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
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: 16
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 500
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
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