init
This commit is contained in:
commit
a8c6025cd3
158 changed files with 86052 additions and 0 deletions
17
Assets/Scripts/Aim.cs
Normal file
17
Assets/Scripts/Aim.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Aim : MonoBehaviour{
|
||||
|
||||
public Vector3 difference;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
|
||||
difference.Normalize();
|
||||
|
||||
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Aim.cs.meta
Normal file
11
Assets/Scripts/Aim.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f31dcc0487462814391df6b29ad46ab5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Scripts/Bullet.cs
Normal file
20
Assets/Scripts/Bullet.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bullet : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
public GameObject bullet;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
transform.Translate(Vector3.right * speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D col){
|
||||
if (col.gameObject.tag != "Player" || col.gameObject.tag != "Bullet"){
|
||||
Destroy(bullet);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Bullet.cs.meta
Normal file
11
Assets/Scripts/Bullet.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 73cfb1facce4f4343a816d0945fbc1b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Scripts/CameraFollow.cs
Normal file
30
Assets/Scripts/CameraFollow.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraFollow : MonoBehaviour {
|
||||
|
||||
public GameObject follow;
|
||||
public Vector2 minCamPos, maxCamPos;
|
||||
public float smoothTime;
|
||||
|
||||
private Vector2 velocity;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate () {
|
||||
float posX = Mathf.SmoothDamp(transform.position.x,
|
||||
follow.transform.position.x, ref velocity.x, smoothTime);
|
||||
float posY = Mathf.SmoothDamp(transform.position.y,
|
||||
follow.transform.position.y, ref velocity.y, smoothTime);
|
||||
|
||||
transform.position = new Vector3(
|
||||
Mathf.Clamp(posX, minCamPos.x, maxCamPos.x),
|
||||
Mathf.Clamp(posY, minCamPos.y, maxCamPos.y),
|
||||
transform.position.z);
|
||||
}
|
||||
}
|
12
Assets/Scripts/CameraFollow.cs.meta
Normal file
12
Assets/Scripts/CameraFollow.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b27a079b274fcba46932735d08fd06be
|
||||
timeCreated: 1492791055
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/CheckGround.cs
Normal file
29
Assets/Scripts/CheckGround.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CheckGround : MonoBehaviour{
|
||||
|
||||
PlayerController player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
player = GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
}
|
||||
private void OnCollisionStay2D(Collision2D col){
|
||||
if (col.gameObject.tag == "Ground"){
|
||||
player.grounded = true;
|
||||
}
|
||||
if (col.gameObject.tag == "Fall"){
|
||||
player.grounded = true;
|
||||
}
|
||||
}
|
||||
private void OnCollisionExit2D(Collision2D col){
|
||||
player.grounded = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/CheckGround.cs.meta
Normal file
11
Assets/Scripts/CheckGround.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: beca54acfa7a6544b964e9f1e12e2372
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/LimitedJumps.cs
Normal file
29
Assets/Scripts/LimitedJumps.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LimitedJumps : MonoBehaviour{
|
||||
|
||||
public bool jump;
|
||||
public bool doubleJump;
|
||||
public bool grounded;
|
||||
|
||||
Rigidbody2D rb2d;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (grounded){
|
||||
jump = true;
|
||||
doubleJump = true;
|
||||
}
|
||||
else if (doubleJump){
|
||||
jump = true;
|
||||
doubleJump = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LimitedJumps.cs.meta
Normal file
11
Assets/Scripts/LimitedJumps.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27d3714321ca50a44afa57592f0b1bea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
107
Assets/Scripts/PlayerController.cs
Normal file
107
Assets/Scripts/PlayerController.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerController : MonoBehaviour{
|
||||
|
||||
public bool shooting;
|
||||
public float shootingSpeed;
|
||||
public GameObject player;
|
||||
public float speed;
|
||||
public float maxSpeed;
|
||||
public float maxJump;
|
||||
public bool grounded;
|
||||
public CircleCollider2D normalCol;
|
||||
public CircleCollider2D healingCol;
|
||||
|
||||
bool jump;
|
||||
bool twojump;
|
||||
bool threejump;
|
||||
bool fourjump;
|
||||
Vector3 difference;
|
||||
Aim aim;
|
||||
Rigidbody2D rb2d;
|
||||
HealthBar health;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
aim = GetComponent<Aim>();
|
||||
health = GameObject.FindGameObjectWithTag("Health").GetComponent<HealthBar>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (Input.GetMouseButtonDown(0)){
|
||||
if (jump == true){
|
||||
shooting = true;
|
||||
rb2d.AddForce(-difference * speed, ForceMode2D.Impulse);
|
||||
jump = false;
|
||||
}
|
||||
if (grounded)
|
||||
{
|
||||
jump = true;
|
||||
twojump = true;
|
||||
threejump = true;
|
||||
fourjump = true;
|
||||
}
|
||||
else if (fourjump)
|
||||
{
|
||||
jump = true;
|
||||
twojump = true;
|
||||
threejump = true;
|
||||
fourjump = false;
|
||||
}
|
||||
else if (threejump)
|
||||
{
|
||||
jump = true;
|
||||
twojump = true;
|
||||
threejump = false;
|
||||
fourjump = false;
|
||||
}
|
||||
else if (twojump)
|
||||
{
|
||||
jump = true;
|
||||
twojump = false;
|
||||
threejump = false;
|
||||
fourjump = false;
|
||||
}
|
||||
}
|
||||
if (grounded){
|
||||
float fixedSpeed = rb2d.velocity.x;
|
||||
fixedSpeed *= 0.95f;
|
||||
rb2d.velocity = new Vector2(fixedSpeed, rb2d.velocity.y);
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0)){
|
||||
shooting = false;
|
||||
}
|
||||
difference = aim.difference;
|
||||
if (rb2d.velocity.x > maxSpeed){
|
||||
rb2d.velocity = new Vector2(maxSpeed, rb2d.velocity.y);
|
||||
}
|
||||
if (rb2d.velocity.x < -maxSpeed){
|
||||
rb2d.velocity = new Vector2(-maxSpeed, rb2d.velocity.y);
|
||||
}
|
||||
if (rb2d.velocity.y > maxJump){
|
||||
rb2d.velocity = new Vector2(rb2d.velocity.x, maxJump);
|
||||
}
|
||||
if (rb2d.velocity.y < -maxJump){
|
||||
rb2d.velocity = new Vector2(rb2d.velocity.x, -maxJump);
|
||||
}
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision){
|
||||
if(collision.gameObject.tag == "Killer"){
|
||||
health.hp = 0f;
|
||||
}
|
||||
if(collision.gameObject.tag == "Enemy"){
|
||||
normalCol.enabled = false;
|
||||
healingCol.enabled = true;
|
||||
StartCoroutine(IsHealing(3f));
|
||||
}
|
||||
}
|
||||
IEnumerator IsHealing (float time){
|
||||
yield return new WaitForSeconds(time);
|
||||
healingCol.enabled = false;
|
||||
normalCol.enabled = true;
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerController.cs.meta
Normal file
11
Assets/Scripts/PlayerController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e9cceb9c0a23bef488f5685de4e1a19b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/PlayerHealth.cs
Normal file
29
Assets/Scripts/PlayerHealth.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerHealth : MonoBehaviour{
|
||||
|
||||
public Image health;
|
||||
public float hp, maxHp = 12f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
hp = maxHp;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
public void TakeDamage(float amount){
|
||||
hp = Mathf.Clamp(hp - amount, 0f, maxHp);
|
||||
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
|
||||
}
|
||||
public void AddHealth(float amount){
|
||||
hp = Mathf.Clamp(hp + amount, 0f, maxHp);
|
||||
health.transform.localScale = new Vector2(hp / maxHp / 100, 0.00927f);
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerHealth.cs.meta
Normal file
11
Assets/Scripts/PlayerHealth.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30b3cda54e9589342ad78cd387ad99e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Assets/Scripts/Shoot.cs
Normal file
41
Assets/Scripts/Shoot.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Shoot : MonoBehaviour{
|
||||
|
||||
public bool isFiring;
|
||||
public Bullet bullet;
|
||||
public float bulletSpeed;
|
||||
public float timeBetweenShots;
|
||||
public Transform firePoint;
|
||||
|
||||
PlayerController player;
|
||||
float shotCounter;
|
||||
|
||||
void Start(){
|
||||
player = GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
if (isFiring == true){
|
||||
shotCounter -= Time.deltaTime;
|
||||
if (shotCounter <= 0){
|
||||
shotCounter = timeBetweenShots;
|
||||
Bullet newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation) as Bullet;
|
||||
newBullet.speed = bulletSpeed;
|
||||
}
|
||||
} else{
|
||||
shotCounter = 0;
|
||||
}
|
||||
|
||||
if (player.shooting == true){
|
||||
isFiring = true;
|
||||
}
|
||||
if (player.shooting == false){
|
||||
isFiring = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Shoot.cs.meta
Normal file
11
Assets/Scripts/Shoot.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0454fd2fba56824f82f464ff137219d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue