forked from JXPorter/OkitaUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cs
More file actions
98 lines (93 loc) · 1.87 KB
/
Copy pathPlayer.cs
File metadata and controls
98 lines (93 loc) · 1.87 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
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
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour
{
// store the position of the player
//Vector3 pos;
// or we can store the position of the player and share it as static variable with the other classes
// because this variable will be the same for every zombie that is created, they don't each need thier own
// instance of it.
public static Vector3 pos;
void Start()
{
// set the position to where we start off with in the scene
pos = transform.position;
}
void Update()
{
// add in a checks for the WASD keys
bool WKey = Input.GetKey(KeyCode.W);
bool AKey = Input.GetKey(KeyCode.A);
bool SKey = Input.GetKey (KeyCode.S);
bool DKey = Input.GetKey (KeyCode.D);
if (DKey)
{
pos.z += 0.1f;
}
if (AKey)
{
pos.x -= 0.1f;
Debug.Log ("AKey");
}
if (SKey)
{
pos.z -= 0.1f;
}
if (DKey)
{
pos.x += 0.1f;
}
gameObject.transform.position = pos;
// calls the static function in Zombie
Zombie.CountZombies();
}
}
//// ORIGINAL CODE FROM ALEX OKITA
//public class Player : MonoBehaviour
//{
//
//}
//
//
//Vector3 pos;
//// Use this for initialization
//void Start()
//{
//
//}
//// Update is called once per frame
//void Update()
//{
// bool WKey = Input.GetKey(KeyCode.W);
// bool SKey = Input.GetKey(KeyCode.S);
// bool AKey = Input.GetKey(KeyCode.A);
// bool DKey = Input.GetKey(KeyCode.D);
// if (WKey)
// {
// pos.z += 0.1f;
// }
// if (SKey)
// {
// pos.z -= 0.1f;
// }
// if (AKey)
// {
// pos.x -= 0.1f;
// }
// if (DKey)
// {
// pos.x += 0.1f;
// }
// gameObject.transform.position = pos;
// //add in a check for the A key
// //bool AKey = Input.GetKey(KeyCode.A);
// //if (AKey)
// //{
// // Debug.Log("AKey");
// // //calls the static function in Zombie
// // Zombie.CountZombies();
// //}
// //Input MyInput = new Input();
// //bool AKey = MyInput.GetKey( KeyCode.A );
// //Debug.Log( AKey );
//}