Add fun when shooting

This commit is contained in:
Sofia 2019-08-04 21:01:28 +03:00
parent c18d1177e2
commit 58947a4583
4 changed files with 45 additions and 19 deletions

View File

@ -157,7 +157,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -947994997 m_SortingLayerID: -947994997
m_SortingLayer: 3 m_SortingLayer: 4
m_SortingOrder: 5 m_SortingOrder: 5
m_Sprite: {fileID: -3565353366220660933, guid: 0aff57dccbcba5d4db39143523f7b1eb, m_Sprite: {fileID: -3565353366220660933, guid: 0aff57dccbcba5d4db39143523f7b1eb,
type: 3} type: 3}
@ -342,7 +342,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -947994997 m_SortingLayerID: -947994997
m_SortingLayer: 3 m_SortingLayer: 4
m_SortingOrder: 0 m_SortingOrder: 0
m_Sprite: {fileID: 1687475652488265116, guid: 0aff57dccbcba5d4db39143523f7b1eb, m_Sprite: {fileID: 1687475652488265116, guid: 0aff57dccbcba5d4db39143523f7b1eb,
type: 3} type: 3}
@ -497,8 +497,9 @@ MonoBehaviour:
FunDegradeSpeed: 5 FunDegradeSpeed: 5
StandingStillMultiplier: 1.5 StandingStillMultiplier: 1.5
WeaponFun: 20 WeaponFun: 20
EnemyExplosionFun: 2 EnemyExplosionFun: 6
FurnitureExplosionFun: 1 FurnitureExplosionFun: 4
ShootingFunAmount: 0.5
DebugAdd10Fun: 0 DebugAdd10Fun: 0
--- !u!1 &8489029732599905358 --- !u!1 &8489029732599905358
GameObject: GameObject:
@ -568,7 +569,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -947994997 m_SortingLayerID: -947994997
m_SortingLayer: 3 m_SortingLayer: 4
m_SortingOrder: 10 m_SortingOrder: 10
m_Sprite: {fileID: -6198316879909490977, guid: 0aff57dccbcba5d4db39143523f7b1eb, m_Sprite: {fileID: -6198316879909490977, guid: 0aff57dccbcba5d4db39143523f7b1eb,
type: 3} type: 3}

View File

@ -9,8 +9,16 @@ namespace Saltosion.OneWeapon {
public Bullet Bullet; public Bullet Bullet;
public SpriteRenderer Sprite; public SpriteRenderer Sprite;
public Transform BulletHole; public Transform BulletHole;
public float Cooldown = 0.5f;
private bool IsHeld = false; private bool IsHeld = false;
private float CurrCooldown = 0;
void Update() {
if (CurrCooldown > 0) {
CurrCooldown -= Time.deltaTime;
}
}
void OnTriggerEnter2D(Collider2D collider) { void OnTriggerEnter2D(Collider2D collider) {
if (IsHeld) { if (IsHeld) {
@ -24,14 +32,19 @@ namespace Saltosion.OneWeapon {
} }
} }
public void Shoot(Vector2 direction, float rotation) { public bool Shoot(Vector2 direction, float rotation) {
if (Bullet == null) { if (Bullet == null) {
Debug.LogError("THERE IS NO BULLET"); Debug.LogError("THERE IS NO BULLET");
} else { } else {
Bullet ShotBullet = Instantiate(Bullet, BulletHole.position, new Quaternion()); if (CurrCooldown <= 0) {
ShotBullet.Direction = direction.normalized; CurrCooldown = Cooldown;
ShotBullet.InitialRotation = rotation; Bullet ShotBullet = Instantiate(Bullet, BulletHole.position, new Quaternion());
ShotBullet.Direction = direction.normalized;
ShotBullet.InitialRotation = rotation;
return true;
}
} }
return false;
} }
public void FlipGun(bool flipped) { public void FlipGun(bool flipped) {

View File

@ -105,13 +105,16 @@ namespace Saltosion.OneWeapon {
bool Shoot = Input.GetButtonDown("Shoot"); bool Shoot = Input.GetButtonDown("Shoot");
if (Shoot) { if (Shoot) {
if (Gun != null) { if (Gun != null) {
Gun.Shoot(LookDirection, Rotation); if (Gun.Shoot(LookDirection, Rotation)) {
CameraFX.StopFor(0.03f); CameraFX.StopFor(0.03f);
CameraFX.ScreenShake(4f); CameraFX.ScreenShake(4f);
PlayerFun.ShootingFun();
}
} else if (CurrentHandDistance <= 0) { } else if (CurrentHandDistance <= 0) {
CurrentHandDistance = 1.5f; CurrentHandDistance = 1.5f;
CurrentHandRotation = 55; CurrentHandRotation = 55;
PunchingHand.Punching = true; PunchingHand.Punching = true;
PlayerFun.ShootingFun();
} }
} }

View File

@ -12,8 +12,9 @@ namespace Saltosion.OneWeapon {
public float StandingStillMultiplier = 1.5f; public float StandingStillMultiplier = 1.5f;
public float WeaponFun = 20; public float WeaponFun = 20;
public float EnemyExplosionFun = 2f; public float EnemyExplosionFun = 6f;
public float FurnitureExplosionFun = 1f; public float FurnitureExplosionFun = 3f;
public float ShootingFunAmount = 0.5f;
public float CurrentFun { private set; get; } public float CurrentFun { private set; get; }
@ -42,19 +43,27 @@ namespace Saltosion.OneWeapon {
CurrentDamageBoost = Mathf.Floor((CurrentFun / 100) * 12) / 12; CurrentDamageBoost = Mathf.Floor((CurrentFun / 100) * 12) / 12;
} }
public void ReceiveNewWeapon() { private void AddFun(float fun) {
float NewFun = CurrentFun + WeaponFun; float NewFun = CurrentFun + fun;
CurrentFun = Mathf.Min(MaxFun, NewFun); CurrentFun = Mathf.Min(MaxFun, NewFun);
Debug.Log("Added " + fun + " fun, " + CurrentFun);
}
public void ReceiveNewWeapon() {
AddFun(WeaponFun);
}
public void ShootingFun() {
AddFun(ShootingFunAmount);
} }
public void Explosion(bool isFurniture) { public void Explosion(bool isFurniture) {
float NewFun = CurrentFun; float NewFun = CurrentFun;
if (isFurniture) { if (isFurniture) {
NewFun += FurnitureExplosionFun; AddFun(FurnitureExplosionFun);
} else { } else {
NewFun += EnemyExplosionFun; AddFun(EnemyExplosionFun);
} }
CurrentFun = Mathf.Min(MaxFun, NewFun);
} }
} }
} }