Browse Source

added pterodactyl

master
Josh 2 years ago
parent
commit
6621a974cc
  1. 13
      unity/Assets/Game.cs
  2. 22
      unity/Assets/Prefabs/Fireball.prefab
  3. 124
      unity/Assets/Prefabs/Pterodactyl.prefab
  4. 7
      unity/Assets/Prefabs/Pterodactyl.prefab.meta
  5. 56
      unity/Assets/Pterodactyl.cs
  6. 11
      unity/Assets/Pterodactyl.cs.meta
  7. 15
      unity/Assets/Scenes/SampleScene.unity
  8. 7
      unity/Assets/Scripts/DragonMovement.cs
  9. BIN
      unity/Assets/Sprites/pterodactyl.png
  10. 109
      unity/Assets/Sprites/pterodactyl.png.meta
  11. 1
      unity/ProjectSettings/TagManager.asset

13
unity/Assets/Game.cs

@ -9,9 +9,11 @@ public class Game : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
[SerializeField] GameObject _cloudPrefab; [SerializeField] GameObject _cloudPrefab;
[SerializeField] GameObject _birdPrefab; [SerializeField] GameObject _birdPrefab;
[SerializeField] GameObject _pterodactylPrefab;
const int NUM_CLOUDS = 8; const int NUM_CLOUDS = 8;
const float START_X = 1300; const float START_X = 1300;
const float PTERODACTYL_CHANCE = .15f;
[SerializeField] Text _victoryMessage; [SerializeField] Text _victoryMessage;
[SerializeField] Text _restartMessage; [SerializeField] Text _restartMessage;
bool _victory = false; bool _victory = false;
@ -43,7 +45,16 @@ public class Game : MonoBehaviour
} }
void SpawnBird() void SpawnBird()
{ {
GameObject bird = GameObject.Instantiate(_birdPrefab); GameObject bird;
if (Random.Range(0f,1f)< PTERODACTYL_CHANCE)
{
bird = GameObject.Instantiate(_pterodactylPrefab);
}
else
{
bird = GameObject.Instantiate(_birdPrefab);
}
float y = Random.Range(0f, 1080f); float y = Random.Range(0f, 1080f);
bird.transform.position = new Vector3(2000f, y, 0f); bird.transform.position = new Vector3(2000f, y, 0f);

22
unity/Assets/Prefabs/Fireball.prefab

@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 3013654646655086451} - component: {fileID: 3013654646655086451}
- component: {fileID: 3013654646655086461} - component: {fileID: 3013654646655086461}
- component: {fileID: 3013654646655086462} - component: {fileID: 3013654646655086462}
- component: {fileID: 6425069043373571486}
m_Layer: 0 m_Layer: 0
m_Name: Fireball m_Name: Fireball
m_TagString: Fireball m_TagString: Fireball
@ -112,3 +113,24 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2a119ef73dcc6194c99e91dd07dcd3e2, type: 3} m_Script: {fileID: 11500000, guid: 2a119ef73dcc6194c99e91dd07dcd3e2, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!50 &6425069043373571486
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3013654646655086450}
m_BodyType: 1
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

124
unity/Assets/Prefabs/Pterodactyl.prefab

@ -0,0 +1,124 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8800180563921210508
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8800180563921210499}
- component: {fileID: 8800180563921210498}
- component: {fileID: 32720342014875606}
- component: {fileID: 1486118656744360977}
m_Layer: 0
m_Name: Pterodactyl
m_TagString: Pterodactyl
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8800180563921210499
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8800180563921210508}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1137.7001, y: 597.95557, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &8800180563921210498
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8800180563921210508}
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: cb0c34c0c205cce41852fef0dc6f3d2b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1.32, y: 0.92}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &32720342014875606
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8800180563921210508}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dd4ec9936f1a3564d94f0d9647590711, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!61 &1486118656744360977
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8800180563921210508}
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}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 360, y: 160}
newSize: {x: 1.32, y: 0.92}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 196.8, y: 47.9}
m_EdgeRadius: 0

7
unity/Assets/Prefabs/Pterodactyl.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bf14bcfe3b3690a489f399b20ba09904
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

