MOD: Sprites hinzugefügt
MOD: Gegner platziert
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//Ben Keller
|
||||
public class PlayerMover : MonoBehaviour
|
||||
{
|
||||
public KeyCode up = KeyCode.W;
|
||||
@@ -18,7 +19,7 @@ public class PlayerMover : MonoBehaviour
|
||||
|
||||
public Player player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
@@ -26,7 +27,7 @@ public class PlayerMover : MonoBehaviour
|
||||
speed = playerStats.speed;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
void Update()
|
||||
{
|
||||
Move();
|
||||
@@ -51,7 +52,7 @@ public class PlayerMover : MonoBehaviour
|
||||
}
|
||||
|
||||
if(moveDirection.magnitude > 1){
|
||||
moveDirection.Normalize(); // Normalize if diagonal to avoid faster movement
|
||||
moveDirection.Normalize();
|
||||
}
|
||||
|
||||
rb.velocity = moveDirection * speed;
|
||||
|
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
//Marvin Schneider
|
||||
public class PlayerStats : MonoBehaviour
|
||||
{
|
||||
public Player player;
|
||||
@@ -13,7 +14,7 @@ public class PlayerStats : MonoBehaviour
|
||||
|
||||
private bool isTakingDamage = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
void Start()
|
||||
{
|
||||
health = player.getCurrentHealth();
|
||||
|
@@ -1,7 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.IO.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
|
||||
//Ben Keller
|
||||
public class Shooting : MonoBehaviour
|
||||
{
|
||||
private Camera mainCam;
|
||||
@@ -14,14 +16,19 @@ public class Shooting : MonoBehaviour
|
||||
|
||||
public PlayerStats playerStats;
|
||||
|
||||
// Start is called before the first frame update
|
||||
SpriteRenderer spriteRenderer;
|
||||
|
||||
public Transform muzzle;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
|
||||
playerStats = gameObject.GetComponentInParent<PlayerStats>();
|
||||
spriteRenderer = gameObject.GetComponentInChildren<SpriteRenderer>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
void Update()
|
||||
{
|
||||
mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);
|
||||
@@ -32,6 +39,25 @@ public class Shooting : MonoBehaviour
|
||||
|
||||
transform.rotation = Quaternion.Euler(0, 0, rotZ);
|
||||
|
||||
flip();
|
||||
|
||||
fire();
|
||||
}
|
||||
|
||||
void flip(){
|
||||
if (mousePos.x < transform.position.x)
|
||||
{
|
||||
spriteRenderer.flipY = true;
|
||||
muzzle.localPosition = new Vector3(1.65f, -0.14f, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteRenderer.flipY = false;
|
||||
muzzle.localPosition = new Vector3(1.65f, 0.14f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void fire(){
|
||||
if(!canFire){
|
||||
timer += Time.deltaTime;
|
||||
if(timer > playerStats.fireRate){
|
||||
|
Reference in New Issue
Block a user