Rename VendingMachine to GunDropper and add Barrel
This commit is contained in:
parent
07045e5aff
commit
772d517aa1
207
Assets/Prefabs/Barrel.prefab
Normal file
207
Assets/Prefabs/Barrel.prefab
Normal file
@ -0,0 +1,207 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &424114502350994919
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8746823443980265568}
|
||||
- component: {fileID: 1866938550730718414}
|
||||
- component: {fileID: 1412464023054947666}
|
||||
- component: {fileID: 1017275022680165955}
|
||||
- component: {fileID: 7944145363570086424}
|
||||
m_Layer: 0
|
||||
m_Name: Barrel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8746823443980265568
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 424114502350994919}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -16.38031, y: 5.175766, z: -6.0566406}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 6622279062642803414}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!50 &1866938550730718414
|
||||
Rigidbody2D:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 424114502350994919}
|
||||
m_BodyType: 2
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDrag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_GravityScale: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
--- !u!61 &1412464023054947666
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 424114502350994919}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: -0.001390934}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 0.50437164, y: 0.5076113}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!114 &1017275022680165955
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 424114502350994919}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a2110188365a59e4cb31d0e84789fbbd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
BodypartPrefabs:
|
||||
- {fileID: 3847767376140256459, guid: b3bfb4ae89e38244dad2c4396ec48ba3, type: 3}
|
||||
- {fileID: 3847767376140256459, guid: 7194f42d640f6cc4b8ff71eff6a9b85b, type: 3}
|
||||
- {fileID: 3847767376140256459, guid: 16e2e783575dcf147bd67039283f1c17, type: 3}
|
||||
DebugExplode: 0
|
||||
ParticlesPerBodypart: 70
|
||||
BodypartMinCount: 1
|
||||
BodypartMaxCount: 3
|
||||
DebrisType: 2
|
||||
--- !u!114 &7944145363570086424
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 424114502350994919}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7a80c0c53597a834e9decbeebcb08434, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GunLaunchForceMultiplier: 1
|
||||
HoleTransform: {fileID: 6622279062642803414}
|
||||
Explodable: {fileID: 1017275022680165955}
|
||||
ExplodeOnEmpty: 1
|
||||
GunsLeft: 1
|
||||
PossibleGuns:
|
||||
- {fileID: 4462327694118370270, guid: 7b3529c1a7d22d143a060281857bbca5, type: 3}
|
||||
- {fileID: 2523517584660005062, guid: 15e91d59183ba524bb3bc46b402b722d, type: 3}
|
||||
SpriteChanger: {fileID: 0}
|
||||
DebugExpelGun: 0
|
||||
--- !u!1 &2707968752687241717
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6622279062642803414}
|
||||
- component: {fileID: 2042706909563280659}
|
||||
m_Layer: 0
|
||||
m_Name: Placeholder
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6622279062642803414
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2707968752687241717}
|
||||
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: 8746823443980265568}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &2042706909563280659
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2707968752687241717}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
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_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: -947994997
|
||||
m_SortingLayer: 4
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 472874229c563e241bddc073ec2dbb90, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 0.5, y: 0.5}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
7
Assets/Prefabs/Barrel.prefab.meta
Normal file
7
Assets/Prefabs/Barrel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2ea86881596cfa4b980184bde6a13be
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -12,7 +12,7 @@ GameObject:
|
||||
- component: {fileID: 11699643643052996}
|
||||
- component: {fileID: 7530413041674808940}
|
||||
m_Layer: 0
|
||||
m_Name: Placeholder
|
||||
m_Name: Sprite
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -114,6 +114,7 @@ GameObject:
|
||||
- component: {fileID: 11699643827672084}
|
||||
- component: {fileID: 11699643827672083}
|
||||
- component: {fileID: 11699643827672086}
|
||||
- component: {fileID: 4165805474229086665}
|
||||
m_Layer: 0
|
||||
m_Name: Vending Machine
|
||||
m_TagString: Environment
|
||||
@ -151,17 +152,12 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
GunLaunchForceMultiplier: 3.5
|
||||
HoleTransform: {fileID: 11699643844798483}
|
||||
Explodable: {fileID: 11699643827672086}
|
||||
ExplodeOnEmpty: 0
|
||||
GunsLeft: 3
|
||||
PossibleGuns:
|
||||
- {fileID: 4462327694118370270, guid: 7b3529c1a7d22d143a060281857bbca5, type: 3}
|
||||
Sprite: {fileID: 11699643643052996}
|
||||
Sprites:
|
||||
- {fileID: 2570391356933361261, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 881297774068237510, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 6754790859930108749, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: -5872275606889041824, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: -7095097463981226713, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 8265045834036228682, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
SpriteChanger: {fileID: 4165805474229086665}
|
||||
DebugExpelGun: 0
|
||||
--- !u!50 &11699643827672084
|
||||
Rigidbody2D:
|
||||
@ -234,6 +230,27 @@ MonoBehaviour:
|
||||
BodypartMinCount: 4
|
||||
BodypartMaxCount: 6
|
||||
DebrisType: 1
|
||||
--- !u!114 &4165805474229086665
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643827672081}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 963ee06ef5f5e0d4a841d0d4a16f0edc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Sprite: {fileID: 11699643643052996}
|
||||
Sprites:
|
||||
- {fileID: 2570391356933361261, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 881297774068237510, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 6754790859930108749, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: -5872275606889041824, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: -7095097463981226713, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
- {fileID: 8265045834036228682, guid: 0aa113ac73f3394448b77e6c4c712232, type: 3}
|
||||
InitialIdx: 5
|
||||
--- !u!1 &11699643844798482
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4,28 +4,33 @@ using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
using Saltosion.OneWeapon.Guns;
|
||||
using Saltosion.OneWeapon.Utils;
|
||||
using Saltosion.OneWeapon.Effects;
|
||||
|
||||
namespace Saltosion.OneWeapon.Environment {
|
||||
public class VendingMachine : MonoBehaviour {
|
||||
[RequireComponent(typeof(Explodable))]
|
||||
public class GunDropper : MonoBehaviour {
|
||||
|
||||
[Header("General")]
|
||||
public float GunLaunchForceMultiplier = 1;
|
||||
public Transform HoleTransform;
|
||||
public Explodable Explodable;
|
||||
public bool ExplodeOnEmpty = false;
|
||||
|
||||
[Header("Gunstuff")]
|
||||
public int GunsLeft = 3;
|
||||
public List<GameObject> PossibleGuns = new List<GameObject>();
|
||||
|
||||
[Header("Graphics")]
|
||||
public SpriteRenderer Sprite;
|
||||
public List<Sprite> Sprites = new List<Sprite>();
|
||||
[Header("Graphics (optional)")]
|
||||
public SpriteChanger SpriteChanger;
|
||||
|
||||
[Header("Debug")]
|
||||
public bool DebugExpelGun = false;
|
||||
|
||||
void Start() {
|
||||
GunsLeft = Mathf.Clamp(GunsLeft, 0, 5);
|
||||
Sprite.sprite = Sprites[GunsLeft];
|
||||
if (SpriteChanger != null) {
|
||||
GunsLeft = Mathf.Clamp(GunsLeft, 0, SpriteChanger.Sprites.Count - 1);
|
||||
SpriteChanger.SetSprite(GunsLeft);
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
@ -47,10 +52,16 @@ namespace Saltosion.OneWeapon.Environment {
|
||||
Body.AddForce(DownwardForce + SidewaysForce, ForceMode2D.Impulse);
|
||||
}
|
||||
GunsLeft -= 1;
|
||||
Sprite.sprite = Sprites[GunsLeft];
|
||||
if (SpriteChanger != null) {
|
||||
SpriteChanger.SetSprite(GunsLeft);
|
||||
}
|
||||
if (GunsLeft == 0) {
|
||||
if (ExplodeOnEmpty) {
|
||||
Explodable.Explode(true);
|
||||
} else {
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
Assets/Scripts/Environment/SpriteChanger.cs
Normal file
27
Assets/Scripts/Environment/SpriteChanger.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Saltosion.OneWeapon.Environment {
|
||||
public class SpriteChanger : MonoBehaviour {
|
||||
|
||||
public SpriteRenderer Sprite;
|
||||
public List<Sprite> Sprites = new List<Sprite>();
|
||||
public int InitialIdx = 0;
|
||||
|
||||
private int CurrentIdx = 0;
|
||||
|
||||
void Start() {
|
||||
CurrentIdx = Mathf.Clamp(InitialIdx, 0, Sprites.Count - 1);
|
||||
}
|
||||
|
||||
public bool SetSprite(int Index) {
|
||||
if (Index < 0 || Index >= Sprites.Count) {
|
||||
Debug.LogError("Cannot change sprite to an index that does not exist!");
|
||||
return false;
|
||||
}
|
||||
Sprite.sprite = Sprites[Index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Environment/SpriteChanger.cs.meta
Normal file
11
Assets/Scripts/Environment/SpriteChanger.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 963ee06ef5f5e0d4a841d0d4a16f0edc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -15,7 +15,7 @@ namespace Saltosion.OneWeapon.Guns {
|
||||
public void DoDamage(float Damage, float Intensity, Collider2D Collider, Vector2 Direction) {
|
||||
Explodable Explodable = Collider.GetComponent<Explodable>();
|
||||
Health Health = Collider.GetComponent<Health>();
|
||||
VendingMachine VendingMachine = Collider.GetComponent<VendingMachine>();
|
||||
GunDropper VendingMachine = Collider.GetComponent<GunDropper>();
|
||||
if (Health != null) {
|
||||
Health.Damage(Damage, -Direction, true);
|
||||
} else if (VendingMachine != null) {
|
||||
|
@ -20,7 +20,7 @@ namespace Saltosion.OneWeapon.Player {
|
||||
|
||||
Explodable Explodable = collider.GetComponent<Explodable>();
|
||||
Health Health = collider.GetComponent<Health>();
|
||||
VendingMachine VendingMachine = collider.GetComponent<VendingMachine>();
|
||||
GunDropper VendingMachine = collider.GetComponent<GunDropper>();
|
||||
Vector2 Direction = (collider.transform.position - transform.position).normalized;
|
||||
if (Health != null) {
|
||||
Health.Damage(8f, -Direction, true);
|
||||
|
Loading…
Reference in New Issue
Block a user