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
|
using System;
using System.Collections;
using System.Linq;
using UnityEngine;
public class SurveillanceMinigame : Minigame
{
public Camera CameraPrefab;
public GameObject Viewables;
public MeshRenderer[] ViewPorts;
public TextRenderer[] SabText;
private ShipRoom[] FilteredRooms;
private RenderTexture[] textures;
public MeshRenderer FillQuad;
public Material DefaultMaterial;
public Material StaticMaterial;
private bool isStatic;
public override void Begin(PlayerTask task)
{
base.Begin(task);
this.FilteredRooms = (from i in ShipStatus.Instance.AllRooms
where i.survCamera
select i).ToArray<ShipRoom>();
this.textures = new RenderTexture[this.FilteredRooms.Length];
for (int j = 0; j < this.FilteredRooms.Length; j++)
{
ShipRoom shipRoom = this.FilteredRooms[j];
Camera camera = UnityEngine.Object.Instantiate<Camera>(this.CameraPrefab);
camera.transform.SetParent(base.transform);
camera.transform.position = shipRoom.transform.position + shipRoom.survCamera.Offset;
camera.orthographicSize = shipRoom.survCamera.CamSize;
RenderTexture temporary = RenderTexture.GetTemporary((int)(256f * shipRoom.survCamera.CamAspect), 256, 16, RenderTextureFormat.ARGB32);
this.textures[j] = temporary;
camera.targetTexture = temporary;
this.ViewPorts[j].material.SetTexture("_MainTex", temporary);
}
if (!PlayerControl.LocalPlayer.Data.IsDead)
{
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Security, 1);
}
}
public void Update()
{
if (this.isStatic && !PlayerTask.PlayerHasHudTask(PlayerControl.LocalPlayer))
{
this.isStatic = false;
for (int i = 0; i < this.ViewPorts.Length; i++)
{
this.ViewPorts[i].sharedMaterial = this.DefaultMaterial;
this.ViewPorts[i].material.SetTexture("_MainTex", this.textures[i]);
this.SabText[i].gameObject.SetActive(false);
}
return;
}
if (!this.isStatic && PlayerTask.PlayerHasHudTask(PlayerControl.LocalPlayer))
{
this.isStatic = true;
for (int j = 0; j < this.ViewPorts.Length; j++)
{
this.ViewPorts[j].sharedMaterial = this.StaticMaterial;
this.SabText[j].gameObject.SetActive(true);
}
}
}
protected override IEnumerator CoAnimateOpen()
{
this.Viewables.SetActive(false);
this.FillQuad.material.SetFloat("_Center", -5f);
this.FillQuad.material.SetColor("_Color2", Color.clear);
for (float timer = 0f; timer < 0.25f; timer += Time.deltaTime)
{
this.FillQuad.material.SetColor("_Color2", Color.Lerp(Color.clear, Color.black, timer / 0.25f));
yield return null;
}
this.FillQuad.material.SetColor("_Color2", Color.black);
this.Viewables.SetActive(true);
for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime)
{
this.FillQuad.material.SetFloat("_Center", Mathf.Lerp(-5f, 0f, timer / 0.1f));
yield return null;
}
for (float timer = 0f; timer < 0.15f; timer += Time.deltaTime)
{
this.FillQuad.material.SetFloat("_Center", Mathf.Lerp(-3f, 0.4f, timer / 0.15f));
yield return null;
}
this.FillQuad.material.SetFloat("_Center", 0.4f);
yield break;
}
private IEnumerator CoAnimateClose()
{
for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime)
{
this.FillQuad.material.SetFloat("_Center", Mathf.Lerp(0.4f, -5f, timer / 0.1f));
yield return null;
}
this.Viewables.SetActive(false);
for (float timer = 0f; timer < 0.3f; timer += Time.deltaTime)
{
this.FillQuad.material.SetColor("_Color2", Color.Lerp(Color.black, Color.clear, timer / 0.3f));
yield return null;
}
this.FillQuad.material.SetColor("_Color2", Color.clear);
yield break;
}
protected override IEnumerator CoDestroySelf()
{
yield return this.CoAnimateClose();
UnityEngine.Object.Destroy(base.gameObject);
yield break;
}
public override void Close()
{
base.Close();
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Security, 2);
}
public void OnDestroy()
{
for (int i = 0; i < this.textures.Length; i++)
{
this.textures[i].Release();
}
}
}
|