init
This commit is contained in:
commit
862afc9b7a
478 changed files with 197737 additions and 0 deletions
29
Assets/Scripts/Ammo.cs
Normal file
29
Assets/Scripts/Ammo.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Ammo : MonoBehaviour
|
||||
{
|
||||
public int amount;
|
||||
public Sprite one, two, three;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
amount = Random.Range(1, 4);
|
||||
SpriteRenderer sr = GetComponent<SpriteRenderer>();
|
||||
if (amount == 1)
|
||||
sr.sprite = one;
|
||||
else if (amount == 2)
|
||||
sr.sprite = two;
|
||||
else if (amount == 3)
|
||||
sr.sprite = three;
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.transform.tag.Equals("Player"))
|
||||
{
|
||||
collision.transform.GetComponent<PlayerWeaponController>().currentBullets += amount;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Ammo.cs.meta
Normal file
11
Assets/Scripts/Ammo.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4a1d767443bb5274ca6d643b5c250161
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Assets/Scripts/AudioManager.cs
Normal file
50
Assets/Scripts/AudioManager.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using UnityEngine.Audio;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManager : MonoBehaviour{
|
||||
|
||||
public Sound[] sounds;
|
||||
|
||||
public static AudioManager instance;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
foreach(Sound s in sounds){
|
||||
s.source = gameObject.AddComponent<AudioSource>();
|
||||
s.source.clip = s.clip;
|
||||
|
||||
s.source.volume = s.volume;
|
||||
s.source.pitch = s.pitch;
|
||||
s.source.loop = s.loop;
|
||||
|
||||
s.source.outputAudioMixerGroup = s.mixerGroup;
|
||||
}
|
||||
}
|
||||
|
||||
public void Play(string name){
|
||||
Sound s = Array.Find(sounds, sound => sound.name == name);
|
||||
if (s == null){
|
||||
Debug.LogError("Sound: " + name + " not found!");
|
||||
return;
|
||||
}
|
||||
s.source.Play();
|
||||
}
|
||||
public void Stop(string name){
|
||||
Sound s = Array.Find(sounds, sound => sound.name == name);
|
||||
if (s == null){
|
||||
Debug.LogError("Sound: " + name + " not found!");
|
||||
return;
|
||||
}
|
||||
s.source.Stop();
|
||||
}
|
||||
}
|
11
Assets/Scripts/AudioManager.cs.meta
Normal file
11
Assets/Scripts/AudioManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66c16b7a414e42948ae63cef64d19919
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
60
Assets/Scripts/Boss.cs
Normal file
60
Assets/Scripts/Boss.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Boss : MonoBehaviour
|
||||
{
|
||||
public float Health, attackDelay;
|
||||
float f;
|
||||
public Transform Missile, Firepoint;
|
||||
public int attack;
|
||||
Animator anim;
|
||||
public GameObject wall;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
f += Time.deltaTime;
|
||||
if (f >= attackDelay && attack == 1)
|
||||
{
|
||||
f = 0;
|
||||
anim.SetTrigger("newAttack");
|
||||
attack = 0;
|
||||
shootMissiles();
|
||||
}
|
||||
if (attack == 0 && GameObject.FindGameObjectsWithTag("Missile").Length == 0)
|
||||
{
|
||||
anim.SetTrigger("newAttack");
|
||||
attack = 1;
|
||||
f = 0;
|
||||
}
|
||||
if (Health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Destroy(wall);
|
||||
}
|
||||
}
|
||||
public void shootMissiles()
|
||||
{
|
||||
Transform bullet = Instantiate(Missile, Firepoint.position, Firepoint.rotation);
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if(collision.gameObject.tag == "Bullet"){
|
||||
Health -= 1;
|
||||
}
|
||||
|
||||
if (collision.transform.tag == "Player")
|
||||
{
|
||||
collision.transform.GetComponent<PlayerStats>().Die();
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Boss.cs.meta
Normal file
11
Assets/Scripts/Boss.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5bc97a4bf67a78d49aa61766e2e93f06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/BulletScript.cs
Normal file
43
Assets/Scripts/BulletScript.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BulletScript : MonoBehaviour
|
||||
{
|
||||
public float damage;
|
||||
public GameObject bulletImpact;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
AudioManager.instance.Play("Shoot");
|
||||
}
|
||||
|
||||
void Update() {
|
||||
Vector2 vel = gameObject.GetComponent<Rigidbody2D>().velocity;
|
||||
gameObject.transform.rotation = Quaternion.Euler(new Vector3(0,0,Mathf.Rad2Deg * Mathf.Atan2(vel.y,vel.x)));
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision) {
|
||||
AudioManager.instance.Play("ShootCollide");
|
||||
CameraShake.instance.Shake(.1f, .1f);
|
||||
Instantiate(bulletImpact, transform.position, Quaternion.identity);
|
||||
Button button = collision.transform.GetComponent<Button>();
|
||||
if (!button)
|
||||
Object.Destroy(gameObject);
|
||||
else if(!button.bulletProof)
|
||||
{
|
||||
button.Press();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
hasHP hp;
|
||||
if (collision.gameObject.TryGetComponent<hasHP>(out hp)) {
|
||||
Debug.Log("Damaging");
|
||||
hp.damage(damage);
|
||||
}
|
||||
Debug.Log(collision.otherCollider.gameObject.name);
|
||||
if (collision.otherCollider.gameObject.name.Equals("Player")) {
|
||||
collision.otherCollider.gameObject.GetComponent<PlayerStats>().Die();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/BulletScript.cs.meta
Normal file
11
Assets/Scripts/BulletScript.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8112eab9c457887488f16d789c8fe98f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
88
Assets/Scripts/Button.cs
Normal file
88
Assets/Scripts/Button.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Button : MonoBehaviour
|
||||
{
|
||||
public Transform[] wall;
|
||||
public GameObject[] insideWallColliders;
|
||||
public bool pressed = false;
|
||||
public Sprite off;
|
||||
public bool bulletProof, changeSprite;
|
||||
public Sprite ChangedSprite;
|
||||
|
||||
[Space(10)]
|
||||
public GameObject[] fallingPlatforms;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if ((collision.transform.tag == "Player") && !pressed)
|
||||
{
|
||||
Press();
|
||||
}
|
||||
|
||||
}
|
||||
public void Press()
|
||||
{
|
||||
if(fallingPlatforms != null){
|
||||
foreach(GameObject platform in fallingPlatforms){
|
||||
platform.GetComponent<PlataformaFalling>().ButtonFall();
|
||||
}
|
||||
}
|
||||
|
||||
if(insideWallColliders != null){
|
||||
foreach(GameObject o in insideWallColliders){
|
||||
o.SetActive(true);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < wall.Length; i++)
|
||||
{
|
||||
wall[i].GetComponent<Collider2D>().enabled = !wall[i].GetComponent<Collider2D>().enabled;
|
||||
if (wall[i].GetComponent<SpriteRenderer>())
|
||||
{
|
||||
if (!changeSprite)
|
||||
{
|
||||
Color col = wall[i].GetComponent<SpriteRenderer>().color;
|
||||
if (wall[i].GetComponent<Collider2D>().enabled)
|
||||
col.a = 1;
|
||||
else col.a = 0.25f;
|
||||
wall[i].GetComponent<SpriteRenderer>().color = col;
|
||||
}else
|
||||
{
|
||||
wall[i].GetComponent<SpriteRenderer>().sprite = ChangedSprite;
|
||||
}
|
||||
}
|
||||
for (int f = 0; f < wall[i].childCount; f++)
|
||||
{
|
||||
if (wall[i].GetChild(f).GetComponent<SpriteRenderer>())
|
||||
{
|
||||
if (!changeSprite)
|
||||
{
|
||||
Color col = wall[i].GetChild(f).GetComponent<SpriteRenderer>().color;
|
||||
if (wall[i].GetComponent<Collider2D>().enabled)
|
||||
col.a = 1;
|
||||
else col.a = 0.25f;
|
||||
wall[i].GetChild(f).GetComponent<SpriteRenderer>().color = col;
|
||||
}else
|
||||
{
|
||||
wall[i].GetChild(f).GetComponent<SpriteRenderer>().sprite = ChangedSprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pressed = true;
|
||||
GetComponent<Collider2D>().enabled = false;
|
||||
GetComponent<SpriteRenderer>().sprite = off;
|
||||
}
|
||||
}
|
12
Assets/Scripts/Button.cs.meta
Normal file
12
Assets/Scripts/Button.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92c3fd8c7980adc43bcadfd877f03aa1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- off: {fileID: -841585974866616352, guid: 38f9cd13ae093e2428e57bb3d401a7f8, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
62
Assets/Scripts/ButtonFalling.cs
Normal file
62
Assets/Scripts/ButtonFalling.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonFalling : MonoBehaviour{
|
||||
|
||||
public Transform[] wall;
|
||||
|
||||
public bool pressed = false;
|
||||
public Sprite off;
|
||||
|
||||
[Space(10)]
|
||||
public GameObject[] fallingPlatforms;
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision){
|
||||
if ((collision.transform.tag == "Player") && !pressed || collision.gameObject.tag == "Bullet" && !pressed){
|
||||
Press();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if ((collision.transform.tag == "Player"))
|
||||
{
|
||||
Press();
|
||||
}
|
||||
}
|
||||
public void Press(){
|
||||
if (fallingPlatforms != null){
|
||||
foreach (GameObject platform in fallingPlatforms){
|
||||
platform.GetComponent<FallingPlatformButton>().ButtonFall();
|
||||
}
|
||||
}
|
||||
|
||||
if (wall != null){
|
||||
for (int i = 0; i < wall.Length; i++){
|
||||
wall[i].GetComponent<Collider2D>().enabled = !wall[i].GetComponent<Collider2D>().enabled;
|
||||
if (wall[i].GetComponent<SpriteRenderer>()){
|
||||
Color col = wall[i].GetComponent<SpriteRenderer>().color;
|
||||
if (wall[i].GetComponent<Collider2D>().enabled)
|
||||
col.a = 1;
|
||||
else col.a = 0.25f;
|
||||
wall[i].GetComponent<SpriteRenderer>().color = col;
|
||||
}
|
||||
for (int f = 0; f < wall[i].childCount; f++){
|
||||
if (wall[i].GetChild(f).GetComponent<SpriteRenderer>()){
|
||||
Color col = wall[i].GetChild(f).GetComponent<SpriteRenderer>().color;
|
||||
if (wall[i].GetComponent<Collider2D>().enabled)
|
||||
col.a = 1;
|
||||
else col.a = 0.25f;
|
||||
wall[i].GetChild(f).GetComponent<SpriteRenderer>().color = col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pressed = true;
|
||||
GetComponent<Collider2D>().enabled = false;
|
||||
GetComponent<SpriteRenderer>().sprite = off;
|
||||
}
|
||||
}
|
11
Assets/Scripts/ButtonFalling.cs.meta
Normal file
11
Assets/Scripts/ButtonFalling.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d90b5f362e3be5047ab97817f558baf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Assets/Scripts/CameraShake.cs
Normal file
38
Assets/Scripts/CameraShake.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraShake : MonoBehaviour{
|
||||
|
||||
float shakeAmount = 0;
|
||||
|
||||
public static CameraShake instance;
|
||||
|
||||
void Awake(){
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void Shake(float amt, float length){
|
||||
shakeAmount = amt;
|
||||
InvokeRepeating("DoShake", 0, 0.01f);
|
||||
Invoke("StopShake", length);
|
||||
}
|
||||
|
||||
void DoShake(){
|
||||
if (shakeAmount > 0){
|
||||
Vector3 camPos = transform.position;
|
||||
|
||||
float offsetX = Random.value * shakeAmount * 2 - shakeAmount;
|
||||
float offsetY = Random.value * shakeAmount * 2 - shakeAmount;
|
||||
camPos.x += offsetX;
|
||||
camPos.y += offsetY;
|
||||
|
||||
transform.position = camPos;
|
||||
}
|
||||
}
|
||||
|
||||
void StopShake(){
|
||||
CancelInvoke("DoShake");
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
11
Assets/Scripts/CameraShake.cs.meta
Normal file
11
Assets/Scripts/CameraShake.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 35ce4982f0a34434d971ccdb10bdadd9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/Checkpoint.cs
Normal file
33
Assets/Scripts/Checkpoint.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Checkpoint : MonoBehaviour
|
||||
{
|
||||
Animator anim;
|
||||
bool active;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.tag == "Player" && !active)
|
||||
{
|
||||
AudioManager.instance.Play("Checkpoint");
|
||||
anim.SetBool("Active", true);
|
||||
Debug.Log("Checkpoint at X" + transform.position.x + " Y" + transform.position.y);
|
||||
collision.GetComponent<PlayerStats>().checkpoint = transform.position;
|
||||
collision.GetComponent<PlayerStats>().checkpoint.y += 1;
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Checkpoint.cs.meta
Normal file
11
Assets/Scripts/Checkpoint.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da76846c75a4bae41b098bf770fb4795
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/Scripts/Credits.cs
Normal file
23
Assets/Scripts/Credits.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Credits : MonoBehaviour{
|
||||
|
||||
RectTransform rectTransform;
|
||||
Vector2 startPos;
|
||||
public float speed;
|
||||
public Vector2 end;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
startPos = transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
rectTransform.position = Vector2.MoveTowards(rectTransform.position, end, speed * Time.deltaTime);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Credits.cs.meta
Normal file
11
Assets/Scripts/Credits.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c81ff4fcba8317f449e267eb709601ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/DrawSceneLine.cs
Normal file
18
Assets/Scripts/DrawSceneLine.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DrawSceneLine : MonoBehaviour {
|
||||
|
||||
public Transform from;
|
||||
public Transform to;
|
||||
|
||||
void OnDrawGizmosSelected(){
|
||||
if (from != null && to != null){
|
||||
Gizmos.color = Color.cyan;
|
||||
Gizmos.DrawLine(from.position, to.position);
|
||||
Gizmos.DrawSphere(from.position, 0.15f);
|
||||
Gizmos.DrawSphere(to.position, 0.15f);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/DrawSceneLine.cs.meta
Normal file
11
Assets/Scripts/DrawSceneLine.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7869d63e7d44f26498f5dc7d53c0fe82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/Dropper.cs
Normal file
27
Assets/Scripts/Dropper.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class Dropper : MonoBehaviour
|
||||
{
|
||||
public GameObject ammo;
|
||||
public void drop(GameObject obj) {
|
||||
GameObject go = Instantiate(obj);
|
||||
go.transform.position = gameObject.transform.position;
|
||||
go.AddComponent<GroundItem>();
|
||||
go.GetComponent<GroundItem>().selfPrefab = obj;
|
||||
go.GetComponent<GroundItem>().Radius = 5;
|
||||
}
|
||||
public void Ammo()
|
||||
{
|
||||
|
||||
if (Random.value <= 0.5f)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Instantiate(ammo, transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Dropper.cs.meta
Normal file
11
Assets/Scripts/Dropper.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 399f1f6925c30294eb2778ebf31bc60b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/FallingPlatformButton.cs
Normal file
33
Assets/Scripts/FallingPlatformButton.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FallingPlatformButton : MonoBehaviour{
|
||||
|
||||
public float fallDelay = .25f;
|
||||
public float respawnDelay = 5f;
|
||||
|
||||
public GameObject particles;
|
||||
private Rigidbody2D rb2d;
|
||||
private BoxCollider2D pc2d;
|
||||
private Vector3 start;
|
||||
|
||||
// Use this for initialization
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
pc2d = GetComponent<BoxCollider2D>();
|
||||
start = transform.position;
|
||||
fallDelay = Random.Range(fallDelay - .1f, fallDelay + .1f);
|
||||
}
|
||||
|
||||
public void ButtonFall(){
|
||||
AudioManager.instance.Play("FallingPlatform");
|
||||
Invoke("Fall", fallDelay);
|
||||
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
||||
}
|
||||
|
||||
void Fall(){
|
||||
rb2d.isKinematic = false;
|
||||
pc2d.isTrigger = true;
|
||||
}
|
||||
}
|
11
Assets/Scripts/FallingPlatformButton.cs.meta
Normal file
11
Assets/Scripts/FallingPlatformButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5e8c052635171c499b74c91476c051f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Scripts/FollowObject.cs
Normal file
25
Assets/Scripts/FollowObject.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FollowObject : MonoBehaviour
|
||||
{
|
||||
public Transform follow;
|
||||
public Vector2 xPosLimit;
|
||||
public float smoothiness;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 pos = transform.position;
|
||||
pos -= (transform.position - follow.position) * smoothiness * Time.deltaTime;
|
||||
pos.x = Mathf.Clamp(pos.x, xPosLimit.x, xPosLimit.y);
|
||||
pos.z = transform.position.z;
|
||||
transform.position = pos;
|
||||
}
|
||||
}
|
11
Assets/Scripts/FollowObject.cs.meta
Normal file
11
Assets/Scripts/FollowObject.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1a4e5fd2d31c6a4695e11f3558d2af1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Assets/Scripts/GoombaAI.cs
Normal file
45
Assets/Scripts/GoombaAI.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GoombaAI : hasHP
|
||||
{
|
||||
Rigidbody2D rb;
|
||||
|
||||
public GameObject itemDrop;
|
||||
|
||||
private Vector2 dir;
|
||||
|
||||
private Vector2 length;
|
||||
void Start()
|
||||
{
|
||||
length = GetComponent<SpriteRenderer>().bounds.size;
|
||||
curHP = MaxHP;
|
||||
rb = gameObject.GetComponent<Rigidbody2D>();
|
||||
dir = new Vector2(-1, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0, rb.velocity.x < 0 ? 180 : 0, 0);
|
||||
if (rb.velocity.magnitude < 0.1) { rb.velocity += new Vector2(0, 5f); }
|
||||
bool hit = Physics2D.Raycast(gameObject.transform.position, dir, (length.x / 2) + 0.1f, 1 << LayerMask.NameToLayer("Ground")) || !Physics2D.Raycast(gameObject.transform.position + (Vector3.right * dir.x * ((length.x / 2) + 0.1f)), Vector3.down, (length.y / 2) + 0.1f, 1 << LayerMask.NameToLayer("Ground"));
|
||||
if(hit) {
|
||||
dir *= -1;
|
||||
}
|
||||
rb.velocity = dir + new Vector2(0,rb.velocity.y);
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision) {
|
||||
if (collision.collider.name.Equals("Player")) {
|
||||
collision.collider.gameObject.GetComponent<PlayerStats>().Die();
|
||||
}
|
||||
}
|
||||
|
||||
public override void die() {
|
||||
gameObject.GetComponent<Dropper>().Ammo();
|
||||
Object.Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/GoombaAI.cs.meta
Normal file
11
Assets/Scripts/GoombaAI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1118e318f06ee4c4082bb1878839b00a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
Assets/Scripts/GroundItem.cs
Normal file
39
Assets/Scripts/GroundItem.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GroundItem : MonoBehaviour
|
||||
{
|
||||
public float Radius;
|
||||
public GameObject selfPrefab;
|
||||
GameObject target;
|
||||
void Start()
|
||||
{
|
||||
target = findPlayer();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 Dist = target.transform.position - gameObject.transform.position;
|
||||
if ((Dist).magnitude <= Radius) {
|
||||
Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
|
||||
rb.AddForce(Dist.normalized * rb.mass * Mathf.Sqrt(Dist.magnitude) * 3);
|
||||
if ((Dist).magnitude <= 1) {
|
||||
Inventory.addItem(selfPrefab);
|
||||
Object.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameObject findPlayer() {
|
||||
GameObject returnObj = null;
|
||||
foreach(GameObject go in Object.FindObjectsOfType<GameObject>()) {
|
||||
if (go.name.Equals("Player")) {
|
||||
returnObj = go;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnObj;
|
||||
}
|
||||
}
|
11
Assets/Scripts/GroundItem.cs.meta
Normal file
11
Assets/Scripts/GroundItem.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9e609265f445e504fbaeec44ae25f5eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/Inventory.cs
Normal file
33
Assets/Scripts/Inventory.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Inventory
|
||||
{
|
||||
public static List<GameObject> Items = new List<GameObject>();
|
||||
public static int Index = 0;
|
||||
public static void cycleItem() {
|
||||
if (Items.Count > 0) {
|
||||
Index = (Index + 1) % Items.Count;
|
||||
}
|
||||
}
|
||||
public static GameObject getActiveItem() {
|
||||
return Items[Index];
|
||||
}
|
||||
public static void addItem(GameObject go) {
|
||||
if (!containsItem(go)) {
|
||||
Items.Add(go);
|
||||
}
|
||||
}
|
||||
public static bool containsItem(GameObject i) {
|
||||
bool found = false;
|
||||
foreach (GameObject a in Items) {
|
||||
if (a.name.Equals(i.name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Inventory.cs.meta
Normal file
11
Assets/Scripts/Inventory.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3b758b97e09e4fa4285fcc482310a81b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
Assets/Scripts/Menu.cs
Normal file
53
Assets/Scripts/Menu.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Menu : MonoBehaviour{
|
||||
|
||||
public TextMeshProUGUI insertCoin;
|
||||
float playAnimation;
|
||||
bool readyToStart;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
InvokeRepeating("InsertCoin", 0, 1);
|
||||
AudioManager.instance.Play("MenuSong");
|
||||
Invoke("Ready", 1);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (Input.anyKeyDown && readyToStart){
|
||||
CancelInvoke("InsertCoin");
|
||||
InvokeRepeating("Play", 0, .05f);
|
||||
}
|
||||
}
|
||||
|
||||
void Ready(){
|
||||
readyToStart = true;
|
||||
}
|
||||
|
||||
void Play(){
|
||||
if(playAnimation < 10f){
|
||||
if (insertCoin.color.a == 0){
|
||||
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 1);
|
||||
}else{
|
||||
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 0);
|
||||
}
|
||||
playAnimation++;
|
||||
}else{
|
||||
SceneManager.LoadScene(1);
|
||||
}
|
||||
}
|
||||
|
||||
void InsertCoin(){
|
||||
if(insertCoin.color.a == 0){
|
||||
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 1);
|
||||
}else{
|
||||
insertCoin.color = new Color(insertCoin.color.r, insertCoin.color.g, insertCoin.color.b, 0);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Menu.cs.meta
Normal file
11
Assets/Scripts/Menu.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f96de3f503bc0a740bf58ccbccf2b20d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
Assets/Scripts/Missile.cs
Normal file
53
Assets/Scripts/Missile.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Missile : MonoBehaviour
|
||||
{
|
||||
Transform player;
|
||||
public float RotateSpeed, speed;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
player = GameObject.FindGameObjectWithTag("Player").transform;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float AngleRad = Mathf.Atan2(player.position.y - transform.position.y, player.position.x - transform.position.x);
|
||||
float AngleDeg = (180 / Mathf.PI) * AngleRad;
|
||||
/*if (AngleDeg > transform.rotation.z)
|
||||
AngleDeg -= 360;
|
||||
float DistanceNegative = transform.rotation.z - AngleDeg;
|
||||
if (AngleDeg > transform.rotation.z)
|
||||
AngleDeg += 360;
|
||||
if (AngleDeg < transform.rotation.z)
|
||||
AngleDeg += 360;
|
||||
float DistancePositive = AngleDeg - transform.rotation.z;
|
||||
float distance = 0;
|
||||
if (Mathf.Abs(DistancePositive) > Mathf.Abs(DistanceNegative))
|
||||
distance = DistanceNegative;
|
||||
else distance = DistancePositive;
|
||||
float rotatespeedclone;
|
||||
if (distance < RotateSpeed)
|
||||
rotatespeedclone = distance;
|
||||
else
|
||||
rotatespeedclone = RotateSpeed;
|
||||
transform.Rotate(Vector3.forward * (DistancePositive > DistanceNegative ? -1 : 1) * rotatespeedclone * Time.deltaTime);
|
||||
*/
|
||||
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0, 0, AngleDeg), RotateSpeed * Time.deltaTime);
|
||||
transform.Translate(Vector3.right * speed * Time.deltaTime, Space.Self);
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.transform.tag == "Player")
|
||||
{
|
||||
collision.transform.GetComponent<PlayerStats>().Die();
|
||||
}else if (collision.transform.tag == "Boss")
|
||||
{
|
||||
collision.transform.GetComponent<Boss>().Health -= 1;
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Missile.cs.meta
Normal file
11
Assets/Scripts/Missile.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 441d8ed450ecc7d42b7d76d9d475bc0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
42
Assets/Scripts/MovingPlatform.cs
Normal file
42
Assets/Scripts/MovingPlatform.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovingPlatform : MonoBehaviour {
|
||||
|
||||
public Transform target;
|
||||
public float speed;
|
||||
public bool i;
|
||||
private Vector3 start, end;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
if(target != null) {
|
||||
target.parent = null;
|
||||
start = transform.position;
|
||||
end = target.position;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
void FixedUpdate(){
|
||||
if (target != null && !i) {
|
||||
float fixedSpeed = speed * Time.deltaTime;
|
||||
transform.position = Vector3.MoveTowards(transform.position, target.position, fixedSpeed);
|
||||
}
|
||||
|
||||
if (transform.position == target.position){
|
||||
target.position = (target.position == start) ? end : start;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision){
|
||||
if(collision.gameObject.tag == "Player"){
|
||||
i = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/MovingPlatform.cs.meta
Normal file
11
Assets/Scripts/MovingPlatform.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f6e0c67787359de4482dde3917d4326e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Assets/Scripts/PlataformaFalling.cs
Normal file
54
Assets/Scripts/PlataformaFalling.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlataformaFalling : MonoBehaviour {
|
||||
|
||||
public float fallDelay = 1f;
|
||||
public float respawnDelay = 5f;
|
||||
|
||||
public GameObject particles;
|
||||
private Rigidbody2D rb2d;
|
||||
private BoxCollider2D pc2d;
|
||||
private Vector3 start;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
pc2d = GetComponent<BoxCollider2D>();
|
||||
start = transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
if (col.gameObject.CompareTag("Player")){
|
||||
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
||||
Invoke("Fall", fallDelay);
|
||||
Invoke("Respawn", fallDelay + respawnDelay);
|
||||
AudioManager.instance.Play("FallingPlatform");
|
||||
}
|
||||
}
|
||||
|
||||
public void ButtonFall(){
|
||||
AudioManager.instance.Play("FallingPlatform");
|
||||
Invoke("Fall", fallDelay);
|
||||
Invoke("Respawn", fallDelay + respawnDelay);
|
||||
Instantiate(particles, new Vector2(transform.position.x, transform.position.y + .5f), Quaternion.identity);
|
||||
}
|
||||
|
||||
void Fall(){
|
||||
rb2d.isKinematic = false;
|
||||
pc2d.isTrigger = true;
|
||||
}
|
||||
|
||||
void Respawn(){
|
||||
transform.position = start;
|
||||
rb2d.isKinematic = true;
|
||||
rb2d.velocity = Vector3.zero;
|
||||
pc2d.isTrigger = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlataformaFalling.cs.meta
Normal file
11
Assets/Scripts/PlataformaFalling.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e941b757c35d71e469b7e7557bfd8b16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/Scripts/PlayerHealth.cs
Normal file
11
Assets/Scripts/PlayerHealth.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerHealth : hasHP {
|
||||
public override void die() {
|
||||
Debug.Log("player die");
|
||||
this.curHP = 1;
|
||||
GetComponent<PlayerStats>().Die();
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerHealth.cs.meta
Normal file
11
Assets/Scripts/PlayerHealth.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2baaf5661ad78e14ea86be1296feea2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/PlayerKill.cs
Normal file
29
Assets/Scripts/PlayerKill.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerKill : MonoBehaviour{
|
||||
|
||||
public GameObject player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
public void Die(){
|
||||
StartCoroutine(Respawn());
|
||||
FindObjectOfType<PlayerWeaponController>().currentBullets += 3f;
|
||||
player.SetActive(false);
|
||||
}
|
||||
|
||||
IEnumerator Respawn(){
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
player.SetActive(true);
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerKill.cs.meta
Normal file
11
Assets/Scripts/PlayerKill.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2cd615b5d422eba47a4632d95f1601cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
63
Assets/Scripts/PlayerMovement.cs
Normal file
63
Assets/Scripts/PlayerMovement.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float speed, jumpForce;
|
||||
Rigidbody2D rb;
|
||||
public Transform feet;
|
||||
public float range;
|
||||
public LayerMask whatIsGround;
|
||||
public float coyoteTime;
|
||||
Vector2 length;
|
||||
private float lastTimeTouchingGround;
|
||||
private float lastJumpTime;
|
||||
public ParticleSystem jumpParticles;
|
||||
[HideInInspector]
|
||||
public bool canMove = true;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
length = transform.GetChild(0).GetComponent<SpriteRenderer>().bounds.size / 2;
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(Physics2D.OverlapCircle(feet.position, range, whatIsGround)) {
|
||||
lastTimeTouchingGround = Time.time;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Space) && Time.time-coyoteTime <= lastTimeTouchingGround & Time.time>=lastJumpTime+coyoteTime)
|
||||
{
|
||||
AudioManager.instance.Play("Jump");
|
||||
lastJumpTime = Time.time;
|
||||
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
|
||||
}
|
||||
if (Input.GetButton("Horizontal") && canMove)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0, Input.GetAxisRaw("Horizontal") == 1 ? 0 : 180, 0);
|
||||
}
|
||||
if (!Physics2D.Raycast(transform.position, Input.GetAxisRaw("Horizontal") * Vector2.right, length.x + 0.01f, whatIsGround)) {
|
||||
rb.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * speed, rb.velocity.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
if(col.gameObject.tag == "MovingPlatform"){
|
||||
transform.parent = col.transform;
|
||||
}
|
||||
if(col.gameObject.tag == "InsideTileKill"){
|
||||
GetComponent<PlayerStats>().Die();
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionExit2D(Collision2D col){
|
||||
if (col.gameObject.tag == "MovingPlatform"){
|
||||
transform.parent = null;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf0cdc8130e287f4caf281ad7a7ba508
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Assets/Scripts/PlayerStats.cs
Normal file
50
Assets/Scripts/PlayerStats.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerStats : MonoBehaviour
|
||||
{
|
||||
public GameObject dieParticles;
|
||||
public Vector2 checkpoint;
|
||||
|
||||
bool firstTime = true;
|
||||
|
||||
void OnEnable(){
|
||||
if (!firstTime){
|
||||
Respawn();
|
||||
Invoke("EnableCameraCollider", 2f);
|
||||
}else{
|
||||
firstTime = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void Die()
|
||||
{
|
||||
AudioManager.instance.Play("Hit");
|
||||
Instantiate(dieParticles, transform.position, Quaternion.identity);
|
||||
Camera.main.GetComponent<BoxCollider2D>().isTrigger = true;
|
||||
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
GetComponent<PlayerMovement>().canMove = false;
|
||||
FindObjectOfType<PlayerKill>().Die();
|
||||
}
|
||||
|
||||
void Respawn(){
|
||||
transform.position = checkpoint;
|
||||
GetComponent<PlayerMovement>().canMove = true;
|
||||
}
|
||||
|
||||
void EnableCameraCollider(){
|
||||
Camera.main.GetComponent<BoxCollider2D>().isTrigger = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerStats.cs.meta
Normal file
11
Assets/Scripts/PlayerStats.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae92e45b9b9de9348befb3d019c3611c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Assets/Scripts/PlayerWeaponController.cs
Normal file
44
Assets/Scripts/PlayerWeaponController.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerWeaponController : MonoBehaviour
|
||||
{
|
||||
private GameObject weapon;
|
||||
public RawImage bulletBar;
|
||||
public float bullets = 11f;
|
||||
[HideInInspector]
|
||||
public float currentBullets;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
currentBullets = bullets;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
currentBullets = Mathf.Clamp(currentBullets, 0, bullets);
|
||||
if (Inventory.Items.Count > 0) {
|
||||
if (weapon==null || weapon.name != Inventory.getActiveItem().name) {
|
||||
if (weapon != null) {
|
||||
Object.Destroy(weapon);
|
||||
}
|
||||
weapon = Instantiate(Inventory.getActiveItem());
|
||||
weapon.name = Inventory.getActiveItem().name;
|
||||
weapon.transform.SetParent(gameObject.transform);
|
||||
weapon.transform.position = gameObject.transform.position;
|
||||
weapon.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f);
|
||||
Destroy(weapon.GetComponent<BoxCollider2D>());
|
||||
Destroy(weapon.GetComponent<Rigidbody2D>());
|
||||
}
|
||||
}
|
||||
bulletBar.transform.localScale = new Vector2(currentBullets, bulletBar.transform.localScale.y);
|
||||
if (Input.GetKeyDown(KeyCode.Mouse0) && currentBullets > 0) {
|
||||
weapon.GetComponent<Weapon>().shoot();
|
||||
currentBullets--;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerWeaponController.cs.meta
Normal file
11
Assets/Scripts/PlayerWeaponController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 53d7c2df27748ab41927a876171c3c88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
51
Assets/Scripts/ShootyEnemyWeaponController.cs
Normal file
51
Assets/Scripts/ShootyEnemyWeaponController.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShootyEnemyWeaponController : GoombaAI {
|
||||
|
||||
public GameObject weaponPrefab;
|
||||
public float Range;
|
||||
|
||||
private GameObject weapon;
|
||||
private GameObject player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
weapon = Instantiate(weaponPrefab);
|
||||
weapon.name = "Weapon";
|
||||
weapon.transform.SetParent(gameObject.transform, true);
|
||||
weapon.transform.position = gameObject.transform.position;
|
||||
//weapon.transform.localScale = new Vector3(1, 1, 1);
|
||||
Destroy(weapon.GetComponent<BoxCollider2D>());
|
||||
Destroy(weapon.GetComponent<Rigidbody2D>());
|
||||
|
||||
player = findPlayer();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
protected void Update()
|
||||
{
|
||||
float horizontalDirection = (player.transform.position - gameObject.transform.position).x;
|
||||
float verticalDirection = (player.transform.position - gameObject.transform.position).y;
|
||||
//weapon.GetComponent<Weapon>().aim(horizontalDirection);
|
||||
|
||||
weapon.GetComponent<SpriteRenderer>().flipX = false;
|
||||
gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, horizontalDirection > 0 ? 0 : 180, 0));
|
||||
if(Mathf.Abs(horizontalDirection) < Range && Mathf.Abs(verticalDirection) < 2f) {
|
||||
weapon.GetComponent<Weapon>().shoot();
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject findPlayer() {
|
||||
GameObject player = null;
|
||||
foreach(GameObject go in FindObjectsOfTypeAll(typeof(GameObject))){
|
||||
if (go.name.Equals("Player")) {
|
||||
Debug.Log("Found player");
|
||||
player = go;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
}
|
11
Assets/Scripts/ShootyEnemyWeaponController.cs.meta
Normal file
11
Assets/Scripts/ShootyEnemyWeaponController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ecbdc132b3c78dc41ab12d1c3ba8f446
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Scripts/Sound.cs
Normal file
22
Assets/Scripts/Sound.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using UnityEngine.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Sound{
|
||||
|
||||
public string name;
|
||||
|
||||
public AudioClip clip;
|
||||
|
||||
[Range(0f, 1f)]
|
||||
public float volume = 1f;
|
||||
[Range(0.1f, 3f)]
|
||||
public float pitch = 1f;
|
||||
|
||||
public bool loop;
|
||||
|
||||
public AudioMixerGroup mixerGroup;
|
||||
|
||||
[HideInInspector]
|
||||
public AudioSource source;
|
||||
}
|
11
Assets/Scripts/Sound.cs.meta
Normal file
11
Assets/Scripts/Sound.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ffdca7193ba5734f9604ee53a00d4f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/Scripts/Spikes.cs
Normal file
23
Assets/Scripts/Spikes.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Spikes : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.transform.tag == "Player")
|
||||
collision.transform.GetComponent<PlayerStats>().Die();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spikes.cs.meta
Normal file
11
Assets/Scripts/Spikes.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a12eb76eaec754d44aed4c359eb8fff6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Scripts/TriggerBoss.cs
Normal file
14
Assets/Scripts/TriggerBoss.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerBoss : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.transform.tag == "Player")
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Boss").GetComponent<Boss>().enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/TriggerBoss.cs.meta
Normal file
11
Assets/Scripts/TriggerBoss.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c56c4a698fe709f439a26c35b85459ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/Weapon.cs
Normal file
27
Assets/Scripts/Weapon.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Weapon : MonoBehaviour
|
||||
{
|
||||
public float bulletVelocity;
|
||||
public float fireRate;
|
||||
public float Damage;
|
||||
public GameObject bulletPrefab;
|
||||
|
||||
private float lastTimeShot;
|
||||
|
||||
public void shoot() {
|
||||
if (Time.time > lastTimeShot + fireRate) {
|
||||
GetComponentInChildren<Animator>().SetTrigger("Shoot");
|
||||
lastTimeShot = Time.time;
|
||||
GameObject bullet = Instantiate(bulletPrefab);
|
||||
bullet.transform.rotation = gameObject.transform.rotation;
|
||||
bullet.transform.position = gameObject.transform.position;
|
||||
Vector2 bulletDirection = bullet.transform.right;
|
||||
bullet.transform.position += new Vector3(bulletDirection.x, bulletDirection.y, 0) * 1;
|
||||
bullet.GetComponent<Rigidbody2D>().velocity = bulletDirection * bulletVelocity;
|
||||
bullet.GetComponent<BulletScript>().damage = Damage;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Weapon.cs.meta
Normal file
11
Assets/Scripts/Weapon.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a63b6da6c2169342ad0d84419900e37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Scripts/WeaponDisplay.cs
Normal file
30
Assets/Scripts/WeaponDisplay.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WeaponDisplay : MonoBehaviour
|
||||
{
|
||||
public GameObject addWeap;
|
||||
public Image weaponDisplay;
|
||||
|
||||
//public GameObject addWeap2;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Inventory.addItem(addWeap);
|
||||
//Inventory.addItem(addWeap2);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
if (Inventory.Items.Count > 0) {
|
||||
weaponDisplay.sprite = Inventory.getActiveItem().GetComponentInChildren<SpriteRenderer>().sprite;
|
||||
}
|
||||
}
|
||||
|
||||
public void nextWeapon() {
|
||||
Debug.Log("nextwep");
|
||||
Inventory.cycleItem();
|
||||
}
|
||||
}
|
11
Assets/Scripts/WeaponDisplay.cs.meta
Normal file
11
Assets/Scripts/WeaponDisplay.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 109f3cb6af17eb945af5d4c9b5189cc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/Scripts/hasHP.cs
Normal file
21
Assets/Scripts/hasHP.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class hasHP: MonoBehaviour
|
||||
{
|
||||
public float MaxHP;
|
||||
public float curHP;
|
||||
|
||||
private void Start() {
|
||||
curHP = MaxHP;
|
||||
}
|
||||
public void damage(float d) {
|
||||
curHP -= d;
|
||||
if (curHP <= 0) {
|
||||
Debug.Log(curHP);
|
||||
this.die();
|
||||
}
|
||||
}
|
||||
public abstract void die();
|
||||
}
|
11
Assets/Scripts/hasHP.cs.meta
Normal file
11
Assets/Scripts/hasHP.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0e4f76dac4aa6e458da05dc24c4ac81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue