Add vending machines
This commit is contained in:
parent
0391622a11
commit
6a96b94a2b
228
Assets/Prefabs/Vending Machine.prefab
Normal file
228
Assets/Prefabs/Vending Machine.prefab
Normal file
@ -0,0 +1,228 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &11699643643052994
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 11699643643052995}
|
||||
- component: {fileID: 11699643643052996}
|
||||
m_Layer: 0
|
||||
m_Name: Placeholder
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &11699643643052995
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643643052994}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 2, y: 3, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 11699643827672082}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &11699643643052996
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643643052994}
|
||||
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: 106348079
|
||||
m_SortingLayer: 3
|
||||
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
|
||||
--- !u!1 &11699643827672081
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 11699643827672082}
|
||||
- component: {fileID: 11699643827672085}
|
||||
- component: {fileID: 11699643827672084}
|
||||
- component: {fileID: 11699643827672083}
|
||||
- component: {fileID: 11699643827672086}
|
||||
m_Layer: 0
|
||||
m_Name: Vending Machine
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &11699643827672082
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643827672081}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 4.08, y: 6.61, z: -11.644531}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 11699643643052995}
|
||||
- {fileID: 11699643844798483}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &11699643827672085
|
||||
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: 7a80c0c53597a834e9decbeebcb08434, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GunsLeft: 3
|
||||
PossibleGuns:
|
||||
- {fileID: 4462327694118370270, guid: 7b3529c1a7d22d143a060281857bbca5, type: 3}
|
||||
GunLaunchForceMultiplier: 3.5
|
||||
HoleTransform: {fileID: 11699643844798483}
|
||||
DebugExpelGun: 0
|
||||
--- !u!50 &11699643827672084
|
||||
Rigidbody2D:
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643827672081}
|
||||
m_BodyType: 2
|
||||
m_Simulated: 1
|
||||
m_UseFullKinematicContacts: 0
|
||||
m_UseAutoMass: 0
|
||||
m_Mass: 1
|
||||
m_LinearDrag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_GravityScale: 0
|
||||
m_Material: {fileID: 0}
|
||||
m_Interpolate: 0
|
||||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 0
|
||||
m_Constraints: 0
|
||||
--- !u!61 &11699643827672083
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643827672081}
|
||||
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}
|
||||
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: 1, y: 1.4901962}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!114 &11699643827672086
|
||||
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: a2110188365a59e4cb31d0e84789fbbd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
BodypartPrefabs: []
|
||||
DebugExplode: 0
|
||||
KillOnZeroHealth: 1
|
||||
--- !u!1 &11699643844798482
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 11699643844798483}
|
||||
m_Layer: 0
|
||||
m_Name: Hole
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &11699643844798483
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 11699643844798482}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -1.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 11699643827672082}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
7
Assets/Prefabs/Vending Machine.prefab.meta
Normal file
7
Assets/Prefabs/Vending Machine.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 254d8b252b63a6547810dd3729ddc91b
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -109320,6 +109320,75 @@ Transform:
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 670706965}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &11699644215422960
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 11699643827672081, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Vending Machine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 4.08
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 6.61
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -11.644531
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11699643827672082, guid: 254d8b252b63a6547810dd3729ddc91b,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 254d8b252b63a6547810dd3729ddc91b, type: 3}
|
||||
--- !u!1001 &592487111117925280
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
8
Assets/Scripts/Environment.meta
Normal file
8
Assets/Scripts/Environment.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52862cb8a131a22418cc1385dc18057f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/Environment/VendingMachine.cs
Normal file
43
Assets/Scripts/Environment/VendingMachine.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Saltosion.OneWeapon.Guns;
|
||||
using Saltosion.OneWeapon.Utils;
|
||||
|
||||
namespace Saltosion.OneWeapon.Environment {
|
||||
public class VendingMachine : MonoBehaviour {
|
||||
|
||||
public int GunsLeft = 3;
|
||||
public List<GameObject> PossibleGuns = new List<GameObject>();
|
||||
|
||||
public float GunLaunchForceMultiplier = 1;
|
||||
|
||||
public Transform HoleTransform;
|
||||
|
||||
public bool DebugExpelGun = false;
|
||||
|
||||
void Update() {
|
||||
if (DebugExpelGun) {
|
||||
ExpelGun();
|
||||
DebugExpelGun = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExpelGun() {
|
||||
GameObject Gun = PossibleGuns[Util.RandomValueBetween(0, PossibleGuns.Count - 1)];
|
||||
GameObject ShotGun = GameObject.Instantiate(Gun, HoleTransform.position, new Quaternion());
|
||||
Rigidbody2D Body = ShotGun.GetComponent<Rigidbody2D>();
|
||||
if (Body == null) {
|
||||
Debug.LogError("Shotted Gun has no RigidBody2D!");
|
||||
} else {
|
||||
Vector2 DownwardForce = new Vector2(0, -1) * (Random.value + 0.2f) * GunLaunchForceMultiplier;
|
||||
Vector2 SidewaysForce = new Vector2(1, 0) * (Random.value * 0.4f - 0.2f) * GunLaunchForceMultiplier;
|
||||
Body.AddForce(DownwardForce + SidewaysForce, ForceMode2D.Impulse);
|
||||
}
|
||||
GunsLeft -= 1;
|
||||
if (GunsLeft == 0) {
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Environment/VendingMachine.cs.meta
Normal file
11
Assets/Scripts/Environment/VendingMachine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a80c0c53597a834e9decbeebcb08434
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
using Saltosion.OneWeapon.Player;
|
||||
using Saltosion.OneWeapon.Enemies;
|
||||
using Saltosion.OneWeapon.Effects;
|
||||
using Saltosion.OneWeapon.Environment;
|
||||
|
||||
namespace Saltosion.OneWeapon.Guns {
|
||||
[RequireComponent(typeof(Bullet))]
|
||||
@ -49,9 +50,12 @@ namespace Saltosion.OneWeapon.Guns {
|
||||
// Do damage here, kill everyone
|
||||
Explodable Explodable = collider.GetComponent<Explodable>();
|
||||
Health Health = collider.GetComponent<Health>();
|
||||
VendingMachine VendingMachine = collider.GetComponent<VendingMachine>();
|
||||
Vector2 Direction = (collider.transform.position - transform.position).normalized;
|
||||
if (Health != null) {
|
||||
Health.Damage(12f, -Direction);
|
||||
} else if (VendingMachine != null) {
|
||||
VendingMachine.ExpelGun();
|
||||
} else if (Explodable != null) {
|
||||
Explodable.Explode(true);
|
||||
} else if (collider.tag == "Environment") {
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Saltosion.OneWeapon.Enemies;
|
||||
using Saltosion.OneWeapon.Effects;
|
||||
using Saltosion.OneWeapon.Environment;
|
||||
|
||||
namespace Saltosion.OneWeapon.Player {
|
||||
public class PunchingHand : MonoBehaviour {
|
||||
@ -19,9 +20,12 @@ namespace Saltosion.OneWeapon.Player {
|
||||
|
||||
Explodable Explodable = collider.GetComponent<Explodable>();
|
||||
Health Health = collider.GetComponent<Health>();
|
||||
VendingMachine VendingMachine = collider.GetComponent<VendingMachine>();
|
||||
Vector2 Direction = (collider.transform.position - transform.position).normalized;
|
||||
if (Health != null) {
|
||||
Health.Damage(8f, -Direction);
|
||||
} else if (VendingMachine != null) {
|
||||
VendingMachine.ExpelGun();
|
||||
} else if (Explodable != null) {
|
||||
Explodable.Explode(true);
|
||||
}
|
||||
|
@ -38,5 +38,10 @@ namespace Saltosion.OneWeapon.Utils {
|
||||
}
|
||||
return FoundTarget;
|
||||
}
|
||||
|
||||
public static int RandomValueBetween(int min, int max) {
|
||||
int RollMax = max - min;
|
||||
return (int)(min + Mathf.Min(Mathf.Floor(Random.value * (RollMax + 1)), RollMax));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user