1
This commit is contained in:
parent
2997fd2284
commit
7fa6ff80dd
5130
Assets/Prefabs/Weapon SubMachineGun.prefab
Normal file
5130
Assets/Prefabs/Weapon SubMachineGun.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/Weapon SubMachineGun.prefab.meta
Normal file
7
Assets/Prefabs/Weapon SubMachineGun.prefab.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6426ac9a2bd960f45b9c77cd4255aa5d
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -7,11 +7,16 @@ public class Player : MonoBehaviour
|
||||||
|
|
||||||
{
|
{
|
||||||
public float speed;
|
public float speed;
|
||||||
|
public GameObject[] weapons;
|
||||||
|
public bool[] hasWeapons;
|
||||||
float hAxis;
|
float hAxis;
|
||||||
float vAxis;
|
float vAxis;
|
||||||
|
|
||||||
bool wDown;
|
bool wDown;
|
||||||
bool iDown;
|
bool iDown;
|
||||||
bool jDown;
|
bool jDown;
|
||||||
|
bool sDown1;
|
||||||
|
bool sDown2;
|
||||||
|
|
||||||
bool isJump;
|
bool isJump;
|
||||||
|
|
||||||
|
|
@ -35,6 +40,8 @@ public class Player : MonoBehaviour
|
||||||
Move();
|
Move();
|
||||||
Turn();
|
Turn();
|
||||||
Jump();
|
Jump();
|
||||||
|
Swap();
|
||||||
|
Interation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetInput()
|
void GetInput()
|
||||||
|
|
@ -43,6 +50,9 @@ public class Player : MonoBehaviour
|
||||||
vAxis = Input.GetAxisRaw("Vertical");
|
vAxis = Input.GetAxisRaw("Vertical");
|
||||||
wDown = Input.GetButton("Walk");
|
wDown = Input.GetButton("Walk");
|
||||||
jDown = Input.GetButtonDown("Jump");
|
jDown = Input.GetButtonDown("Jump");
|
||||||
|
iDown = Input.GetButtonDown("Interation");
|
||||||
|
sDown1 = Input.GetButtonDown("Swap1");
|
||||||
|
sDown2 = Input.GetButtonDown("Swap2");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Move()
|
void Move()
|
||||||
|
|
@ -74,6 +84,32 @@ public class Player : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Swap()
|
||||||
|
{
|
||||||
|
int weaponIndex = -1;
|
||||||
|
if (sDown1) weaponIndex = 0;
|
||||||
|
if (sDown2) weaponIndex = 1;
|
||||||
|
|
||||||
|
if ((sDown1 || sDown2) && !isJump)
|
||||||
|
{
|
||||||
|
weapons[weaponIndex].SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Interation()
|
||||||
|
{
|
||||||
|
if(iDown && nearObject != null) {
|
||||||
|
if(nearObject.tag == "Weapon") {
|
||||||
|
Item item = nearObject.GetComponent<Item>();
|
||||||
|
int weaponIndex = item.value;
|
||||||
|
hasWeapons[weaponIndex] = true;
|
||||||
|
|
||||||
|
Destroy(nearObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void OnCollisionEnter(Collision collision)
|
void OnCollisionEnter(Collision collision)
|
||||||
{
|
{
|
||||||
if(collision.gameObject.tag == "Floor") {
|
if(collision.gameObject.tag == "Floor") {
|
||||||
|
|
|
||||||
|
|
@ -294,13 +294,13 @@ InputManager:
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Cancel
|
m_Name: Interation
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: escape
|
positiveButton: e
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: joystick button 1
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
|
|
@ -310,13 +310,13 @@ InputManager:
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Cancel
|
m_Name: Swap1
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: escape
|
positiveButton: 1
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: joystick button 1
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
|
|
@ -326,13 +326,13 @@ InputManager:
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
m_Name: Cancel
|
m_Name: Swap2
|
||||||
descriptiveName:
|
descriptiveName:
|
||||||
descriptiveNegativeName:
|
descriptiveNegativeName:
|
||||||
negativeButton:
|
negativeButton:
|
||||||
positiveButton: escape
|
positiveButton: 2
|
||||||
altNegativeButton:
|
altNegativeButton:
|
||||||
altPositiveButton: joystick button 1
|
altPositiveButton:
|
||||||
gravity: 1000
|
gravity: 1000
|
||||||
dead: 0.001
|
dead: 0.001
|
||||||
sensitivity: 1000
|
sensitivity: 1000
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user