-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerSprite.cs
More file actions
55 lines (49 loc) · 1.77 KB
/
PlayerSprite.cs
File metadata and controls
55 lines (49 loc) · 1.77 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerSprite : MonoBehaviour
{
Transform test;
bool myTurn;
int moveCount;
public static GameObject Test;
async void Start() {
test = GetComponent<Transform>();
myTurn = false;
moveCount = 3;
}
async void Update() {
myTurn = moveCount > 0;
while (myTurn) {
if (Input.GetKeyDown(KeyCode.W)) {
test.Translate(new Vector3(0, 0, 1));
moveCount--;
}
if (Input.GetKeyDown(KeyCode.S)) {
test.Translate(new Vector3(0, 0, -1));
moveCount--;
}
if (Input.GetKeyDown(KeyCode.A)) {
test.Translate(new Vector3(-1, 0, 0));
moveCount--;
}
if (Input.GetKeyDown(KeyCode.D)) {
test.Translate(new Vector3(1, 0, 0));
moveCount--;
}
if(moveCount <= 0) {
myTurn = false;
break;
}
}
}
public bool getFriendlyTurn() { // Naming was because I was originally going to make a full team in this class, but wasn't sure if that was the greatest idea
return myTurn;
}
public void changeTurn() { // I don't have the time in class to make a full system for clicking and selecting characters to move, so instead they'll move 1 at a time with WASD
myTurn = !myTurn;
}
public static GameObject inst(float x, float y, float z) { // I don't even know man, I'm just trying whatever I can to make this game work
return Instantiate(Test, new Vector3(x, y, z), Quaternion.identity);
}
}