This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathZombieSky.cs
100 lines (89 loc) · 2 KB
/
ZombieSky.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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
namespace Tremor.ZombieEvent
{
public class ZombieSky : CustomSky
{
private bool isActive;
private float intensity;
private int CalIndex = -1;
public override void Update(GameTime gameTime)
{
if (isActive && intensity < 1f)
{
intensity += 0.01f;
}
else if (!isActive && intensity > 0f)
{
intensity -= 0.01f;
}
}
private float GetIntensity()
{
if (UpdateCalIndex())
{
float x = 0f;
if (CalIndex != -1)
{
x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[CalIndex].Center);
}
return 1f - Utils.SmoothStep(3000f, 6000f, x);
}
return 0f;
}
public override Color OnTileColor(Color inColor)
{
float intensity = GetIntensity();
return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity));
}
private bool UpdateCalIndex()
{
bool CalType = ZWorld.ZInvasion;
if (CalIndex >= 0 && Main.npc[CalIndex].active && CalType)
{
return true;
}
CalIndex = -1;
for (int i = 0; i < Main.npc.Length; i++)
{
if (Main.npc[i].active && CalType)
{
CalIndex = i;
break;
}
}
//this.DoGIndex = DoGIndex;
return CalIndex != -1;
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if (maxDepth >= 0 && minDepth < 0)
{
float intensity = GetIntensity();
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity);
}
}
public override float GetCloudAlpha()
{
return 0f;
}
public override void Activate(Vector2 position, params object[] args)
{
isActive = true;
}
public override void Deactivate(params object[] args)
{
isActive = false;
}
public override void Reset()
{
isActive = false;
}
public override bool IsActive()
{
return isActive || intensity > 0f;
}
}
}