Skip to content
Snippets Groups Projects
Commit fb19e5b8 authored by averrous's avatar averrous
Browse files

Merge branch 'master' into averrous/feat/cutscene

parents 1add5ac2 2ffc84ea
Branches
Tags
1 merge request!20Averrous/feat/cutscene
Showing
with 84 additions and 26 deletions
using UnityEngine; using UnityEngine;
public class ElementalHealth : MonoBehaviour public class ElementalHealth : MonoBehaviour, IEnemyHealthHandler
{ {
public int startingHealth = 500; public int startingHealth = 500;
public int currentHealth; public int currentHealth;
......
using UnityEngine; using UnityEngine;
public class EnemyHealth : MonoBehaviour public class EnemyHealth : MonoBehaviour, IEnemyHealthHandler
{ {
public int startingHealth = 100; public int startingHealth = 100;
public int currentHealth; public int currentHealth;
...@@ -9,6 +9,8 @@ public class EnemyHealth : MonoBehaviour ...@@ -9,6 +9,8 @@ public class EnemyHealth : MonoBehaviour
public AudioClip deathClip; public AudioClip deathClip;
public EnemyType enemyType; public EnemyType enemyType;
GameObject pet;
PetHealth petHealth;
PetType petType; PetType petType;
Animator anim; Animator anim;
AudioSource enemyAudio; AudioSource enemyAudio;
...@@ -28,6 +30,12 @@ public class EnemyHealth : MonoBehaviour ...@@ -28,6 +30,12 @@ public class EnemyHealth : MonoBehaviour
currentHealth = startingHealth; currentHealth = startingHealth;
questTemple = FindObjectOfType<Temple>(); questTemple = FindObjectOfType<Temple>();
pet = GameObject.FindGameObjectWithTag("Pet");
if (pet != null)
{
petHealth = pet.GetComponent<PetHealth>();
petType = petHealth.GetPetType();
}
} }
......
...@@ -30,6 +30,7 @@ public class GameOverCanvas : MonoBehaviour ...@@ -30,6 +30,7 @@ public class GameOverCanvas : MonoBehaviour
public void OnClickLatestSave() public void OnClickLatestSave()
{ {
GlobalManager.Instance.IsFirstLoad = true;
SceneManager.LoadScene("Quest"); SceneManager.LoadScene("Quest");
IsSet = true; IsSet = true;
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
public interface IEnemyHealthHandler
{
public void TakeDamage(int amount, Vector3 hitPoint);
public Transform transform { get; }
}
fileFormatVersion: 2
guid: e83f67c5f57e60d42bd9a210c6144486
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -21,7 +21,7 @@ public class EnemyManager : MonoBehaviour ...@@ -21,7 +21,7 @@ public class EnemyManager : MonoBehaviour
void Start() void Start()
{ {
isBoss = GlobalStateManager.Instance.IdxQuest == 3;
} }
......
...@@ -12,7 +12,7 @@ public class GlobalManager : MonoBehaviour ...@@ -12,7 +12,7 @@ public class GlobalManager : MonoBehaviour
private string defaultName = "PLAYER"; private string defaultName = "PLAYER";
private string playerName; private string playerName;
private double totalTime; private double totalTime;
private int volume = 60; private float volume = 60;
public bool isFromEnding = false; public bool isFromEnding = false;
public string PlayerName public string PlayerName
...@@ -35,7 +35,7 @@ public class GlobalManager : MonoBehaviour ...@@ -35,7 +35,7 @@ public class GlobalManager : MonoBehaviour
totalTime = value; totalTime = value;
} }
} }
public int Volume public float Volume
{ {
get => volume; get => volume;
set set
......
...@@ -21,7 +21,10 @@ public class SettingManager : MonoBehaviour ...@@ -21,7 +21,10 @@ public class SettingManager : MonoBehaviour
void Update() void Update()
{ {
GlobalManager.Instance.PlayerName = nameInput.text; GlobalManager.Instance.PlayerName = nameInput.text;
GlobalManager.Instance.Volume = (int) (volumeInput.GetComponent<Slider>()).value; var volume = (volumeInput.GetComponent<Slider>()).value * 0.1f;
GlobalManager.Instance.Volume = volume;
AudioListener.volume = volume;
Debug.Log("PLAYER NAME: " + GlobalManager.Instance.PlayerName); Debug.Log("PLAYER NAME: " + GlobalManager.Instance.PlayerName);
Debug.Log("VOLUME: " + GlobalManager.Instance.Volume); Debug.Log("VOLUME: " + GlobalManager.Instance.Volume);
if (Input.GetKeyDown(KeyCode.Escape)) if (Input.GetKeyDown(KeyCode.Escape))
......
...@@ -47,7 +47,10 @@ public class AnglerAttack : MonoBehaviour ...@@ -47,7 +47,10 @@ public class AnglerAttack : MonoBehaviour
shootRay.direction = transform.forward; shootRay.direction = transform.forward;
if (timer >= timeBetweenBullets && !GameControl.control.cantShoot && Physics.Raycast(shootRay, out shootHit, range, shootableMask)) if (timer >= timeBetweenBullets && !GameControl.control.cantShoot && Physics.Raycast(shootRay, out shootHit, range, shootableMask))
{ {
Shoot(); if (!shootHit.collider.CompareTag("Player"))
{
Shoot();
}
} }
if (timer >= timeBetweenBullets * effectsDisplayTime) if (timer >= timeBetweenBullets * effectsDisplayTime)
......
...@@ -51,6 +51,13 @@ public class PetMovement : MonoBehaviour ...@@ -51,6 +51,13 @@ public class PetMovement : MonoBehaviour
if (enemyHealth.currentHealth > 0) if (enemyHealth.currentHealth > 0)
{ {
nav.SetDestination (enemyPosition.position); nav.SetDestination (enemyPosition.position);
var damping = 2;
var target = enemy.transform;
var lookPos = target.position - transform.position;
lookPos.y = 0;
var rotation = Quaternion.LookRotation(lookPos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
} }
} }
else else
......
...@@ -70,6 +70,8 @@ public class PlayerHealth : MonoBehaviour ...@@ -70,6 +70,8 @@ public class PlayerHealth : MonoBehaviour
damaged = false; damaged = false;
frozen = false; frozen = false;
healthSlider.value = currentHealth;
} }
public void TakeDamage(int amount) public void TakeDamage(int amount)
......
...@@ -7,7 +7,7 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler ...@@ -7,7 +7,7 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler
[SerializeField] [SerializeField]
private float damagePerShot = 30f; private float damagePerShot = 30f;
[SerializeField] [SerializeField]
private float timeBetweenBullets = 0.15f; private float timeBetweenBullets = 1f;
[SerializeField] [SerializeField]
private float range = 100f; private float range = 100f;
public GameObject prefabEffect; public GameObject prefabEffect;
...@@ -22,7 +22,7 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler ...@@ -22,7 +22,7 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler
Light gunLight; Light gunLight;
readonly float effectsDisplayTime = 0.2f; readonly float effectsDisplayTime = 0.2f;
private readonly float maxDist = 8f; private readonly float maxDist = 10f;
int numBullet = 3; int numBullet = 3;
List<GameObject> effects = new List<GameObject>(); List<GameObject> effects = new List<GameObject>();
...@@ -36,6 +36,13 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler ...@@ -36,6 +36,13 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler
} }
set set
{ {
var diff = value - level;
for (int i = 0; i < diff; i++)
{
AddBullet();
numBullet++;
}
level = value; level = value;
} }
} }
...@@ -116,14 +123,16 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler ...@@ -116,14 +123,16 @@ public class PlayerShotGunning : MonoBehaviour, WeaponHandler
if (Physics.Raycast(shootRay, out shootHit, range, shootableMask)) if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
{ {
EnemyHealth enemyHealth = shootHit.collider.GetComponent<EnemyHealth>(); IEnemyHealthHandler enemyHealth = shootHit.collider.GetComponent<ElementalHealth>();
enemyHealth ??= shootHit.collider.GetComponent< EnemyHealth>();
if (enemyHealth != null) if (enemyHealth != null)
{ {
var dist = Vector3.Distance(shootHit.transform.position, transform.position); var dist = Vector3.Distance(shootHit.transform.position, transform.position);
if (dist <= maxDist) if (dist <= maxDist)
{ {
Debug.Log("Enemy is On Distance"); Debug.Log("Enemy is On Distance");
int finalDamage = (int)(damagePerShot / Math.Sqrt(range)); int finalDamage = (int)(damagePerShot / Math.Sqrt(dist));
enemyHealth.TakeDamage(finalDamage, shootHit.point); enemyHealth.TakeDamage(finalDamage, shootHit.point);
} }
else else
......
...@@ -35,18 +35,17 @@ public class PlayerArrow : MonoBehaviour ...@@ -35,18 +35,17 @@ public class PlayerArrow : MonoBehaviour
if (didHit) return; if (didHit) return;
didHit = true; didHit = true;
if (other.gameObject.TryGetComponent<EnemyHealth>(out var enemyHealth))
IEnemyHealthHandler enemyHealth = other.gameObject.GetComponent<ElementalHealth>();
enemyHealth ??= other.gameObject.GetComponent<EnemyHealth>();
if (enemyHealth != null)
{ {
var energy = 0.5 * rb.mass * rb.velocity.magnitude * rb.velocity.magnitude; var energy = 0.5 * rb.mass * rb.velocity.magnitude * rb.velocity.magnitude;
var damage = energy * damageMultiplier; var damage = energy * damageMultiplier;
Debug.Log("damage: "+ damage); Debug.Log("damage: "+ damage);
enemyHealth.TakeDamage((int)damage, enemyHealth.transform.position); enemyHealth.TakeDamage((int)damage, enemyHealth.transform.position);
} }
/* rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.isKinematic = true;
transform.parent = other.transform;*/
Destroy(gameObject); Destroy(gameObject);
} }
} }
...@@ -28,7 +28,10 @@ public class PlayerSword : MonoBehaviour, WeaponHandler ...@@ -28,7 +28,10 @@ public class PlayerSword : MonoBehaviour, WeaponHandler
void OnTriggerEnter(Collider other) void OnTriggerEnter(Collider other)
{ {
if (other.gameObject.TryGetComponent<EnemyHealth>(out var enemyHealth)) IEnemyHealthHandler enemyHealth = other.gameObject.GetComponent<ElementalHealth>();
enemyHealth ??= other.gameObject.GetComponent<EnemyHealth>();
if (enemyHealth != null)
{ {
if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("SwordSwing")) if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("SwordSwing"))
{ {
......
...@@ -111,7 +111,10 @@ public class Temple : MonoBehaviour ...@@ -111,7 +111,10 @@ public class Temple : MonoBehaviour
GlobalManager.Instance.TotalTime += questTime; GlobalManager.Instance.TotalTime += questTime;
ToastManager.Instance.ShowToastQueue(System.TimeSpan.FromSeconds(GlobalManager.Instance.TotalTime).ToString("mm':'ss"), 1); ToastManager.Instance.ShowToastQueue(System.TimeSpan.FromSeconds(GlobalManager.Instance.TotalTime).ToString("mm':'ss"), 1);
StartCoroutine(saveDialogHandler()); if (idxCurrentQuest != 4)
{
StartCoroutine(saveDialogHandler());
}
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
...@@ -163,7 +166,7 @@ public class Temple : MonoBehaviour ...@@ -163,7 +166,7 @@ public class Temple : MonoBehaviour
if (questNumberEnemy.IsEmpty()) if (questNumberEnemy.IsEmpty())
{ {
ExitingQuest(); ExitingQuest();
if (idxCurrentQuest == 1) if (idxCurrentQuest == 4)
{ {
ToastManager.Instance.ShowToast("YOU WIN", 1); ToastManager.Instance.ShowToast("YOU WIN", 1);
StartCoroutine(winHandler()); StartCoroutine(winHandler());
......
...@@ -76,6 +76,7 @@ public class SaveLoadManager : MonoBehaviour ...@@ -76,6 +76,7 @@ public class SaveLoadManager : MonoBehaviour
public void LoadState(int Id) public void LoadState(int Id)
{ {
var state = GetSavedStateFromFile(Id); var state = GetSavedStateFromFile(Id);
state.playerStateSave.playerName = GlobalManager.Instance.PlayerName;
if (state != null) if (state != null)
{ {
Debug.Log("Load State " + Id); Debug.Log("Load State " + Id);
......
...@@ -24,11 +24,6 @@ public class SavePlace : MonoBehaviour ...@@ -24,11 +24,6 @@ public class SavePlace : MonoBehaviour
} }
SaveLoadManager.Instance.ShowUI(); SaveLoadManager.Instance.ShowUI();
} }
if (onArea && Input.GetKeyDown(KeyCode.N))
{
SaveLoadManager.Instance.LoadState(2);
}
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
......
...@@ -131,7 +131,7 @@ All the specifications were implemented. ...@@ -131,7 +131,7 @@ All the specifications were implemented.
| 2. | Angelica Winasta Sinisuka | Shopkeeper, Cheat, Enemy | 000 | 2. | Angelica Winasta Sinisuka | Shopkeeper, Cheat, Enemy | 000
| 3. | Averrous Saloom | Main Menu, Game Over, HUD, Story Mode | 000 | 3. | Averrous Saloom | Main Menu, Game Over, HUD, Story Mode | 000
| 4. | Malik Akbar Hashemi Rafsanjani | Weapon, Story Mode | 000 | 4. | Malik Akbar Hashemi Rafsanjani | Weapon, Story Mode | 000
| 5. | Nelsen Putra | Initialitazion, Local Scoreboard, ReadMe | 000 | 5. | Nelsen Putra | Initialization, Local Scoreboard, README | 000
## Contact ## Contact
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment