Josh
2 years ago
10 changed files with 270 additions and 12 deletions
@ -0,0 +1,128 @@ |
|||||
|
%YAML 1.1 |
||||
|
%TAG !u! tag:unity3d.com,2011: |
||||
|
--- !u!1 &2355887706657292512 |
||||
|
GameObject: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
serializedVersion: 6 |
||||
|
m_Component: |
||||
|
- component: {fileID: 2355887706657292524} |
||||
|
- component: {fileID: 2355887706657292515} |
||||
|
- component: {fileID: 2355887706657292514} |
||||
|
- component: {fileID: 2355887706657292513} |
||||
|
- component: {fileID: 2355887706657292525} |
||||
|
m_Layer: 0 |
||||
|
m_Name: Powerup Prefab |
||||
|
m_TagString: Untagged |
||||
|
m_Icon: {fileID: 0} |
||||
|
m_NavMeshLayer: 0 |
||||
|
m_StaticEditorFlags: 0 |
||||
|
m_IsActive: 1 |
||||
|
--- !u!4 &2355887706657292524 |
||||
|
Transform: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
m_GameObject: {fileID: 2355887706657292512} |
||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
|
m_LocalPosition: {x: 833.31, y: 809.7, z: -9.3} |
||||
|
m_LocalScale: {x: 0.38822, y: 0.38822, z: 0.38822} |
||||
|
m_Children: [] |
||||
|
m_Father: {fileID: 0} |
||||
|
m_RootOrder: 0 |
||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
|
--- !u!212 &2355887706657292515 |
||||
|
SpriteRenderer: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
m_GameObject: {fileID: 2355887706657292512} |
||||
|
m_Enabled: 1 |
||||
|
m_CastShadows: 0 |
||||
|
m_ReceiveShadows: 0 |
||||
|
m_DynamicOccludee: 1 |
||||
|
m_MotionVectors: 1 |
||||
|
m_LightProbeUsage: 1 |
||||
|
m_ReflectionProbeUsage: 1 |
||||
|
m_RayTracingMode: 0 |
||||
|
m_RayTraceProcedural: 0 |
||||
|
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: 0 |
||||
|
m_SortingLayer: 0 |
||||
|
m_SortingOrder: 0 |
||||
|
m_Sprite: {fileID: 21300000, guid: d6c3531494da6b64fba26dea94bc6098, type: 3} |
||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1} |
||||
|
m_FlipX: 0 |
||||
|
m_FlipY: 0 |
||||
|
m_DrawMode: 0 |
||||
|
m_Size: {x: 160, y: 218} |
||||
|
m_AdaptiveModeThreshold: 0.5 |
||||
|
m_SpriteTileMode: 0 |
||||
|
m_WasSpriteAssigned: 1 |
||||
|
m_MaskInteraction: 0 |
||||
|
m_SpriteSortPoint: 0 |
||||
|
--- !u!58 &2355887706657292514 |
||||
|
CircleCollider2D: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
m_GameObject: {fileID: 2355887706657292512} |
||||
|
m_Enabled: 1 |
||||
|
m_Density: 1 |
||||
|
m_Material: {fileID: 0} |
||||
|
m_IsTrigger: 1 |
||||
|
m_UsedByEffector: 0 |
||||
|
m_UsedByComposite: 0 |
||||
|
m_Offset: {x: 0, y: 0} |
||||
|
serializedVersion: 2 |
||||
|
m_Radius: 109 |
||||
|
--- !u!114 &2355887706657292513 |
||||
|
MonoBehaviour: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
m_GameObject: {fileID: 2355887706657292512} |
||||
|
m_Enabled: 1 |
||||
|
m_EditorHideFlags: 0 |
||||
|
m_Script: {fileID: 11500000, guid: 02d335f1af9cc3e47837750dc736c2ba, type: 3} |
||||
|
m_Name: |
||||
|
m_EditorClassIdentifier: |
||||
|
--- !u!114 &2355887706657292525 |
||||
|
MonoBehaviour: |
||||
|
m_ObjectHideFlags: 0 |
||||
|
m_CorrespondingSourceObject: {fileID: 0} |
||||
|
m_PrefabInstance: {fileID: 0} |
||||
|
m_PrefabAsset: {fileID: 0} |
||||
|
m_GameObject: {fileID: 2355887706657292512} |
||||
|
m_Enabled: 1 |
||||
|
m_EditorHideFlags: 0 |
||||
|
m_Script: {fileID: 11500000, guid: 37dfc580ad57d894caaababe502afb5b, type: 3} |
||||
|
m_Name: |
||||
|
m_EditorClassIdentifier: |
||||
|
_useWorldSpace: 0 |
@ -0,0 +1,7 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: fe820c2aff8b39b4e9017b4b0e042dae |
||||
|
PrefabImporter: |
||||
|
externalObjects: {} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
@ -0,0 +1,48 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using UnityEngine; |
||||
|
|
||||
|
public class Powerup : MonoBehaviour |
||||
|
{ |
||||
|
const float SPEED = 200f; |
||||
|
List<Player> _players = new List<Player>(); |
||||
|
float _direction = 1f; |
||||
|
// Start is called before the first frame update
|
||||
|
void Start() |
||||
|
{ |
||||
|
_players = new List<Player>(FindObjectsOfType<Player>()); |
||||
|
if (Random.Range(0, 2) == 0) |
||||
|
_direction = -1f; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// Update is called once per frame
|
||||
|
void Update() |
||||
|
{ |
||||
|
Player closestPlayer = null; |
||||
|
float closestDistance = 9999999f; |
||||
|
foreach (Player player in _players) |
||||
|
{ |
||||
|
float distance = Vector3.Distance(player.transform.position, transform.position); |
||||
|
if (distance < closestDistance) |
||||
|
{ |
||||
|
closestDistance = distance; |
||||
|
closestPlayer = player; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Vector3 direction = new Vector3(_direction, 0, 0); |
||||
|
//move away from closest player
|
||||
|
if (closestPlayer != null && closestDistance < 300f) |
||||
|
{ |
||||
|
direction = closestPlayer.transform.position - transform.position; |
||||
|
direction.Normalize(); |
||||
|
direction.z = 0f; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
transform.position += direction * Time.deltaTime * -1 * SPEED; |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 02d335f1af9cc3e47837750dc736c2ba |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
Loading…
Reference in new issue