/
Damagenumbers.cs
926 lines (796 loc) · 31.6 KB
/
Damagenumbers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using ModAPI.Attributes;
using TheForest;
using TheForest.Utils;
namespace DamageNumbers
{
public class DamageIndicator : EnemyHealth
{
public IndicatorInfo info;
protected override void Start()
{
base.Start();
info = gameObject.AddComponent<IndicatorInfo>();
info.hp = this;
info.Male = true;
string n = "";
if (ai.pale)
{
n += "PALE ";
if (ai.skinned)
{
n = "SKINNED ";
}
}
if (ai.painted)
{
n += "PAINTED ";
}
if (ai.male)
{
n += "MALE ";
}
if (ai.creepy_male)
{
n += "ARMSY ";
}
if (ai.maleSkinny)
{
n += "SKINNY MALE ";
}
if (ai.female)
{
n += "FEMALE ";
info.Male = false;
}
if (ai.femaleSkinny)
{
n += "SKINNY FEMALE ";
info.Male = false;
}
if (ai.creepy)
{
n += "VIRGINIA ";
info.Male = false;
}
if (ai.creepy_baby)
{
n += "BABY";
}
if (ai.creepy_fat)
{
n += "FATMAN ";
}
if (ai.fireman)
{
n += "FIREMAN ";
}
if (ai.leader)
{
n += "LEADER ";
}
info.MutantName = n;
}
public override void HitReal(int damage)
{
if (info.MaxHealth < Health)
{
info.MaxHealth = Health;
}
base.HitReal(damage);
info.CurrentHealth = Health;
IndicatorDisplay.ChangeTarget(info);
}
}
public class IndicatorInfo : MonoBehaviour
{
public EnemyHealth hp;
public bool Male;
public int CurrentHealth;
public int MaxHealth;
public string MutantName;
public string PersonName;
void LateStart()
{
CurrentHealth = hp.Health;
MaxHealth = CurrentHealth;
}
void Start()
{
Invoke("LateStart", 2);
string[] Femalenames = new string[]
{
"Megan",
"Moritzka",
"Tatsumaki",
"Laura",
"LizzPlays",
"Mia",
"Mona Lisa",
"Lydia",
"Sasha",
"Eva",
"Eve",
"Chick",
"Gloria Borger",
"Helga",
"Nevaeh",
"Schartzmugel",
"Boomquifa",
"Sweden",
"Samara",
"Hitler",
"China",
"Isis",
"Miku",
"Yo fat momma",
"Poppy",
"Thot",
"Feminazist",
"Wolfskull",
"Kitty",
"Caustic",
};
string[] Malenames = new string[] {
"Moritz",
"Hazard",
"Kutie",
"Farket",
"Saladass",
"SoulDr!nker",
"SixxKillur",
"Alex Armsy",
"Broadbent",
"Bob",
"Fetid",
"Fooster",
"Chris AKA Axt",
"Steve",
"Pepe",
"Shrek",
"Kim John Oof",
"Trump",
"Geralt from Rivia",
"Typical Russian pub",
"Yoshi",
"Mario",
"Luigi",
"Not Waluigi",
"Dad",
"Timmy",
"German",
"Bob Ross",
"SampleText",
"_Bottom_Text_",
"Meme",
"John Wick",
"Frank",
"Vsauce, Michael here",
"Vsauce, Jake here",
"IDubbz",
"Saitama",
"DNL",
"Smokey",
"Admin",
"Elon Musk",
"Donald",
"Dr.Tursko",
"Thanos",
"BOY",
"Kratos",
"Jabba",
"Sonic",
"_xX_Pu$$yD3str0y3r_Xx",
"Hodor",
"John Snow",
"Franklin",
"George Washington",
"James Bond",
"Indiana Johnes",
"Boris",
"Tupac",
"Dragonborn",
"Jesus",
"Jack Sparrow",
"Linus",
"PewDiePie",
"Flash",
"Phoenix",
"Diesel",
"Neo",
"Breaker",
"Pudge",
"Gaylord",
"Dick",
"Satan",
"Cannon",
"Seaman",
"Elmo",
"Wolfgang",
"Osama",
"Justin Biebier",
"Gaylon",
"Mustafa",
"Billy",
"Donkey",
"Pinocchio",
"Reddit",
"CJ",
"Damn Train",
"Rick Harrison",
"Ali",
"Kaspito",
"Luis Fonsi",
"Jojo",
"Metamoth741",
"Matt",
"White lynx",
"Phoenix",
"Bananafalls",
};
string[] suffixes = new string[]
{
"",
"with huge fuckin' anime tiddies",
"on a bike",
"and he is angry",
"that gay dipshit",
"who hasn't got a bonus meme for a month",
"the scammer",
"the retard",
"the ninja",
"the pro",
"the boar vessel 500 to 600 BC Etruskan ceramic",
"the forest gump",
"the wizard",
"the next president",
"the shitposter",
"the normie",
"the dank",
"the deepfried",
"the modder",
"the admin",
"the haxor",
"the best dud evr",
"the mega gay",
"the trap",
"the loli",
"the lolipop",
"the lolicon",
"the hentai star",
"the one with PornHub premium",
"the fortnite youtuber",
"the good youtuber",
"the pirate",
"the absolute unit",
"the shitty bot",
"the iron man",
"the reaper",
"the bear",
"the paladin",
"the Emperor",
"the mad lad",
"the Feminazist",
"the hedgehog",
"the twitch thot",
"the hoe",
"the fat pig",
"the fat cunt",
"the absolute beauty",
"the god",
"the frickin alien",
"the interdimensional traveller",
"the memelord",
"the banned",
"the salesman",
"the one who spilld beans",
"the familiar",
"the clone",
", your fanboy",
"the stalker",
"the one",
"the mutant",
"the creepy",
"the bullyhunter77",
"the bully",
"the guy who took your virginity",
"the griefer",
"the already dead",
"the anime star",
"the weeb",
"the twitch streamer",
"the pro minecraft player",
"the pro roblox player",
"the Grand Master of Unity",
"the son of owner of Microsoft",
"the chairman",
"the toilet lady",
"the Enemy",
"the spy",
"the shitty soundcloud rapper",
"the lord of forest",
"the nazi",
"the real nigga",
"the fat fricking fag",
"the communist",
"who does quick mafs",
"the homosexual",
"the straightn't",
"the automod",
"lives fast and eats ass",
"the raw sauce",
"the libtard",
"and this is my pawn shop",
"the nugget",
",you... nugget",
"the Börgarfjörður",
"the nerfed to the ground",
"the over powered",
"the guy who made this mod",
"the party girl",
"the cat",
"the pussy",
"the immune to MAGIC!",
"the WEEBZARD",
"who has the only weakness of damage",
"with a six pack",
"with a huge dick",
"with a small dick",
"without a dick",
"the communist",
"the arab",
"the Polish guy",
"V2",
": global offensive",
"2",
"the famous",
"the twitch thot",
"the decent at killing players",
"the one who will die second",
"the borb",
"who faps to loli",
"who can breathe underwater for the rest of his life",
"the Yeetus",
"the peepo",
"the forest dev",
"who is into BDSM",
};
string[] prefixes = new string[]
{
"",
"Tilted",
"Slightly stronger",
"Dirty",
"DJ",
"",
"Pale",
"Overpowered",
"Undefeated",
"Filthy",
"Funny",
"Weakend",
"STD having",
"Aussie",
"Big",
"Massive",
"Fat",
"Weeabo",
"Toxic",
"Very angry",
"Grandma",
"Grandpa",
"Brother",
"Thicc",
"Gargantuan",
"Master",
"Prince",
"King",
"Shitty",
"Lil'",
"Small",
"Alpha",
"Enslaved",
"Mr.",
"Long",
"Fearful",
"Rebel",
"Thin",
"Loli",
"Sloppy",
"Ruthless",
"Horny",
"Always wet",
"Crazy",
"Old",
"Elder",
"Chief",
"Darth",
"I'm",
"Desperate",
"Despacito",
"Acustic",
"Autistic",
"Nazi",
"( ͡° ͜ʖ ͡°)",
"Deepfried",
"Dank",
"Edgy",
"NSFW",
"Goth",
"Big tiddy",
"Mega thicc",
"Honest",
"Erect for 4hrs straight",
"Erect",
"Pissed",
"Unerect",
"Slutty",
"Horny",
"THIRSTY",
"Smoking",
"Lit AF",
"Grown up",
"Retarded",
"Crippled",
"Depressed",
"Very sad",
"Randy",
"Underaged",
"Not yet legal",
"Swolo",
"Overrated",
"Numskulled",
"Meaty",
"Swollen",
"Oversized",
"Enraged",
"Insulted",
};
int pref = Random.Range(0, prefixes.Length);
PersonName = prefixes[pref];
if (Male)
{
int nameindex = Random.Range(0, Malenames.Length);
PersonName += " "+Malenames[nameindex];
}
else
{
int nameindex = Random.Range(0, Femalenames.Length);
PersonName += " " + Femalenames[nameindex];
}
int suff= Random.Range(0, suffixes.Length);
PersonName +=" "+ suffixes[suff];
}
}
public class IndicatorDisplay : MonoBehaviour
{
private static IndicatorDisplay instance;
private IndicatorInfo info;
private Font customFont;
private Texture2D HPBG;
private Texture2D HPF;
private GUIStyle nameStyle;
private GUIStyle JKnameStyle;
private float UpperRectHeight;
private float LowerRectPosY;
private Rect rect;
private Rect NameRect;
private Rect HealthTotalRect;
private Rect JokeNameRect;
private bool CustomizationOpen;
[ExecuteOnGameStart]
public static void Init()
{
if(instance==null)
instance=new GameObject("IndicatorDisplayManager").AddComponent<IndicatorDisplay>();
}
//Called only once upon creating the object
void Start()
{
if (IndicatorDisplaySettings.Load())
{
IndicatorDisplaySettings.instance = new IndicatorDisplaySettings();
}
Invoke("LateStart", 4);
CustomizationOpen = false;
}
// Hitting any enemy will trigger this and change the current display, the display will last 20 seconds then it will disappear
public static void ChangeTarget(IndicatorInfo newinfo)
{
instance.info = newinfo;
instance.ClearTarget();
}
public void ClearTarget()
{
CancelInvoke("ClearTargetLate");
Invoke("ClearTargetLate", 20);
}
public void ClearTargetLate()
{
info = null; //Setting display to target to null so OnGUI is stopped
}
void LateStart()
{
ChangeFont(IndicatorDisplaySettings.instance.FontName);
SetDesign();
IndicatorDisplaySettings.Save();
}
// Assigning variables only when they need to be assigned
void SetDesign()
{
switch (IndicatorDisplaySettings.instance.displayMode)
{
case IndicatorDisplaySettings.DisplayMode.BottomCenter:
rect = new Rect(Screen.width / 2 - IndicatorDisplaySettings.instance.Width / 2 + IndicatorDisplaySettings.instance.offsetX,
Screen.height + IndicatorDisplaySettings.instance.offsetY,
IndicatorDisplaySettings.instance.Width,
IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.BottomLeft:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX,
Screen.height + IndicatorDisplaySettings.instance.offsetY,
IndicatorDisplaySettings.instance.Width,
IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.BottomRight:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX + Screen.width - IndicatorDisplaySettings.instance.Width,
Screen.height + IndicatorDisplaySettings.instance.offsetY,
IndicatorDisplaySettings.instance.Width,
IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.MiddleCenter:
rect = new Rect(0, 0, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
rect.center = new Vector2(Screen.width / 2 + IndicatorDisplaySettings.instance.offsetX, Screen.height / 2 + IndicatorDisplaySettings.instance.offsetY);
break;
case IndicatorDisplaySettings.DisplayMode.MiddleLeft:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX, Screen.height / 2 - IndicatorDisplaySettings.instance.Height / 2 + IndicatorDisplaySettings.instance.offsetY, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.MiddleRight:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX + Screen.width - IndicatorDisplaySettings.instance.Width, Screen.height / 2 - IndicatorDisplaySettings.instance.Height / 2 + IndicatorDisplaySettings.instance.offsetY, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.TopCenter:
rect = new Rect(Screen.width / 2 - IndicatorDisplaySettings.instance.Width / 2 + IndicatorDisplaySettings.instance.offsetX, IndicatorDisplaySettings.instance.offsetY, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.TopLeft:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX, IndicatorDisplaySettings.instance.offsetY, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
break;
case IndicatorDisplaySettings.DisplayMode.TopRight:
rect = new Rect(IndicatorDisplaySettings.instance.offsetX + Screen.width - IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.offsetY, IndicatorDisplaySettings.instance.Width, IndicatorDisplaySettings.instance.Height);
break;
}
JKnameStyle = new GUIStyle(ModAPI.Interface.Skin.label);
nameStyle = new GUIStyle(ModAPI.Interface.Skin.label);
nameStyle.fontSize = IndicatorDisplaySettings.instance.FontSize;
nameStyle.alignment = TextAnchor.MiddleCenter;
nameStyle.font = customFont;
nameStyle.richText = true;
JKnameStyle.fontSize = IndicatorDisplaySettings.instance.FontSize;
JKnameStyle.alignment = TextAnchor.UpperCenter;
JKnameStyle.font = customFont;
JKnameStyle.fontStyle = FontStyle.Italic;
JKnameStyle.overflow = new RectOffset(1000, 1000, 0, 10);
LowerRectPosY = rect.yMax;
UpperRectHeight = rect.height * IndicatorDisplaySettings.instance.HealthToNameRatio;
JokeNameRect = new Rect(rect.x, rect.y + IndicatorDisplaySettings.instance.FontSize - 500, rect.width + 1000, UpperRectHeight);
NameRect = new Rect(rect.x, rect.y, rect.width, UpperRectHeight);
LowerRectPosY-= rect.height * (1-IndicatorDisplaySettings.instance.HealthToNameRatio);
HealthTotalRect = new Rect(rect.x + 3, LowerRectPosY + 3, rect.width - 6, rect.height - UpperRectHeight);
HPBG = new Texture2D(10, 10);
for (int x = 0; x < HPBG.width; x++)
{
for (int y = 0; y < HPBG.height; y++)
{
HPBG.SetPixel(x, y, new Color(IndicatorDisplaySettings.instance.HealthBarBackgroundR, IndicatorDisplaySettings.instance.HealthBarBackgroundG, IndicatorDisplaySettings.instance.HealthBarBackgroundB));
}
}
HPBG.Apply();
HPF = new Texture2D(10, 10);
for (int x = 0; x < HPBG.width; x++)
{
for (int y = 0; y < HPBG.height; y++)
{
HPF.SetPixel(x, y, new Color(IndicatorDisplaySettings.instance.HealthBarR, IndicatorDisplaySettings.instance.HealthBarG, IndicatorDisplaySettings.instance.HealthBarB));
}
}
HPF.Apply();
}
public void ChangeFont(string s)
{
customFont = Font.CreateDynamicFontFromOSFont(s, 20);
if (customFont == null)
{
customFont = Font.CreateDynamicFontFromOSFont("Arial", 20);
ModAPI.Console.Write("Incorrect font please input another one");
}
}
void Update()
{
if (ModAPI.Input.GetButtonDown("OpenCustomization"))
{
CustomizationOpen = !CustomizationOpen;
}
}
void MoritzIsFunny()
{
new Mario();
// MarioMaker someMario = new MarioMaker();
// someMario.Start();
}
// Drawing all the ui elements
void OnGUI()
{
if (CustomizationOpen)
{
GUI.Label(new Rect(200, 0, 200, 20), "Offset X = " + IndicatorDisplaySettings.instance.offsetX);
IndicatorDisplaySettings.instance.offsetX = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 0, 200, 20), IndicatorDisplaySettings.instance.offsetX, 0, Screen.width));
GUI.Label(new Rect(200, 30, 200, 20), "Offset Y = " + IndicatorDisplaySettings.instance.offsetY);
IndicatorDisplaySettings.instance.offsetY = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 30, 200, 20), IndicatorDisplaySettings.instance.offsetY, 0, Screen.height));
GUI.Label(new Rect(200, 60, 200, 20), "Width = " + IndicatorDisplaySettings.instance.Width);
IndicatorDisplaySettings.instance.Width = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 60, 200, 20), IndicatorDisplaySettings.instance.Width, 0, Screen.width));
GUI.Label(new Rect(200, 90, 200, 20), "Height = " + IndicatorDisplaySettings.instance.Height);
IndicatorDisplaySettings.instance.Height = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 90, 200, 20), IndicatorDisplaySettings.instance.Height, 0, Screen.height));
GUI.Label(new Rect(200, 140, 200, 20), "Healthbar To Name Ratio = " + IndicatorDisplaySettings.instance.HealthToNameRatio);
IndicatorDisplaySettings.instance.HealthToNameRatio = GUI.HorizontalSlider(new Rect(0, 140, 200, 20), IndicatorDisplaySettings.instance.HealthToNameRatio, 0, 1);
GUI.Label(new Rect(0, 190, 200, 20), "Anchor = " + IndicatorDisplaySettings.instance.displayMode.ToString());
if (GUI.Button(new Rect(0, 210, 30, 30), "TOP L"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopLeft;
}
if (GUI.Button(new Rect(30, 210, 30, 30), "TOP M"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopCenter;
}
if (GUI.Button(new Rect(60, 210, 30, 30), "TOP R"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopRight;
}
if (GUI.Button(new Rect(0, 240, 30, 30), "MID L"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleLeft;
}
if (GUI.Button(new Rect(30, 240, 30, 30), "MID M"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleCenter;
}
if (GUI.Button(new Rect(60, 240, 30, 30), "MID R"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleRight;
}
if (GUI.Button(new Rect(0, 270, 30, 30), "BOT L"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomLeft;
}
if (GUI.Button(new Rect(30, 270, 30, 30), "BOT M"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomCenter;
}
if (GUI.Button(new Rect(60, 270, 30, 30), "BOT R"))
{
IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomRight;
}
GUI.Label(new Rect(200, 300, 200, 30), "Custom font name");
IndicatorDisplaySettings.instance.FontName = GUI.TextField(new Rect(0, 300, 200, 30), IndicatorDisplaySettings.instance.FontName);
GUIStyle samplestyle = new GUIStyle(GUI.skin.label);
samplestyle.font = customFont;
samplestyle.fontSize = IndicatorDisplaySettings.instance.FontSize;
GUI.Label(new Rect(400, 300, 200, 100), "AaBbCcDdEeFfGgHh 1234567890", samplestyle);
IndicatorDisplaySettings.instance.FontSize = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(200, 330, 200, 30), IndicatorDisplaySettings.instance.FontSize, 4, 40));
int i = 370;
IndicatorDisplaySettings.instance.HealthBarBackgroundR = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundR, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Background Red ");
i += 30;
IndicatorDisplaySettings.instance.HealthBarBackgroundG = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundG, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Background Green ");
i += 30;
IndicatorDisplaySettings.instance.HealthBarBackgroundB = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundB, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Background Blue ");
i += 60;
IndicatorDisplaySettings.instance.HealthBarR = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarR, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Foreground Red ");
i += 30;
IndicatorDisplaySettings.instance.HealthBarG = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarG, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Foreground Green ");
i += 30;
IndicatorDisplaySettings.instance.HealthBarB = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarB, 0, 1);
GUI.Label(new Rect(200, i, 200, 30), "Foreground Blue ");
i += 50;
if (GUI.Button(new Rect(20, i, 250, 40), "SAVE AND UPDATE CHANGES"))
{
IndicatorDisplaySettings.Save();
ChangeFont(IndicatorDisplaySettings.instance.FontName);
SetDesign();
}
i += 50;
//if (GUI.Button(new Rect(20, i, 250, 40), "Mario?")){
// MoritzIsFunny();
//}
}
else
{
// if there isnt a target to display return out of this method to save processing power
// otherwise continue
if (info == null)
{
return;
}
// drawing a simple background with predefined texture
GUI.Box(rect, "");
// following calls from GUI class will be displayed on top of previous one
float f = (float)info.CurrentHealth / info.MaxHealth;
f = Mathf.Clamp(f, 0, 1);
Rect HealthCurrentRect = new Rect(HealthTotalRect);
HealthCurrentRect.width *= f;
Rect BGrect = new Rect(HealthTotalRect.x + HealthCurrentRect.width, HealthTotalRect.y, HealthTotalRect.width * (1-f), HealthTotalRect.height);
string currhealthtext = info.CurrentHealth + " / " + info.MaxHealth;
GUI.Label(NameRect, info.PersonName, nameStyle);
GUI.DrawTexture(BGrect, HPBG);
GUI.DrawTexture(HealthCurrentRect, HPF);
GUI.Label(NameRect, info.PersonName, nameStyle);
GUI.Label(HealthTotalRect, currhealthtext, nameStyle);
}
}
}
// Current setting data container class
public class IndicatorDisplaySettings
{
public static IndicatorDisplaySettings instance;
private const string Path = "IndicatorSettings.json";
public enum DisplayMode
{
TopLeft,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight,
}
// anchor, the position from which the offset will be calculated
public DisplayMode displayMode = DisplayMode.TopLeft;
//box offset
public int offsetX = 0;
public int offsetY = 0;
//font settings
public string FontName = "Arial";
public int FontSize = 20;
// box size
public int Width = 300;
public int Height = 80;
//slider - values from 0 to 1
public float HealthToNameRatio = 0.6f;
// Color of background
public float HealthBarBackgroundR = 0.3f;
public float HealthBarBackgroundG = 0.3f;
public float HealthBarBackgroundB = 0.3f;
// Color of foreground
public float HealthBarR = 0.1f;
public float HealthBarG = 1f;
public float HealthBarB = 0.1f;
//static methods for save load
public static void Save()
{
string json = JsonUtility.ToJson(instance);
File.WriteAllText(Path, json);
}
public static bool Load()
{
if (File.Exists(Path))
{
string json = File.ReadAllText(Path);
if (!string.IsNullOrEmpty(json))
{
instance = JsonUtility.FromJson<IndicatorDisplaySettings>(json);
return false;
}
}
return true;
}
}
}