-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSky and Cloud Mod.cs
1743 lines (1563 loc) · 79 KB
/
Sky and Cloud Mod.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
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.IO;
using UnityEngine;
using spaar.ModLoader;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
namespace SkyAndCloud
{
public class BesiegeModLoader : Mod
{
public override string Name { get { return "Sky_Mod"; } }
public override string DisplayName { get { return "Sky Mod"; } }
public override string BesiegeVersion { get { return "v0.45"; } }
public override string Author { get { return "覅是"; } }
public override Version Version { get { return new Version("1.01"); } }
public override bool CanBeUnloaded { get { return true; } }
public GameObject temp;
public override void OnLoad()
{
temp = new GameObject();
temp.name = "Cloud Mod";
temp.AddComponent<CloudMod>();
GameObject.DontDestroyOnLoad(temp);
}
public override void OnUnload()
{
GameObject.Destroy(temp);
}
}
public class CloudMod : MonoBehaviour
{
public Shader AlphaBlended = new Shader { };
private List<GameObject> clouds = new List<GameObject>(60);
/*private GameObject floatingRock = new GameObject();
private int floatingrocksCloneCount = 0;*/
public GameObject cloudTemp;
//private GameObject godLightTemp;
//private GameObject rainTemp;
//private GameObject thunderCloudTemp;
public int cloudAmount = 60;
public int cloudAmountTemp = 0;
public float cloudSizeScale = 1;
public float lowerCloudsMinHeight = 130f;
public float lowerCloudsMaxHeight = 200f;
public float higherCloudsMinHeight = 300;
public float higherCloudsMaxHeight = 377.25f;
public Color higherCloudsColor = new Color(1f, 1f, 1f, 1f);
public Color lowerCloudsColor = new Color(0.92f, 0.9f, 0.8f, 1);
public Color SkyColor;
public float[] cloudSpeed = new float[2];
public bool CustomCloudSpeed = false;
public bool isFogAway = false;
public Vector3 floorScale = new Vector3(911, 10, 900);
public float CameraFarClip = 1500;
public bool isShadowOff = false;
public bool isExtendingShadow = false;
public bool isBoundairesAway = false;
public bool IsNightMode = false;
public bool resetCloudsNow = false;
public bool ExtraCannonSmokeEffect = false;
private string tempLevelName;
//private GameObject sunS = new GameObject();
//private GameObject sun;
public GameObject[] shadow;
public string settingTemp;
public string[] Settings;
private bool DetectedStartedSimulating = false;
//private Flare finalFlare;
//private object FlareIns;
//private bool OkGo = false;
public Color FlameLightColor = new Color(0.9f, 0.6f, 0);
public float FireLightIntensity = 2.5f;
public float FireLightRange = 30f;
public float Shakefrequency = 10f;
public float ShakeMax = 1.25f;
public float ShakeMin = 0.9f;
Shader shader;
/*private IEnumerator LoadBundle()
{
WWW www = new WWW("File:///" + Application.dataPath + "/Mods/Resources/ManyFlares.assetbundle");
yield return www;
AssetBundle asset = www.assetBundle;
Debug.Log("Load Asset completed!");
AssetBundleRequest request = asset.LoadAssetAsync("50mmZoom.flare", typeof(Flare));
yield return request;
Debug.Log("Load Asset completed!");
Flare go = request.asset as Flare;
go.name = "GOOOO";
DontDestroyOnLoad(go);
OkGo = true;
foreach(UnityEngine.Object obj in asset.LoadAllAssets())
{
Instantiate(obj);
}
asset.Unload(false);
}*/
void Start()
{
//Application.LoadLevel (5);
shader = Resources.Load(Application.dataPath + "/Mods/Blocks/Resources/LineBlend.shader") as Shader;
Commands.RegisterHelpMessage("CLOUDS!");
Commands.RegisterCommand("ResetCloudsAmount", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
int cccloudcloudAmount = int.Parse(args[0]);
if (cccloudcloudAmount < 0 || cccloudcloudAmount > 3000) { return "Your cloud amount is not available. "; }
else { cloudAmount = cccloudcloudAmount; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to cloud amount";
}
return "There will be " + cloudAmount.ToString() + " clouds";
}, "Reset the amount of clouds. No bigger than 3000 and no less than 2.");//Amount
Commands.RegisterCommand("ResetCloudsSizeScale", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float cccloudcloudSizeScale = float.Parse(args[0]);
if (cccloudcloudSizeScale <= 0) { return "Your cloud size scale is not available. "; }
else { cloudSizeScale = cccloudcloudSizeScale; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to cloud size scale";
}
return "The clouds' size scale will be " + cloudSizeScale.ToString();
}, "Reset Clouds' Size Scale");//SizeScale
Commands.RegisterCommand("ResetLowerCloudsMinHeight", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float llllowerCloudsMinHeight = float.Parse(args[0]);
if (llllowerCloudsMinHeight >= lowerCloudsMaxHeight) { return "Your lower cloud minimum height is not available. "; }
else { lowerCloudsMinHeight = llllowerCloudsMinHeight; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to lower cloud minimum height";
}
return "The lower clouds' minimum height will be " + lowerCloudsMinHeight.ToString();
}, "Reset Lower Clouds' Min Height");//ResetLowerCloudsMinHeight
Commands.RegisterCommand("ResetLowerCloudsMaxHeight", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float llllowerCloudsMaxHeight = float.Parse(args[0]);
if (llllowerCloudsMaxHeight <= lowerCloudsMinHeight) { return "Your lower cloud maximum height is not available. "; }
else { lowerCloudsMaxHeight = llllowerCloudsMaxHeight; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to lower cloud maximum height";
}
return "The lower clouds' maximum height will be " + lowerCloudsMaxHeight.ToString();
}, "Reset Lower Clouds' Max Height");//ResetLowerCloudsMaxHeight
Commands.RegisterCommand("ResetHigherCloudsMinHeight", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float hhhhigherCloudsMinHeight = float.Parse(args[0]);
if (hhhhigherCloudsMinHeight >= higherCloudsMaxHeight) { return "Your higher cloud minimum height is not available. "; }
else { higherCloudsMinHeight = hhhhigherCloudsMinHeight; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to higher cloud minimum height";
}
return "The higher clouds' minimum height will be " + higherCloudsMinHeight.ToString();
}, "Reset Higher Clouds' Min Height");//ResetHigherCloudsMinHeight
Commands.RegisterCommand("ResetHigherCloudsMaxHeight", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float hhhigherCloudsMaxHeight = float.Parse(args[0]);
if (hhhigherCloudsMaxHeight <= higherCloudsMinHeight) { return "Your higher cloud maximum height is not available. "; }
else { higherCloudsMaxHeight = hhhigherCloudsMaxHeight; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to higher cloud maximum height";
}
return "The higher clouds' maximum height will be " + higherCloudsMaxHeight.ToString();
}, "Reset Higher Clouds' Max Height.");//ResetHigherCloudsMaxHeight
Commands.RegisterCommand("ResetHigherCloudsColorRGBA", (args, notUses) =>
{
if (args.Length < 3)
{
return "ERROR!You don't have all four color elements! (Red, Green, Blue, Alpha) \n Please do it like this\n ResetHigherCloudsColorRGBA 155 0 255 99";
}
try
{
higherCloudsColor = new Color(float.Parse(args[0]) / 255f, float.Parse(args[1]) / 255f, float.Parse(args[2]) / 255f, float.Parse(args[3]) / 100f);
保存设定();
}
catch
{
return "ERROR! Please do it like this\n ResetHigherCloudsColorRGBA 155 0 255 99";
}
return "The higher cloud color will be " + higherCloudsColor.ToString();
}, "Reset the color of higher clouds by R G B A.");//ResetHigherCloudsColor
Commands.RegisterCommand("ResetLowerCloudsColorRGBA", (args, notUses) =>
{
if (args.Length < 3)
{
return "ERROR!You don't have all four color elements! (Red, Green, Blue, Alpha) \n Please do it like this\n ResetLowerCloudsColorRGBA 155 0 255 99";
}
try
{
lowerCloudsColor = new Color(float.Parse(args[0]) / 255f, float.Parse(args[1]) / 255f, float.Parse(args[2]) / 255f, float.Parse(args[3]) / 100f);
保存设定();
}
catch
{
return "ERROR! Please do it like this\n ResetLowCloudsColorRGBA 155 0 255 99";
}
return "The lower cloud color will be " + lowerCloudsColor.ToString();
}, "Reset the color of lower clouds by R G B A.");//ResetLowerCloudsColor
Commands.RegisterCommand("ResetSkyColorRGBA", (args, notUses) =>
{
if (args.Length < 3)
{
return "ERROR!You don't have all four color elements! (Red, Green, Blue, Alpha) \n Please do it like this\n ResetSkyColorRGBA 155 0 255 99";
}
try
{
GameObject.Find("Main Camera").GetComponent<Camera>().backgroundColor = new Color(float.Parse(args[0]) / 255f, float.Parse(args[1]) / 255f, float.Parse(args[2]) / 255f, float.Parse(args[3]) / 100f);
SkyColor = new Color(float.Parse(args[0]) / 255f, float.Parse(args[1]) / 255f, float.Parse(args[2]) / 255f, float.Parse(args[3]) / 100f);
保存设定();
}
catch
{
return "ERROR! Please do it like this\n ResetSkyColorRGBA 155 0 255 99";
}
return "The sky color will be " + lowerCloudsColor.ToString();
}, "Reset the color of sky by R G B A. Default is 144 166 180 100");//ResetSkyColor
Commands.RegisterCommand("Re-ProduceAllClouds", (args, notUses) =>
{
resetCloudsNow = true;
保存设定();
return "The clouds will be re-produce";
}, "Produce your clouds again");//Reproduce All Clouds
Commands.RegisterCommand("CleanFog", (args, notUses) =>
{
isFogAway = true;
保存设定();
return FogOpreation(isFogAway);
}, "Put the fog away to make your view cleaner");//Clean Fog
Commands.RegisterCommand("ResetFog", (args, notUses) =>
{
isFogAway = false;
保存设定();
return FogOpreation(isFogAway);
}, "Put the fog back");//Reset Fog
Commands.RegisterCommand("ResetCloudSpeed", (args, notUses) =>
{
if (args.Length < 2)
{
return "ERROR!You need to have two speed value!";
}
try
{
cloudSpeed[0] = float.Parse(args[0]);
cloudSpeed[1] = float.Parse(args[1]);
保存设定();
}
catch
{
return "ERROR!";
}
CustomCloudSpeed = true;
return "The speed will be: X: " + cloudSpeed[0] + " Z: " + cloudSpeed[1];
}, "Change the moving speed of yur clouds by x and z");//Cloud speed
Commands.RegisterCommand("ResetFloorSizeScale", (args, notUses) =>
{
if (args.Length < 2)
{
return "ERROR!";
}
try
{
GameObject.Find("FloorBig").transform.localScale = new Vector3(float.Parse(args[0]), GameObject.Find("FloorBig").transform.localScale.y, float.Parse(args[1]));
floorScale = new Vector3(float.Parse(args[0]), GameObject.Find("FloorBig").transform.localScale.y, float.Parse(args[1]));
保存设定();
}
catch
{
return "Could not parse " + args[0] + "and" + args[1] + "to floor size scale";
}
return "The floor's size scale will be " + GameObject.Find("FloorBig").transform.localScale.ToString();
}, "Reset the size of the floor as big as you want.(default is 900 900)");//FloorSizeScale
Commands.RegisterCommand("ResetCameraDrawingRange", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
CameraFarClip = float.Parse(args[0]);
if (CameraFarClip <= 1) { return "Your Range is not available. "; }
else { GameObject.Find("Main Camera").GetComponent<Camera>().farClipPlane = CameraFarClip; 保存设定(); }
}
catch
{
return "Could not parse " + args[0] + "to camara drawing range";
}
return "The camara drawing range will be " + GameObject.Find("Main Camera").GetComponent<Camera>().farClipPlane.ToString();
}, "Reset the camera drawing range to the value you want (no less than 1; default is 1500)");//ResetCameraDrawingRange
Commands.RegisterCommand("TurnOn/OffCloudShadows", (args, notUses) =>
{
try
{
if (!isShadowOff)
{
foreach (GameObject shadowMaker in shadow) { shadowMaker.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; }
isShadowOff = true;
保存设定();
return "The shadow has been turned off";
}
else if (isShadowOff)
{
foreach (GameObject shadowMaker in shadow) { shadowMaker.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; }
isShadowOff = false;
保存设定();
return "The shadow has been turned on";
}
else { return "Nothing Can be turn off/on"; }
}
catch { return "The shadows does not exist!"; }
}, "Turn on/off your clouds' shadows");//Shadow
Commands.RegisterCommand("FurthurShadowDistance", (args, notUses) =>
{
try
{
if (!isExtendingShadow)
{
ShadowDistSetter();
isExtendingShadow = true;
保存设定();
return "The shadow drawing distance has been extended to the camera far clip.";
}
else if (isExtendingShadow)
{
isExtendingShadow = false;
保存设定();
return "Restart the game in order to make it effective.";
}
else { return "Wrong!"; }
}
catch { return "Wrong!"; }
}, "Set if the shadow drawing distance is extended. ");//ShadowDist
/* Commands.RegisterCommand("AddOneFloatingRock", (args, notUses) =>
{
if (args.Length < 3)
{
return "ERROR!You don't have all four position and rotation values! (X, Y, Z, Rotation) \n Please do it like this\n AddOneFloatingRock -120 110 56 92";
}
if (Application.loadedLevel == 23 || floatingRock != null)
{
floatingRock = GameObject.Find("FloatingRocks");
GameObject.DontDestroyOnLoad(floatingRock);
DontDestroyOnLoad(floatingRock);
floatingRock.transform.parent = null;
floatingRock.SetActive(false);
try
{
Quaternion qtnon = new Quaternion();
qtnon.eulerAngles = new Vector3(0, float.Parse(args[3]), 0);
GameObject floatingrocksClone = new GameObject();
floatingrocksCloneCount += 1;
floatingrocksClone.name = ("floatingrocksClone" + floatingrocksCloneCount);
floatingrocksClone = (GameObject)GameObject.Instantiate(floatingRock, new Vector3(float.Parse(args[0]), float.Parse(args[1]), float.Parse(args[2])), qtnon);
floatingrocksClone.SetActive(true);
}
catch
{
if (GameObject.Find("FloatingRocks"))
{
return "ERROR! Please do it like this\n AddOneFloatingRock -120 110 56 93";
}
else { return "You need to go Level 18 to get FloatingRocks!"; }
}
}
else
{
return "The" + floatingrocksCloneCount + "'s stone will be " + GameObject.Find("floatingrocksClone" + floatingrocksCloneCount).transform.position.ToString();
}
return "a";
}, "Reset the color of lower clouds by X Y Z Rotation.");//AddOneFloatingRock
Commands.RegisterCommand("DeleteAllFloatingStones", (args, notUses) =>
{
try
{
if (floatingRocks.Length < 1) { return "No Rocks!"; }
else
{
for (int i = floatingRocks.Length; i >= 0; i--)
{
Destroy(floatingRocks[i]);
}
return "Done!";
}
}
catch { return "The stones does not existed!"; }
}, "Delete All Floating Stones");//DeleteAllFloatingStones
Commands.RegisterCommand("DeleteLatestFloatingStone", (args, notUses) =>
{
try
{
if (floatingRocks.Length < 1) { return "No Rocks!"; }
else
{
Destroy(floatingRocks[floatingRocks.Length]);
return "Done!";
}
}
catch { return "The stones does not existed!"; }
}, "Delete Latest Floating Stone");//DeleteLatestFloatingStones
Commands.RegisterCommand("ResetLatestStoneSizeScale", (args, notUses) =>
{
if (args.Length < 1)
{
return "ERROR!";
}
try
{
float stoneSizeScale = float.Parse(args[0]);
if (stoneSizeScale <= 0) { return "Your stone size scale is not available. "; }
else { floatingRocks[floatingRocks.Length].transform.localScale = new Vector3(stoneSizeScale, stoneSizeScale, stoneSizeScale); }
}
catch
{
return "Could not parse " + args[0] + "to stone size scale";
}
return "The clouds' size scale will be " + floatingRocks[floatingRocks.Length].transform.localScale.x.ToString();
}, "Reset the latest Stone's Size Scale");//StoneSizeScale*/
Commands.RegisterCommand("NoWorldBoundaries", (args, notUses) =>
{
try
{
GameObject.Find("WORLD BOUNDARIES").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
保存设定();
return "The World Boundaries will be moved away";
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES LARGE").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
保存设定();
return "The World Boundaries will be moved away";
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
保存设定();
return "The World Boundaries will be moved away";
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE (1)").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
保存设定();
return "The World Boundaries will be moved away";
}
catch { return "The World Boundaries does not exist!"; }
}
}
}
}, "Move the World Boundaries away");//Clean World Boundaries
Commands.RegisterCommand("ResetWorldBoundaries", (args, notUses) =>
{
string tip = "The World Boundaries will be reset.";
try
{
GameObject.Find("WORLD BOUNDARIES").transform.position = new Vector3(1, 1, 1);
isBoundairesAway = false;
保存设定();
return tip;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES LARGE").transform.position = new Vector3(2.8f, 1, 2.3f);
isBoundairesAway = false;
保存设定();
return tip;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE").transform.localScale = new Vector3(5.6f, 1, 5.6f);
isBoundairesAway = false;
保存设定();
return tip;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE (1)").transform.localScale = new Vector3(3, 0, 3);
isBoundairesAway = false;
保存设定();
return tip;
}
catch { return "The World Boundaries does not exist!"; }
}
}
}
}, "Put the World Boundaries back");//Reset World Boundaries
Commands.RegisterCommand("On/OffNightMode", (args, notUses) =>
{
try
{
if (!IsNightMode)
{
IsNightMode = true;
GameObject.Find("Main Camera").GetComponent<Camera>().backgroundColor = new Color(0.1f, 0.1f, 0.1f);
GameObject DL = GameObject.Find("Directional light");
if (DL)
{
/*try
{
DL.GetComponent<Light>().intensity = 0f;
DL.GetComponent<LensFlare>().brightness = 10;
DL.GetComponent<LensFlare>().color = Color.white;
DL.GetComponent<LensFlare>().enabled = true;
DL.GetComponent<LensFlare>().fadeSpeed = 1;
}
catch { }*/
}
ItIsNightSoEveryCloudShouldBeDeepDarkFantasy();
保存设定();
return "Night is coming......";
}
else
{
IsNightMode = false;
GameObject.Find("Main Camera").GetComponent<Camera>().backgroundColor = new Color(0.5803922f, 0.6509804f, 0.7058824f, 1); ;
GameObject DL = GameObject.Find("Directional light");
if (DL)
{
GameObject.Find("Directional light").GetComponent<Light>().intensity = 0.92f;
/*try
{
Destroy(GameObject.Find("Directional light").GetComponent<LensFlare>());
}
catch { }*/
}
ItIsDaySoEveryCloudShouldBeBright();
保存设定();
return "Day is coming _(:3」∠)_";
}
}
catch { return "The Main Camera does not exists!"; }
}, "Turn on/off the night mode");//Night
Commands.RegisterCommand("ApplyFloorTexture", (args, notUses) =>
{
float sizeScale = 1;
try
{
sizeScale = float.Parse(args[0]);
}
catch
{
Debug.Log("Please give me your scale! Or I will defautly define it as 1.");
sizeScale = 1;
}
try
{
GameObject FloorBig = GameObject.Find("FloorBig");
GameObject FloorGrid = GameObject.Find("FloorGrid");
Renderer FBRenderer = FloorBig.GetComponent<Renderer>();
try
{
WWW png = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.png");
WWW jpg = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.jpg");
FBRenderer.material = new Material(Shader.Find("Diffuse"));
//GameObject.Find("FloorBig").GetComponent<Renderer>().material.mainTexture.wrapMode = TextureWrapMode.Clamp;
if (png.size > 5)
{
try
{
FBRenderer.material.mainTexture = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.png").texture;
}
catch { }
}
else if (jpg.size > 5)
{
try
{
FBRenderer.material.mainTexture = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.jpg").texture;
}
catch { }
}
else { return ("There is no such a texture file named \"GroundTexture.png\" or \"GroundTexture.jpg\" \n under \\Besiege_Data\\Mods\\Blocks\\Textures\\! "); }
FBRenderer.material.SetTextureScale("_MainTex", Vector2.one * 1 / sizeScale);
FloorGrid.transform.position = new Vector3(0, -15, 0);
}
catch { }
}
catch { return "Something wrong happened! Please make sure that the legal floor (not level 30 floor or well floor) exists!"; }
return "Applied!";
}, "Set the floor texture");//FloorTexture
Commands.RegisterCommand("ApplyFloorTexture2", (args, notUses) =>
{
float sizeScale = 1;
try
{
sizeScale = float.Parse(args[0]);
}
catch
{
Debug.Log("Please give me your scale! Or I will defautly define it as 1.");
sizeScale = 1;
}
try
{
GameObject FloorGrid = GameObject.Find("FloorGrid");
Renderer FGRenderer = FloorGrid.GetComponent<Renderer>();
try
{
WWW png = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.png");
WWW jpg = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.jpg");
FGRenderer.material = new Material(Shader.Find("Diffuse"));
//GameObject.Find("FloorBig").GetComponent<Renderer>().material.mainTexture.wrapMode = TextureWrapMode.Clamp;
if (png.size > 5)
{
try
{
FGRenderer.material.mainTexture = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.png").texture;
}
catch { }
}
else if (jpg.size > 5)
{
try
{
FGRenderer.material.mainTexture = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Textures/GroundTexture.jpg").texture;
}
catch { }
}
else { return ("There is no such a texture file named \"GroundTexture.png\" or \"GroundTexture.jpg\" \n under \\Besiege_Data\\Mods\\Blocks\\Textures\\! "); }
FGRenderer.material.SetTextureScale("_MainTex", Vector2.one * 1 / sizeScale);
FloorGrid.transform.position = new Vector3(0, -5, 0);
}
catch { }
}
catch { return "Something wrong happened! Please make sure that the legal floor (not level 30 floor or well floor) exists!"; }
return "Applied!";
}, "Set the floor texture in a different way");//FloorTextureD
Commands.RegisterCommand("On/OffExtraCannonEffect", (args, notUses) =>
{
ExtraCannonSmokeEffect = !ExtraCannonSmokeEffect;
保存设定();
return "Extra Cannon Effect is now" + ExtraCannonSmokeEffect;
}, "Add Extra Smoke and light to cannons");//Cannon
}
//public int CurrentLevel = 2;
void SkyBox(Shader shaderzzz)
{
try
{
WWW www = new WWW("File:///" + Application.dataPath + "/Mods/Blocks/Resources/SkyBoxTexture.jpg");
Texture2D texture;
//YAY adding models in game
NeededResource TheBall = new NeededResource(ResourceType.Mesh, "Skydome.obj");
AssetImporter.StartImport.Mesh(ref TheBall.mesh, TheBall.resourcePath);
GameObject SkySphere;
Destroy(GameObject.Find("STAR SPHERE"));
SkySphere = new GameObject("SKY SPHERE");
SkySphere.AddComponent<MeshRenderer>();
SkySphere.AddComponent<MeshFilter>();
SkySphere.AddComponent<CameraFollower>();
SkySphere.GetComponent<MeshFilter>().mesh = TheBall.mesh;
try
{
byte[] TexByte = System.IO.File.ReadAllBytes(Application.dataPath + "/Mods/Blocks/Resources/SkyBoxTexture.jpg");
texture = www.texture;
MeshRenderer mr = SkySphere.GetComponent<MeshRenderer>();
mr.material = new Material(shaderzzz);
mr.material.mainTexture = texture;
mr.material.mainTexture.wrapMode = TextureWrapMode.Clamp;
mr.receiveShadows = false;
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
}
catch (Exception e)
{
Debug.LogException(e);
Debug.Log("Exception happened! Check if there is such a texture file named \"SkyBoxTexture.jpg\" \n under \\Besiege_Data\\Mods\\Blocks\\Resources\\ and a obj file called \"Skydome.obj\"! "); return;
}
//GameObject.Find("Main Camera").GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
}
catch (Exception e) { Debug.Log(e); }
}
void Update()
{
//Debug.Log(GameObject.Find("ICE ROCK (3)/Ice Rock").GetComponent<MeshRenderer>().material.shader.name);
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "TITLE SCREEN")
{
if (Input.GetKey(KeyCode.F5))
{
SkyBox(Shader.Find("Custom/ReflectBumpEmiss/late"));
}
if (Input.GetKey(KeyCode.F6))
{
SkyBox(Shader.Find("Particles/Alpha Blended"));
}
if (ExtraCannonSmokeEffect)
{
炮火添加器();
}
}
try
{
if (isShadowOff)
{
try
{
foreach (GameObject shadowMaker in shadow)
{
shadowMaker.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
}
}
catch { }
}
if (isBoundairesAway)
{
try
{
GameObject.Find("WORLD BOUNDARIES").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES LARGE").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
}
catch
{
try
{
GameObject.Find("WORLD BOUNDARIES_LARGE (1)").transform.localScale = new Vector3(0, 0, 0);
isBoundairesAway = true;
}
catch { }
}
}
}
}
if (isFogAway)
{
try { GameObject.Find("Fog Volume").transform.position = new Vector3(0, Mathf.Infinity, 0); } catch { }
}
try { GameObject.Find("Main Camera").GetComponent<Camera>().farClipPlane = CameraFarClip; } catch { }
}
catch { }
//Debug.Log("here!!!");
/*GameObject.Find("Directional light").AddComponent<LensFlare>();
GameObject.Find("Directional light").GetComponent<LensFlare>().flare = (Flare)finalFlare;
GameObject.Find("Directional light").GetComponent<Light>().flare = (Flare)finalFlare;*/
/*if (!GameObject.Find("Directional light").GetComponent<LensFlare>())
{
GameObject.Find("Directional light").AddComponent<LensFlare>();
try {
UnityEngine.Object FrySomeFlare = (Flare)Instantiate(asset.LoadAsset("./Lens Flares/Halogen Bulb"));
}catch(Exception e){ Debug.Log(e); }
//FrySomeFlare.name = "KillYA";
//GameObject.Find("Directional light").GetComponent<LensFlare>().flare =
Debug.Log("Loaded!");
}
if (Input.GetKeyDown(KeyCode.F1))
{
if (!OkGo)
{
StartCoroutine(LoadBundle());
return;
}
}*/
}
void FixedUpdate()
{
//Debug.Log(Application.loadedLevel);
if (StatMaster.isSimulating && !DetectedStartedSimulating && IsNightMode)
{
DetectedStartedSimulating = true;
ItIsNightSoEveryCloudShouldBeDeepDarkFantasy();
}
if (GameObject.Find("STAR SPHERE"))
{
GameObject.Find("STAR SPHERE").transform.eulerAngles += new Vector3(0, 0.001f, 0.001f);
GameObject.Find("STAR SPHERE").transform.localScale = Vector3.one * (2068 / 1500) * CameraFarClip;
}
if (!StatMaster.isSimulating) { DetectedStartedSimulating = false; }
resetCloudsNow = cloudAmountTemp != cloudAmount;
if (tempLevelName != UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)
{
tempLevelName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
读取设定();
resetCloudsNow = true;
}
if (cloudTemp == null)
{
cloudTemp = Instantiate(GameObject.Find("CLoud"));
cloudTemp.SetActive(false);
DontDestroyOnLoad(cloudTemp);
}
/*if (godLightTemp != null) { Debug.Log("RunningG"); godLightTemp = (GameObject)UnityEngine.Object.Instantiate(GameObject.Find("GodRays")); godLightTemp.SetActive(false); Debug.Log("GL"); }
if (rainTemp != null) { Debug.Log("RunningR"); rainTemp = (GameObject)UnityEngine.Object.Instantiate(GameObject.Find("Rain Particles")); rainTemp.SetActive(false); Debug.Log("RP"); }
if (thunderCloudTemp != null) { Debug.Log("RunningT"); thunderCloudTemp = (GameObject)UnityEngine.Object.Instantiate(GameObject.Find("THUNDER CLOUD")); thunderCloudTemp.SetActive(false); Debug.Log("TC"); }
*///DontDestroyOnLoad(cloudTemp);
/*DontDestroyOnLoad(godLightTemp);
DontDestroyOnLoad(rainTemp);
DontDestroyOnLoad(thunderCloudTemp);*/
if (resetCloudsNow)
{
resetCloudsNow = false;
cloudAmountTemp = cloudAmount;
//foreach (Transform cloud in this.transform)
//{ if (cloud.gameObject != cloudTemp && cloud.name.Equals("CLoud(Clone)(Clone)")) { } }
clouds.Clear();
clouds.Capacity = cloudAmount;