cool title screen
This commit is contained in:
parent
b0625ae834
commit
949135cecb
33 changed files with 4977 additions and 7 deletions
|
|
@ -1,17 +1,74 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
public class ReisenShoot : Ability
|
||||
{
|
||||
[SerializeField] private Projectile projectile;
|
||||
[SerializeField] private Projectile chargedProjectile;
|
||||
[SerializeField] private Camera cam;
|
||||
[Header("Charge")]
|
||||
[SerializeField] private float mouseHoldTime;
|
||||
private float currentMouseHoldTime;
|
||||
private float currentChargeTime;
|
||||
private bool isCharging;
|
||||
[SerializeField] private float maxChargeTime;
|
||||
[SerializeField] private float chargeCooldown;
|
||||
private float currentChargeCooldown;
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
ShootBullet(projectile, power);
|
||||
}
|
||||
else
|
||||
{
|
||||
isCharging = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShootBullet(Projectile projectileToShoot, int damage)
|
||||
{
|
||||
direction = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
Projectile newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
||||
Projectile newProjectile = Instantiate(projectileToShoot, origin.position, Quaternion.identity);
|
||||
newProjectile.transform.Lookat2D(direction);
|
||||
newProjectile.damage = power;
|
||||
newProjectile.damage = damage;
|
||||
newProjectile.tag = tag;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (currentMouseHoldTime >= 0)
|
||||
{
|
||||
currentMouseHoldTime -= Time.deltaTime;
|
||||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(1) && currentChargeTime <= 0)
|
||||
{
|
||||
isCharging = true;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
ShootBullet(projectile, power);
|
||||
}
|
||||
}
|
||||
if (isCharging && Input.GetMouseButton(0)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
}
|
||||
else if (isCharging && Input.GetMouseButtonUp(0))
|
||||
{
|
||||
Debug.Log("here");
|
||||
currentChargeTime = 0;
|
||||
ShootBullet(chargedProjectile, power * (int)Math.Clamp(currentChargeTime, 0, maxChargeTime));
|
||||
currentChargeCooldown = chargeCooldown;
|
||||
isCharging = false;
|
||||
}
|
||||
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
currentChargeCooldown -= Time.deltaTime;
|
||||
}
|
||||
Debug.Log(currentChargeTime);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
|
|
@ -10,17 +11,47 @@ public class YoumuDeflect : Ability
|
|||
public float deflectionAngleMin = -48;
|
||||
public float deflectionAngleMax = 90;
|
||||
|
||||
[Header("SlashCharge")]
|
||||
[SerializeField] private float mouseHoldTime;
|
||||
private float currentMouseHoldTime;
|
||||
private float currentChargeTime;
|
||||
private bool isCharging;
|
||||
[SerializeField] private float maxChargeTime;
|
||||
[SerializeField] private float chargeCooldown;
|
||||
private float currentChargeCooldown;
|
||||
private float currentUnleashedChargeTime;
|
||||
[Header("Effects")]
|
||||
[SerializeField] private ParticleSystem deflectionParticles;
|
||||
[SerializeField] private GameObject swordSweepEffect;
|
||||
[SerializeField] private GameObject chargeSweepEffect;
|
||||
private float currentDissipationTime = 0f;
|
||||
[SerializeField] private float dissipationTime;
|
||||
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
RegularDeflection();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentMouseHoldTime = mouseHoldTime;
|
||||
currentChargeTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void RegularDeflection()
|
||||
{
|
||||
//Debug.Log("Regular Deflection");
|
||||
swordSweepEffect.gameObject.SetActive(true);
|
||||
currentDissipationTime = dissipationTime;
|
||||
DeflectProjectiles();
|
||||
}
|
||||
|
||||
private void DeflectProjectiles()
|
||||
{
|
||||
foreach (Projectile projectile in projectilesInRange.ToList())
|
||||
{
|
||||
if (!projectile)
|
||||
|
|
@ -64,5 +95,49 @@ public class YoumuDeflect : Ability
|
|||
swordSweepEffect.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMouseHoldTime >= 0)
|
||||
{
|
||||
currentMouseHoldTime -= Time.deltaTime;
|
||||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(1) && currentChargeTime <= 0)
|
||||
{
|
||||
isCharging = true;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
RegularDeflection();
|
||||
}
|
||||
}
|
||||
if (isCharging && Input.GetMouseButton(1)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
}
|
||||
else if (isCharging && Input.GetMouseButtonUp(1))
|
||||
{
|
||||
Debug.Log("here");
|
||||
chargeSweepEffect.SetActive(true);
|
||||
currentUnleashedChargeTime = Math.Clamp(currentChargeTime, 0, maxChargeTime) * 2;
|
||||
currentChargeCooldown = chargeCooldown;
|
||||
isCharging = false;
|
||||
}
|
||||
else if (currentUnleashedChargeTime > 0)
|
||||
{
|
||||
currentUnleashedChargeTime -= Time.deltaTime;
|
||||
if (currentUnleashedChargeTime < 0)
|
||||
{
|
||||
chargeSweepEffect.SetActive(false);
|
||||
}
|
||||
|
||||
if (projectilesInRange.Count > 0)
|
||||
{
|
||||
DeflectProjectiles();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentChargeCooldown > 0)
|
||||
{
|
||||
currentChargeCooldown -= Time.deltaTime;
|
||||
}
|
||||
Debug.Log(currentChargeTime);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
37
Assets/Scripts/MainMenuHandler.cs
Normal file
37
Assets/Scripts/MainMenuHandler.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MainMenuHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Animator uiAnimator;
|
||||
[SerializeField] private string openUIAction;
|
||||
[SerializeField] private string closeUIAction;
|
||||
[SerializeField] private Transform uiMovingObject;
|
||||
|
||||
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
SceneManager.LoadScene(1);
|
||||
}
|
||||
|
||||
public void StartEndless()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
public void OpenUI(GameObject uiToOpen)
|
||||
{
|
||||
uiAnimator.SetTrigger(openUIAction);
|
||||
uiToOpen.transform.SetParent(uiMovingObject);
|
||||
uiToOpen.transform.position = uiMovingObject.position;
|
||||
}
|
||||
public void CloseUI(GameObject uiToClose)
|
||||
{
|
||||
uiAnimator.SetTrigger(closeUIAction);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/MainMenuHandler.cs.meta
Normal file
2
Assets/Scripts/MainMenuHandler.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3659a3a7b338bdffa8938d0500d4a4bc
|
||||
86
Assets/Scripts/TypeWriterUI.cs
Normal file
86
Assets/Scripts/TypeWriterUI.cs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class TypeWriterUI : MonoBehaviour
|
||||
{
|
||||
Text _text;
|
||||
TMP_Text _tmpProText;
|
||||
string writer;
|
||||
|
||||
[SerializeField] float delayBeforeStart = 0f;
|
||||
[SerializeField] float timeBtwChars = 0.1f;
|
||||
[SerializeField] string leadingChar = "";
|
||||
[SerializeField] bool leadingCharBeforeDelay = false;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
_text = GetComponent<Text>()!;
|
||||
_tmpProText = GetComponent<TMP_Text>()!;
|
||||
|
||||
if(_text != null)
|
||||
{
|
||||
writer = _text.text;
|
||||
_text.text = "";
|
||||
|
||||
StartCoroutine("TypeWriterText");
|
||||
}
|
||||
|
||||
if (_tmpProText != null)
|
||||
{
|
||||
writer = _tmpProText.text;
|
||||
_tmpProText.text = "";
|
||||
|
||||
StartCoroutine("TypeWriterTMP");
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator TypeWriterText()
|
||||
{
|
||||
_text.text = leadingCharBeforeDelay ? leadingChar : "";
|
||||
|
||||
yield return new WaitForSeconds(delayBeforeStart);
|
||||
|
||||
foreach (char c in writer)
|
||||
{
|
||||
if (_text.text.Length > 0)
|
||||
{
|
||||
_text.text = _text.text.Substring(0, _text.text.Length - leadingChar.Length);
|
||||
}
|
||||
_text.text += c;
|
||||
_text.text += leadingChar;
|
||||
yield return new WaitForSeconds(timeBtwChars);
|
||||
}
|
||||
|
||||
if(leadingChar != "")
|
||||
{
|
||||
_text.text = _text.text.Substring(0, _text.text.Length - leadingChar.Length);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator TypeWriterTMP()
|
||||
{
|
||||
_tmpProText.text = leadingCharBeforeDelay ? leadingChar : "";
|
||||
|
||||
yield return new WaitForSeconds(delayBeforeStart);
|
||||
|
||||
foreach (char c in writer)
|
||||
{
|
||||
if (_tmpProText.text.Length > 0)
|
||||
{
|
||||
_tmpProText.text = _tmpProText.text.Substring(0, _tmpProText.text.Length - leadingChar.Length);
|
||||
}
|
||||
_tmpProText.text += c;
|
||||
_tmpProText.text += leadingChar;
|
||||
yield return new WaitForSeconds(timeBtwChars);
|
||||
}
|
||||
|
||||
if (leadingChar != "")
|
||||
{
|
||||
_tmpProText.text = _tmpProText.text.Substring(0, _tmpProText.text.Length - leadingChar.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/TypeWriterUI.cs.meta
Normal file
2
Assets/Scripts/TypeWriterUI.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a4eaaf76386a739a69249fa7c58a154b
|
||||
Loading…
Add table
Add a link
Reference in a new issue