Browse Source

red birds are fire, green birds are boosts

master
Josh 2 years ago
parent
commit
fd360a6efd
  1. 4
      unity/Assets/Prefabs/Bird.prefab
  2. 14
      unity/Assets/Scripts/Bird.cs
  3. 32
      unity/Assets/Scripts/DragonMovement.cs
  4. 2
      unity/Assets/Sprites/birds/bird_blue_1.png.meta
  5. BIN
      unity/Assets/Sprites/birds/bird_green_1.png
  6. 109
      unity/Assets/Sprites/birds/bird_green_1.png.meta
  7. BIN
      unity/Assets/Sprites/birds/bird_red_1.png
  8. 109
      unity/Assets/Sprites/birds/bird_red_1.png.meta
  9. 2
      unity/Assets/Sprites/birds/bird_yellow_1.png.meta

4
unity/Assets/Prefabs/Bird.prefab

@ -96,8 +96,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fd8ad88e69cd45a4ebfb8515d31be3d1, type: 3}
m_Name:
m_EditorClassIdentifier:
_blueBird: {fileID: 21300000, guid: 96ac1047b12197a429d1c6396c1a4675, type: 3}
_yellowBird: {fileID: 21300000, guid: b618c1b99c40e3a4c87d042969b1dcc0, type: 3}
_boostBird: {fileID: 21300000, guid: f38f5ee8b3c44574986f6897bd30c60b, type: 3}
_fireBird: {fileID: 21300000, guid: 088595d78fed12e4f9eab45ee4e74f5b, type: 3}
--- !u!58 &8800180563921210496
CircleCollider2D:
m_ObjectHideFlags: 0

14
unity/Assets/Scripts/Bird.cs

@ -4,14 +4,15 @@ using UnityEngine;
public class Bird : MonoBehaviour
{
const int CHANCE_FOR_BOOST = 30; //out of 100
const float horizontalSpeed = 100f;
const float verticalSpeed = 5f;
const float amplitude = 30f;
private float startTime;
float _startingY;
[SerializeField] Sprite _blueBird;
[SerializeField] Sprite _yellowBird;
[SerializeField] Sprite _boostBird;
[SerializeField] Sprite _fireBird;
DragonMovement.AttackType _attackType;
public DragonMovement.AttackType AttackType { get => _attackType; set => _attackType = value; }
@ -21,15 +22,18 @@ public class Bird : MonoBehaviour
startTime = Time.time;
_startingY = transform.position.y;
int type = Random.Range(0, 2);
int r = Random.Range(0, 100);
int type = r < CHANCE_FOR_BOOST ? 0 : 1;
if (type == 0) {
AttackType = DragonMovement.AttackType.CONE;
GetComponent<SpriteRenderer>().sprite = _blueBird;
GetComponent<SpriteRenderer>().sprite = _boostBird;
}
else
{
AttackType = DragonMovement.AttackType.FIREBALL;
GetComponent<SpriteRenderer>().sprite = _yellowBird;
GetComponent<SpriteRenderer>().sprite = _fireBird;
}
}

32
unity/Assets/Scripts/DragonMovement.cs

@ -37,6 +37,7 @@ public class DragonMovement : MonoBehaviour
float _speedBoostTime = 0f;
float _timeToUpdateGhosts = 0f;
bool _isInDive = false;
bool _superFlap = false;
public enum AttackType
{
@ -178,8 +179,18 @@ public class DragonMovement : MonoBehaviour
_rigidbody = this.GetComponent<Rigidbody2D>();
_animator = this.GetComponent<Animator>();
//Ammo = 5;
//_attackType = AttackType.CONE;
//StartWithAmmo();
}
void StartWithAmmo()
{
Ammo = 5;
_attackType = AttackType.CONE;
if (_attackType == AttackType.FIREBALL)
ColorizeAmmo(Color.red);
else
ColorizeAmmo(Color.green);
}
private void Update()
@ -207,6 +218,11 @@ public class DragonMovement : MonoBehaviour
void Flap()
{
if (Ammo > 0 && _attackType == AttackType.CONE)
_superFlap = true;
else
_superFlap = false;
_flapTime = FlapLength;
_animator.Play("fly");
transform.eulerAngles = new Vector3(-45f, transform.eulerAngles.y, transform.eulerAngles.z);
@ -230,7 +246,7 @@ public class DragonMovement : MonoBehaviour
if (Ammo <= 0)
return;
_speedBoostTime = .25f;
Ammo--;
@ -240,12 +256,16 @@ public class DragonMovement : MonoBehaviour
}
else if (_attackType == AttackType.CONE)
{
/*
GameObject fireball = GameObject.Instantiate(_fireballPrefab, _coneSpawnPoint.transform.position, Quaternion.identity);
fireball.name = CONE_NAME;
fireball.GetComponent<Fireball>().AttackType = AttackType.CONE;
fireball.transform.parent = this.transform;
Rigidbody2D rigidBody = fireball.AddComponent<Rigidbody2D>();
rigidBody.isKinematic = true;
*/
_speedBoostTime = .3f;
}
}
@ -253,7 +273,11 @@ public class DragonMovement : MonoBehaviour
{
if (_flapTime > 0f && _stunTime < 0f)
{
_rigidbody.AddForce(new Vector2(0f, FlapForce));
float force = FlapForce;
if (_superFlap)
force *= 2f;
_rigidbody.AddForce(new Vector2(0f, force));
}
if (_stunTime > 0f)
{

2
unity/Assets/Sprites/birds/bird_blue_1.png.meta

@ -32,7 +32,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1

BIN
unity/Assets/Sprites/birds/bird_green_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

109
unity/Assets/Sprites/birds/bird_green_1.png.meta

@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: f38f5ee8b3c44574986f6897bd30c60b
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: 0
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: 3
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:

BIN
unity/Assets/Sprites/birds/bird_red_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

109
unity/Assets/Sprites/birds/bird_red_1.png.meta

@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: 088595d78fed12e4f9eab45ee4e74f5b
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: 0
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: 3
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:

2
unity/Assets/Sprites/birds/bird_yellow_1.png.meta

@ -32,7 +32,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1

Loading…
Cancel
Save