-
Notifications
You must be signed in to change notification settings - Fork 1
/
vv.cs
206 lines (181 loc) · 6.01 KB
/
vv.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class vv : MonoBehaviour
{
// Start is called before the first frame update
private List<replay> input1;
private List<replay> input2;
private List<replay> input3;
private SpriteRenderer renderer;
private List<List<replay>> cloneinput = new List<List<replay>>();
public LayerMask groundlayer;
public Animator animator;
public v sc;
public spwan sc1;
public int clonenum;
public Transform clonecheckobj;
bool clonecheck;
public LayerMask clone;
//private GameObject player = GameObject.Find("Square");
bool isgrounded;
public Transform groundcheck;
int i = 0;
int j = 0;
int k = 0;
Rigidbody2D rb;
public float jumpforce = 7f;
//public Vector2 spwanpoint;
public GameObject currentclone;
CapsuleCollider2D capsule;
CapsuleCollider2D capsule1;
public int cloneidnew;
private List<replay> temp = new List<replay>();
void Start()
{
float a = Random.Range(0.5f, 1f);
float b = Random.Range(0.5f, 1f);
float c = Random.Range(0.4f, 1f);
float d = Random.Range(0.3f, 1f);
cloneidnew = sc1.cloneid1;
cloneinput = sc.clonereplay;
//playerscript sc = GameObject.Find("Square").GetComponent<playerscript>();
input1 = sc.InputRecord;
input2 = sc.InputRecord1;
input3 = sc.InputRecord2;
Debug.Log(cloneidnew);
renderer = GetComponent<SpriteRenderer>();
rb = GetComponent<Rigidbody2D>();
renderer.color = new Color(a, b, c, d);
//cloneidnew = sc.cloneid;
cloneinput = sc.clonereplay;
List<replay> temp = cloneinput[cloneidnew - 1];
Debug.Log(temp.Count + " k" + temp.Count);
}
private void Update()
{
//Physics2D.IgnoreCollision(capsule, capsule1);
Vector2 spwanpoint = new Vector2(-6.78f, -3.5f);
Vector2 spwanpoint1 = new Vector2(-7.65f, -3.5f);
Vector2 spwanpoint2 = new Vector2(-8.77f, -3.5f);
Vector2 spwanpoint3 = new Vector2(-9.72f, -3.5f);
if (Input.GetKeyDown(KeyCode.K))
{
//transform.position = spwanpoint;
if (cloneidnew == 1)
{
transform.position = spwanpoint;
}
if (cloneidnew == 2)
{
transform.position = spwanpoint1;
}
if (cloneidnew == 3)
{
transform.position = spwanpoint2;
}
i = 0;
k = 0;
j = 0;
}
isgrounded = Physics2D.OverlapCapsule(groundcheck.position, new Vector2(0.99f, 0.16f), CapsuleDirection2D.Horizontal, 0, groundlayer);
clonecheck = Physics2D.OverlapCapsule(clonecheckobj.position, new Vector2(0.99f, 0.16f), CapsuleDirection2D.Horizontal, 0, clone);
}
// Update is called once per frame
void FixedUpdate()
{
/*if (Time.time > 1)
{
replay temp = input1[i];
transform.position = new Vector2(transform.position.x + temp.x * Time.deltaTime * 10f, transform.position.y);
if (temp.y == 1 && isgrounded)
{
rb.velocity = new Vector2(rb.velocity.x,jumpforce);
}
i++;
}*/
if (cloneidnew == 1)
{
//transform.position = spwanpoint;
if (Time.time > 1)
{
replay temp = input1[i];
if (temp.x != 0)
{
animator.SetBool("walking", true);
}
else
{
animator.SetBool("walking", false);
}
transform.position = new Vector2(transform.position.x + temp.x * Time.fixedDeltaTime * 7f, transform.position.y);
if (temp.y == 1)
{
if (clonecheck || isgrounded)
{
rb.velocity = new Vector2(rb.velocity.x, jumpforce);
}
}
i++;
}
}
if (cloneidnew == 2)
{
//transform.position = spwanpoint;
if (Time.time > 1)
{
replay temp = input2[k];
if (temp.x != 0)
{
animator.SetBool("walking", true);
}
else
{
animator.SetBool("walking", false);
}
transform.position = new Vector2(transform.position.x + temp.x * Time.fixedDeltaTime * 7f, transform.position.y);
if (temp.y == 1)
{
if (clonecheck || isgrounded)
{
rb.velocity = new Vector2(rb.velocity.x, jumpforce);
}
}
k++;
}
}
if (cloneidnew == 3)
{
if (Time.time > 1)
{
replay temp = input3[j];
if (temp.x != 0)
{
animator.SetBool("walking", true);
}
else
{
animator.SetBool("walking", false);
}
transform.position = new Vector2(transform.position.x + temp.x * Time.fixedDeltaTime * 7f, transform.position.y);
if (temp.y == 1)
{
if (clonecheck || isgrounded)
{
rb.velocity = new Vector2(rb.velocity.x, jumpforce);
}
}
j++;
}
}
/*if (i < temp.Count)
{
replay temp1 = temp[i];
transform.position = new Vector2(transform.position.x + temp1.x * Time.deltaTime * 10f, transform.position.y);
i++;
}
if (Input.GetKeyDown(KeyCode.K))
{
}*/
}
}