From 38d621ff5c118ec98d4020ec02c5296ad2036233 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 29 Oct 2023 11:11:58 +0800 Subject: * move --- .../3d8e945f-421c-4d35-a532-fe79d7e82ae5.vsidx | Bin 122898 -> 0 bytes ROUNDS/.vs/ROUNDS/v17/.suo | Bin 172032 -> 169984 bytes ROUNDS/Aim.cs | 39 --- ROUNDS/Block.cs | 353 -------------------- ROUNDS/CharacterStatModifiers.cs | 281 ---------------- ROUNDS/DamageOverTime.cs | 38 --- ROUNDS/ForceMultiplier.cs | 6 - ROUNDS/HealthHandler.cs | 362 --------------------- ROUNDS/Player.cs | 153 --------- ROUNDS/PlayerAudioModifyers.cs | 50 --- ROUNDS/PlayerImmunity.cs | 43 --- ROUNDS/PlayerSounds.cs | 126 ------- ROUNDS/RotationHandler.cs | 21 -- ROUNDS/SilenceHandler.cs | 70 ---- ROUNDS/StunHandler.cs | 102 ------ ROUNDS/WeaponHandler.cs | 173 ---------- ROUNDS/_Player/Aim.cs | 39 +++ ROUNDS/_Player/Block.cs | 353 ++++++++++++++++++++ ROUNDS/_Player/CharacterStatModifiers.cs | 281 ++++++++++++++++ ROUNDS/_Player/DamageOverTime.cs | 38 +++ ROUNDS/_Player/ForceMultiplier.cs | 6 + ROUNDS/_Player/HealthHandler.cs | 362 +++++++++++++++++++++ ROUNDS/_Player/Player.cs | 153 +++++++++ ROUNDS/_Player/PlayerAudioModifyers.cs | 50 +++ ROUNDS/_Player/PlayerImmunity.cs | 43 +++ ROUNDS/_Player/PlayerSounds.cs | 126 +++++++ ROUNDS/_Player/RotationHandler.cs | 21 ++ ROUNDS/_Player/SilenceHandler.cs | 70 ++++ ROUNDS/_Player/StunHandler.cs | 102 ++++++ ROUNDS/_Player/WeaponHandler.cs | 173 ++++++++++ 30 files changed, 1817 insertions(+), 1817 deletions(-) delete mode 100644 ROUNDS/.vs/ROUNDS/FileContentIndex/3d8e945f-421c-4d35-a532-fe79d7e82ae5.vsidx delete mode 100644 ROUNDS/Aim.cs delete mode 100644 ROUNDS/Block.cs delete mode 100644 ROUNDS/CharacterStatModifiers.cs delete mode 100644 ROUNDS/DamageOverTime.cs delete mode 100644 ROUNDS/ForceMultiplier.cs delete mode 100644 ROUNDS/HealthHandler.cs delete mode 100644 ROUNDS/Player.cs delete mode 100644 ROUNDS/PlayerAudioModifyers.cs delete mode 100644 ROUNDS/PlayerImmunity.cs delete mode 100644 ROUNDS/PlayerSounds.cs delete mode 100644 ROUNDS/RotationHandler.cs delete mode 100644 ROUNDS/SilenceHandler.cs delete mode 100644 ROUNDS/StunHandler.cs delete mode 100644 ROUNDS/WeaponHandler.cs create mode 100644 ROUNDS/_Player/Aim.cs create mode 100644 ROUNDS/_Player/Block.cs create mode 100644 ROUNDS/_Player/CharacterStatModifiers.cs create mode 100644 ROUNDS/_Player/DamageOverTime.cs create mode 100644 ROUNDS/_Player/ForceMultiplier.cs create mode 100644 ROUNDS/_Player/HealthHandler.cs create mode 100644 ROUNDS/_Player/Player.cs create mode 100644 ROUNDS/_Player/PlayerAudioModifyers.cs create mode 100644 ROUNDS/_Player/PlayerImmunity.cs create mode 100644 ROUNDS/_Player/PlayerSounds.cs create mode 100644 ROUNDS/_Player/RotationHandler.cs create mode 100644 ROUNDS/_Player/SilenceHandler.cs create mode 100644 ROUNDS/_Player/StunHandler.cs create mode 100644 ROUNDS/_Player/WeaponHandler.cs diff --git a/ROUNDS/.vs/ROUNDS/FileContentIndex/3d8e945f-421c-4d35-a532-fe79d7e82ae5.vsidx b/ROUNDS/.vs/ROUNDS/FileContentIndex/3d8e945f-421c-4d35-a532-fe79d7e82ae5.vsidx deleted file mode 100644 index d41cef9..0000000 Binary files a/ROUNDS/.vs/ROUNDS/FileContentIndex/3d8e945f-421c-4d35-a532-fe79d7e82ae5.vsidx and /dev/null differ diff --git a/ROUNDS/.vs/ROUNDS/v17/.suo b/ROUNDS/.vs/ROUNDS/v17/.suo index 8011a78..f3e1fe7 100644 Binary files a/ROUNDS/.vs/ROUNDS/v17/.suo and b/ROUNDS/.vs/ROUNDS/v17/.suo differ diff --git a/ROUNDS/Aim.cs b/ROUNDS/Aim.cs deleted file mode 100644 index 45288a5..0000000 --- a/ROUNDS/Aim.cs +++ /dev/null @@ -1,39 +0,0 @@ -using UnityEngine; - -public class Aim : MonoBehaviour -{ - private GeneralInput input; - - private HoldingObject holdingObject; - - private CharacterData data; - - private Vector3 aimDirection; - - private void Awake() - { - input = GetComponent(); - data = GetComponent(); - holdingObject = GetComponentInChildren(); - } - - private void Update() - { - if ((double)input.aimDirection.magnitude > 0.2) - { - aimDirection = input.aimDirection; - } - if (input.direction.magnitude > 0.2f && Optionshandler.leftStickAim && input.aimDirection == Vector3.zero) - { - aimDirection = input.direction; - } - if ((bool)holdingObject) - { - if (aimDirection != Vector3.zero) - { - holdingObject.transform.rotation = Quaternion.LookRotation(aimDirection); - } - data.aimDirection = aimDirection; - } - } -} diff --git a/ROUNDS/Block.cs b/ROUNDS/Block.cs deleted file mode 100644 index b48d264..0000000 --- a/ROUNDS/Block.cs +++ /dev/null @@ -1,353 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Photon.Pun; -using Sonigon; -using UnityEngine; - -public class Block : MonoBehaviour -{ - [Header("Sounds")] - public SoundEvent soundBlockStart; - - public SoundEvent soundBlockRecharged; - - public SoundEvent soundBlockBlocked; - - public SoundEvent soundBlockStatusEffect; - - [Header("Settings")] - public List objectsToSpawn = new List(); - - public float sinceBlock; - - private GeneralInput input; - - public ParticleSystem particle; - - public ParticleSystem reloadParticle; - - public ParticleSystem blockedPart; - - public float cooldown; - - public float counter = 1000f; - - public float cdMultiplier = 1f; - - public float cdAdd; - - public float forceToAdd; - - public float forceToAddUp; - - public bool autoBlock; - - public bool blockedThisFrame; - - public int additionalBlocks; - - public float healing; - - private float timeBetweenBlocks = 0.2f; - - private CharacterData data; - - private HealthHandler health; - - private bool active = true; - - public Action BlockRechargeAction; - - private bool blockedLastFrame; - - public Action BlockAction; - - public Action BlockActionEarly; - - public Action FirstBlockActionThatDelaysOthers; - - public Action SuperFirstBlockAction; - - public Vector3 blockedAtPos; - - public bool delayOtherActions; - - public ParticleSystem statusBlockPart; - - private float lastStatusBlock; - - public Action BlockProjectileAction; - - public float Cooldown() - { - return (cooldown + cdAdd) * cdMultiplier; - } - - private void Start() - { - input = GetComponent(); - data = GetComponent(); - health = GetComponent(); - sinceBlock = 100f; - } - - private void Update() - { - if ((bool)input && data.playerVel.simulated) - { - if (!blockedLastFrame) - { - blockedThisFrame = false; - } - blockedLastFrame = false; - sinceBlock += TimeHandler.deltaTime; - counter += TimeHandler.deltaTime; - if (counter > Cooldown() && !active) - { - active = true; - reloadParticle.Play(); - BlockRechargeAction(); - SoundManager.Instance.Play(soundBlockRecharged, base.transform); - } - if (input.shieldWasPressed) - { - TryBlock(); - } - } - } - - public void DoBlockAtPosition(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 blockPos = default(Vector3), bool onlyBlockEffects = false) - { - blockedAtPos = blockPos; - RPCA_DoBlock(firstBlock, dontSetCD, triggerType, blockPos, onlyBlockEffects); - } - - internal void ResetStats() - { - objectsToSpawn = new List(); - sinceBlock = 10f; - cooldown = 4f; - counter = 1000f; - cdMultiplier = 1f; - cdAdd = 0f; - forceToAdd = 0f; - forceToAddUp = 0f; - autoBlock = false; - blockedThisFrame = false; - additionalBlocks = 0; - healing = 0f; - delayOtherActions = false; - } - - public void CallDoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) - { - data.view.RPC("RPCA_DoBlock", RpcTarget.All, firstBlock, dontSetCD, (int)triggerType, useBlockPos, onlyBlockEffects); - } - - [PunRPC] - public void RPCA_DoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) - { - if (triggerType == BlockTrigger.BlockTriggerType.Default && firstBlock) - { - for (int i = 0; i < additionalBlocks; i++) - { - StartCoroutine(DelayBlock(((float)i + 1f) * timeBetweenBlocks)); - } - } - StartCoroutine(IDoBlock(firstBlock, dontSetCD, triggerType, useBlockPos, onlyBlockEffects)); - } - - private IEnumerator IDoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) - { - active = false; - Vector3 position = base.transform.position; - if (useBlockPos != Vector3.zero) - { - base.transform.position = useBlockPos; - } - if (SuperFirstBlockAction != null) - { - SuperFirstBlockAction(triggerType); - } - if (FirstBlockActionThatDelaysOthers != null) - { - FirstBlockActionThatDelaysOthers(triggerType); - } - if (useBlockPos != Vector3.zero) - { - base.transform.position = position; - } - if (!onlyBlockEffects) - { - sinceBlock = 0f; - } - if (delayOtherActions) - { - yield return new WaitForSeconds(0.2f); - } - position = base.transform.position; - if (useBlockPos != Vector3.zero) - { - base.transform.position = useBlockPos; - } - if (BlockActionEarly != null) - { - BlockActionEarly(triggerType); - } - if (BlockAction != null) - { - BlockAction(triggerType); - } - if (firstBlock) - { - if (forceToAdd != 0f) - { - health.TakeForce(data.hand.transform.forward * forceToAdd * data.playerVel.mass * 0.01f); - } - if (forceToAddUp != 0f) - { - health.TakeForce(Vector3.up * forceToAddUp * data.playerVel.mass * 0.01f); - } - } - blockedLastFrame = true; - bool flag = false; - for (int i = 0; i < data.currentCards.Count; i++) - { - if (data.currentCards[i].soundDisableBlockBasic) - { - flag = true; - break; - } - } - if (!flag && triggerType != BlockTrigger.BlockTriggerType.ShieldCharge) - { - SoundManager.Instance.Play(soundBlockStart, base.transform); - } - if (!onlyBlockEffects) - { - particle.Play(); - } - if (!dontSetCD) - { - counter = 0f; - } - GamefeelManager.GameFeel(UnityEngine.Random.insideUnitCircle.normalized * 1f); - if (!onlyBlockEffects) - { - sinceBlock = 0f; - } - Spawn(); - health.Heal(healing); - if (useBlockPos != Vector3.zero) - { - base.transform.position = position; - } - } - - public void ShowStatusEffectBlock() - { - if (!(Time.unscaledTime < lastStatusBlock + 0.25f) && data.view.IsMine) - { - lastStatusBlock = Time.unscaledTime; - data.view.RPC("RPCA_ShowStatusEffectBlock", RpcTarget.All); - } - } - - [PunRPC] - public void RPCA_ShowStatusEffectBlock() - { - SoundManager.Instance.Play(soundBlockStatusEffect, base.transform); - statusBlockPart.Play(); - } - - public void TryBlock() - { - if (!(counter < Cooldown())) - { - RPCA_DoBlock(firstBlock: true); - counter = 0f; - } - } - - private IEnumerator DelayBlock(float t) - { - yield return new WaitForSeconds(t); - yield return new WaitForEndOfFrame(); - RPCA_DoBlock(firstBlock: false, dontSetCD: true, BlockTrigger.BlockTriggerType.Echo); - } - - public void Spawn() - { - for (int i = 0; i < objectsToSpawn.Count; i++) - { - SpawnedAttack component = UnityEngine.Object.Instantiate(objectsToSpawn[i], base.transform.position, Quaternion.identity).GetComponent(); - if ((bool)component) - { - component.spawner = GetComponent(); - } - } - } - - public void blocked(GameObject projectile, Vector3 forward, Vector3 hitPos) - { - SoundManager.Instance.Play(soundBlockBlocked, base.transform); - projectile.GetComponent().RemoveOwnPlayerFromPlayersHit(); - projectile.GetComponent().AddPlayerToHeld(GetComponent()); - projectile.GetComponent().velocity *= -1f; - projectile.GetComponent().WasBlocked(); - blockedPart.transform.position = hitPos + base.transform.forward * 5f; - blockedPart.transform.rotation = Quaternion.LookRotation(-forward * 1.5f); - GamefeelManager.GameFeel(forward); - blockedPart.Play(); - SpawnedAttack componentInParent = projectile.GetComponentInParent(); - if ((!componentInParent || !(componentInParent.spawner.gameObject == base.transform.root.gameObject)) && BlockProjectileAction != null) - { - BlockProjectileAction(projectile, forward, hitPos); - } - } - - public void ResetCD(bool soundPlay) - { - active = true; - reloadParticle.Play(); - counter = Cooldown() + 1f; - if (soundPlay) - { - SoundManager.Instance.Play(soundBlockRecharged, base.transform); - } - } - - public bool TryBlockMe(GameObject toBlock, Vector3 forward, Vector3 hitPos) - { - if (sinceBlock < 0.3f) - { - blocked(toBlock, forward, hitPos); - sinceBlock = 0f; - particle.Play(); - return true; - } - return false; - } - - public void DoBlock(GameObject toBlock, Vector3 forward, Vector3 hitPos) - { - sinceBlock = 0f; - blocked(toBlock, forward, hitPos); - particle.Play(); - } - - public bool IsBlocking() - { - if (sinceBlock < 0.3f) - { - ShowStatusEffectBlock(); - } - return sinceBlock < 0.3f; - } - - public bool IsOnCD() - { - return counter < Cooldown(); - } -} diff --git a/ROUNDS/CharacterStatModifiers.cs b/ROUNDS/CharacterStatModifiers.cs deleted file mode 100644 index 9122d66..0000000 --- a/ROUNDS/CharacterStatModifiers.cs +++ /dev/null @@ -1,281 +0,0 @@ -using System; -using System.Collections.Generic; -using Photon.Pun; -using Sonigon; -using UnityEngine; - -public class CharacterStatModifiers : MonoBehaviour -{ - [Header("Sounds")] - public SoundEvent soundCharacterSlowFreeze; - - private float soundSlowTime; - - private float soundSlowSpeedSec = 0.3f; - - [Header("Settings")] - public GameObject AddObjectToPlayer; - - [HideInInspector] - public List objectsAddedToPlayer; - - [Header("Multiply")] - public float sizeMultiplier = 1f; - - public float health = 1f; - - public float movementSpeed = 1f; - - public float jump = 1f; - - public float gravity = 1f; - - public float slow; - - public float slowSlow; - - public float fastSlow; - - [Header("Add")] - public float secondsToTakeDamageOver; - - public int numberOfJumps; - - public float regen; - - public float lifeSteal; - - public bool refreshOnDamage; - - public bool automaticReload = true; - - public int respawns; - - [HideInInspector] - public int remainingRespawns; - - [HideInInspector] - public float tasteOfBloodSpeed = 1f; - - [HideInInspector] - public float rageSpeed = 1f; - - public float attackSpeedMultiplier = 1f; - - private WasDealtDamageEffect[] wasDealtDamageEffects; - - private DealtDamageEffect[] dealtDamageEffects; - - private CharacterData data; - - public ParticleSystem slowPart; - - private float soundBigThreshold = 1.5f; - - public Action DealtDamageAction; - - public Action WasDealtDamageAction; - - public Action OnReloadDoneAction; - - public Action OutOfAmmpAction; - - internal float sinceDealtDamage; - - public bool SoundTransformScaleThresholdReached() - { - if (base.transform.localScale.x > soundBigThreshold) - { - return true; - } - return false; - } - - private void Start() - { - data = GetComponent(); - } - - public float GetSlow() - { - return Mathf.Clamp(slow, 0f, 0.9f); - } - - private void Update() - { - attackSpeedMultiplier = tasteOfBloodSpeed * rageSpeed; - sinceDealtDamage += TimeHandler.deltaTime; - if ((bool)data && !data.isPlaying) - { - sinceDealtDamage = 100f; - } - slow = slowSlow; - if (fastSlow > slowSlow) - { - slow = fastSlow; - } - if (slowSlow > 0f) - { - slowSlow = Mathf.Clamp(slowSlow - TimeHandler.deltaTime * 0.3f, 0f, 10f); - } - if (fastSlow > 0f) - { - fastSlow = Mathf.Clamp(fastSlow - TimeHandler.deltaTime * 2f, 0f, 1f); - } - } - - public void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer = null) - { - if (lifeSteal != 0f && !selfDamage) - { - GetComponent().Heal(damage.magnitude * lifeSteal); - } - if (refreshOnDamage) - { - GetComponent().holdable.GetComponent().sinceAttack = float.PositiveInfinity; - } - if (DealtDamageAction != null) - { - DealtDamageAction(damage, selfDamage); - } - if ((bool)damagedPlayer) - { - data.lastDamagedPlayer = damagedPlayer; - } - if (!selfDamage) - { - sinceDealtDamage = 0f; - } - if (dealtDamageEffects != null) - { - for (int i = 0; i < dealtDamageEffects.Length; i++) - { - dealtDamageEffects[i].DealtDamage(damage, selfDamage, damagedPlayer); - } - } - } - - internal void ResetStats() - { - for (int i = 0; i < objectsAddedToPlayer.Count; i++) - { - UnityEngine.Object.Destroy(objectsAddedToPlayer[i]); - } - objectsAddedToPlayer.Clear(); - data.health = 100f; - data.maxHealth = 100f; - sizeMultiplier = 1f; - health = 1f; - movementSpeed = 1f; - jump = 1f; - gravity = 1f; - slow = 0f; - slowSlow = 0f; - fastSlow = 0f; - secondsToTakeDamageOver = 0f; - numberOfJumps = 0; - regen = 0f; - lifeSteal = 0f; - respawns = 0; - refreshOnDamage = false; - automaticReload = true; - tasteOfBloodSpeed = 1f; - rageSpeed = 1f; - attackSpeedMultiplier = 1f; - WasUpdated(); - ConfigureMassAndSize(); - } - - public void WasDealtDamage(Vector2 damage, bool selfDamage) - { - if (WasDealtDamageAction != null) - { - WasDealtDamageAction(damage, selfDamage); - } - if (wasDealtDamageEffects != null) - { - for (int i = 0; i < wasDealtDamageEffects.Length; i++) - { - wasDealtDamageEffects[i].WasDealtDamage(damage, selfDamage); - } - } - } - - public void WasUpdated() - { - GetComponent().multiplier = 1f / base.transform.root.localScale.x; - wasDealtDamageEffects = GetComponentsInChildren(); - dealtDamageEffects = GetComponentsInChildren(); - } - - public void AddSlowAddative(float slowToAdd, float maxValue = 1f, bool isFastSlow = false) - { - if (data.block.IsBlocking()) - { - return; - } - DoSlowDown(slowToAdd); - if (isFastSlow) - { - if (fastSlow < maxValue) - { - fastSlow += slowToAdd; - fastSlow = Mathf.Clamp(slow, 0f, maxValue); - } - } - else if (slowSlow < maxValue) - { - slowSlow += slowToAdd; - slowSlow = Mathf.Clamp(slowSlow, 0f, maxValue); - } - } - - [PunRPC] - public void RPCA_AddSlow(float slowToAdd, bool isFastSlow = false) - { - DoSlowDown(slowToAdd); - if (isFastSlow) - { - fastSlow = Mathf.Clamp(fastSlow, slowToAdd, 1f); - } - else - { - slowSlow = Mathf.Clamp(slowSlow, slowToAdd, 10f); - } - } - - private void DoSlowDown(float newSlow) - { - if (soundSlowTime + soundSlowSpeedSec < Time.time) - { - soundSlowTime = Time.time; - SoundManager.Instance.Play(soundCharacterSlowFreeze, base.transform); - } - float num = Mathf.Clamp(newSlow - slow, 0f, 1f); - slowPart.Emit((int)Mathf.Clamp((newSlow * 0.1f + num * 0.7f) * 50f, 1f, 50f)); - data.playerVel.velocity *= 1f - num * 1f; - data.sinceGrounded *= 1f - num * 1f; - } - - internal void ConfigureMassAndSize() - { - base.transform.localScale = Vector3.one * 1.2f * Mathf.Pow(data.maxHealth / 100f * 1.2f, 0.2f) * sizeMultiplier; - data.playerVel.mass = 100f * Mathf.Pow(data.maxHealth / 100f * 1.2f, 0.8f) * sizeMultiplier; - } - - internal void OnReload(int bulletsReloaded) - { - if (OnReloadDoneAction != null) - { - OnReloadDoneAction(bulletsReloaded); - } - } - - internal void OnOutOfAmmp(int maxAmmo) - { - if (OutOfAmmpAction != null) - { - OutOfAmmpAction(maxAmmo); - } - } -} diff --git a/ROUNDS/DamageOverTime.cs b/ROUNDS/DamageOverTime.cs deleted file mode 100644 index c1c6a17..0000000 --- a/ROUNDS/DamageOverTime.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; -using Sonigon; -using UnityEngine; - -public class DamageOverTime : MonoBehaviour -{ - private HealthHandler health; - - private CharacterData data; - - private void Start() - { - health = GetComponent(); - data = GetComponent(); - } - - public void TakeDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, SoundEvent soundDamageOverTime, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) - { - StartCoroutine(DoDamageOverTime(damage, position, time, interval, color, soundDamageOverTime, damagingWeapon, damagingPlayer, lethal)); - } - - private IEnumerator DoDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, SoundEvent soundDamageOverTime, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) - { - float damageDealt = 0f; - float damageToDeal = damage.magnitude; - float dpt = damageToDeal / time * interval; - while (damageDealt < damageToDeal) - { - if (soundDamageOverTime != null && data.isPlaying && !data.dead) - { - SoundManager.Instance.Play(soundDamageOverTime, base.transform); - } - damageDealt += dpt; - health.DoDamage(damage.normalized * dpt, position, color, damagingWeapon, damagingPlayer, healthRemoval: true, lethal); - yield return new WaitForSeconds(interval / TimeHandler.timeScale); - } - } -} diff --git a/ROUNDS/ForceMultiplier.cs b/ROUNDS/ForceMultiplier.cs deleted file mode 100644 index 064bbfc..0000000 --- a/ROUNDS/ForceMultiplier.cs +++ /dev/null @@ -1,6 +0,0 @@ -using UnityEngine; - -public class ForceMultiplier : MonoBehaviour -{ - public float multiplier = 1f; -} diff --git a/ROUNDS/HealthHandler.cs b/ROUNDS/HealthHandler.cs deleted file mode 100644 index bbc739f..0000000 --- a/ROUNDS/HealthHandler.cs +++ /dev/null @@ -1,362 +0,0 @@ -using System; -using System.Collections; -using Photon.Pun; -using Sonigon; -using UnityEngine; - -public class HealthHandler : Damagable -{ - [Header("Sounds")] - public SoundEvent soundDie; - - public SoundEvent soundHeal; - - public SoundEvent soundDamagePassive; - - public SoundEvent soundDamageLifeSteal; - - public SoundEvent soundBounce; - - [Header("Settings")] - public SpriteRenderer hpSprite; - - public GameObject deathEffect; - - public float regeneration; - - private CharacterData data; - - private CodeAnimation anim; - - private Player player; - - private CharacterStatModifiers stats; - - public ParticleSystem healPart; - - private DamageOverTime dot; - - private Vector3 startHealthSpriteScale; - - public float flyingFor; - - private float lastDamaged; - - public Action delayedReviveAction; - - public Action reviveAction; - - [HideInInspector] - public bool DestroyOnDeath; - - public bool isRespawning; - - public GameObject deathEffectPhoenix; - - private void Awake() - { - dot = GetComponent(); - data = GetComponent(); - anim = GetComponentInChildren(); - player = GetComponent(); - stats = GetComponent(); - } - - private void Start() - { - startHealthSpriteScale = hpSprite.transform.localScale; - } - - private void Update() - { - flyingFor -= TimeHandler.deltaTime; - if (regeneration > 0f) - { - Heal(regeneration * TimeHandler.deltaTime); - } - } - - public void Heal(float healAmount) - { - if (healAmount != 0f && data.health != data.maxHealth) - { - SoundManager.Instance.Play(soundHeal, base.transform); - data.health += healAmount; - data.health = Mathf.Clamp(data.health, float.NegativeInfinity, data.maxHealth); - healPart.Emit((int)Mathf.Clamp(healAmount * 0.2f, 1f, 10f)); - } - } - - public void CallTakeForce(Vector2 force, ForceMode2D forceMode = ForceMode2D.Impulse, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) - { - if (data.isPlaying && (!data.block.IsBlocking() || ignoreBlock)) - { - data.view.RPC("RPCA_SendTakeForce", RpcTarget.All, force, (int)forceMode, forceIgnoreMass, true, setFlying); - } - } - - [PunRPC] - public void RPCA_SendTakeForce(Vector2 force, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) - { - TakeForce(force, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock, setFlying); - data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); - } - - [PunRPC] - public void RPCA_SendForceOverTime(Vector2 force, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) - { - StartCoroutine(IForceOverTime(force, time, forceMode, forceIgnoreMass, ignoreBlock)); - } - - private IEnumerator IForceOverTime(Vector2 force, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) - { - for (float i = 0f; i < time; i += TimeHandler.deltaTime) - { - TakeForce(force, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock); - data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); - yield return new WaitForFixedUpdate(); - } - } - - [PunRPC] - public void RPCA_SendForceTowardsPointOverTime(float force, float drag, float clampDistancce, Vector2 point, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) - { - StartCoroutine(IForceTowardsPointOverTime(force, drag, clampDistancce, point, time, forceMode, forceIgnoreMass, ignoreBlock)); - } - - private IEnumerator IForceTowardsPointOverTime(float force, float drag, float clampDistancce, Vector2 point, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) - { - for (float i = 0f; i < time; i += TimeHandler.fixedDeltaTime) - { - Vector2 vector = point - (Vector2)base.transform.position; - vector = Vector2.ClampMagnitude(vector, clampDistancce); - Vector2 vector2 = data.playerVel.velocity * (0f - drag) * TimeHandler.fixedDeltaTime; - TakeForce(force * vector + vector2 * drag * TimeHandler.timeScale, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock); - data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); - yield return new WaitForFixedUpdate(); - } - } - - public void TakeForce(Vector2 force, ForceMode2D forceMode = ForceMode2D.Impulse, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) - { - if (!data.isPlaying || !data.playerVel.simulated) - { - return; - } - bool flag = data.block.IsBlocking(); - if (flag && !ignoreBlock) - { - return; - } - if (!flag) - { - if (setFlying > flyingFor && setFlying > 0.25f) - { - flyingFor = setFlying; - SoundManager.Instance.Play(soundBounce, base.transform); - } - } - if (forceIgnoreMass) - { - force *= data.playerVel.mass / 100f; - } - data.playerVel.AddForce(force, forceMode); - if (force.y > 0f) - { - if (!forceIgnoreMass) - { - force.y /= data.playerVel.mass / 100f; - } - if (forceMode == ForceMode2D.Force) - { - force *= 0.003f; - } - data.sinceGrounded -= force.y * 0.003f; - } - data.sinceGrounded = Mathf.Clamp(data.sinceGrounded, -0.5f, 100f); - } - - public override void CallTakeDamage(Vector2 damage, Vector2 position, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) - { - if (!(damage == Vector2.zero) && !data.block.IsBlocking()) - { - data.view.RPC("RPCA_SendTakeDamage", RpcTarget.All, damage, position, lethal, (damagingPlayer != null) ? damagingPlayer.playerID : (-1)); - } - } - - [PunRPC] - public void RPCA_SendTakeDamage(Vector2 damage, Vector2 position, bool lethal = true, int playerID = -1) - { - if (!(damage == Vector2.zero)) - { - Player playerWithID = PlayerManager.instance.GetPlayerWithID(playerID); - GameObject damagingWeapon = null; - if ((bool)playerWithID) - { - damagingWeapon = playerWithID.data.weaponHandler.gun.gameObject; - } - TakeDamage(damage, position, damagingWeapon, playerWithID, lethal, ignoreBlock: true); - } - } - - public override void TakeDamage(Vector2 damage, Vector2 position, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true, bool ignoreBlock = false) - { - if (!(damage == Vector2.zero)) - { - TakeDamage(damage, position, Color.white * 0.85f, damagingWeapon, damagingPlayer, lethal, ignoreBlock); - } - } - - public override void TakeDamage(Vector2 damage, Vector2 position, Color dmgColor, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true, bool ignoreBlock = false) - { - if (!(damage == Vector2.zero) && data.isPlaying && data.playerVel.simulated && !data.dead && (!data.block.IsBlocking() || ignoreBlock)) - { - if (dmgColor == Color.black) - { - dmgColor = Color.white * 0.85f; - } - if (stats.secondsToTakeDamageOver == 0f) - { - DoDamage(damage, position, dmgColor, damagingWeapon, damagingPlayer, healthRemoval: false, lethal, ignoreBlock); - } - else - { - TakeDamageOverTime(damage, position, stats.secondsToTakeDamageOver, 0.25f, dmgColor, damagingWeapon, damagingPlayer, lethal); - } - } - } - - public void DoDamage(Vector2 damage, Vector2 position, Color blinkColor, GameObject damagingWeapon = null, Player damagingPlayer = null, bool healthRemoval = false, bool lethal = true, bool ignoreBlock = false) - { - if (damage == Vector2.zero || !data.isPlaying || data.dead || (data.block.IsBlocking() && !ignoreBlock) || isRespawning) - { - return; - } - if ((bool)damagingPlayer) - { - damagingPlayer.GetComponent().DealtDamage(damage, damagingPlayer != null && damagingPlayer.transform.root == base.transform, data.player); - } - StopAllCoroutines(); - DisplayDamage(blinkColor); - data.lastSourceOfDamage = damagingPlayer; - data.health -= damage.magnitude; - stats.WasDealtDamage(damage, damagingPlayer != null && damagingPlayer.transform.root == base.transform); - if (!lethal) - { - data.health = Mathf.Clamp(data.health, 1f, data.maxHealth); - } - if (data.health < 0f && !data.dead) - { - if (data.stats.remainingRespawns > 0) - { - data.view.RPC("RPCA_Die_Phoenix", RpcTarget.All, damage); - } - else - { - data.view.RPC("RPCA_Die", RpcTarget.All, damage); - } - } - if (lastDamaged + 0.15f < Time.time && damagingPlayer != null && damagingPlayer.data.stats.lifeSteal != 0f) - { - SoundManager.Instance.Play(soundDamageLifeSteal, base.transform); - } - lastDamaged = Time.time; - } - - public void TakeDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) - { - dot.TakeDamageOverTime(damage, position, time, interval, color, soundDamagePassive, damagingWeapon, damagingPlayer, lethal); - } - - private void DisplayDamage(Color blinkColor) - { - GetComponentInChildren().BlinkColor(blinkColor); - } - - private IEnumerator DelayReviveAction() - { - yield return new WaitForSecondsRealtime(2f); - delayedReviveAction?.Invoke(); - } - - public void Revive(bool isFullRevive = true) - { - reviveAction?.Invoke(); - if (base.gameObject.activeInHierarchy) - { - StartCoroutine(DelayReviveAction()); - } - flyingFor = 0f; - if (isFullRevive) - { - data.stats.remainingRespawns = data.stats.respawns; - } - data.healthHandler.isRespawning = false; - data.health = data.maxHealth; - data.playerVel.velocity = Vector2.zero; - data.playerVel.angularVelocity = 0f; - data.stunTime = 0f; - data.block.ResetCD(soundPlay: false); - data.weaponHandler.gun.GetComponentInChildren().ReloadAmmo(playSound: false); - data.GetComponent().IgnoreWallForFrames(5); - base.gameObject.SetActive(value: true); - if ((bool)deathEffect && data.dead) - { - anim.PlayIn(); - } - data.dead = false; - hpSprite.color = PlayerSkinBank.GetPlayerSkinColors(player.playerID).color; - data.stunHandler.StopStun(); - data.silenceHandler.StopSilence(); - GetComponent().slow = 0f; - GetComponent().slowSlow = 0f; - GetComponent().fastSlow = 0f; - GetComponent().isOverHeated = false; - GetComponent().sinceBlock = float.PositiveInfinity; - dot.StopAllCoroutines(); - } - - [PunRPC] - private void RPCA_Die(Vector2 deathDirection) - { - if (data.isPlaying && !data.dead) - { - SoundManager.Instance.Play(soundDie, base.transform); - data.dead = true; - if (!DestroyOnDeath) - { - base.gameObject.SetActive(value: false); - GamefeelManager.GameFeel(deathDirection.normalized * 3f); - UnityEngine.Object.Instantiate(deathEffect, base.transform.position, base.transform.rotation).GetComponent().PlayDeath(PlayerSkinBank.GetPlayerSkinColors(player.playerID).color, data.playerVel, deathDirection); - dot.StopAllCoroutines(); - data.stunHandler.StopStun(); - data.silenceHandler.StopSilence(); - PlayerManager.instance.PlayerDied(player); - } - else - { - UnityEngine.Object.Destroy(base.transform.root.gameObject); - } - } - } - - [PunRPC] - private void RPCA_Die_Phoenix(Vector2 deathDirection) - { - if (data.isPlaying && !data.dead) - { - data.stats.remainingRespawns--; - isRespawning = true; - SoundManager.Instance.Play(soundDie, base.transform); - if (!DestroyOnDeath) - { - base.gameObject.SetActive(value: false); - GamefeelManager.GameFeel(deathDirection.normalized * 3f); - UnityEngine.Object.Instantiate(deathEffectPhoenix, base.transform.position, base.transform.rotation).GetComponent().PlayDeath(PlayerSkinBank.GetPlayerSkinColors(player.playerID).color, data.playerVel, deathDirection, player.playerID); - dot.StopAllCoroutines(); - data.stunHandler.StopStun(); - data.silenceHandler.StopSilence(); - } - } - } -} diff --git a/ROUNDS/Player.cs b/ROUNDS/Player.cs deleted file mode 100644 index d912f63..0000000 --- a/ROUNDS/Player.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using ExitGames.Client.Photon; -using Photon.Pun; -using UnityEngine; - -public class Player : MonoBehaviour -{ - public int playerID; - - public int teamID; - - [HideInInspector] - public CharacterData data; - - public PlayerSkinBank colors; - - private void Awake() - { - data = GetComponent(); - } - - private void Start() - { - if (!data.view.IsMine) - { - ReadPlayerID(); - ReadTeamID(); - PlayerAssigner.instance.OtherPlayerWasCreated(); - } - else - { - int num = 0; - if (!PhotonNetwork.OfflineMode) - { - try - { - num = 0; - PlayerFace playerFace = CharacterCreatorHandler.instance.selectedPlayerFaces[num]; - data.view.RPC("RPCA_SetFace", RpcTarget.All, playerFace.eyeID, playerFace.eyeOffset, playerFace.mouthID, playerFace.mouthOffset, playerFace.detailID, playerFace.detailOffset, playerFace.detail2ID, playerFace.detail2Offset); - } - catch - { - } - } - else if (GM_ArmsRace.instance != null) - { - GM_ArmsRace instance = GM_ArmsRace.instance; - instance.StartGameAction = (Action)Delegate.Combine(instance.StartGameAction, new Action(GetFaceOffline)); - } - } - PlayerManager.instance.PlayerJoined(this); - } - - public void GetFaceOffline() - { - PlayerFace playerFace = CharacterCreatorHandler.instance.selectedPlayerFaces[playerID]; - data.view.RPC("RPCA_SetFace", RpcTarget.All, playerFace.eyeID, playerFace.eyeOffset, playerFace.mouthID, playerFace.mouthOffset, playerFace.detailID, playerFace.detailOffset, playerFace.detail2ID, playerFace.detail2Offset); - } - - [PunRPC] - public void RPCA_SetFace(int eyeID, Vector2 eyeOffset, int mouthID, Vector2 mouthOffset, int detailID, Vector2 detailOffset, int detail2ID, Vector2 detail2Offset) - { - PlayerFace face = PlayerFace.CreateFace(eyeID, eyeOffset, mouthID, mouthOffset, detailID, detailOffset, detail2ID, detail2Offset); - GetComponentInChildren().EquipFace(face); - } - - internal void Call_AllGameFeel(Vector2 vector2) - { - data.view.RPC("RPCA_AllGameFeel", RpcTarget.All, vector2); - } - - [PunRPC] - internal void RPCA_AllGameFeel(Vector2 vector2) - { - GamefeelManager.instance.AddGameFeel(vector2); - } - - public void AssignPlayerID(int ID) - { - playerID = ID; - SetColors(); - if (!PhotonNetwork.OfflineMode) - { - Hashtable customProperties = PhotonNetwork.LocalPlayer.CustomProperties; - if (customProperties.ContainsKey("PlayerID")) - { - customProperties["PlayerID"] = playerID; - } - else - { - customProperties.Add("PlayerID", playerID); - } - PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties); - } - } - - internal float GetRadius() - { - return 5f; - } - - private void ReadPlayerID() - { - if (!PhotonNetwork.OfflineMode) - { - playerID = (int)data.view.Owner.CustomProperties["PlayerID"]; - SetColors(); - } - } - - public void AssignTeamID(int ID) - { - teamID = ID; - if (!PhotonNetwork.OfflineMode) - { - Hashtable customProperties = PhotonNetwork.LocalPlayer.CustomProperties; - if (customProperties.ContainsKey("TeamID")) - { - customProperties["TeamID"] = playerID; - } - else - { - customProperties.Add("TeamID", teamID); - } - PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties); - } - } - - private void ReadTeamID() - { - if (!PhotonNetwork.OfflineMode) - { - teamID = (int)data.view.Owner.CustomProperties["TeamID"]; - } - } - - public void SetColors() - { - SetTeamColor.TeamColorThis(base.gameObject, PlayerSkinBank.GetPlayerSkinColors(playerID)); - } - - public PlayerSkin GetTeamColors() - { - return PlayerSkinBank.GetPlayerSkinColors(playerID); - } - - internal void FullReset() - { - data.weaponHandler.NewGun(); - data.stats.ResetStats(); - data.block.ResetStats(); - } -} diff --git a/ROUNDS/PlayerAudioModifyers.cs b/ROUNDS/PlayerAudioModifyers.cs deleted file mode 100644 index 7f82b58..0000000 --- a/ROUNDS/PlayerAudioModifyers.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -public class PlayerAudioModifyers : MonoBehaviour -{ - public List modifyers = new List(); - - public static List activeModifyer = new List(); - - public void AddToStack(CardAudioModifier mod) - { - int num = -1; - for (int i = 0; i < modifyers.Count; i++) - { - if (modifyers[i].modifier.stackName == mod.stackName) - { - num = i; - break; - } - } - if (num != -1) - { - modifyers[num].stacks++; - return; - } - AudioModifyer audioModifyer = new AudioModifyer(); - audioModifyer.modifier = new CardAudioModifier(); - audioModifyer.modifier.stackName = mod.stackName; - audioModifyer.modifier.stackType = mod.stackType; - audioModifyer.stacks = 1; - activeModifyer.Add(audioModifyer.modifier); - modifyers.Add(audioModifyer); - } - - public void SetStacks() - { - for (int i = 0; i < activeModifyer.Count; i++) - { - _ = activeModifyer[i].stackType; - _ = 1; - _ = activeModifyer[i].stackType; - } - for (int j = 0; j < modifyers.Count; j++) - { - _ = modifyers[j].modifier.stackType; - _ = 1; - _ = modifyers[j].modifier.stackType; - } - } -} diff --git a/ROUNDS/PlayerImmunity.cs b/ROUNDS/PlayerImmunity.cs deleted file mode 100644 index 791fadf..0000000 --- a/ROUNDS/PlayerImmunity.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -public class PlayerImmunity : MonoBehaviour -{ - private List immunities = new List(); - - private void Start() - { - } - - private void Update() - { - for (int num = immunities.Count - 1; num >= 0; num--) - { - immunities[num].time -= TimeHandler.deltaTime; - if (immunities[num].time <= 0f) - { - immunities.RemoveAt(num); - } - } - } - - public bool IsImune(float time, float dmg, string name) - { - for (int i = 0; i < immunities.Count; i++) - { - if (immunities[i].name == name) - { - if (dmg > immunities[i].dmg) - { - immunities[i].dmg = dmg; - immunities[i].name = name; - immunities[i].time = time; - return false; - } - return true; - } - } - immunities.Add(new Immunities(time, dmg, name)); - return false; - } -} diff --git a/ROUNDS/PlayerSounds.cs b/ROUNDS/PlayerSounds.cs deleted file mode 100644 index aeffb32..0000000 --- a/ROUNDS/PlayerSounds.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using Sonigon; -using UnityEngine; - -public class PlayerSounds : MonoBehaviour -{ - [Header("Sounds")] - public SoundEvent soundCharacterJump; - - public SoundEvent soundCharacterJumpBig; - - public SoundEvent soundCharacterJumpEnsnare; - - public SoundEvent soundCharacterLand; - - public SoundEvent soundCharacterLandBig; - - private SoundParameterIntensity parameterIntensityLand = new SoundParameterIntensity(0f); - - public SoundEvent soundCharacterStickWall; - - public SoundEvent soundCharacterStickWallBig; - - private SoundParameterIntensity parameterIntensityStickWall = new SoundParameterIntensity(0f); - - public SoundEvent soundCharacterDamageScreenEdge; - - private CharacterData data; - - private List ensnareEffectList = new List(); - - private bool ensnareEnabled; - - public void AddEnsnareEffect(EnsnareEffect ensnareEffect) - { - ensnareEffectList.Add(ensnareEffect); - } - - public void RemoveEnsnareEffect(EnsnareEffect ensnareEffect) - { - ensnareEffectList.Remove(ensnareEffect); - } - - private void Start() - { - data = GetComponent(); - CharacterData characterData = data; - characterData.TouchGroundAction = (Action)Delegate.Combine(characterData.TouchGroundAction, new Action(TouchGround)); - CharacterData characterData2 = data; - characterData2.TouchWallAction = (Action)Delegate.Combine(characterData2.TouchWallAction, new Action(TouchWall)); - PlayerJump jump = data.jump; - jump.JumpAction = (Action)Delegate.Combine(jump.JumpAction, new Action(Jump)); - } - - public void Jump() - { - ensnareEnabled = false; - for (int num = ensnareEffectList.Count - 1; num >= 0; num--) - { - if (ensnareEffectList[num] == null) - { - ensnareEffectList.RemoveAt(num); - } - } - for (int i = 0; i < ensnareEffectList.Count; i++) - { - if (ensnareEffectList[i].soundEnsnareJumpChange) - { - ensnareEnabled = true; - } - } - if (ensnareEnabled) - { - if (ensnareEnabled) - { - SoundManager.Instance.Play(soundCharacterJumpEnsnare, base.transform); - } - } - else if (data.stats.SoundTransformScaleThresholdReached()) - { - SoundManager.Instance.Play(soundCharacterJumpBig, base.transform); - } - else - { - SoundManager.Instance.Play(soundCharacterJump, base.transform); - } - } - - public void TouchGround(float sinceGrounded, Vector3 pos, Vector3 normal, Transform ground) - { - if (sinceGrounded > 0.05f) - { - parameterIntensityLand.intensity = sinceGrounded; - if (data.stats.SoundTransformScaleThresholdReached()) - { - SoundManager.Instance.Play(soundCharacterLandBig, base.transform, parameterIntensityLand); - } - else - { - SoundManager.Instance.Play(soundCharacterLand, base.transform, parameterIntensityLand); - } - } - } - - public void TouchWall(float sinceWall, Vector3 pos, Vector3 normal) - { - float num = sinceWall; - if (data.sinceGrounded < num) - { - num = data.sinceGrounded; - } - if (num > 0.05f) - { - parameterIntensityStickWall.intensity = num; - if (data.stats.SoundTransformScaleThresholdReached()) - { - SoundManager.Instance.Play(soundCharacterStickWallBig, base.transform, parameterIntensityStickWall); - } - else - { - SoundManager.Instance.Play(soundCharacterStickWall, base.transform, parameterIntensityStickWall); - } - } - } -} diff --git a/ROUNDS/RotationHandler.cs b/ROUNDS/RotationHandler.cs deleted file mode 100644 index 121bda8..0000000 --- a/ROUNDS/RotationHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using UnityEngine; - -public class RotationHandler : MonoBehaviour -{ - private CharacterData data; - - private PlayerVelocity rig; - - public float torque; - - private void Start() - { - data = GetComponent(); - rig = GetComponent(); - } - - private void FixedUpdate() - { - rig.AddTorque(torque * TimeHandler.timeScale * (Vector3.Angle(Vector3.up, base.transform.up) * Vector3.Cross(Vector3.up, base.transform.up).normalized).z); - } -} diff --git a/ROUNDS/SilenceHandler.cs b/ROUNDS/SilenceHandler.cs deleted file mode 100644 index a1cab30..0000000 --- a/ROUNDS/SilenceHandler.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Photon.Pun; -using UnityEngine; - -public class SilenceHandler : MonoBehaviour -{ - [Header("Settings")] - public CodeAnimation codeAnim; - - private Player player; - - private CharacterData data; - - private void Start() - { - player = GetComponent(); - data = player.data; - } - - private void Update() - { - if (data.silenceTime > 0f) - { - data.silenceTime -= TimeHandler.deltaTime; - if (!data.isSilenced) - { - StartSilence(); - } - } - else if (data.isSilenced) - { - StopSilence(); - } - } - - private void StartSilence() - { - player.data.input.silencedInput = true; - codeAnim.PlayIn(); - data.isSilenced = true; - } - - public void StopSilence() - { - player.data.input.silencedInput = false; - if (codeAnim.currentState == CodeAnimationInstance.AnimationUse.In) - { - codeAnim.PlayOut(); - } - data.isSilenced = false; - data.silenceTime = 0f; - } - - private void OnDisable() - { - codeAnim.transform.localScale = Vector3.zero; - } - - [PunRPC] - public void RPCA_AddSilence(float f) - { - if (f > data.silenceTime) - { - data.silenceTime = f; - } - if (!data.isSilenced) - { - StartSilence(); - } - } -} diff --git a/ROUNDS/StunHandler.cs b/ROUNDS/StunHandler.cs deleted file mode 100644 index bb3f93e..0000000 --- a/ROUNDS/StunHandler.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Sonigon; -using UnityEngine; - -public class StunHandler : MonoBehaviour -{ - [Header("Sounds")] - public SoundEvent soundCharacterStunLoop; - - private bool soundStunIsPlaying; - - [Header("Settings")] - public CodeAnimation codeAnim; - - private Player player; - - private CharacterData data; - - private void Start() - { - player = GetComponent(); - data = player.data; - } - - private void Update() - { - if (data.stunTime > 0f) - { - data.stunTime -= TimeHandler.deltaTime; - data.sinceGrounded = 0f; - if (!data.isStunned) - { - StartStun(); - } - } - else if (data.isStunned) - { - StopStun(); - } - if (data.isStunned && data.isPlaying && !data.dead) - { - if (!soundStunIsPlaying) - { - soundStunIsPlaying = true; - SoundManager.Instance.Play(soundCharacterStunLoop, base.transform); - } - } - else if (soundStunIsPlaying) - { - soundStunIsPlaying = false; - SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); - } - } - - private void StartStun() - { - player.data.playerVel.velocity *= 0f; - player.data.playerVel.isKinematic = true; - player.data.input.stunnedInput = true; - codeAnim.PlayIn(); - data.isStunned = true; - } - - public void StopStun() - { - player.data.playerVel.isKinematic = false; - player.data.input.stunnedInput = false; - if (codeAnim.currentState == CodeAnimationInstance.AnimationUse.In) - { - codeAnim.PlayOut(); - } - data.isStunned = false; - data.stunTime = 0f; - } - - private void OnDisable() - { - codeAnim.transform.localScale = Vector3.zero; - soundStunIsPlaying = false; - SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); - } - - private void OnDestroy() - { - soundStunIsPlaying = false; - SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); - } - - public void AddStun(float f) - { - if (!data.block.IsBlocking()) - { - if (f > data.stunTime) - { - data.stunTime = f; - } - if (!data.isStunned) - { - StartStun(); - } - } - } -} diff --git a/ROUNDS/WeaponHandler.cs b/ROUNDS/WeaponHandler.cs deleted file mode 100644 index 35be82f..0000000 --- a/ROUNDS/WeaponHandler.cs +++ /dev/null @@ -1,173 +0,0 @@ -using System.Collections; -using Sonigon; -using UnityEngine; - -public class WeaponHandler : MonoBehaviour -{ - [Header("Sounds")] - public SoundEvent soundCharacterCantShoot; - - private bool soundFireHold; - - [Header("Settings")] - public Gun gun; - - private Holding holding; - - private GeneralInput input; - - private CharacterData data; - - private float heatSinceAttack; - - private float heat; - - public float heatPerBullet = 0.1f; - - public float secondsBeforeStartToCool = 0.1f; - - public float coolPerSecond = 0.2f; - - public float overHeatTime = 1f; - - public float resetSpeed = 2f; - - public bool isOverHeated; - - private bool hasBeenHeated; - - public SpriteRenderer heatRenderer; - - private Transform overHeatPivot; - - public Color overHeatColor; - - private Color baseHeatColor; - - internal void DoReload() - { - gun.GetComponentInChildren().ReloadAmmo(); - } - - private void Awake() - { - holding = GetComponent(); - input = GetComponent(); - data = GetComponent(); - } - - private void Start() - { - overHeatPivot = heatRenderer.transform.parent; - baseHeatColor = heatRenderer.color; - } - - private void Update() - { - if (!gun.holdable.holder && (bool)data) - { - gun.holdable.holder = data; - } - if (data.playerVel.simulated) - { - gun.attackSpeedMultiplier = data.stats.attackSpeedMultiplier; - heatSinceAttack += TimeHandler.deltaTime; - Attack(); - OverHeat(); - } - } - - private void Attack() - { - if (!gun || !gun.IsReady()) - { - return; - } - if (input.shootIsPressed) - { - if (!soundFireHold) - { - soundFireHold = true; - if (gun.isReloading || data.isSilenced) - { - SoundManager.Instance.Play(soundCharacterCantShoot, base.transform); - } - } - } - else - { - soundFireHold = false; - } - if (gun.bursts == 0 && (!soundFireHold || gun.isReloading || data.isSilenced)) - { - gun.soundGun.StopAutoPlayTail(); - } - if ((!input.shootWasPressed || gun.useCharge) && (!input.shootWasReleased || !gun.useCharge) && (!(gun.attackSpeed / data.stats.attackSpeedMultiplier < 0.3f) || !input.shootIsPressed || gun.useCharge || gun.dontAllowAutoFire)) - { - return; - } - if (isOverHeated) - { - heatRenderer.GetComponent().PlayBoop(); - gun.sinceAttack = 0f; - return; - } - gun.Attack(0f); - if (heat >= 1f) - { - StartCoroutine(DoOverHeat()); - isOverHeated = true; - } - heatSinceAttack = 0f; - } - - internal void NewGun() - { - gun.ResetStats(); - gun.soundGun.ClearSoundModifiers(); - } - - private void OverHeat() - { - if (!isOverHeated) - { - if (heatSinceAttack > secondsBeforeStartToCool) - { - heat -= TimeHandler.deltaTime * coolPerSecond; - } - SetOverHeatColor(); - } - } - - private IEnumerator DoOverHeat() - { - SetOverHeatColor(); - yield return new WaitForSeconds(overHeatTime); - while (heat > 0f) - { - heat -= resetSpeed * TimeHandler.deltaTime; - SetOverHeatColor(); - yield return null; - } - isOverHeated = false; - } - - private void SetOverHeatColor() - { - heat = Mathf.Clamp(heat, 0f, 1f); - heatRenderer.color = Color.Lerp(baseHeatColor, overHeatColor, heat); - if (heat > 0.25f || hasBeenHeated) - { - hasBeenHeated = true; - overHeatPivot.transform.localScale = new Vector3(heat, 1f, 1f); - } - else - { - overHeatPivot.transform.localScale = new Vector3(0f, 1f, 1f); - } - if (heat == 0f) - { - hasBeenHeated = false; - } - } -} diff --git a/ROUNDS/_Player/Aim.cs b/ROUNDS/_Player/Aim.cs new file mode 100644 index 0000000..45288a5 --- /dev/null +++ b/ROUNDS/_Player/Aim.cs @@ -0,0 +1,39 @@ +using UnityEngine; + +public class Aim : MonoBehaviour +{ + private GeneralInput input; + + private HoldingObject holdingObject; + + private CharacterData data; + + private Vector3 aimDirection; + + private void Awake() + { + input = GetComponent(); + data = GetComponent(); + holdingObject = GetComponentInChildren(); + } + + private void Update() + { + if ((double)input.aimDirection.magnitude > 0.2) + { + aimDirection = input.aimDirection; + } + if (input.direction.magnitude > 0.2f && Optionshandler.leftStickAim && input.aimDirection == Vector3.zero) + { + aimDirection = input.direction; + } + if ((bool)holdingObject) + { + if (aimDirection != Vector3.zero) + { + holdingObject.transform.rotation = Quaternion.LookRotation(aimDirection); + } + data.aimDirection = aimDirection; + } + } +} diff --git a/ROUNDS/_Player/Block.cs b/ROUNDS/_Player/Block.cs new file mode 100644 index 0000000..b48d264 --- /dev/null +++ b/ROUNDS/_Player/Block.cs @@ -0,0 +1,353 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Photon.Pun; +using Sonigon; +using UnityEngine; + +public class Block : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundBlockStart; + + public SoundEvent soundBlockRecharged; + + public SoundEvent soundBlockBlocked; + + public SoundEvent soundBlockStatusEffect; + + [Header("Settings")] + public List objectsToSpawn = new List(); + + public float sinceBlock; + + private GeneralInput input; + + public ParticleSystem particle; + + public ParticleSystem reloadParticle; + + public ParticleSystem blockedPart; + + public float cooldown; + + public float counter = 1000f; + + public float cdMultiplier = 1f; + + public float cdAdd; + + public float forceToAdd; + + public float forceToAddUp; + + public bool autoBlock; + + public bool blockedThisFrame; + + public int additionalBlocks; + + public float healing; + + private float timeBetweenBlocks = 0.2f; + + private CharacterData data; + + private HealthHandler health; + + private bool active = true; + + public Action BlockRechargeAction; + + private bool blockedLastFrame; + + public Action BlockAction; + + public Action BlockActionEarly; + + public Action FirstBlockActionThatDelaysOthers; + + public Action SuperFirstBlockAction; + + public Vector3 blockedAtPos; + + public bool delayOtherActions; + + public ParticleSystem statusBlockPart; + + private float lastStatusBlock; + + public Action BlockProjectileAction; + + public float Cooldown() + { + return (cooldown + cdAdd) * cdMultiplier; + } + + private void Start() + { + input = GetComponent(); + data = GetComponent(); + health = GetComponent(); + sinceBlock = 100f; + } + + private void Update() + { + if ((bool)input && data.playerVel.simulated) + { + if (!blockedLastFrame) + { + blockedThisFrame = false; + } + blockedLastFrame = false; + sinceBlock += TimeHandler.deltaTime; + counter += TimeHandler.deltaTime; + if (counter > Cooldown() && !active) + { + active = true; + reloadParticle.Play(); + BlockRechargeAction(); + SoundManager.Instance.Play(soundBlockRecharged, base.transform); + } + if (input.shieldWasPressed) + { + TryBlock(); + } + } + } + + public void DoBlockAtPosition(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 blockPos = default(Vector3), bool onlyBlockEffects = false) + { + blockedAtPos = blockPos; + RPCA_DoBlock(firstBlock, dontSetCD, triggerType, blockPos, onlyBlockEffects); + } + + internal void ResetStats() + { + objectsToSpawn = new List(); + sinceBlock = 10f; + cooldown = 4f; + counter = 1000f; + cdMultiplier = 1f; + cdAdd = 0f; + forceToAdd = 0f; + forceToAddUp = 0f; + autoBlock = false; + blockedThisFrame = false; + additionalBlocks = 0; + healing = 0f; + delayOtherActions = false; + } + + public void CallDoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) + { + data.view.RPC("RPCA_DoBlock", RpcTarget.All, firstBlock, dontSetCD, (int)triggerType, useBlockPos, onlyBlockEffects); + } + + [PunRPC] + public void RPCA_DoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) + { + if (triggerType == BlockTrigger.BlockTriggerType.Default && firstBlock) + { + for (int i = 0; i < additionalBlocks; i++) + { + StartCoroutine(DelayBlock(((float)i + 1f) * timeBetweenBlocks)); + } + } + StartCoroutine(IDoBlock(firstBlock, dontSetCD, triggerType, useBlockPos, onlyBlockEffects)); + } + + private IEnumerator IDoBlock(bool firstBlock, bool dontSetCD = false, BlockTrigger.BlockTriggerType triggerType = BlockTrigger.BlockTriggerType.Default, Vector3 useBlockPos = default(Vector3), bool onlyBlockEffects = false) + { + active = false; + Vector3 position = base.transform.position; + if (useBlockPos != Vector3.zero) + { + base.transform.position = useBlockPos; + } + if (SuperFirstBlockAction != null) + { + SuperFirstBlockAction(triggerType); + } + if (FirstBlockActionThatDelaysOthers != null) + { + FirstBlockActionThatDelaysOthers(triggerType); + } + if (useBlockPos != Vector3.zero) + { + base.transform.position = position; + } + if (!onlyBlockEffects) + { + sinceBlock = 0f; + } + if (delayOtherActions) + { + yield return new WaitForSeconds(0.2f); + } + position = base.transform.position; + if (useBlockPos != Vector3.zero) + { + base.transform.position = useBlockPos; + } + if (BlockActionEarly != null) + { + BlockActionEarly(triggerType); + } + if (BlockAction != null) + { + BlockAction(triggerType); + } + if (firstBlock) + { + if (forceToAdd != 0f) + { + health.TakeForce(data.hand.transform.forward * forceToAdd * data.playerVel.mass * 0.01f); + } + if (forceToAddUp != 0f) + { + health.TakeForce(Vector3.up * forceToAddUp * data.playerVel.mass * 0.01f); + } + } + blockedLastFrame = true; + bool flag = false; + for (int i = 0; i < data.currentCards.Count; i++) + { + if (data.currentCards[i].soundDisableBlockBasic) + { + flag = true; + break; + } + } + if (!flag && triggerType != BlockTrigger.BlockTriggerType.ShieldCharge) + { + SoundManager.Instance.Play(soundBlockStart, base.transform); + } + if (!onlyBlockEffects) + { + particle.Play(); + } + if (!dontSetCD) + { + counter = 0f; + } + GamefeelManager.GameFeel(UnityEngine.Random.insideUnitCircle.normalized * 1f); + if (!onlyBlockEffects) + { + sinceBlock = 0f; + } + Spawn(); + health.Heal(healing); + if (useBlockPos != Vector3.zero) + { + base.transform.position = position; + } + } + + public void ShowStatusEffectBlock() + { + if (!(Time.unscaledTime < lastStatusBlock + 0.25f) && data.view.IsMine) + { + lastStatusBlock = Time.unscaledTime; + data.view.RPC("RPCA_ShowStatusEffectBlock", RpcTarget.All); + } + } + + [PunRPC] + public void RPCA_ShowStatusEffectBlock() + { + SoundManager.Instance.Play(soundBlockStatusEffect, base.transform); + statusBlockPart.Play(); + } + + public void TryBlock() + { + if (!(counter < Cooldown())) + { + RPCA_DoBlock(firstBlock: true); + counter = 0f; + } + } + + private IEnumerator DelayBlock(float t) + { + yield return new WaitForSeconds(t); + yield return new WaitForEndOfFrame(); + RPCA_DoBlock(firstBlock: false, dontSetCD: true, BlockTrigger.BlockTriggerType.Echo); + } + + public void Spawn() + { + for (int i = 0; i < objectsToSpawn.Count; i++) + { + SpawnedAttack component = UnityEngine.Object.Instantiate(objectsToSpawn[i], base.transform.position, Quaternion.identity).GetComponent(); + if ((bool)component) + { + component.spawner = GetComponent(); + } + } + } + + public void blocked(GameObject projectile, Vector3 forward, Vector3 hitPos) + { + SoundManager.Instance.Play(soundBlockBlocked, base.transform); + projectile.GetComponent().RemoveOwnPlayerFromPlayersHit(); + projectile.GetComponent().AddPlayerToHeld(GetComponent()); + projectile.GetComponent().velocity *= -1f; + projectile.GetComponent().WasBlocked(); + blockedPart.transform.position = hitPos + base.transform.forward * 5f; + blockedPart.transform.rotation = Quaternion.LookRotation(-forward * 1.5f); + GamefeelManager.GameFeel(forward); + blockedPart.Play(); + SpawnedAttack componentInParent = projectile.GetComponentInParent(); + if ((!componentInParent || !(componentInParent.spawner.gameObject == base.transform.root.gameObject)) && BlockProjectileAction != null) + { + BlockProjectileAction(projectile, forward, hitPos); + } + } + + public void ResetCD(bool soundPlay) + { + active = true; + reloadParticle.Play(); + counter = Cooldown() + 1f; + if (soundPlay) + { + SoundManager.Instance.Play(soundBlockRecharged, base.transform); + } + } + + public bool TryBlockMe(GameObject toBlock, Vector3 forward, Vector3 hitPos) + { + if (sinceBlock < 0.3f) + { + blocked(toBlock, forward, hitPos); + sinceBlock = 0f; + particle.Play(); + return true; + } + return false; + } + + public void DoBlock(GameObject toBlock, Vector3 forward, Vector3 hitPos) + { + sinceBlock = 0f; + blocked(toBlock, forward, hitPos); + particle.Play(); + } + + public bool IsBlocking() + { + if (sinceBlock < 0.3f) + { + ShowStatusEffectBlock(); + } + return sinceBlock < 0.3f; + } + + public bool IsOnCD() + { + return counter < Cooldown(); + } +} diff --git a/ROUNDS/_Player/CharacterStatModifiers.cs b/ROUNDS/_Player/CharacterStatModifiers.cs new file mode 100644 index 0000000..9122d66 --- /dev/null +++ b/ROUNDS/_Player/CharacterStatModifiers.cs @@ -0,0 +1,281 @@ +using System; +using System.Collections.Generic; +using Photon.Pun; +using Sonigon; +using UnityEngine; + +public class CharacterStatModifiers : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundCharacterSlowFreeze; + + private float soundSlowTime; + + private float soundSlowSpeedSec = 0.3f; + + [Header("Settings")] + public GameObject AddObjectToPlayer; + + [HideInInspector] + public List objectsAddedToPlayer; + + [Header("Multiply")] + public float sizeMultiplier = 1f; + + public float health = 1f; + + public float movementSpeed = 1f; + + public float jump = 1f; + + public float gravity = 1f; + + public float slow; + + public float slowSlow; + + public float fastSlow; + + [Header("Add")] + public float secondsToTakeDamageOver; + + public int numberOfJumps; + + public float regen; + + public float lifeSteal; + + public bool refreshOnDamage; + + public bool automaticReload = true; + + public int respawns; + + [HideInInspector] + public int remainingRespawns; + + [HideInInspector] + public float tasteOfBloodSpeed = 1f; + + [HideInInspector] + public float rageSpeed = 1f; + + public float attackSpeedMultiplier = 1f; + + private WasDealtDamageEffect[] wasDealtDamageEffects; + + private DealtDamageEffect[] dealtDamageEffects; + + private CharacterData data; + + public ParticleSystem slowPart; + + private float soundBigThreshold = 1.5f; + + public Action DealtDamageAction; + + public Action WasDealtDamageAction; + + public Action OnReloadDoneAction; + + public Action OutOfAmmpAction; + + internal float sinceDealtDamage; + + public bool SoundTransformScaleThresholdReached() + { + if (base.transform.localScale.x > soundBigThreshold) + { + return true; + } + return false; + } + + private void Start() + { + data = GetComponent(); + } + + public float GetSlow() + { + return Mathf.Clamp(slow, 0f, 0.9f); + } + + private void Update() + { + attackSpeedMultiplier = tasteOfBloodSpeed * rageSpeed; + sinceDealtDamage += TimeHandler.deltaTime; + if ((bool)data && !data.isPlaying) + { + sinceDealtDamage = 100f; + } + slow = slowSlow; + if (fastSlow > slowSlow) + { + slow = fastSlow; + } + if (slowSlow > 0f) + { + slowSlow = Mathf.Clamp(slowSlow - TimeHandler.deltaTime * 0.3f, 0f, 10f); + } + if (fastSlow > 0f) + { + fastSlow = Mathf.Clamp(fastSlow - TimeHandler.deltaTime * 2f, 0f, 1f); + } + } + + public void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer = null) + { + if (lifeSteal != 0f && !selfDamage) + { + GetComponent().Heal(damage.magnitude * lifeSteal); + } + if (refreshOnDamage) + { + GetComponent().holdable.GetComponent().sinceAttack = float.PositiveInfinity; + } + if (DealtDamageAction != null) + { + DealtDamageAction(damage, selfDamage); + } + if ((bool)damagedPlayer) + { + data.lastDamagedPlayer = damagedPlayer; + } + if (!selfDamage) + { + sinceDealtDamage = 0f; + } + if (dealtDamageEffects != null) + { + for (int i = 0; i < dealtDamageEffects.Length; i++) + { + dealtDamageEffects[i].DealtDamage(damage, selfDamage, damagedPlayer); + } + } + } + + internal void ResetStats() + { + for (int i = 0; i < objectsAddedToPlayer.Count; i++) + { + UnityEngine.Object.Destroy(objectsAddedToPlayer[i]); + } + objectsAddedToPlayer.Clear(); + data.health = 100f; + data.maxHealth = 100f; + sizeMultiplier = 1f; + health = 1f; + movementSpeed = 1f; + jump = 1f; + gravity = 1f; + slow = 0f; + slowSlow = 0f; + fastSlow = 0f; + secondsToTakeDamageOver = 0f; + numberOfJumps = 0; + regen = 0f; + lifeSteal = 0f; + respawns = 0; + refreshOnDamage = false; + automaticReload = true; + tasteOfBloodSpeed = 1f; + rageSpeed = 1f; + attackSpeedMultiplier = 1f; + WasUpdated(); + ConfigureMassAndSize(); + } + + public void WasDealtDamage(Vector2 damage, bool selfDamage) + { + if (WasDealtDamageAction != null) + { + WasDealtDamageAction(damage, selfDamage); + } + if (wasDealtDamageEffects != null) + { + for (int i = 0; i < wasDealtDamageEffects.Length; i++) + { + wasDealtDamageEffects[i].WasDealtDamage(damage, selfDamage); + } + } + } + + public void WasUpdated() + { + GetComponent().multiplier = 1f / base.transform.root.localScale.x; + wasDealtDamageEffects = GetComponentsInChildren(); + dealtDamageEffects = GetComponentsInChildren(); + } + + public void AddSlowAddative(float slowToAdd, float maxValue = 1f, bool isFastSlow = false) + { + if (data.block.IsBlocking()) + { + return; + } + DoSlowDown(slowToAdd); + if (isFastSlow) + { + if (fastSlow < maxValue) + { + fastSlow += slowToAdd; + fastSlow = Mathf.Clamp(slow, 0f, maxValue); + } + } + else if (slowSlow < maxValue) + { + slowSlow += slowToAdd; + slowSlow = Mathf.Clamp(slowSlow, 0f, maxValue); + } + } + + [PunRPC] + public void RPCA_AddSlow(float slowToAdd, bool isFastSlow = false) + { + DoSlowDown(slowToAdd); + if (isFastSlow) + { + fastSlow = Mathf.Clamp(fastSlow, slowToAdd, 1f); + } + else + { + slowSlow = Mathf.Clamp(slowSlow, slowToAdd, 10f); + } + } + + private void DoSlowDown(float newSlow) + { + if (soundSlowTime + soundSlowSpeedSec < Time.time) + { + soundSlowTime = Time.time; + SoundManager.Instance.Play(soundCharacterSlowFreeze, base.transform); + } + float num = Mathf.Clamp(newSlow - slow, 0f, 1f); + slowPart.Emit((int)Mathf.Clamp((newSlow * 0.1f + num * 0.7f) * 50f, 1f, 50f)); + data.playerVel.velocity *= 1f - num * 1f; + data.sinceGrounded *= 1f - num * 1f; + } + + internal void ConfigureMassAndSize() + { + base.transform.localScale = Vector3.one * 1.2f * Mathf.Pow(data.maxHealth / 100f * 1.2f, 0.2f) * sizeMultiplier; + data.playerVel.mass = 100f * Mathf.Pow(data.maxHealth / 100f * 1.2f, 0.8f) * sizeMultiplier; + } + + internal void OnReload(int bulletsReloaded) + { + if (OnReloadDoneAction != null) + { + OnReloadDoneAction(bulletsReloaded); + } + } + + internal void OnOutOfAmmp(int maxAmmo) + { + if (OutOfAmmpAction != null) + { + OutOfAmmpAction(maxAmmo); + } + } +} diff --git a/ROUNDS/_Player/DamageOverTime.cs b/ROUNDS/_Player/DamageOverTime.cs new file mode 100644 index 0000000..c1c6a17 --- /dev/null +++ b/ROUNDS/_Player/DamageOverTime.cs @@ -0,0 +1,38 @@ +using System.Collections; +using Sonigon; +using UnityEngine; + +public class DamageOverTime : MonoBehaviour +{ + private HealthHandler health; + + private CharacterData data; + + private void Start() + { + health = GetComponent(); + data = GetComponent(); + } + + public void TakeDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, SoundEvent soundDamageOverTime, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) + { + StartCoroutine(DoDamageOverTime(damage, position, time, interval, color, soundDamageOverTime, damagingWeapon, damagingPlayer, lethal)); + } + + private IEnumerator DoDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, SoundEvent soundDamageOverTime, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) + { + float damageDealt = 0f; + float damageToDeal = damage.magnitude; + float dpt = damageToDeal / time * interval; + while (damageDealt < damageToDeal) + { + if (soundDamageOverTime != null && data.isPlaying && !data.dead) + { + SoundManager.Instance.Play(soundDamageOverTime, base.transform); + } + damageDealt += dpt; + health.DoDamage(damage.normalized * dpt, position, color, damagingWeapon, damagingPlayer, healthRemoval: true, lethal); + yield return new WaitForSeconds(interval / TimeHandler.timeScale); + } + } +} diff --git a/ROUNDS/_Player/ForceMultiplier.cs b/ROUNDS/_Player/ForceMultiplier.cs new file mode 100644 index 0000000..064bbfc --- /dev/null +++ b/ROUNDS/_Player/ForceMultiplier.cs @@ -0,0 +1,6 @@ +using UnityEngine; + +public class ForceMultiplier : MonoBehaviour +{ + public float multiplier = 1f; +} diff --git a/ROUNDS/_Player/HealthHandler.cs b/ROUNDS/_Player/HealthHandler.cs new file mode 100644 index 0000000..bbc739f --- /dev/null +++ b/ROUNDS/_Player/HealthHandler.cs @@ -0,0 +1,362 @@ +using System; +using System.Collections; +using Photon.Pun; +using Sonigon; +using UnityEngine; + +public class HealthHandler : Damagable +{ + [Header("Sounds")] + public SoundEvent soundDie; + + public SoundEvent soundHeal; + + public SoundEvent soundDamagePassive; + + public SoundEvent soundDamageLifeSteal; + + public SoundEvent soundBounce; + + [Header("Settings")] + public SpriteRenderer hpSprite; + + public GameObject deathEffect; + + public float regeneration; + + private CharacterData data; + + private CodeAnimation anim; + + private Player player; + + private CharacterStatModifiers stats; + + public ParticleSystem healPart; + + private DamageOverTime dot; + + private Vector3 startHealthSpriteScale; + + public float flyingFor; + + private float lastDamaged; + + public Action delayedReviveAction; + + public Action reviveAction; + + [HideInInspector] + public bool DestroyOnDeath; + + public bool isRespawning; + + public GameObject deathEffectPhoenix; + + private void Awake() + { + dot = GetComponent(); + data = GetComponent(); + anim = GetComponentInChildren(); + player = GetComponent(); + stats = GetComponent(); + } + + private void Start() + { + startHealthSpriteScale = hpSprite.transform.localScale; + } + + private void Update() + { + flyingFor -= TimeHandler.deltaTime; + if (regeneration > 0f) + { + Heal(regeneration * TimeHandler.deltaTime); + } + } + + public void Heal(float healAmount) + { + if (healAmount != 0f && data.health != data.maxHealth) + { + SoundManager.Instance.Play(soundHeal, base.transform); + data.health += healAmount; + data.health = Mathf.Clamp(data.health, float.NegativeInfinity, data.maxHealth); + healPart.Emit((int)Mathf.Clamp(healAmount * 0.2f, 1f, 10f)); + } + } + + public void CallTakeForce(Vector2 force, ForceMode2D forceMode = ForceMode2D.Impulse, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) + { + if (data.isPlaying && (!data.block.IsBlocking() || ignoreBlock)) + { + data.view.RPC("RPCA_SendTakeForce", RpcTarget.All, force, (int)forceMode, forceIgnoreMass, true, setFlying); + } + } + + [PunRPC] + public void RPCA_SendTakeForce(Vector2 force, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) + { + TakeForce(force, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock, setFlying); + data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); + } + + [PunRPC] + public void RPCA_SendForceOverTime(Vector2 force, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) + { + StartCoroutine(IForceOverTime(force, time, forceMode, forceIgnoreMass, ignoreBlock)); + } + + private IEnumerator IForceOverTime(Vector2 force, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) + { + for (float i = 0f; i < time; i += TimeHandler.deltaTime) + { + TakeForce(force, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock); + data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); + yield return new WaitForFixedUpdate(); + } + } + + [PunRPC] + public void RPCA_SendForceTowardsPointOverTime(float force, float drag, float clampDistancce, Vector2 point, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) + { + StartCoroutine(IForceTowardsPointOverTime(force, drag, clampDistancce, point, time, forceMode, forceIgnoreMass, ignoreBlock)); + } + + private IEnumerator IForceTowardsPointOverTime(float force, float drag, float clampDistancce, Vector2 point, float time, int forceMode, bool forceIgnoreMass = false, bool ignoreBlock = false) + { + for (float i = 0f; i < time; i += TimeHandler.fixedDeltaTime) + { + Vector2 vector = point - (Vector2)base.transform.position; + vector = Vector2.ClampMagnitude(vector, clampDistancce); + Vector2 vector2 = data.playerVel.velocity * (0f - drag) * TimeHandler.fixedDeltaTime; + TakeForce(force * vector + vector2 * drag * TimeHandler.timeScale, (ForceMode2D)forceMode, forceIgnoreMass, ignoreBlock); + data.GetComponent().SetDontSyncFor((float)PhotonNetwork.GetPing() * 0.001f + 0.2f); + yield return new WaitForFixedUpdate(); + } + } + + public void TakeForce(Vector2 force, ForceMode2D forceMode = ForceMode2D.Impulse, bool forceIgnoreMass = false, bool ignoreBlock = false, float setFlying = 0f) + { + if (!data.isPlaying || !data.playerVel.simulated) + { + return; + } + bool flag = data.block.IsBlocking(); + if (flag && !ignoreBlock) + { + return; + } + if (!flag) + { + if (setFlying > flyingFor && setFlying > 0.25f) + { + flyingFor = setFlying; + SoundManager.Instance.Play(soundBounce, base.transform); + } + } + if (forceIgnoreMass) + { + force *= data.playerVel.mass / 100f; + } + data.playerVel.AddForce(force, forceMode); + if (force.y > 0f) + { + if (!forceIgnoreMass) + { + force.y /= data.playerVel.mass / 100f; + } + if (forceMode == ForceMode2D.Force) + { + force *= 0.003f; + } + data.sinceGrounded -= force.y * 0.003f; + } + data.sinceGrounded = Mathf.Clamp(data.sinceGrounded, -0.5f, 100f); + } + + public override void CallTakeDamage(Vector2 damage, Vector2 position, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) + { + if (!(damage == Vector2.zero) && !data.block.IsBlocking()) + { + data.view.RPC("RPCA_SendTakeDamage", RpcTarget.All, damage, position, lethal, (damagingPlayer != null) ? damagingPlayer.playerID : (-1)); + } + } + + [PunRPC] + public void RPCA_SendTakeDamage(Vector2 damage, Vector2 position, bool lethal = true, int playerID = -1) + { + if (!(damage == Vector2.zero)) + { + Player playerWithID = PlayerManager.instance.GetPlayerWithID(playerID); + GameObject damagingWeapon = null; + if ((bool)playerWithID) + { + damagingWeapon = playerWithID.data.weaponHandler.gun.gameObject; + } + TakeDamage(damage, position, damagingWeapon, playerWithID, lethal, ignoreBlock: true); + } + } + + public override void TakeDamage(Vector2 damage, Vector2 position, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true, bool ignoreBlock = false) + { + if (!(damage == Vector2.zero)) + { + TakeDamage(damage, position, Color.white * 0.85f, damagingWeapon, damagingPlayer, lethal, ignoreBlock); + } + } + + public override void TakeDamage(Vector2 damage, Vector2 position, Color dmgColor, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true, bool ignoreBlock = false) + { + if (!(damage == Vector2.zero) && data.isPlaying && data.playerVel.simulated && !data.dead && (!data.block.IsBlocking() || ignoreBlock)) + { + if (dmgColor == Color.black) + { + dmgColor = Color.white * 0.85f; + } + if (stats.secondsToTakeDamageOver == 0f) + { + DoDamage(damage, position, dmgColor, damagingWeapon, damagingPlayer, healthRemoval: false, lethal, ignoreBlock); + } + else + { + TakeDamageOverTime(damage, position, stats.secondsToTakeDamageOver, 0.25f, dmgColor, damagingWeapon, damagingPlayer, lethal); + } + } + } + + public void DoDamage(Vector2 damage, Vector2 position, Color blinkColor, GameObject damagingWeapon = null, Player damagingPlayer = null, bool healthRemoval = false, bool lethal = true, bool ignoreBlock = false) + { + if (damage == Vector2.zero || !data.isPlaying || data.dead || (data.block.IsBlocking() && !ignoreBlock) || isRespawning) + { + return; + } + if ((bool)damagingPlayer) + { + damagingPlayer.GetComponent().DealtDamage(damage, damagingPlayer != null && damagingPlayer.transform.root == base.transform, data.player); + } + StopAllCoroutines(); + DisplayDamage(blinkColor); + data.lastSourceOfDamage = damagingPlayer; + data.health -= damage.magnitude; + stats.WasDealtDamage(damage, damagingPlayer != null && damagingPlayer.transform.root == base.transform); + if (!lethal) + { + data.health = Mathf.Clamp(data.health, 1f, data.maxHealth); + } + if (data.health < 0f && !data.dead) + { + if (data.stats.remainingRespawns > 0) + { + data.view.RPC("RPCA_Die_Phoenix", RpcTarget.All, damage); + } + else + { + data.view.RPC("RPCA_Die", RpcTarget.All, damage); + } + } + if (lastDamaged + 0.15f < Time.time && damagingPlayer != null && damagingPlayer.data.stats.lifeSteal != 0f) + { + SoundManager.Instance.Play(soundDamageLifeSteal, base.transform); + } + lastDamaged = Time.time; + } + + public void TakeDamageOverTime(Vector2 damage, Vector2 position, float time, float interval, Color color, GameObject damagingWeapon = null, Player damagingPlayer = null, bool lethal = true) + { + dot.TakeDamageOverTime(damage, position, time, interval, color, soundDamagePassive, damagingWeapon, damagingPlayer, lethal); + } + + private void DisplayDamage(Color blinkColor) + { + GetComponentInChildren().BlinkColor(blinkColor); + } + + private IEnumerator DelayReviveAction() + { + yield return new WaitForSecondsRealtime(2f); + delayedReviveAction?.Invoke(); + } + + public void Revive(bool isFullRevive = true) + { + reviveAction?.Invoke(); + if (base.gameObject.activeInHierarchy) + { + StartCoroutine(DelayReviveAction()); + } + flyingFor = 0f; + if (isFullRevive) + { + data.stats.remainingRespawns = data.stats.respawns; + } + data.healthHandler.isRespawning = false; + data.health = data.maxHealth; + data.playerVel.velocity = Vector2.zero; + data.playerVel.angularVelocity = 0f; + data.stunTime = 0f; + data.block.ResetCD(soundPlay: false); + data.weaponHandler.gun.GetComponentInChildren().ReloadAmmo(playSound: false); + data.GetComponent().IgnoreWallForFrames(5); + base.gameObject.SetActive(value: true); + if ((bool)deathEffect && data.dead) + { + anim.PlayIn(); + } + data.dead = false; + hpSprite.color = PlayerSkinBank.GetPlayerSkinColors(player.playerID).color; + data.stunHandler.StopStun(); + data.silenceHandler.StopSilence(); + GetComponent().slow = 0f; + GetComponent().slowSlow = 0f; + GetComponent().fastSlow = 0f; + GetComponent().isOverHeated = false; + GetComponent().sinceBlock = float.PositiveInfinity; + dot.StopAllCoroutines(); + } + + [PunRPC] + private void RPCA_Die(Vector2 deathDirection) + { + if (data.isPlaying && !data.dead) + { + SoundManager.Instance.Play(soundDie, base.transform); + data.dead = true; + if (!DestroyOnDeath) + { + base.gameObject.SetActive(value: false); + GamefeelManager.GameFeel(deathDirection.normalized * 3f); + UnityEngine.Object.Instantiate(deathEffect, base.transform.position, base.transform.rotation).GetComponent().PlayDeath(PlayerSkinBank.GetPlayerSkinColors(player.playerID).color, data.playerVel, deathDirection); + dot.StopAllCoroutines(); + data.stunHandler.StopStun(); + data.silenceHandler.StopSilence(); + PlayerManager.instance.PlayerDied(player); + } + else + { + UnityEngine.Object.Destroy(base.transform.root.gameObject); + } + } + } + + [PunRPC] + private void RPCA_Die_Phoenix(Vector2 deathDirection) + { + if (data.isPlaying && !data.dead) + { + data.stats.remainingRespawns--; + isRespawning = true; + SoundManager.Instance.Play(soundDie, base.transform); + if (!DestroyOnDeath) + { + base.gameObject.SetActive(value: false); + GamefeelManager.GameFeel(deathDirection.normalized * 3f); + UnityEngine.Object.Instantiate(deathEffectPhoenix, base.transform.position, base.transform.rotation).GetComponent().PlayDeath(PlayerSkinBank.GetPlayerSkinColors(player.playerID).color, data.playerVel, deathDirection, player.playerID); + dot.StopAllCoroutines(); + data.stunHandler.StopStun(); + data.silenceHandler.StopSilence(); + } + } + } +} diff --git a/ROUNDS/_Player/Player.cs b/ROUNDS/_Player/Player.cs new file mode 100644 index 0000000..d912f63 --- /dev/null +++ b/ROUNDS/_Player/Player.cs @@ -0,0 +1,153 @@ +using System; +using ExitGames.Client.Photon; +using Photon.Pun; +using UnityEngine; + +public class Player : MonoBehaviour +{ + public int playerID; + + public int teamID; + + [HideInInspector] + public CharacterData data; + + public PlayerSkinBank colors; + + private void Awake() + { + data = GetComponent(); + } + + private void Start() + { + if (!data.view.IsMine) + { + ReadPlayerID(); + ReadTeamID(); + PlayerAssigner.instance.OtherPlayerWasCreated(); + } + else + { + int num = 0; + if (!PhotonNetwork.OfflineMode) + { + try + { + num = 0; + PlayerFace playerFace = CharacterCreatorHandler.instance.selectedPlayerFaces[num]; + data.view.RPC("RPCA_SetFace", RpcTarget.All, playerFace.eyeID, playerFace.eyeOffset, playerFace.mouthID, playerFace.mouthOffset, playerFace.detailID, playerFace.detailOffset, playerFace.detail2ID, playerFace.detail2Offset); + } + catch + { + } + } + else if (GM_ArmsRace.instance != null) + { + GM_ArmsRace instance = GM_ArmsRace.instance; + instance.StartGameAction = (Action)Delegate.Combine(instance.StartGameAction, new Action(GetFaceOffline)); + } + } + PlayerManager.instance.PlayerJoined(this); + } + + public void GetFaceOffline() + { + PlayerFace playerFace = CharacterCreatorHandler.instance.selectedPlayerFaces[playerID]; + data.view.RPC("RPCA_SetFace", RpcTarget.All, playerFace.eyeID, playerFace.eyeOffset, playerFace.mouthID, playerFace.mouthOffset, playerFace.detailID, playerFace.detailOffset, playerFace.detail2ID, playerFace.detail2Offset); + } + + [PunRPC] + public void RPCA_SetFace(int eyeID, Vector2 eyeOffset, int mouthID, Vector2 mouthOffset, int detailID, Vector2 detailOffset, int detail2ID, Vector2 detail2Offset) + { + PlayerFace face = PlayerFace.CreateFace(eyeID, eyeOffset, mouthID, mouthOffset, detailID, detailOffset, detail2ID, detail2Offset); + GetComponentInChildren().EquipFace(face); + } + + internal void Call_AllGameFeel(Vector2 vector2) + { + data.view.RPC("RPCA_AllGameFeel", RpcTarget.All, vector2); + } + + [PunRPC] + internal void RPCA_AllGameFeel(Vector2 vector2) + { + GamefeelManager.instance.AddGameFeel(vector2); + } + + public void AssignPlayerID(int ID) + { + playerID = ID; + SetColors(); + if (!PhotonNetwork.OfflineMode) + { + Hashtable customProperties = PhotonNetwork.LocalPlayer.CustomProperties; + if (customProperties.ContainsKey("PlayerID")) + { + customProperties["PlayerID"] = playerID; + } + else + { + customProperties.Add("PlayerID", playerID); + } + PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties); + } + } + + internal float GetRadius() + { + return 5f; + } + + private void ReadPlayerID() + { + if (!PhotonNetwork.OfflineMode) + { + playerID = (int)data.view.Owner.CustomProperties["PlayerID"]; + SetColors(); + } + } + + public void AssignTeamID(int ID) + { + teamID = ID; + if (!PhotonNetwork.OfflineMode) + { + Hashtable customProperties = PhotonNetwork.LocalPlayer.CustomProperties; + if (customProperties.ContainsKey("TeamID")) + { + customProperties["TeamID"] = playerID; + } + else + { + customProperties.Add("TeamID", teamID); + } + PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties); + } + } + + private void ReadTeamID() + { + if (!PhotonNetwork.OfflineMode) + { + teamID = (int)data.view.Owner.CustomProperties["TeamID"]; + } + } + + public void SetColors() + { + SetTeamColor.TeamColorThis(base.gameObject, PlayerSkinBank.GetPlayerSkinColors(playerID)); + } + + public PlayerSkin GetTeamColors() + { + return PlayerSkinBank.GetPlayerSkinColors(playerID); + } + + internal void FullReset() + { + data.weaponHandler.NewGun(); + data.stats.ResetStats(); + data.block.ResetStats(); + } +} diff --git a/ROUNDS/_Player/PlayerAudioModifyers.cs b/ROUNDS/_Player/PlayerAudioModifyers.cs new file mode 100644 index 0000000..7f82b58 --- /dev/null +++ b/ROUNDS/_Player/PlayerAudioModifyers.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using UnityEngine; + +public class PlayerAudioModifyers : MonoBehaviour +{ + public List modifyers = new List(); + + public static List activeModifyer = new List(); + + public void AddToStack(CardAudioModifier mod) + { + int num = -1; + for (int i = 0; i < modifyers.Count; i++) + { + if (modifyers[i].modifier.stackName == mod.stackName) + { + num = i; + break; + } + } + if (num != -1) + { + modifyers[num].stacks++; + return; + } + AudioModifyer audioModifyer = new AudioModifyer(); + audioModifyer.modifier = new CardAudioModifier(); + audioModifyer.modifier.stackName = mod.stackName; + audioModifyer.modifier.stackType = mod.stackType; + audioModifyer.stacks = 1; + activeModifyer.Add(audioModifyer.modifier); + modifyers.Add(audioModifyer); + } + + public void SetStacks() + { + for (int i = 0; i < activeModifyer.Count; i++) + { + _ = activeModifyer[i].stackType; + _ = 1; + _ = activeModifyer[i].stackType; + } + for (int j = 0; j < modifyers.Count; j++) + { + _ = modifyers[j].modifier.stackType; + _ = 1; + _ = modifyers[j].modifier.stackType; + } + } +} diff --git a/ROUNDS/_Player/PlayerImmunity.cs b/ROUNDS/_Player/PlayerImmunity.cs new file mode 100644 index 0000000..791fadf --- /dev/null +++ b/ROUNDS/_Player/PlayerImmunity.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using UnityEngine; + +public class PlayerImmunity : MonoBehaviour +{ + private List immunities = new List(); + + private void Start() + { + } + + private void Update() + { + for (int num = immunities.Count - 1; num >= 0; num--) + { + immunities[num].time -= TimeHandler.deltaTime; + if (immunities[num].time <= 0f) + { + immunities.RemoveAt(num); + } + } + } + + public bool IsImune(float time, float dmg, string name) + { + for (int i = 0; i < immunities.Count; i++) + { + if (immunities[i].name == name) + { + if (dmg > immunities[i].dmg) + { + immunities[i].dmg = dmg; + immunities[i].name = name; + immunities[i].time = time; + return false; + } + return true; + } + } + immunities.Add(new Immunities(time, dmg, name)); + return false; + } +} diff --git a/ROUNDS/_Player/PlayerSounds.cs b/ROUNDS/_Player/PlayerSounds.cs new file mode 100644 index 0000000..aeffb32 --- /dev/null +++ b/ROUNDS/_Player/PlayerSounds.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using Sonigon; +using UnityEngine; + +public class PlayerSounds : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundCharacterJump; + + public SoundEvent soundCharacterJumpBig; + + public SoundEvent soundCharacterJumpEnsnare; + + public SoundEvent soundCharacterLand; + + public SoundEvent soundCharacterLandBig; + + private SoundParameterIntensity parameterIntensityLand = new SoundParameterIntensity(0f); + + public SoundEvent soundCharacterStickWall; + + public SoundEvent soundCharacterStickWallBig; + + private SoundParameterIntensity parameterIntensityStickWall = new SoundParameterIntensity(0f); + + public SoundEvent soundCharacterDamageScreenEdge; + + private CharacterData data; + + private List ensnareEffectList = new List(); + + private bool ensnareEnabled; + + public void AddEnsnareEffect(EnsnareEffect ensnareEffect) + { + ensnareEffectList.Add(ensnareEffect); + } + + public void RemoveEnsnareEffect(EnsnareEffect ensnareEffect) + { + ensnareEffectList.Remove(ensnareEffect); + } + + private void Start() + { + data = GetComponent(); + CharacterData characterData = data; + characterData.TouchGroundAction = (Action)Delegate.Combine(characterData.TouchGroundAction, new Action(TouchGround)); + CharacterData characterData2 = data; + characterData2.TouchWallAction = (Action)Delegate.Combine(characterData2.TouchWallAction, new Action(TouchWall)); + PlayerJump jump = data.jump; + jump.JumpAction = (Action)Delegate.Combine(jump.JumpAction, new Action(Jump)); + } + + public void Jump() + { + ensnareEnabled = false; + for (int num = ensnareEffectList.Count - 1; num >= 0; num--) + { + if (ensnareEffectList[num] == null) + { + ensnareEffectList.RemoveAt(num); + } + } + for (int i = 0; i < ensnareEffectList.Count; i++) + { + if (ensnareEffectList[i].soundEnsnareJumpChange) + { + ensnareEnabled = true; + } + } + if (ensnareEnabled) + { + if (ensnareEnabled) + { + SoundManager.Instance.Play(soundCharacterJumpEnsnare, base.transform); + } + } + else if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterJumpBig, base.transform); + } + else + { + SoundManager.Instance.Play(soundCharacterJump, base.transform); + } + } + + public void TouchGround(float sinceGrounded, Vector3 pos, Vector3 normal, Transform ground) + { + if (sinceGrounded > 0.05f) + { + parameterIntensityLand.intensity = sinceGrounded; + if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterLandBig, base.transform, parameterIntensityLand); + } + else + { + SoundManager.Instance.Play(soundCharacterLand, base.transform, parameterIntensityLand); + } + } + } + + public void TouchWall(float sinceWall, Vector3 pos, Vector3 normal) + { + float num = sinceWall; + if (data.sinceGrounded < num) + { + num = data.sinceGrounded; + } + if (num > 0.05f) + { + parameterIntensityStickWall.intensity = num; + if (data.stats.SoundTransformScaleThresholdReached()) + { + SoundManager.Instance.Play(soundCharacterStickWallBig, base.transform, parameterIntensityStickWall); + } + else + { + SoundManager.Instance.Play(soundCharacterStickWall, base.transform, parameterIntensityStickWall); + } + } + } +} diff --git a/ROUNDS/_Player/RotationHandler.cs b/ROUNDS/_Player/RotationHandler.cs new file mode 100644 index 0000000..121bda8 --- /dev/null +++ b/ROUNDS/_Player/RotationHandler.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public class RotationHandler : MonoBehaviour +{ + private CharacterData data; + + private PlayerVelocity rig; + + public float torque; + + private void Start() + { + data = GetComponent(); + rig = GetComponent(); + } + + private void FixedUpdate() + { + rig.AddTorque(torque * TimeHandler.timeScale * (Vector3.Angle(Vector3.up, base.transform.up) * Vector3.Cross(Vector3.up, base.transform.up).normalized).z); + } +} diff --git a/ROUNDS/_Player/SilenceHandler.cs b/ROUNDS/_Player/SilenceHandler.cs new file mode 100644 index 0000000..a1cab30 --- /dev/null +++ b/ROUNDS/_Player/SilenceHandler.cs @@ -0,0 +1,70 @@ +using Photon.Pun; +using UnityEngine; + +public class SilenceHandler : MonoBehaviour +{ + [Header("Settings")] + public CodeAnimation codeAnim; + + private Player player; + + private CharacterData data; + + private void Start() + { + player = GetComponent(); + data = player.data; + } + + private void Update() + { + if (data.silenceTime > 0f) + { + data.silenceTime -= TimeHandler.deltaTime; + if (!data.isSilenced) + { + StartSilence(); + } + } + else if (data.isSilenced) + { + StopSilence(); + } + } + + private void StartSilence() + { + player.data.input.silencedInput = true; + codeAnim.PlayIn(); + data.isSilenced = true; + } + + public void StopSilence() + { + player.data.input.silencedInput = false; + if (codeAnim.currentState == CodeAnimationInstance.AnimationUse.In) + { + codeAnim.PlayOut(); + } + data.isSilenced = false; + data.silenceTime = 0f; + } + + private void OnDisable() + { + codeAnim.transform.localScale = Vector3.zero; + } + + [PunRPC] + public void RPCA_AddSilence(float f) + { + if (f > data.silenceTime) + { + data.silenceTime = f; + } + if (!data.isSilenced) + { + StartSilence(); + } + } +} diff --git a/ROUNDS/_Player/StunHandler.cs b/ROUNDS/_Player/StunHandler.cs new file mode 100644 index 0000000..bb3f93e --- /dev/null +++ b/ROUNDS/_Player/StunHandler.cs @@ -0,0 +1,102 @@ +using Sonigon; +using UnityEngine; + +public class StunHandler : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundCharacterStunLoop; + + private bool soundStunIsPlaying; + + [Header("Settings")] + public CodeAnimation codeAnim; + + private Player player; + + private CharacterData data; + + private void Start() + { + player = GetComponent(); + data = player.data; + } + + private void Update() + { + if (data.stunTime > 0f) + { + data.stunTime -= TimeHandler.deltaTime; + data.sinceGrounded = 0f; + if (!data.isStunned) + { + StartStun(); + } + } + else if (data.isStunned) + { + StopStun(); + } + if (data.isStunned && data.isPlaying && !data.dead) + { + if (!soundStunIsPlaying) + { + soundStunIsPlaying = true; + SoundManager.Instance.Play(soundCharacterStunLoop, base.transform); + } + } + else if (soundStunIsPlaying) + { + soundStunIsPlaying = false; + SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); + } + } + + private void StartStun() + { + player.data.playerVel.velocity *= 0f; + player.data.playerVel.isKinematic = true; + player.data.input.stunnedInput = true; + codeAnim.PlayIn(); + data.isStunned = true; + } + + public void StopStun() + { + player.data.playerVel.isKinematic = false; + player.data.input.stunnedInput = false; + if (codeAnim.currentState == CodeAnimationInstance.AnimationUse.In) + { + codeAnim.PlayOut(); + } + data.isStunned = false; + data.stunTime = 0f; + } + + private void OnDisable() + { + codeAnim.transform.localScale = Vector3.zero; + soundStunIsPlaying = false; + SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); + } + + private void OnDestroy() + { + soundStunIsPlaying = false; + SoundManager.Instance.Stop(soundCharacterStunLoop, base.transform); + } + + public void AddStun(float f) + { + if (!data.block.IsBlocking()) + { + if (f > data.stunTime) + { + data.stunTime = f; + } + if (!data.isStunned) + { + StartStun(); + } + } + } +} diff --git a/ROUNDS/_Player/WeaponHandler.cs b/ROUNDS/_Player/WeaponHandler.cs new file mode 100644 index 0000000..35be82f --- /dev/null +++ b/ROUNDS/_Player/WeaponHandler.cs @@ -0,0 +1,173 @@ +using System.Collections; +using Sonigon; +using UnityEngine; + +public class WeaponHandler : MonoBehaviour +{ + [Header("Sounds")] + public SoundEvent soundCharacterCantShoot; + + private bool soundFireHold; + + [Header("Settings")] + public Gun gun; + + private Holding holding; + + private GeneralInput input; + + private CharacterData data; + + private float heatSinceAttack; + + private float heat; + + public float heatPerBullet = 0.1f; + + public float secondsBeforeStartToCool = 0.1f; + + public float coolPerSecond = 0.2f; + + public float overHeatTime = 1f; + + public float resetSpeed = 2f; + + public bool isOverHeated; + + private bool hasBeenHeated; + + public SpriteRenderer heatRenderer; + + private Transform overHeatPivot; + + public Color overHeatColor; + + private Color baseHeatColor; + + internal void DoReload() + { + gun.GetComponentInChildren().ReloadAmmo(); + } + + private void Awake() + { + holding = GetComponent(); + input = GetComponent(); + data = GetComponent(); + } + + private void Start() + { + overHeatPivot = heatRenderer.transform.parent; + baseHeatColor = heatRenderer.color; + } + + private void Update() + { + if (!gun.holdable.holder && (bool)data) + { + gun.holdable.holder = data; + } + if (data.playerVel.simulated) + { + gun.attackSpeedMultiplier = data.stats.attackSpeedMultiplier; + heatSinceAttack += TimeHandler.deltaTime; + Attack(); + OverHeat(); + } + } + + private void Attack() + { + if (!gun || !gun.IsReady()) + { + return; + } + if (input.shootIsPressed) + { + if (!soundFireHold) + { + soundFireHold = true; + if (gun.isReloading || data.isSilenced) + { + SoundManager.Instance.Play(soundCharacterCantShoot, base.transform); + } + } + } + else + { + soundFireHold = false; + } + if (gun.bursts == 0 && (!soundFireHold || gun.isReloading || data.isSilenced)) + { + gun.soundGun.StopAutoPlayTail(); + } + if ((!input.shootWasPressed || gun.useCharge) && (!input.shootWasReleased || !gun.useCharge) && (!(gun.attackSpeed / data.stats.attackSpeedMultiplier < 0.3f) || !input.shootIsPressed || gun.useCharge || gun.dontAllowAutoFire)) + { + return; + } + if (isOverHeated) + { + heatRenderer.GetComponent().PlayBoop(); + gun.sinceAttack = 0f; + return; + } + gun.Attack(0f); + if (heat >= 1f) + { + StartCoroutine(DoOverHeat()); + isOverHeated = true; + } + heatSinceAttack = 0f; + } + + internal void NewGun() + { + gun.ResetStats(); + gun.soundGun.ClearSoundModifiers(); + } + + private void OverHeat() + { + if (!isOverHeated) + { + if (heatSinceAttack > secondsBeforeStartToCool) + { + heat -= TimeHandler.deltaTime * coolPerSecond; + } + SetOverHeatColor(); + } + } + + private IEnumerator DoOverHeat() + { + SetOverHeatColor(); + yield return new WaitForSeconds(overHeatTime); + while (heat > 0f) + { + heat -= resetSpeed * TimeHandler.deltaTime; + SetOverHeatColor(); + yield return null; + } + isOverHeated = false; + } + + private void SetOverHeatColor() + { + heat = Mathf.Clamp(heat, 0f, 1f); + heatRenderer.color = Color.Lerp(baseHeatColor, overHeatColor, heat); + if (heat > 0.25f || hasBeenHeated) + { + hasBeenHeated = true; + overHeatPivot.transform.localScale = new Vector3(heat, 1f, 1f); + } + else + { + overHeatPivot.transform.localScale = new Vector3(0f, 1f, 1f); + } + if (heat == 0f) + { + hasBeenHeated = false; + } + } +} -- cgit v1.1-26-g67d0