Commit 2dc14da8 authored by Jan Meissner's avatar Jan Meissner
Browse files

Fixed various cannon related bugs

parent 46c95adc
......@@ -35,6 +35,8 @@ GameObject:
m_Component:
- component: {fileID: 4060432582790156}
- component: {fileID: 212375044863857432}
- component: {fileID: 95144805117775786}
- component: {fileID: 114146924872583258}
m_Layer: 0
m_Name: CannonBarrel
m_TagString: Untagged
......@@ -51,8 +53,6 @@ GameObject:
m_Component:
- component: {fileID: 4205805952014266}
- component: {fileID: 212810178329633298}
- component: {fileID: 114951741708822878}
- component: {fileID: 95324237381742790}
m_Layer: 0
m_Name: Cannon
m_TagString: Untagged
......@@ -80,6 +80,39 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1560975367157764
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4515523674784162}
- component: {fileID: 212085445371616958}
- component: {fileID: 95645392377643954}
m_Layer: 0
m_Name: RadVorne
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1797984525371050
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4266236885723778}
- component: {fileID: 212267718161678974}
m_Layer: 0
m_Name: RadHinten
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4060432582790156
Transform:
m_ObjectHideFlags: 1
......@@ -87,12 +120,12 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1263581091867116}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: -0.27, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4468318558309648}
m_Father: {fileID: 4205805952014266}
m_RootOrder: 1
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4205805952014266
Transform:
......@@ -105,10 +138,25 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4439103326679612}
- {fileID: 4515523674784162}
- {fileID: 4266236885723778}
- {fileID: 4060432582790156}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4266236885723778
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1797984525371050}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4205805952014266}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4439103326679612
Transform:
m_ObjectHideFlags: 1
......@@ -135,6 +183,19 @@ Transform:
m_Father: {fileID: 4060432582790156}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4515523674784162
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1560975367157764}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4205805952014266}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!54 &54292225418600956
Rigidbody:
m_ObjectHideFlags: 1
......@@ -150,16 +211,16 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 120
m_CollisionDetection: 1
--- !u!95 &95324237381742790
--- !u!95 &95144805117775786
Animator:
serializedVersion: 3
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1320188170728490}
m_Enabled: 0
m_GameObject: {fileID: 1263581091867116}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: e8e097724cf19c54587221f2cd4dc16c, type: 2}
m_Controller: {fileID: 9100000, guid: ba5e37f816bbcb0489fd748ceeb1bf10, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
......@@ -186,32 +247,51 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114347105395272648
--- !u!95 &95645392377643954
Animator:
serializedVersion: 3
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1560975367157764}
m_Enabled: 0
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: bcef264006909234a8cded8383ab670c, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114146924872583258
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1369319522436270}
m_GameObject: {fileID: 1263581091867116}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9ab36b54f09296e4c90a725b52b5fe36, type: 3}
m_Script: {fileID: 11500000, guid: ac31383bdebf5e0489030e22a3c8c57b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114951741708822878
cannonBarrel: {fileID: 1263581091867116}
firePrefab: {fileID: 1354393239555122, guid: 3fd0675fac3d4794aafbb72c8557c635, type: 2}
shotsPerSeconds: 1
speed: 10
anim: {fileID: 95144805117775786}
--- !u!114 &114347105395272648
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1320188170728490}
m_GameObject: {fileID: 1369319522436270}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ac31383bdebf5e0489030e22a3c8c57b, type: 3}
m_Script: {fileID: 11500000, guid: 9ab36b54f09296e4c90a725b52b5fe36, type: 3}
m_Name:
m_EditorClassIdentifier:
cannonBarrel: {fileID: 1263581091867116}
firePrefab: {fileID: 1354393239555122, guid: 3fd0675fac3d4794aafbb72c8557c635, type: 2}
fireRate: 5
speed: 10
--- !u!135 &135608683392948086
SphereCollider:
m_ObjectHideFlags: 1
......@@ -224,6 +304,98 @@ SphereCollider:
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!212 &212085445371616958
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1560975367157764}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, 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: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1393728747
m_SortingLayer: 1
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 33ecf2ae4e3a2644bbed70e0c499ad5d, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 2.56, y: 2.56}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!212 &212267718161678974
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1797984525371050}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, 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: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 18bc6232e653f8f44965c2d0a6eed5cf, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 2.56, y: 2.56}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!212 &212303751120566804
SpriteRenderer:
m_ObjectHideFlags: 1
......@@ -302,10 +474,10 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingLayerID: 1393728747
m_SortingLayer: 1
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: b0e02b31b07a6a148bd6e457f3179f16, type: 3}
m_Sprite: {fileID: 21300000, guid: 14cd72156ec4da5408968db87210c7e9, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
......
......@@ -7,32 +7,31 @@ public class CannonController : MonoBehaviour
public GameObject cannonBarrel;
public GameObject firePrefab;
private GameObject currentFire;
public float fireRate = 10f;
private float fireWait;
public float shotsPerSeconds;
private float cooldown;
public float speed = 10f;
// Use this for initialization
void Start ()
{
fireWait = 1f / (fireRate/10f);
}
[SerializeField] private Animator anim;
// Update is called once per frame
void FixedUpdate ()
{
if (fireWait <= 0)
if (cooldown <= 0)
{
currentFire = Instantiate(firePrefab, cannonBarrel.transform.position, cannonBarrel.transform.rotation);
fireWait = 1f / (fireRate / 10f);
// Drehung
currentFire.transform.rotation = Quaternion.Euler(0, 0, 90) * cannonBarrel.transform.rotation;
// Flugrichtung
currentFire.GetComponent<Rigidbody>().velocity = cannonBarrel.transform.right * speed;
anim.SetTrigger("Fire");
}
else
{
fireWait -= Time.deltaTime;
cooldown = Mathf.Max(0, cooldown - Time.deltaTime);
}
}
public void Fire()
{
currentFire = Instantiate(firePrefab, cannonBarrel.transform.position, cannonBarrel.transform.rotation);
cooldown = 1f / (shotsPerSeconds);
// Drehung
currentFire.transform.rotation = Quaternion.Euler(0, 0, 90) * cannonBarrel.transform.rotation;
// Flugrichtung
currentFire.GetComponent<Rigidbody>().velocity = cannonBarrel.transform.right * speed;
}
}
......@@ -376,7 +376,7 @@ public class PlayerActor : MonoBehaviour {
UpdateOrientation();
}
private void Die()
public void Die()
{
transform.position = startingPosition;
......
......@@ -4,16 +4,9 @@ using UnityEngine;
public class ProjektilController : MonoBehaviour
{
private Rigidbody rb;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody>();
}
private void OnTriggerEnter2D(Collider2D other)
{
Debug.Log(other.name);
if (other.gameObject.name != "Cannon" || other.gameObject.name != "CannonBarrel")
{
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: CannonAnimator
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Fire
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 1107958033844076676}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &1101399011918543454
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102136452061446966}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101606714366998500
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Fire
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102222599320385362}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &1102136452061446966
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: CannonIdle
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101606714366998500}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 2041ab4af1be1714cb70aa12045ee359, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &1102222599320385362
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: CannonFire
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101399011918543454}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: ebb25ac1fad22594eb71afd2eac29f05, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &1107958033844076676
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102136452061446966}
m_Position: {x: 384, y: 108, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102222599320385362}
m_Position: {x: 396, y: 216, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102136452061446966}
fileFormatVersion: 2
guid: ba5e37f816bbcb0489fd748ceeb1bf10
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: CannonFire
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 21300000, guid: 14cd72156ec4da5408968db87210c7e9, type: 3}
- time: 0.041666668
value: {fileID: 21300000, guid: 21f5a4f0422aaca43ab857110a14ad02, type: 3}
- time: 0.083333336
value: {fileID: 21300000, guid: 9ebc326e7bd094b4c8a562ee03fb7fd8, type: 3}
- time: 0.125
value: {fileID: 21300000, guid: 323f8162cf7bf75488d6ebb320c068f2, type: 3}
- time: 0.16666667
value: {fileID: 21300000, guid: 6fa6c6f051e157642aa21e3b4610995d, type: 3}
- time: 0.20833333
value: {fileID: 21300000, guid: f130a0814c0cc054099afafc53bf9b42, type: 3}
- time: 0.25
value: {fileID: 21300000, guid: 3dcc78263d25e5040ad93396c7e1950d, type: 3}
- time: 0.29166666
value: {fileID: 21300000, guid: ca13749ff5e45f449b6869aca58c6687, type: 3}
- time: 0.33333334
value: {fileID: 21300000, guid: 5993f3ea65cfc8e429047aa1897fb78e, type: 3}
- time: 0.375
value: {fileID: 21300000, guid: bd87c6cc4178cfc4aa92d3b519d386ed, type: 3}
- time: 0.41666666
value: {fileID: 21300000, guid: bcd70210a8507ac409230d5b3d5c95b9, type: 3}
- time: 0.45833334
value: {fileID: 21300000, guid: 266af654601b5ee4c92141e7b8ddcd89, type: 3}
- time: 0.5
value: {fileID: 21300000, guid: df82b58ec17829f4d99ae927617e7452, type: 3}
- time: 0.5416667
value: {fileID: 21300000, guid: 15368947b307ea749beb6ff19949ec86, type: 3}
- time: 0.5833333