-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLivesPlayer_Mortality.cs
59 lines (48 loc) · 1.38 KB
/
LivesPlayer_Mortality.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using HamstarHelpers.Helpers.Debug;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace Lives {
partial class LivesPlayer : ModPlayer {
public void DeathHappened( bool pvp ) {
var mymod = (LivesMod)this.mod;
this.Deaths++;
if( !this.IsImmortal ) {
this.Lives -= 1;
}
this.UpdateMortality();
}
////////////////
public void UpdateMortality() {
var config = LivesConfig.Instance;
if( this.Lives > config.MaxLives ) {
this.Lives = config.MaxLives;
}
//Main.NewText("difficulty: "+this.player.difficulty+", immortal? "+this.IsImmortal+", lives: "+this.Lives+", continues? "+this.IsContinue());
if( this.player.difficulty != 2 ) { // Not hardcore
if( !this.IsImmortal ) {
if( this.Lives <= 0 ) {
if( this.IsContinue() ) {
//DebugHelpers.Print("LivesContinues", "", 20);
this.Lives = config.InitialLives;
string gameOverReason;
if( !this.ApplyContinue( out gameOverReason ) ) {
Main.NewText( gameOverReason+" Game over!", Color.Red );
this.ApplyDeathFinal();
}
} else {
//DebugHelpers.Print("LivesFinal", "", 20);
Main.NewText( "No lives left. Game over!", Color.Red );
this.ApplyDeathFinal();
}
}
}
} else {
if( this.Lives > 0 ) {
//DebugHelpers.Print("LivesNonFinal", "", 20);
this.ApplyDeathNonFinal();
}
}
}
}
}