Make punches work and make damage boost work

This commit is contained in:
Sofia 2019-08-04 20:48:26 +03:00
parent e171049731
commit 9218838fbb
9 changed files with 135 additions and 13 deletions

View File

@ -120,8 +120,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7d43d0a4a6d1e2d46a74083bdecde13e, type: 3}
m_Name:
m_EditorClassIdentifier:
MaxHealth: 3
CurrentHealth: 3
MaxHealth: 30
CurrentHealth: 30
--- !u!114 &592487110401094200
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -211,6 +211,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 340836170559364036}
- component: {fileID: 3148879525607712928}
- component: {fileID: 7903806047682221272}
m_Layer: 0
m_Name: SubHand
m_TagString: Untagged
@ -233,6 +235,45 @@ Transform:
m_Father: {fileID: 8334477035414792174}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &3148879525607712928
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6171388266710565393}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.0075235516, y: -0.3507555}
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: 0.23259524, y: 0.62920177}
m_EdgeRadius: 0
--- !u!114 &7903806047682221272
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6171388266710565393}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 757c56aa5236c3c42a2afcc7a4b2eadf, type: 3}
m_Name:
m_EditorClassIdentifier:
Punching: 0
--- !u!1 &8489029732241002798
GameObject:
m_ObjectHideFlags: 0
@ -346,9 +387,10 @@ GameObject:
- component: {fileID: 8489029732530782792}
- component: {fileID: 412028545510300634}
- component: {fileID: 8489029732530782806}
- component: {fileID: 5050980832709922958}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -434,8 +476,30 @@ MonoBehaviour:
HandRight: {fileID: 1270933798917005542}
HandMiddle: {fileID: 3118287694834230934}
CameraFX: {fileID: 0}
PunchingHand: {fileID: 7903806047682221272}
PlayerFun: {fileID: 5050980832709922958}
HandRetractSpeed: 10
HandRotationRetractSpeed: 300
--- !u!114 &5050980832709922958
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8489029732530782804}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0a7560055c54ab479467ce5b1c7cfcd, type: 3}
m_Name:
m_EditorClassIdentifier:
Player: {fileID: 8489029732530782806}
MaxFun: 100
FunDegradeSpeed: 5
StandingStillMultiplier: 1.5
WeaponFun: 20
EnemyExplosionFun: 2
FurnitureExplosionFun: 1
DebugAdd10Fun: 0
--- !u!1 &8489029732599905358
GameObject:
m_ObjectHideFlags: 0

View File

@ -48,7 +48,7 @@ namespace Saltosion.OneWeapon.Bullets {
ExplodableHealth Health = collider.GetComponent<ExplodableHealth>();
Vector2 Direction = (collider.transform.position - transform.position).normalized;
if (Health != null) {
Health.Damage(1f, -Direction);
Health.Damage(12f, -Direction);
} else if (Explodable != null) {
Explodable.Explode(true);
} else if (collider.tag == "Environment") {

View File

@ -10,13 +10,16 @@ namespace Saltosion.OneWeapon {
private Explodable Explodable;
private PlayerFun PlayerFun;
private void Start() {
Explodable = GetComponent<Explodable>();
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
}
public void Damage(float amount, Vector2 fromDirection) {
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(10 * amount), 100f, 100);
MaxHealth -= amount;
MaxHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
if (MaxHealth <= 0) {
MaxHealth = 0;
Explodable.Explode(true);

View File

@ -22,6 +22,10 @@ namespace Saltosion.OneWeapon {
public CameraFX CameraFX;
public PunchingHand PunchingHand;
public PlayerFun PlayerFun;
private Gun Gun;
private Vector2 GunLocation = new Vector2(0, -0.6f);
@ -106,13 +110,16 @@ namespace Saltosion.OneWeapon {
CameraFX.ScreenShake(4f);
} else if (CurrentHandDistance <= 0) {
CurrentHandDistance = 1.5f;
CurrentHandRotation = 100;
CurrentHandRotation = 55;
PunchingHand.Punching = true;
}
}
if (CurrentHandDistance > 0) {
CurrentHandDistance -= HandRetractSpeed * Time.deltaTime;
CurrentHandDistance = Mathf.Max(CurrentHandDistance, 0);
} else {
PunchingHand.Punching = false;
}
if (CurrentHandRotation > 0) {
@ -127,16 +134,24 @@ namespace Saltosion.OneWeapon {
Vector3 HandRotation = SubHand.localEulerAngles;
HandRotation.z = CurrentHandRotation;
SubHand.localEulerAngles = HandRotation;
bool Drop = Input.GetButtonDown("DropWeapon");
if (Gun != null && Drop) {
SetGun(null);
}
}
public void SetGun(Gun gun) {
PlayerFun.ReceiveNewWeapon();
if (Gun != null) {
Destroy(Gun.gameObject);
}
Gun = gun;
Gun.transform.parent = Hand;
Gun.transform.localPosition = GunLocation;
Gun.transform.localEulerAngles = GunRotation;
if (gun != null) {
Gun.transform.parent = Hand;
Gun.transform.localPosition = GunLocation;
Gun.transform.localEulerAngles = GunRotation;
}
}
}

View File

@ -22,7 +22,7 @@ namespace Saltosion.OneWeapon {
public float CurrentDamageBoost { private set; get; }
void Start() {
CurrentFun = MaxFun;
CurrentFun = MaxFun * 0.75f;
}
void Update() {

View File

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Saltosion.OneWeapon {
public class PunchingHand : MonoBehaviour {
public bool Punching = false;
void Update() {
}
void OnTriggerEnter2D(Collider2D collider) {
if (Punching) {
Punching = false;
Explodable Explodable = collider.GetComponent<Explodable>();
ExplodableHealth Health = collider.GetComponent<ExplodableHealth>();
Vector2 Direction = (collider.transform.position - transform.position).normalized;
if (Health != null) {
Health.Damage(8f, -Direction);
} else if (Explodable != null) {
Explodable.Explode(true);
}
}
}
}
}

View File

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

View File

@ -54,13 +54,13 @@ InputManager:
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Fire2
m_Name: DropWeapon
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
positiveButton: q
altNegativeButton:
altPositiveButton: mouse 1
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000