-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapDIYManager.cs
166 lines (162 loc) · 6.15 KB
/
MapDIYManager.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MapDIYManager : MonoBehaviour
{
public GameObject block;
public GameObject block1;
public GameObject block2;
public GameObject block3;
public GameObject block4;
public GameObject meleeButton;
public GameObject remoteButton;
public Renderer cube;
LayerMask sp = 1 << 8;
public Slider r;
public Slider g;
public Slider b;
public Text t;
public InputField input;
public static int BLOCK=1;
public void SetMelee()
{
sp = 1 << 8;
remoteButton.SetActive(true);
meleeButton.SetActive(false);
}
public void SetRemote()
{
sp = 1 << 9;
meleeButton.SetActive(true);
remoteButton.SetActive(false);
}
public void SetBlock(int n)
{
BLOCK = n;
}
public void MoveCamera( bool move)
{
moving=move;
}
bool moving=false;
float rvalue;
float gvalue;
float bvalue;
float result;
void Update()
{
//if (moving)
//Camera.main.transform.position += new Vector3(0, 0.1f, 0);
//if (rvalue != r.value|| gvalue != g.value || bvalue != b.value)//相当于On value changed
//{
// cube.material.color = new Color(r.value, g.value, b.value, 1);
// rvalue = r.value;
// gvalue = g.value;
// bvalue = b.value;
// input.text = (r.value * 255).ToString();
//}
//r.value = float.Parse(input.text) / 255;
// float.TryParse(t.text, out result);
//Camera.main.fieldOfView = 29 + r.value * 10;
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out RaycastHit m, 100, sp.value);
if (m.transform && m.transform.childCount==0)
{
switch (BLOCK)
{
case 1:
Instantiate(block, m.transform.position, Quaternion.identity,m.transform);
break;
case 2:
Instantiate(block1, m.transform.position, Quaternion.identity, m.transform);
break;
case 3:
Instantiate(block2, m.transform.position, Quaternion.identity, m.transform);
break;
case 4:
Instantiate(block3, m.transform.position, Quaternion.identity, m.transform);
break;
case 5:
Instantiate(block4, m.transform.position, Quaternion.identity, m.transform);
break;
}
}
else if (m.transform && m.transform.childCount != 0)
{
Destroy(m.transform.GetChild(0).gameObject);
switch (BLOCK)
{
case 0:break;
case 1:
Instantiate(block, m.transform.position, Quaternion.identity, m.transform);
break;
case 2:
Instantiate(block1, m.transform.position, Quaternion.identity,m.transform);
break;
case 3:
Instantiate(block2, m.transform.position, Quaternion.identity,m.transform);
break;
case 4:
Instantiate(block3, m.transform.position, Quaternion.identity, m.transform);
break;
case 5:
Instantiate(block4, m.transform.position, Quaternion.identity, m.transform);
break;
}
}
}
if (Input.GetMouseButton(1))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out RaycastHit m, 100, sp.value);
if (m.transform && m.transform.childCount == 0)
{
switch (BLOCK)
{
case 1:
Instantiate(block, m.transform.position, Quaternion.identity, m.transform);
break;
case 2:
Instantiate(block1, m.transform.position, Quaternion.identity, m.transform);
break;
case 3:
Instantiate(block2, m.transform.position, Quaternion.identity, m.transform);
break;
case 4:
Instantiate(block3, m.transform.position, Quaternion.identity, m.transform);
break;
case 5:
Instantiate(block4, m.transform.position, Quaternion.identity, m.transform);
break;
}
}
else if (m.transform && m.transform.childCount != 0)
{
Destroy(m.transform.GetChild(0).gameObject);
switch (BLOCK)
{
case 0:
break;
case 1:
Instantiate(block, m.transform.position, Quaternion.identity, m.transform);
break;
case 2:
Instantiate(block1, m.transform.position, Quaternion.identity, m.transform);
break;
case 3:
Instantiate(block2, m.transform.position, Quaternion.identity, m.transform);
break;
case 4:
Instantiate(block3, m.transform.position, Quaternion.identity, m.transform);
break;
case 5:
Instantiate(block4, m.transform.position, Quaternion.identity, m.transform);
break;
}
}
}
}
}