Skip to content
Snippets Groups Projects
Commit dea583dd authored by Gard Aleksander Furre's avatar Gard Aleksander Furre
Browse files

Merge branch 'gardaf' into 'main'

Gardaf

See merge request !87
parents fcff0f1e 32eb2753
No related branches found
No related tags found
1 merge request!87Gardaf
......@@ -88,6 +88,9 @@ namespace BigSock {
// The direction the character last moved.
protected Vector2 moveDir;
// trigger for in knockback.
protected bool inKnockBack = false;
/*
The inventory of the character.
......@@ -178,20 +181,30 @@ namespace BigSock {
MovementDir = moveDir,
};
}
/*
Using a courutine to set trigger in knockback.
*/
IEnumerator knockBackTimer()
{
inKnockBack = true;
yield return new WaitForSeconds(0.15F);
rb.velocity = Vector2.zero;
inKnockBack = false;
}
/*
Add Knockback.
Add Knockback. (used only for dash ?)
*/
public void KnockBack(float force, Vector2 difference) {
rb.AddForce(difference * force, ForceMode2D.Impulse);
StartCoroutine(knockBackTimer());
//rb.MovePosition((Vector2)transform.position + (difference * force * Time.fixedDeltaTime));
}
public void KnockBack(IAttackStats attack) {
Vector2 difference = ((Vector2) transform.position - attack.Source).normalized;
//KnockBack(attack.Knockback, difference);
rb.AddForce(difference * attack.Knockback, ForceMode2D.Impulse);
StartCoroutine(knockBackTimer());
}
/*
......@@ -199,8 +212,11 @@ namespace BigSock {
*/
protected virtual bool TryMove(Vector2 direction) {
moveDir = direction;
if(direction != Vector2.zero) {
rb.AddForce(direction * (float) MovementSpeed * Time.fixedDeltaTime, ForceMode2D.Impulse);
if(direction != Vector2.zero && !inKnockBack) {
//Using movePosition to get a "snappy" movement.
//rb.AddForce(direction * (float) MovementSpeed * Time.fixedDeltaTime, ForceMode2D.Impulse);
rb.MovePosition((Vector2)transform.position + (direction * (float) MovementSpeed * Time.fixedDeltaTime));
//rb.velocity = (direction * (float) MovementSpeed);
return true;
}
return false;
......@@ -299,6 +315,7 @@ namespace BigSock {
var res = HP + amount;
if(res > MaxHP) res = MaxHP;
HP = res;
AfterHeal();
return true;
}
......@@ -310,6 +327,10 @@ namespace BigSock {
KnockBack(attack);
}
protected virtual void AfterHeal() {
}
/*
Method for what to do when the character dies.
*/
......
......@@ -13,7 +13,7 @@ namespace BigSock {
A basic dodge move that gives a push and a short invincibility.
*/
public class AbilityDodge : BaseAbility {
public static readonly float BASE_FORCE = 0.5f;
public static readonly float BASE_FORCE = 1f;
public static readonly TimeSpan IFRAME_DURATION = new TimeSpan(0, 0, 0, 0, 500);
public override ulong Id => 201;
......
......@@ -395,6 +395,10 @@ namespace BigSock {
utilBar?.WithHealth(Convert.ToInt32(HP));
}
protected override void AfterHeal() {
utilBar?.WithHealth(Convert.ToInt32(HP));
}
public void GainXp(float xp) {
GiveXp(xp * XP_SCALE_RATE);
CheckXp();
......
......@@ -29,15 +29,15 @@ namespace BigSock {
/*
Minimum idle time.
*/
protected static readonly TimeSpan IDLE_WAIT_TIME = new TimeSpan(0, 0, 0, 1, 0);
protected static readonly TimeSpan IDLE_WAIT_TIME = new TimeSpan(0, 0, 0, 0, 400);
/*
Minimum animation time.
*/
protected static readonly TimeSpan CHARGE_WAIT_TIME = new TimeSpan(0, 0, 0, 2, 0);
protected static readonly TimeSpan CHARGE_WAIT_TIME = new TimeSpan(0, 0, 0, 0, 400);
/*
Maximum time the slime should attack before it can idle.
*/
protected static readonly TimeSpan ATTACK_WAIT_TIME = new TimeSpan(0, 0, 0, 4, 0);
protected static readonly TimeSpan ATTACK_WAIT_TIME = new TimeSpan(0, 0, 0, 1, 0);
protected Animator m_Animator_bow;
......
......@@ -176,8 +176,8 @@ MonoBehaviour:
baseMovementSpeed: 2
baseDamage: 1
knockbackForce: 3
baseHP: 20
baseMaxHP: 20
baseHP: 7
baseMaxHP: 7
dropXP: 20
xp: 0
maxXp: 0
......
......@@ -170,7 +170,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e5613a049bf8e2c4cbae8505b526107e, type: 3}
m_Name:
m_EditorClassIdentifier:
baseAttackSpeed: 1
baseAttackSpeed: 8
source: []
TakeDamageAudio: {fileID: 8300000, guid: 0d78a0205a770454c86c53710a0b4ff1, type: 3}
baseMovementSpeed: 1
......
......@@ -17,21 +17,54 @@ AnimationClip:
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: -19692615, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.083333336
value: {fileID: -1152038991, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.16666667
value: {fileID: 229421652, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.25
value: {fileID: -556319578, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.33333334
value: {fileID: -99956278, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.41666666
value: {fileID: -1010177793, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- time: 0.5
value: {fileID: 844625333, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: -19692615, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: -1152038991, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: 229421652, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: -556319578, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: -99956278, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: -1010177793, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
- {fileID: 844625333, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_StopTime: 0.5833333
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment