initial commit
This commit is contained in:
parent
8766216908
commit
23576e137e
1033 changed files with 499339 additions and 0 deletions
16
Assets/Scripts/AutomatedPlayer.cs
Normal file
16
Assets/Scripts/AutomatedPlayer.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class AutomatedPlayer : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/AutomatedPlayer.cs.meta
Normal file
2
Assets/Scripts/AutomatedPlayer.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 88cc3202b26534d78b932ebaf49077f4
|
||||
16
Assets/Scripts/Enemy.cs
Normal file
16
Assets/Scripts/Enemy.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Enemy : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemy.cs.meta
Normal file
2
Assets/Scripts/Enemy.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 29eabb6316cb9023da130abba3ba64fc
|
||||
34
Assets/Scripts/Entity.cs
Normal file
34
Assets/Scripts/Entity.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Health")]
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
[Header("Stats")]
|
||||
public float speed;
|
||||
public float jumpPower;
|
||||
[Header("Cache")]
|
||||
[SerializeField] protected Rigidbody2D rb;
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
health -= damage;
|
||||
if (health <= 0)
|
||||
{
|
||||
OnDeath();
|
||||
}
|
||||
}
|
||||
|
||||
public void Heal(float healing)
|
||||
{
|
||||
health += healing;
|
||||
health = Math.Clamp(health, 0, maxHealth);
|
||||
}
|
||||
|
||||
protected virtual void OnDeath()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entity.cs.meta
Normal file
2
Assets/Scripts/Entity.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a436974b96680ea6287afa659d6b0b4a
|
||||
23
Assets/Scripts/Player.cs
Normal file
23
Assets/Scripts/Player.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : Entity
|
||||
{
|
||||
[Header("Ground Detection")]
|
||||
[SerializeField] private Transform groundCheck;
|
||||
[SerializeField] private LayerMask groundLayer;
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * speed, rb.linearVelocityY);
|
||||
if (Input.GetKeyDown(KeyCode.Space) && OnGround())
|
||||
{
|
||||
movement.y = jumpPower;
|
||||
}
|
||||
rb.linearVelocity = movement;
|
||||
}
|
||||
|
||||
private bool OnGround()
|
||||
{
|
||||
return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Player.cs.meta
Normal file
2
Assets/Scripts/Player.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d4ea4a5fe3d2523039e302c010b04daf
|
||||
16
Assets/Scripts/PlayerSwitcher.cs
Normal file
16
Assets/Scripts/PlayerSwitcher.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PlayerSwitcher : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/PlayerSwitcher.cs.meta
Normal file
2
Assets/Scripts/PlayerSwitcher.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3db97897f8dc0482a9a25edd2d1ef4a0
|
||||
Loading…
Add table
Add a link
Reference in a new issue