56
unity/Assets/Pterodactyl.cs

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pterodactyl : MonoBehaviour
{
const float horizontalSpeed = 300f;
const float verticalSpeed = 200f;
DragonMovement[] _dragons;
// Start is called before the first frame update
void Start()
{
_dragons = FindObjectsOfType<DragonMovement>();
}
// Update is called once per frame
void Update()
{
DragonMovement closestPlayerToMyLeft = null;
float closestDistance = float.MaxValue;
foreach (DragonMovement dragon in _dragons)
{
float distance = Vector3.Distance(gameObject.transform.position, dragon.transform.transform.position);
if (distance < closestDistance && dragon.transform.position.x < this.transform.position.x)
{
closestDistance = distance;
closestPlayerToMyLeft = dragon;
}
}
float verticalDirection = 1f;
if (closestPlayerToMyLeft != null && closestPlayerToMyLeft.transform.position.y < this.transform.position.y)
verticalDirection = -1f;
if (closestPlayerToMyLeft == null)
verticalDirection = 0;
transform.position = new Vector3(transform.position.x - Time.deltaTime * horizontalSpeed, transform.position.y + (Time.deltaTime * verticalSpeed * verticalDirection), transform.position.z);
if (transform.position.x < -100f)
{
GameObject.Destroy(this.gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Fireball"))
{
GameObject.Destroy(this.gameObject);
}
}
}

11
unity/Assets/Pterodactyl.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd4ec9936f1a3564d94f0d9647590711
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
unity/Assets/Scenes/SampleScene.unity

@ -2530,7 +2530,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 629347643} m_GameObject: {fileID: 629347643}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 180, y: 663.9, z: 0.024148} m_LocalPosition: {x: 180, y: 663.9, z: 0.001}
m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226} m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226}
m_Children: m_Children:
- {fileID: 702048808} - {fileID: 702048808}
@ -2544,7 +2544,7 @@ Transform:
- {fileID: 1201008832} - {fileID: 1201008832}
- {fileID: 1980046889} - {fileID: 1980046889}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &647939879 --- !u!1 &647939879
GameObject: GameObject:
@ -3017,6 +3017,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_cloudPrefab: {fileID: 8093627333698608799, guid: 222963b5f45b20141bf7dd413f3342cd, type: 3} _cloudPrefab: {fileID: 8093627333698608799, guid: 222963b5f45b20141bf7dd413f3342cd, type: 3}
_birdPrefab: {fileID: 8800180563921210508, guid: 9777a80f11a5216499bc46c9edf06b7b, type: 3} _birdPrefab: {fileID: 8800180563921210508, guid: 9777a80f11a5216499bc46c9edf06b7b, type: 3}
_pterodactylPrefab: {fileID: 8800180563921210508, guid: bf14bcfe3b3690a489f399b20ba09904, type: 3}
_victoryMessage: {fileID: 1794958515} _victoryMessage: {fileID: 1794958515}
_restartMessage: {fileID: 1744497687} _restartMessage: {fileID: 1744497687}
--- !u!4 &822168905 --- !u!4 &822168905
@ -3032,7 +3033,7 @@ Transform:
m_Children: m_Children:
- {fileID: 1627385223} - {fileID: 1627385223}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &824113789 --- !u!1 &824113789
GameObject: GameObject:
@ -4677,7 +4678,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1208042745} m_GameObject: {fileID: 1208042745}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 180, y: 396.3, z: 0} m_LocalPosition: {x: 180, y: 396.3, z: 0.002}
m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226} m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226}
m_Children: m_Children:
- {fileID: 833231469} - {fileID: 833231469}
@ -4691,7 +4692,7 @@ Transform:
- {fileID: 1309452131} - {fileID: 1309452131}
- {fileID: 144142773} - {fileID: 144142773}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1226411071 --- !u!1 &1226411071
GameObject: GameObject:
@ -5750,7 +5751,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1588360791} m_GameObject: {fileID: 1588360791}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 180, y: 154.9, z: 0} m_LocalPosition: {x: 180, y: 154.9, z: 0.003}
m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226} m_LocalScale: {x: 1.2226, y: 1.2226, z: 1.2226}
m_Children: m_Children:
- {fileID: 1779421299} - {fileID: 1779421299}
@ -5764,7 +5765,7 @@ Transform:
- {fileID: 883733605} - {fileID: 883733605}
- {fileID: 836019842} - {fileID: 836019842}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1627385222 --- !u!1 &1627385222
GameObject: GameObject:

7
unity/Assets/Scripts/DragonMovement.cs

@ -105,7 +105,7 @@ public class DragonMovement : MonoBehaviour
if (collision.CompareTag("Fireball")) if (collision.CompareTag("Fireball"))
{ {
Fireball fireball = collision.GetComponent<Fireball>(); Fireball fireball = collision.GetComponent<Fireball>();
if (fireball.transform.parent.gameObject == this.gameObject) if (fireball != null && fireball.transform.parent != null && fireball.transform.parent.gameObject == this.gameObject)
return; return;
if (fireball.AttackType == AttackType.CONE) if (fireball.AttackType == AttackType.CONE)
@ -117,6 +117,11 @@ public class DragonMovement : MonoBehaviour
Stun(.6f); Stun(.6f);
} }
} }
if (collision.CompareTag("Pterodactyl"))
{
Stun(.8f);
}
} }
void ColorizeAmmo(Color color) void ColorizeAmmo(Color color)

BIN
unity/Assets/Sprites/pterodactyl.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

109
unity/Assets/Sprites/pterodactyl.png.meta

@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: cb0c34c0c205cce41852fef0dc6f3d2b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 2
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

1
unity/ProjectSettings/TagManager.asset

@ -9,6 +9,7 @@ TagManager:
- Cloud - Cloud
- FinishLine - FinishLine
- Bird - Bird
- Pterodactyl
layers: layers:
- Default - Default
- TransparentFX - TransparentFX

Loading…
Cancel
Save