From 894aa095cc2df809ea9d1db3516e7363826b00f2 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 21 Nov 2018 22:16:20 +0200 Subject: [PATCH] Format code --- src/CloudRegionCode.cs | 40 ++-- src/Fie.AI/FieAIControllerBase.cs | 8 +- src/Fie.AI/FieAIHateController.cs | 159 +++++++------- src/Fie.AI/FieAITaskApplejackBackstep.cs | 105 +++++----- src/Fie.AI/FieAITaskApplejackEnemyTracking.cs | 63 +++--- src/Fie.AI/FieAITaskApplejackIdle.cs | 137 ++++++------ src/Fie.AI/FieAITaskInterface.cs | 25 ++- .../FieAITaskRainbowDashEnemyTracking.cs | 44 ++-- src/Fie.AI/FieAITaskTwilightBase.cs | 33 ++- src/Fie.AI/FieAITaskTwilightSummonArrow.cs | 71 +++---- src/Fie.Core/FieBootstrap.cs | 36 ++-- src/Fie.DebugUtility/FieDebugGameSceneBoot.cs | 103 +++++---- .../FieEnemiesAnimationContainer.cs | 15 +- ...FieEnemiesHoovesRacesAnimationContainer.cs | 57 +++-- src/Fie.Fader/FieFader.cs | 44 ++-- src/Fie.Footstep/FieFootstepMaterial.cs | 42 ++-- src/Fie.Footstep/FieFootstepPlayer.cs | 35 ++-- src/Fie.Object/FieAnimationContainerBase.cs | 70 ++++--- src/Fie.Object/FieInputControllerBase.cs | 19 +- src/Fie.Utility/Wiggler.cs | 197 +++++++++--------- src/NetworkingPeer.cs | 36 ++-- src/TwilightMagicSphere.cs | 20 +- src/TwilightMagicSphereNormal.cs | 21 +- src/ValueList.cs | 17 +- 24 files changed, 696 insertions(+), 701 deletions(-) diff --git a/src/CloudRegionCode.cs b/src/CloudRegionCode.cs index 9454808..b0c39de 100644 --- a/src/CloudRegionCode.cs +++ b/src/CloudRegionCode.cs @@ -1,14 +1,28 @@ -public enum CloudRegionCode -{ - eu = 0, - us = 1, - asia = 2, - jp = 3, - au = 5, - usw = 6, - sa = 7, - cae = 8, - kr = 9, - @in = 10, - none = 4 + +/// +/// Country region codes for the remote cloud server +/// +public enum CloudRegionCode { + // Europe + eu = 0, + // United States + us = 1, + // Asia + asia = 2, + // Japone + jp = 3, + // Australia + au = 5, + // ??? + usw = 6, + // Saddle Arabia + sa = 7, + // ??? + cae = 8, + // ??? + kr = 9, + // India + @in = 10, + // None/Offline + none = 4 } diff --git a/src/Fie.AI/FieAIControllerBase.cs b/src/Fie.AI/FieAIControllerBase.cs index a2e19b0..d35d87d 100644 --- a/src/Fie.AI/FieAIControllerBase.cs +++ b/src/Fie.AI/FieAIControllerBase.cs @@ -1,8 +1,6 @@ using Fie.Object; -namespace Fie.AI -{ - public class FieAIControllerBase : FieInputControllerBase - { - } +namespace Fie.AI { + public class FieAIControllerBase : FieInputControllerBase { + } } diff --git a/src/Fie.AI/FieAIHateController.cs b/src/Fie.AI/FieAIHateController.cs index bc56b07..adf0217 100644 --- a/src/Fie.AI/FieAIHateController.cs +++ b/src/Fie.AI/FieAIHateController.cs @@ -3,97 +3,84 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -namespace Fie.AI -{ - public class FieAIHateController : FieAIControllerBase - { - private float MAXIMUM_STACKED_HATE = 6f; +namespace Fie.AI { + public class FieAIHateController : FieAIControllerBase { - private Dictionary _hateCorutine = new Dictionary(); + private float MAXIMUM_STACKED_HATE = 6; - private Dictionary _hateList = new Dictionary(); + private Dictionary _hateCorutine = new Dictionary(); - private void Start() - { - _ownerCharacter.damageSystem.damagedEvent += delegate(FieGameCharacter attacker, FieDamage damage) - { - if (!(attacker == null) && damage != null && PhotonNetwork.isMasterClient) - { - AddHate(attacker, damage.hate); - } - }; - } + private Dictionary _hateList = new Dictionary(); - private void AddHate(FieGameCharacter attaker, float hate) - { - if (!(attaker == null)) - { - int instanceID = attaker.GetInstanceID(); - if (_hateCorutine.ContainsKey(instanceID)) - { - StopCoroutine(_hateCorutine[instanceID]); - } - if (!_hateList.ContainsKey(instanceID)) - { - _hateList[instanceID] = hate; - } - else - { - _hateList[instanceID] = Mathf.Min(_hateList[instanceID] + hate, MAXIMUM_STACKED_HATE); - } - _hateCorutine[instanceID] = CalculateHateCoroutine(instanceID); - StartCoroutine(_hateCorutine[instanceID]); - } - } + private void Start() { + _ownerCharacter.damageSystem.damagedEvent += delegate (FieGameCharacter attacker, FieDamage damage) { + if (attacker != null && damage != null && PhotonNetwork.isMasterClient) { + AddHate(attacker, damage.hate); + } + }; + } - private void Update() - { - updateLockonTargetByHate(); - } + private void AddHate(FieGameCharacter attaker, float hate) { + if (!(attaker == null)) { + int instanceID = attaker.GetInstanceID(); - private void updateLockonTargetByHate() - { - if (_hateList.Count > 0) - { - bool flag = false; - int instanceId = 0; - float num = 0f; - foreach (KeyValuePair hate in _hateList) - { - if (num < hate.Value) - { - instanceId = hate.Key; - flag = true; - } - num = Mathf.Max(num, hate.Value); - } - if (flag) - { - _ownerCharacter.detector.ChangeLockonTargetByInstanceID(instanceId); - } - } - } + if (_hateCorutine.ContainsKey(instanceID)) { + StopCoroutine(_hateCorutine[instanceID]); + } - private IEnumerator CalculateHateCoroutine(int attackerInstanceId) - { - if (_hateList.ContainsKey(attackerInstanceId)) - { - Dictionary hateList; - int key; - (hateList = _hateList)[key = attackerInstanceId] = hateList[key] - Time.deltaTime; - if (!(_hateList[attackerInstanceId] <= 0f)) - { - yield return (object)0; - /*Error: Unable to find new state assignment for yield return*/; - } - _hateList.Remove(attackerInstanceId); - } - if (_hateCorutine.ContainsKey(attackerInstanceId)) - { - _hateCorutine.Remove(attackerInstanceId); - } - yield return (object)null; - /*Error: Unable to find new state assignment for yield return*/; - } - } + if (!_hateList.ContainsKey(instanceID)) { + _hateList[instanceID] = hate; + } else { + _hateList[instanceID] = Mathf.Min(_hateList[instanceID] + hate, MAXIMUM_STACKED_HATE); + } + + _hateCorutine[instanceID] = CalculateHateCoroutine(instanceID); + + StartCoroutine(_hateCorutine[instanceID]); + } + } + + private void Update() { + updateLockonTargetByHate(); + } + + private void updateLockonTargetByHate() { + if (_hateList.Count > 0) { + bool flag = false; + int instanceId = 0; + float num = 0; + + foreach (KeyValuePair hate in _hateList) { + if (num < hate.Value) { + instanceId = hate.Key; + flag = true; + } + num = Mathf.Max(num, hate.Value); + } + + if (flag) { + _ownerCharacter.detector.ChangeLockonTargetByInstanceID(instanceId); + } + } + } + + private IEnumerator CalculateHateCoroutine(int attackerInstanceId) { + if (_hateList.ContainsKey(attackerInstanceId)) { + + _hateList[attackerInstanceId] -= Time.deltaTime; + + if (_hateList[attackerInstanceId] > 0) { + yield return 0; + } + + _hateList.Remove(attackerInstanceId); + } + + if (_hateCorutine.ContainsKey(attackerInstanceId)) { + _hateCorutine.Remove(attackerInstanceId); + } + + yield return null; + } + } } diff --git a/src/Fie.AI/FieAITaskApplejackBackstep.cs b/src/Fie.AI/FieAITaskApplejackBackstep.cs index d3988bc..da34e9f 100644 --- a/src/Fie.AI/FieAITaskApplejackBackstep.cs +++ b/src/Fie.AI/FieAITaskApplejackBackstep.cs @@ -2,63 +2,60 @@ using Fie.Object; using Fie.Ponies.Applejack; using UnityEngine; -namespace Fie.AI -{ - public class FieAITaskApplejackBackstep : FieAITaskBase - { - private enum StepState - { - STATE_PREPARE, - STATE_STEP - } +namespace Fie.AI { + public class FieAITaskApplejackBackstep : FieAITaskBase { + private enum StepState { + STATE_PREPARE, + STATE_STEP + } - private const float ATTACK_DISTANCE = 15f; + private const float ATTACK_DISTANCE = 15f; - private bool _isEndState; + private bool _isEndState; - private StepState _stepState; + private StepState _stepState; - public override void Initialize(FieAITaskController manager) - { - _isEndState = false; - _stepState = StepState.STATE_PREPARE; - } + public override void Initialize(FieAITaskController manager) { + _isEndState = false; + _stepState = StepState.STATE_PREPARE; + } - public override bool Task(FieAITaskController manager) - { - if (manager.ownerCharacter.groundState != 0) - { - return true; - } - switch (_stepState) - { - case StepState.STATE_PREPARE: - { - Vector3 directionalVec = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); - manager.ownerCharacter.RequestToChangeState(directionalVec, 1f, FieGameCharacter.StateMachineType.Base); - FieStateMachineInterface currentStateMachine = manager.ownerCharacter.getStateMachine().getCurrentStateMachine(); - if (currentStateMachine is FieStateMachineApplejackEvasion || currentStateMachine is FieStateMachineApplejackBackstep || currentStateMachine is FieStateMachineApplejackCharge) - { - currentStateMachine.stateChangeEvent += delegate - { - _isEndState = true; - }; - _stepState = StepState.STATE_STEP; - } - else - { - _isEndState = true; - } - break; - } - case StepState.STATE_STEP: - if (_isEndState) - { - return true; - } - break; - } - return false; - } - } + public override bool Task(FieAITaskController manager) { + if (manager.ownerCharacter.groundState != 0) { + return true; + } + switch (_stepState) { + case StepState.STATE_PREPARE: { + Vector3 directionalVec = new Vector3( + Random.Range(-1f, 1f), + Random.Range(-1f, 1f), + Random.Range(-1f, 1f) + ); + + manager.ownerCharacter.RequestToChangeState(directionalVec, 1f, FieGameCharacter.StateMachineType.Base); + + FieStateMachineInterface currentStateMachine = manager.ownerCharacter.getStateMachine().getCurrentStateMachine(); + + if (currentStateMachine is FieStateMachineApplejackEvasion + || currentStateMachine is FieStateMachineApplejackBackstep + || currentStateMachine is FieStateMachineApplejackCharge) { + + currentStateMachine.stateChangeEvent += delegate { + _isEndState = true; + }; + _stepState = StepState.STATE_STEP; + } else { + _isEndState = true; + } + break; + } + case StepState.STATE_STEP: + if (_isEndState) { + return true; + } + break; + } + return false; + } + } } diff --git a/src/Fie.AI/FieAITaskApplejackEnemyTracking.cs b/src/Fie.AI/FieAITaskApplejackEnemyTracking.cs index ddb1e35..8f4cdef 100644 --- a/src/Fie.AI/FieAITaskApplejackEnemyTracking.cs +++ b/src/Fie.AI/FieAITaskApplejackEnemyTracking.cs @@ -2,34 +2,37 @@ using Fie.Ponies; using Fie.Ponies.Applejack; using UnityEngine; -namespace Fie.AI -{ - public class FieAITaskApplejackEnemyTracking : FieAITaskBase - { - public override bool Task(FieAITaskController manager) - { - if (manager.ownerCharacter.detector.lockonTargetObject == null) - { - return true; - } - float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); - if (!(num > 2f)) - { - Vector3 position = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position; - float y = position.y; - Vector3 position2 = manager.ownerCharacter.transform.position; - if (y > position2.y + 5f && manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) - { - nextStateWeightList[typeof(FieStateMachineApplejackRope)] = 100; - return true; - } - return true; - } - Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; - vector.y = vector.z; - vector.z = 0f; - manager.ownerCharacter.RequestToChangeState(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base); - return false; - } - } +namespace Fie.AI { + public class FieAITaskApplejackEnemyTracking : FieAITaskBase { + public override bool Task(FieAITaskController manager) { + if (manager.ownerCharacter.detector.lockonTargetObject == null) { + return true; + } + + float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); + + if (!(num > 2f)) { + Vector3 position = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position; + + float y = position.y; + + Vector3 position2 = manager.ownerCharacter.transform.position; + + if (y > position2.y + 5f && manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) { + nextStateWeightList[typeof(FieStateMachineApplejackRope)] = 100; + + return true; + } + + return true; + } + + Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; + vector.y = vector.z; + vector.z = 0f; + manager.ownerCharacter.RequestToChangeState(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base); + + return false; + } + } } diff --git a/src/Fie.AI/FieAITaskApplejackIdle.cs b/src/Fie.AI/FieAITaskApplejackIdle.cs index 03f1d0c..7f16995 100644 --- a/src/Fie.AI/FieAITaskApplejackIdle.cs +++ b/src/Fie.AI/FieAITaskApplejackIdle.cs @@ -4,82 +4,67 @@ using Fie.Ponies; using Fie.Ponies.Applejack; using UnityEngine; -namespace Fie.AI -{ - public class FieAITaskApplejackIdle : FieAITaskBase - { - private FieGameCharacter injuryCharacter; +namespace Fie.AI { + public class FieAITaskApplejackIdle : FieAITaskBase { + private FieGameCharacter injuryCharacter; - public override void Initialize(FieAITaskController manager) - { - if (Random.Range(0f, 100f) > 50f) - { - FieGameCharacter randomEnemyGameCharacter = manager.ownerCharacter.detector.getRandomEnemyGameCharacter(); - if (randomEnemyGameCharacter != null) - { - manager.ownerCharacter.detector.ChangeLockonTargetByInstanceID(randomEnemyGameCharacter.GetInstanceID()); - } - } - injuryCharacter = FieManagerBehaviour.I.GetNearbyInjuryAllyCharacter(manager.ownerCharacter); - } + public override void Initialize(FieAITaskController manager) { + if (Random.Range(0f, 100f) > 50f) { + FieGameCharacter randomEnemyGameCharacter = manager.ownerCharacter.detector.getRandomEnemyGameCharacter(); + if (randomEnemyGameCharacter != null) { + manager.ownerCharacter.detector.ChangeLockonTargetByInstanceID(randomEnemyGameCharacter.GetInstanceID()); + } + } + injuryCharacter = FieManagerBehaviour.I.GetNearbyInjuryAllyCharacter(manager.ownerCharacter); + } - public override bool Task(FieAITaskController manager) - { - if (manager.ownerCharacter.groundState != 0) - { - return false; - } - if (manager.ownerCharacter.damageSystem.isDead) - { - if (manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 3) - { - (manager.ownerCharacter as FiePonies).TryToRevive(); - } - return true; - } - if (injuryCharacter != null && manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 2) - { - nextStateWeightList[typeof(FieAITaskPoniesRescue)] = 100; - return true; - } - float num = Vector3.Distance(manager.ownerCharacter.transform.position, FieManagerBehaviour.I.gameOwnerCharacter.transform.position); - if (manager.ownerCharacter.detector.lockonTargetObject == null) - { - if (num > 2.5f) - { - nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; - return true; - } - return false; - } - float num2 = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.position); - if (num2 > 4.5f) - { - nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; - return true; - } - if (num2 > 2.5f) - { - nextStateWeightList[typeof(FieAITaskApplejackEnemyTracking)] = 500; - if (manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) - { - nextStateWeightList[typeof(FieAITaskApplejackRope)] = 500; - } - return true; - } - if (manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f && manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) - { - nextStateWeightList[typeof(FieAITaskApplejackStomp)] = (int)Mathf.Max(1000f * manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax, 100f); - nextStateWeightList[typeof(FieAITaskApplejackYeehaw)] = (int)Mathf.Max(2000f * (1f - manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax), 500f); - return true; - } - nextStateWeightList[typeof(FieAITaskApplejackBackstep)] = 200; - if (manager.ownerCharacter.groundState == FieObjectGroundState.Grounding) - { - nextStateWeightList[typeof(FieAITaskApplejackJump)] = 200; - } - nextStateWeightList[typeof(FieAITaskApplejackMelee)] = 200; - return true; - } - } + public override bool Task(FieAITaskController manager) { + if (manager.ownerCharacter.groundState != 0) { + return false; + } + if (manager.ownerCharacter.damageSystem.isDead) { + if (manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 3) { + (manager.ownerCharacter as FiePonies).TryToRevive(); + } + return true; + } + if (injuryCharacter != null && manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 2) { + nextStateWeightList[typeof(FieAITaskPoniesRescue)] = 100; + return true; + } + float num = Vector3.Distance(manager.ownerCharacter.transform.position, FieManagerBehaviour.I.gameOwnerCharacter.transform.position); + if (manager.ownerCharacter.detector.lockonTargetObject == null) { + if (num > 2.5f) { + nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; + return true; + } + return false; + } + float num2 = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.position); + if (num2 > 4.5f) { + nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; + return true; + } + if (num2 > 2.5f) { + nextStateWeightList[typeof(FieAITaskApplejackEnemyTracking)] = 500; + if (manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) { + nextStateWeightList[typeof(FieAITaskApplejackRope)] = 500; + } + return true; + } + if (manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f && manager.ownerCharacter.abilitiesContainer.GetCooltime() <= 0f) { + nextStateWeightList[typeof(FieAITaskApplejackStomp)] = (int)Mathf.Max(1000f * manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax, 100f); + nextStateWeightList[typeof(FieAITaskApplejackYeehaw)] = (int)Mathf.Max(2000f * (1f - manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax), 500f); + return true; + } + + nextStateWeightList[typeof(FieAITaskApplejackBackstep)] = 200; + + if (manager.ownerCharacter.groundState == FieObjectGroundState.Grounding) { + nextStateWeightList[typeof(FieAITaskApplejackJump)] = 200; + } + nextStateWeightList[typeof(FieAITaskApplejackMelee)] = 200; + return true; + } + } } diff --git a/src/Fie.AI/FieAITaskInterface.cs b/src/Fie.AI/FieAITaskInterface.cs index 00b0aa2..d4ad756 100644 --- a/src/Fie.AI/FieAITaskInterface.cs +++ b/src/Fie.AI/FieAITaskInterface.cs @@ -1,14 +1,23 @@ using System; using System.Collections.Generic; -namespace Fie.AI -{ - public interface FieAITaskInterface - { - bool TaskExec(FieAITaskController manager); +namespace Fie.AI { + /// + /// An AI task that a character can perform. Called to handle movement/targetting/etc. + /// + public interface FieAITaskInterface { + /// + /// Runs this task. + /// + /// The manager responsible for calling this task + /// + bool TaskExec(FieAITaskController manager); - bool Task(FieAITaskController manager); + bool Task(FieAITaskController manager); - Dictionary GetWeight(); - } + /// + /// Gets a relative importance mapping for this task given different targets and contexts. + /// + Dictionary GetWeight(); + } } diff --git a/src/Fie.AI/FieAITaskRainbowDashEnemyTracking.cs b/src/Fie.AI/FieAITaskRainbowDashEnemyTracking.cs index 524803b..721dc8a 100644 --- a/src/Fie.AI/FieAITaskRainbowDashEnemyTracking.cs +++ b/src/Fie.AI/FieAITaskRainbowDashEnemyTracking.cs @@ -1,26 +1,26 @@ using Fie.Ponies; using UnityEngine; -namespace Fie.AI -{ - public class FieAITaskRainbowDashEnemyTracking : FieAITaskBase - { - public override bool Task(FieAITaskController manager) - { - if (manager.ownerCharacter.detector.lockonTargetObject == null) - { - return true; - } - float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); - if (!(num > 2f)) - { - return true; - } - Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; - vector.y = vector.z; - vector.z = 0f; - manager.ownerCharacter.RequestToChangeState(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base); - return false; - } - } +namespace Fie.AI { + public class FieAITaskRainbowDashEnemyTracking : FieAITaskBase { + public override bool Task(FieAITaskController manager) { + if (manager.ownerCharacter.detector.lockonTargetObject == null) { + return true; + } + + float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); + + if (num <= 2) { + return true; + } + + Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; + vector.y = vector.z; + vector.z = 0f; + + manager.ownerCharacter.RequestToChangeState(vector.normalized, 1, FieGameCharacter.StateMachineType.Base); + + return false; + } + } } diff --git a/src/Fie.AI/FieAITaskTwilightBase.cs b/src/Fie.AI/FieAITaskTwilightBase.cs index f0118db..bea20a7 100644 --- a/src/Fie.AI/FieAITaskTwilightBase.cs +++ b/src/Fie.AI/FieAITaskTwilightBase.cs @@ -1,21 +1,20 @@ using Fie.Ponies; using UnityEngine; -namespace Fie.AI -{ - public abstract class FieAITaskTwilightBase : FieAITaskBase - { - protected bool AdjustDirectionByBasicMovement(FieAITaskController manager) - { - if (manager.ownerCharacter.detector.lockonTargetObject.flipDirectionVector != manager.ownerCharacter.flipDirectionVector) - { - return false; - } - Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.position - manager.ownerCharacter.transform.position; - vector.y = vector.z; - vector.z = 0f; - manager.ownerCharacter.RequestToChangeState(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base); - return true; - } - } +namespace Fie.AI { + public abstract class FieAITaskTwilightBase : FieAITaskBase { + protected bool AdjustDirectionByBasicMovement(FieAITaskController manager) { + if (manager.ownerCharacter.detector.lockonTargetObject.flipDirectionVector != manager.ownerCharacter.flipDirectionVector) { + return false; + } + + Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.position - manager.ownerCharacter.transform.position; + vector.y = vector.z; + vector.z = 0; + + manager.ownerCharacter.RequestToChangeState(vector.normalized, 1, FieGameCharacter.StateMachineType.Base); + + return true; + } + } } diff --git a/src/Fie.AI/FieAITaskTwilightSummonArrow.cs b/src/Fie.AI/FieAITaskTwilightSummonArrow.cs index b3a137a..9716f66 100644 --- a/src/Fie.AI/FieAITaskTwilightSummonArrow.cs +++ b/src/Fie.AI/FieAITaskTwilightSummonArrow.cs @@ -2,49 +2,40 @@ using Fie.Object; using Fie.Ponies.Twilight; using UnityEngine; -namespace Fie.AI -{ - public class FieAITaskTwilightSummonArrow : FieAITaskTwilightBase - { - private bool _isEnd; +namespace Fie.AI { + /// + /// Summons a magic bold + /// + public class FieAITaskTwilightSummonArrow : FieAITaskTwilightBase { + private bool _isEnd; - public override void Initialize(FieAITaskController manager) - { - _isEnd = false; - manager.ownerCharacter.damageSystem.staggerEvent += healthSystem_staggerEvent; - manager.ownerCharacter.damageSystem.damagedEvent += HealthSystem_damagedEvent; - } + public override void Initialize(FieAITaskController manager) { + _isEnd = false; + manager.ownerCharacter.damageSystem.staggerEvent += healthSystem_staggerEvent; + manager.ownerCharacter.damageSystem.damagedEvent += HealthSystem_damagedEvent; + } - public override void Terminate(FieAITaskController manager) - { - manager.ownerCharacter.damageSystem.staggerEvent -= healthSystem_staggerEvent; - manager.ownerCharacter.damageSystem.damagedEvent -= HealthSystem_damagedEvent; - } + public override void Terminate(FieAITaskController manager) { + manager.ownerCharacter.damageSystem.staggerEvent -= healthSystem_staggerEvent; + manager.ownerCharacter.damageSystem.damagedEvent -= HealthSystem_damagedEvent; + } - private void HealthSystem_damagedEvent(FieGameCharacter attacker, FieDamage damage) - { - nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; - _isEnd = true; - } + private void HealthSystem_damagedEvent(FieGameCharacter attacker, FieDamage damage) { + nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; + _isEnd = true; + } - private void healthSystem_staggerEvent(FieDamage damageObject) - { - nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; - _isEnd = true; - } + private void healthSystem_staggerEvent(FieDamage damageObject) { + nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; + _isEnd = true; + } - public override bool Task(FieAITaskController manager) - { - if (_isEnd) - { - return true; - } - if (manager.ownerCharacter.detector.lockonTargetObject == null) - { - return true; - } - manager.ownerCharacter.RequestToChangeState(Vector3.zero, 0f, FieGameCharacter.StateMachineType.Attack); - return true; - } - } + public override bool Task(FieAITaskController manager) { + if (!_isEnd && manager.ownerCharacter.detector.lockonTargetObject != null) { + manager.ownerCharacter.RequestToChangeState(Vector3.zero, 0, FieGameCharacter.StateMachineType.Attack); + } + + return true; + } + } } diff --git a/src/Fie.Core/FieBootstrap.cs b/src/Fie.Core/FieBootstrap.cs index bf1e543..3d3d2b3 100644 --- a/src/Fie.Core/FieBootstrap.cs +++ b/src/Fie.Core/FieBootstrap.cs @@ -2,20 +2,32 @@ using Fie.Manager; using Fie.Scene; using UnityEngine; -namespace Fie.Core -{ - public class FieBootstrap : MonoBehaviour - { - private static bool _isBootedFromBootStrap; +namespace Fie.Core { + /// + /// Entry-point for Fie. Everything starts here. + /// + public class FieBootstrap : MonoBehaviour { + public static bool isBootedFromBootStrap { get; private set; }; - public static bool isBootedFromBootStrap => _isBootedFromBootStrap; - - private void Start() - { + /// + /// Starts the game. Loads the title screen. + /// + private void Start() { FieManagerFactory.I.StartUp(); - FieManagerBehaviour.I.LoadScene(new FieSceneTitle(), allowSceneActivation: true, FieFaderManager.FadeType.OUT_TO_WHITE, FieFaderManager.FadeType.IN_FROM_WHITE, 1.5f); - _isBootedFromBootStrap = true; - FieManagerBehaviour.I.ChangeMixerVolume(0f, 0.5f, FieAudioManager.FieAudioMixerType.BGM, FieAudioManager.FieAudioMixerType.Voice, FieAudioManager.FieAudioMixerType.SE); + FieManagerBehaviour.I.LoadScene(new FieSceneTitle(), allowSceneActivation: true, + FieFaderManager.FadeType.OUT_TO_WHITE, + FieFaderManager.FadeType.IN_FROM_WHITE, + 1.5f + ); + + isBootedFromBootStrap = true; + + FieManagerBehaviour.I.ChangeMixerVolume(0f, 0.5f, + FieAudioManager.FieAudioMixerType.BGM, + FieAudioManager.FieAudioMixerType.Voice, + FieAudioManager.FieAudioMixerType.SE + ); + UnityEngine.Object.Destroy(base.gameObject); } } diff --git a/src/Fie.DebugUtility/FieDebugGameSceneBoot.cs b/src/Fie.DebugUtility/FieDebugGameSceneBoot.cs index b51caf5..c4b8b23 100644 --- a/src/Fie.DebugUtility/FieDebugGameSceneBoot.cs +++ b/src/Fie.DebugUtility/FieDebugGameSceneBoot.cs @@ -5,63 +5,60 @@ using GameDataEditor; using System.Collections.Generic; using UnityEngine; -namespace Fie.DebugUtility -{ - public class FieDebugGameSceneBoot : MonoBehaviour - { - [Range(1f, 3f)] - [SerializeField] - private int playerNum = 1; +namespace Fie.DebugUtility { + public class FieDebugGameSceneBoot : MonoBehaviour { + [Range(1f, 3f)] + [SerializeField] + private int playerNum = 1; - [SerializeField] - private List _debugCharacters = new List(); + [SerializeField] + private List _debugCharacters = new List(); - [SerializeField] - private List _debugCharactersIntelligenceTypes = new List(); + [SerializeField] + private List _debugCharactersIntelligenceTypes = new List(); - [SerializeField] - private List _debugCharactersNames = new List(); + [SerializeField] + private List _debugCharactersNames = new List(); - [SerializeField] - private List _debugSkills = new List(); + [SerializeField] + private List _debugSkills = new List(); - private void Awake() - { - if (!FieBootstrap.isBootedFromBootStrap && _debugCharacters.Count == _debugCharactersIntelligenceTypes.Count && _debugCharactersIntelligenceTypes.Count == _debugCharactersNames.Count && _debugCharacters.Count == _debugCharactersNames.Count) - { - PhotonNetwork.offlineMode = true; - PhotonNetwork.InstantiateInRoomOnly = false; - FieManagerFactory.I.currentSceneType = FieSceneType.INGAME; - FieManagerBehaviour.I.StartUp(); - FieManagerBehaviour.I.StartUp(); - FieManagerBehaviour.I.StartUp(); - FieManagerBehaviour.I.StartUp(); - FieManagerBehaviour.I.nowPlayerNum = playerNum; - FieManagerBehaviour.I.StartUp(); - List list = FieMasterData.FindMasterDataList(delegate(GDESkillTreeData data) - { - if (_debugSkills.Contains((FieConstValues.FieSkill)data.ID)) - { - return true; - } - return false; - }); - for (int i = 0; i < playerNum; i++) - { - _debugCharacters[i].intelligenceType = _debugCharactersIntelligenceTypes[i]; - if (list != null && list.Count > 0) - { - FieSaveManager.debugSkills = list; - } - FieManagerBehaviour.I.SetUserName(i, _debugCharactersNames[i]); - FieManagerBehaviour.I.SetUserCharacterPrefab(i, _debugCharacters[i]); - } - } - } + private void Awake() { + if (!FieBootstrap.isBootedFromBootStrap + && _debugCharacters.Count == _debugCharactersIntelligenceTypes.Count + && _debugCharactersIntelligenceTypes.Count == _debugCharactersNames.Count + && _debugCharacters.Count == _debugCharactersNames.Count) { - private void Start() - { - FieManagerBehaviour.I.StartUp(); - } - } + PhotonNetwork.offlineMode = true; + PhotonNetwork.InstantiateInRoomOnly = false; + + FieManagerFactory.I.currentSceneType = FieSceneType.INGAME; + FieManagerBehaviour.I.StartUp(); + FieManagerBehaviour.I.StartUp(); + FieManagerBehaviour.I.StartUp(); + FieManagerBehaviour.I.StartUp(); + FieManagerBehaviour.I.nowPlayerNum = playerNum; + FieManagerBehaviour.I.StartUp(); + + List list = FieMasterData.FindMasterDataList(delegate (GDESkillTreeData data) { + return _debugSkills.Contains((FieConstValues.FieSkill)data.ID); + }); + + for (int i = 0; i < playerNum; i++) { + _debugCharacters[i].intelligenceType = _debugCharactersIntelligenceTypes[i]; + + if (list != null && list.Count > 0) { + FieSaveManager.debugSkills = list; + } + + FieManagerBehaviour.I.SetUserName(i, _debugCharactersNames[i]); + FieManagerBehaviour.I.SetUserCharacterPrefab(i, _debugCharacters[i]); + } + } + } + + private void Start() { + FieManagerBehaviour.I.StartUp(); + } + } } diff --git a/src/Fie.Enemies/FieEnemiesAnimationContainer.cs b/src/Fie.Enemies/FieEnemiesAnimationContainer.cs index e57ff28..400e9e4 100644 --- a/src/Fie.Enemies/FieEnemiesAnimationContainer.cs +++ b/src/Fie.Enemies/FieEnemiesAnimationContainer.cs @@ -1,12 +1,9 @@ using Fie.Object; -namespace Fie.Enemies -{ - public class FieEnemiesAnimationContainer : FieAnimationContainerBase - { - public FieEnemiesAnimationContainer() - { - addAnimationData(0, new FieSkeletonAnimationObject(0, "idle")); - } - } +namespace Fie.Enemies { + public class FieEnemiesAnimationContainer : FieAnimationContainerBase { + public FieEnemiesAnimationContainer() { + addAnimationData(0, new FieSkeletonAnimationObject(0, "idle")); + } + } } diff --git a/src/Fie.Enemies/FieEnemiesHoovesRacesAnimationContainer.cs b/src/Fie.Enemies/FieEnemiesHoovesRacesAnimationContainer.cs index 338562b..a1ff481 100644 --- a/src/Fie.Enemies/FieEnemiesHoovesRacesAnimationContainer.cs +++ b/src/Fie.Enemies/FieEnemiesHoovesRacesAnimationContainer.cs @@ -1,36 +1,31 @@ using Fie.Object; -namespace Fie.Enemies -{ - public class FieEnemiesHoovesRacesAnimationContainer : FieEnemiesAnimationContainer - { - public enum HoovesRacesAnimTrack - { - HORN = 2, - MAX_HOOVES_RACES_TRACK - } +namespace Fie.Enemies { + public class FieEnemiesHoovesRacesAnimationContainer : FieEnemiesAnimationContainer { + public enum HoovesRacesAnimTrack { + HORN = 2, + MAX_HOOVES_RACES_TRACK + } - public enum HoovesRacesAnimList - { - WALK = 1, - GALLOP, - STAGGER, - STAGGER_AIR, - STAGGER_FALL, - STAGGER_FALL_RECOVER, - DEAD, - MAX_HOOVES_RACES_ANIMATION - } + public enum HoovesRacesAnimList { + WALK = 1, + GALLOP, + STAGGER, + STAGGER_AIR, + STAGGER_FALL, + STAGGER_FALL_RECOVER, + DEAD, + MAX_HOOVES_RACES_ANIMATION + } - public FieEnemiesHoovesRacesAnimationContainer() - { - addAnimationData(1, new FieSkeletonAnimationObject(0, "walk")); - addAnimationData(2, new FieSkeletonAnimationObject(0, "gallop")); - addAnimationData(3, new FieSkeletonAnimationObject(0, "stagger")); - addAnimationData(4, new FieSkeletonAnimationObject(0, "stagger_air")); - addAnimationData(5, new FieSkeletonAnimationObject(0, "stagger_fall")); - addAnimationData(6, new FieSkeletonAnimationObject(0, "stagger_fall_recover")); - addAnimationData(7, new FieSkeletonAnimationObject(0, "dead")); - } - } + public FieEnemiesHoovesRacesAnimationContainer() { + addAnimationData(1, new FieSkeletonAnimationObject(0, "walk")); + addAnimationData(2, new FieSkeletonAnimationObject(0, "gallop")); + addAnimationData(3, new FieSkeletonAnimationObject(0, "stagger")); + addAnimationData(4, new FieSkeletonAnimationObject(0, "stagger_air")); + addAnimationData(5, new FieSkeletonAnimationObject(0, "stagger_fall")); + addAnimationData(6, new FieSkeletonAnimationObject(0, "stagger_fall_recover")); + addAnimationData(7, new FieSkeletonAnimationObject(0, "dead")); + } + } } diff --git a/src/Fie.Fader/FieFader.cs b/src/Fie.Fader/FieFader.cs index afbabc6..ab41054 100644 --- a/src/Fie.Fader/FieFader.cs +++ b/src/Fie.Fader/FieFader.cs @@ -5,6 +5,9 @@ using UnityEngine.UI; namespace Fie.Fader { + /// + /// Fader used to white out the screen whilst the game is loading. + /// public class FieFader : MonoBehaviour { [SerializeField] @@ -13,52 +16,61 @@ namespace Fie.Fader [SerializeField] private Image faderPlaneObject; + /// + /// The loading icon that appears in the lower right corner. + /// [SerializeField] private SkeletonGraphic _loadingIcon; private Tweener faderTweener = new Tweener(); + /// + /// True if the loading screen is currently visible. + /// private bool isDrawFader; - public void Initialize() - { + public void Initialize() { faderCameraRootObject.transform.gameObject.SetActive(value: false); } - public void HideFader() - { + public void HideFader() { isDrawFader = false; faderCameraRootObject.transform.gameObject.SetActive(value: false); } - public void InitFader(Vector4 startColor, Vector4 endColor, float time) - { + /// + /// Creates this view, sets it to visible, and starts showing the loading screen. + /// + public void InitFader(Vector4 startColor, Vector4 endColor, float time) { isDrawFader = true; faderTweener.InitTweener(time, startColor, endColor); faderCameraRootObject.transform.gameObject.SetActive(value: true); } - public bool IsEndUpdateFader() - { + /// + /// Checks if the loading screen is still fading in/our and returns false otherwise. + /// + public bool IsEndUpdateFader() { return faderTweener == null || faderTweener.IsEnd(); } - private void Update() - { - if (isDrawFader) - { + /// + /// Draws the loading screen. Currently just a plain white background. + /// + private void Update() { + if (isDrawFader) { Color color = faderTweener.UpdateParameterVec4(Time.deltaTime); faderPlaneObject.color = color; _loadingIcon.color = new Color(1f, 1f, 1f, color.a); } } - public void ShowLoadScreen() - { + public void ShowLoadScreen() { + // TODO: Implement this } - public void HideLoadScreen() - { + public void HideLoadScreen() { + // TODO: Implement this } } } diff --git a/src/Fie.Footstep/FieFootstepMaterial.cs b/src/Fie.Footstep/FieFootstepMaterial.cs index 18a94ff..78a9716 100644 --- a/src/Fie.Footstep/FieFootstepMaterial.cs +++ b/src/Fie.Footstep/FieFootstepMaterial.cs @@ -2,41 +2,53 @@ using Fie.Utility; using System.Collections.Generic; using UnityEngine; -namespace Fie.Footstep -{ - public class FieFootstepMaterial : MonoBehaviour - { +namespace Fie.Footstep { + /// + /// Plays the footstep animations created as players or enemies move around. + /// + public class FieFootstepMaterial : MonoBehaviour { [SerializeField] private float _audioVolume = 0.5f; [SerializeField] private List _audioClips = new List(); + /// + /// The particle material to spawn under an entity's hooves as they walk. + /// [SerializeField] private Material _footStepParticleMaterial; + /// + /// A lotto of audio clips to play. Provides a random one when queried. + /// private Lottery _lottery = new Lottery(); + /// + /// The pool of sounds that can be played by this material. + /// public List audioClips => _audioClips; - private void Awake() - { - foreach (AudioClip audioClip in _audioClips) - { - _lottery.AddItem(audioClip); + private void Awake() { + foreach (AudioClip audioClip in _audioClips) { + _lottery.AddItem(audioClip); // add each audio clip to the lottery } } - public void playFootstepAudio(FieFootstepPlayer player) - { - if (!(player == null) && _lottery.IsExecutable()) - { + /// + /// Attempts to play an audio clip for the given footstep player. + /// Accepts nulls. + /// + public void playFootstepAudio(FieFootstepPlayer player) { + if (!(player == null) && _lottery.IsExecutable()) { AudioClip audioClip = _lottery.Lot(); - if (!(audioClip == null)) - { + + if (!(audioClip == null)) { player.SetMaterial(_footStepParticleMaterial); + player.audioSource.pitch = player.pitchOffset; player.audioSource.PlayOneShot(audioClip, _audioVolume); + player.EmitFootstepParticle(audioClip.length); } } diff --git a/src/Fie.Footstep/FieFootstepPlayer.cs b/src/Fie.Footstep/FieFootstepPlayer.cs index d017a42..3d6c45d 100644 --- a/src/Fie.Footstep/FieFootstepPlayer.cs +++ b/src/Fie.Footstep/FieFootstepPlayer.cs @@ -2,10 +2,11 @@ using ParticlePlayground; using UnityEngine; using UnityEngine.SceneManagement; -namespace Fie.Footstep -{ - public class FieFootstepPlayer : MonoBehaviour - { +namespace Fie.Footstep { + /// + /// An audio player for playing audio clips under a player. + /// + public class FieFootstepPlayer : MonoBehaviour { [SerializeField] private AudioSource _audioSource; @@ -21,35 +22,31 @@ namespace Fie.Footstep public float pitchOffset => _pitchOffset; - public void EmitFootstepParticle(float duration) - { + public void EmitFootstepParticle(float duration) { _particleDuration = duration; } - public void SetMaterial(Material material) - { + public void SetMaterial(Material material) { _particle.particleSystemRenderer.material = material; } - private void Update() - { - bool flag = _particleDuration > 0f; + private void Update() { + bool flag = _particleDuration > 0; _particle.emit = flag; - if (flag) - { + if (flag) { _particleDuration -= Time.deltaTime; } } - private void Awake() - { + private void Awake() { SceneManager.sceneLoaded += SceneManager_sceneLoaded; } - private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene arg0, LoadSceneMode arg1) - { - if ((bool)_particle) - { + /// + /// Called when the scene is loaded. + /// + private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene scene, LoadSceneMode mode) { + if ((bool)_particle) { _particle.Start(); } } diff --git a/src/Fie.Object/FieAnimationContainerBase.cs b/src/Fie.Object/FieAnimationContainerBase.cs index 54334d6..5ea4402 100644 --- a/src/Fie.Object/FieAnimationContainerBase.cs +++ b/src/Fie.Object/FieAnimationContainerBase.cs @@ -1,41 +1,45 @@ using System.Collections.Generic; -namespace Fie.Object -{ - public abstract class FieAnimationContainerBase - { - public enum BaseAnimTrack - { - MOTION, - EMOTION, - MAX_BASE_TRACK - } +namespace Fie.Object { - public enum BaseAnimList - { - IDLE, - MAX_BASE_ANIMATION - } + public abstract class FieAnimationContainerBase { + public enum BaseAnimTrack { + MOTION, + EMOTION, + MAX_BASE_TRACK + } - private Dictionary animationList = new Dictionary(); + public enum BaseAnimList { + IDLE, + MAX_BASE_ANIMATION + } - public Dictionary getAnimationList() - { - return animationList; - } + private Dictionary animationList = new Dictionary(); - public FieSkeletonAnimationObject getAnimation(int animationId) - { - if (animationList.ContainsKey(animationId)) - { - return null; - } - return animationList[animationId]; - } + /// + /// Gets the list of all animations registered to this container. + /// + public Dictionary getAnimationList() { + return animationList; + } - public void addAnimationData(int animationID, FieSkeletonAnimationObject animationObject) - { - animationList.Add(animationID, animationObject); - } - } + /// + /// Gets the skeleton animation for the provided animation id. + /// Returns null of one such animation exists (????) + /// + public FieSkeletonAnimationObject getAnimation(int animationId) { + // TODO: Shouldn't this be inverted? + if (animationList.ContainsKey(animationId)) { + return null; + } + return animationList[animationId]; + } + + /// + /// Registers animation details for the given id to this container. + /// + public void addAnimationData(int animationID, FieSkeletonAnimationObject animationObject) { + animationList.Add(animationID, animationObject); + } + } } diff --git a/src/Fie.Object/FieInputControllerBase.cs b/src/Fie.Object/FieInputControllerBase.cs index f6883a6..b2f05d0 100644 --- a/src/Fie.Object/FieInputControllerBase.cs +++ b/src/Fie.Object/FieInputControllerBase.cs @@ -1,16 +1,13 @@ using UnityEngine; -namespace Fie.Object -{ - public class FieInputControllerBase : MonoBehaviour - { - public FieGameCharacter _ownerCharacter; +namespace Fie.Object { + public class FieInputControllerBase : MonoBehaviour { + public FieGameCharacter _ownerCharacter; - public FieGameCharacter ownerCharacter => _ownerCharacter; + public FieGameCharacter ownerCharacter => _ownerCharacter; - public void SetOwner(FieGameCharacter character) - { - _ownerCharacter = character; - } - } + public void SetOwner(FieGameCharacter character) { + _ownerCharacter = character; + } + } } diff --git a/src/Fie.Utility/Wiggler.cs b/src/Fie.Utility/Wiggler.cs index 375a9a9..fe00ae9 100644 --- a/src/Fie.Utility/Wiggler.cs +++ b/src/Fie.Utility/Wiggler.cs @@ -1,122 +1,117 @@ using UnityEngine; -namespace Fie.Utility -{ - public class Wiggler - { - public enum WiggleTemplate - { - WIGGLE_TYPE_MINIMUM, - WIGGLE_TYPE_SMALL, - WIGGLE_TYPE_MIDDLE, - WIGGLE_TYPE_BIG - } +namespace Fie.Utility { + public class Wiggler { + public enum WiggleTemplate { + WIGGLE_TYPE_MINIMUM, + WIGGLE_TYPE_SMALL, + WIGGLE_TYPE_MIDDLE, + WIGGLE_TYPE_BIG + } - private const float MIN_RANDOM_SHAKE_ANGLE_RANGE = 120f; + private const float MIN_RANDOM_SHAKE_ANGLE_RANGE = 120f; - private const float MAX_RANDOM_SHAKE_ANGLE_RANGE = 240f; + private const float MAX_RANDOM_SHAKE_ANGLE_RANGE = 240f; - private float nowAngle; + private float nowAngle; - private float nowTime; + private float nowTime; - private float totalTime; + private float totalTime; - private float wiggleSegmentTime; + private float wiggleSegmentTime; - private int totalWiggleCount = 1; + private int totalWiggleCount = 1; - private int nowWiggleCount; + private int nowWiggleCount; - private Vector3 wiggleScale = Vector3.zero; + private Vector3 wiggleScale = Vector3.zero; - private Vector3 wiggleNormal = Vector3.zero; + private Vector3 wiggleNormal = Vector3.zero; - private Vector3 nowWigglePoint = Vector3.zero; + private Vector3 nowWigglePoint = Vector3.zero; - private Vector3 nextWigglePoint = Vector3.zero; + private Vector3 nextWigglePoint = Vector3.zero; - public bool isEnd => nowWiggleCount >= totalWiggleCount; + public bool isEnd => nowWiggleCount >= totalWiggleCount; - public Wiggler(Vector3 normal, float initTotalTime, int initWiggleCount, Vector3 initWiggleScale) - { - totalTime = Mathf.Max(initTotalTime, 0f); - totalWiggleCount = Mathf.Max(initWiggleCount, 1); - wiggleScale = initWiggleScale; - wiggleNormal = normal.normalized; - InitializeGeneralParams(); - } + public Wiggler(Vector3 normal, float initTotalTime, int initWiggleCount, Vector3 initWiggleScale) { + totalTime = Mathf.Max(initTotalTime, 0f); + totalWiggleCount = Mathf.Max(initWiggleCount, 1); + wiggleScale = initWiggleScale; + wiggleNormal = normal.normalized; + InitializeGeneralParams(); + } - public Wiggler(Vector3 normal, WiggleTemplate template) - { - float num = 0f; - int num2 = 1; - Vector3 zero = Vector3.zero; - switch (template) - { - default: - num = 0.15f; - num2 = 4; - zero = new Vector3(0.015f, 0.015f); - break; - case WiggleTemplate.WIGGLE_TYPE_SMALL: - num = 0.2f; - num2 = 5; - zero = new Vector3(0.03f, 0.03f); - break; - case WiggleTemplate.WIGGLE_TYPE_MIDDLE: - num = 0.3f; - num2 = 7; - zero = new Vector3(0.1f, 0.1f); - break; - case WiggleTemplate.WIGGLE_TYPE_BIG: - num = 0.5f; - num2 = 10; - zero = new Vector3(0.1f, 0.1f); - break; - } - totalTime = Mathf.Max(num, 0f); - totalWiggleCount = Mathf.Max(num2, 1); - wiggleScale = zero; - wiggleNormal = normal.normalized; - InitializeGeneralParams(); - } + public Wiggler(Vector3 normal, WiggleTemplate template) { + float num = 0f; + int num2 = 1; + Vector3 zero = Vector3.zero; + switch (template) { + default: + num = 0.15f; + num2 = 4; + zero = new Vector3(0.015f, 0.015f); + break; + case WiggleTemplate.WIGGLE_TYPE_SMALL: + num = 0.2f; + num2 = 5; + zero = new Vector3(0.03f, 0.03f); + break; + case WiggleTemplate.WIGGLE_TYPE_MIDDLE: + num = 0.3f; + num2 = 7; + zero = new Vector3(0.1f, 0.1f); + break; + case WiggleTemplate.WIGGLE_TYPE_BIG: + num = 0.5f; + num2 = 10; + zero = new Vector3(0.1f, 0.1f); + break; + } + totalTime = Mathf.Max(num, 0f); + totalWiggleCount = Mathf.Max(num2, 1); + wiggleScale = zero; + wiggleNormal = normal.normalized; + InitializeGeneralParams(); + } - public Vector3 UpdateWiggler(float updateTime) - { - if (nowTime >= totalTime) - { - return Vector3.zero; - } - Vector3 result = (!(wiggleSegmentTime > 0f)) ? Vector3.zero : Vector3.Lerp(nowWigglePoint, nextWigglePoint, Mathf.Min(nowTime / wiggleSegmentTime, 1f)); - nowTime += updateTime; - if (nowTime > wiggleSegmentTime && nowWiggleCount < totalWiggleCount) - { - nowWiggleCount++; - SetNextWigglePoint(nowWiggleCount); - nowTime = 0f; - } - return result; - } + public Vector3 UpdateWiggler(float updateTime) { + if (nowTime >= totalTime) { + return Vector3.zero; + } + Vector3 result = (!(wiggleSegmentTime > 0f)) ? Vector3.zero : Vector3.Lerp(nowWigglePoint, nextWigglePoint, Mathf.Min(nowTime / wiggleSegmentTime, 1f)); + nowTime += updateTime; + if (nowTime > wiggleSegmentTime && nowWiggleCount < totalWiggleCount) { + nowWiggleCount++; + SetNextWigglePoint(nowWiggleCount); + nowTime = 0f; + } + return result; + } - private void InitializeGeneralParams() - { - nowTime = 0f; - wiggleSegmentTime = totalTime / (float)totalWiggleCount; - nowWiggleCount = 0; - SetNextWigglePoint(nowWiggleCount); - } + private void InitializeGeneralParams() { + nowTime = 0f; + wiggleSegmentTime = totalTime / (float)totalWiggleCount; + nowWiggleCount = 0; + SetNextWigglePoint(nowWiggleCount); + } - private void SetNextWigglePoint(int count) - { - nowWigglePoint = new Vector3(nextWigglePoint.x, nextWigglePoint.y); - float num = ((float)totalWiggleCount - (float)count) / (float)totalWiggleCount; - float angle = nowAngle + Random.Range(120f, 240f); - Quaternion rotation = Quaternion.AngleAxis(angle, wiggleNormal); - Vector3 vector = rotation * Vector3.up; - vector.Normalize(); - nextWigglePoint = new Vector3(wiggleScale.x * (vector.x * num), wiggleScale.y * (vector.y * num)); - nowAngle = angle; - } - } + private void SetNextWigglePoint(int count) { + nowWigglePoint = new Vector3(nextWigglePoint.x, nextWigglePoint.y); + + float num = ((float)totalWiggleCount - (float)count) / (float)totalWiggleCount; + float angle = nowAngle + Random.Range(120f, 240f); + + Quaternion rotation = Quaternion.AngleAxis(angle, wiggleNormal); + + Vector3 vector = rotation * Vector3.up; + + vector.Normalize(); + + nextWigglePoint = new Vector3(wiggleScale.x * vector.x * num, wiggleScale.y * vector.y * num); + + nowAngle = angle; + } + } } diff --git a/src/NetworkingPeer.cs b/src/NetworkingPeer.cs index c36fb07..36a0d9a 100644 --- a/src/NetworkingPeer.cs +++ b/src/NetworkingPeer.cs @@ -20,24 +20,24 @@ internal class NetworkingPeer : LoadBalancingPeer, IPhotonPeerListener public const string NameServerHttp = "http://ns.exitgamescloud.com:80/photon/n"; private static readonly Dictionary ProtocolToNameServerPort = new Dictionary - { - { - ConnectionProtocol.Udp, - 5058 - }, - { - ConnectionProtocol.Tcp, - 4533 - }, - { - ConnectionProtocol.WebSocket, - 9093 - }, - { - ConnectionProtocol.WebSocketSecure, - 19093 - } - }; + { + { + ConnectionProtocol.Udp, + 5058 + }, + { + ConnectionProtocol.Tcp, + 4533 + }, + { + ConnectionProtocol.WebSocket, + 9093 + }, + { + ConnectionProtocol.WebSocketSecure, + 19093 + } + }; public bool IsInitialConnect; diff --git a/src/TwilightMagicSphere.cs b/src/TwilightMagicSphere.cs index 8cd2203..277db15 100644 --- a/src/TwilightMagicSphere.cs +++ b/src/TwilightMagicSphere.cs @@ -1,16 +1,14 @@ using UnityEngine; -public class TwilightMagicSphere : MonoBehaviour -{ - private float angle; +public class TwilightMagicSphere : MonoBehaviour { + private float angle; - private void Start() - { - } + private void Start() { + } - private void Update() - { - angle += 60f * Time.deltaTime; - base.transform.rotation = Quaternion.AngleAxis(angle, Vector3.up); - } + private void Update() { + angle += 60f * Time.deltaTime; + + transform.rotation = Quaternion.AngleAxis(angle, Vector3.up); + } } diff --git a/src/TwilightMagicSphereNormal.cs b/src/TwilightMagicSphereNormal.cs index 786a98b..4963284 100644 --- a/src/TwilightMagicSphereNormal.cs +++ b/src/TwilightMagicSphereNormal.cs @@ -1,17 +1,14 @@ using UnityEngine; -public class TwilightMagicSphereNormal : MonoBehaviour -{ - private float angle; +public class TwilightMagicSphereNormal : MonoBehaviour { + private float angle; - private void Start() - { - } + private void Start() { + } - private void Update() - { - angle += 0.9f * Time.deltaTime; - angle = Mathf.Repeat(angle, 1f); - base.gameObject.GetComponent().material.SetTextureOffset("_BumpMap", new Vector2(0f - angle, 1f)); - } + private void Update() { + angle = Mathf.Repeat(angle + 0.9f * Time.deltaTime, 1f); + + gameObject.GetComponent().material.SetTextureOffset("_BumpMap", new Vector2(0 - angle, 1)); + } } diff --git a/src/ValueList.cs b/src/ValueList.cs index a4718df..0a5260b 100644 --- a/src/ValueList.cs +++ b/src/ValueList.cs @@ -2,19 +2,18 @@ using Fie.Enemies; using System; [Serializable] -public class ValueList -{ - public FieObjectEnemies _enemy; +public class ValueList { + public FieObjectEnemies _enemy; - public int _spawnableCapForEasy; + public int _spawnableCapForEasy; - public int _spawnableCapForNormal; + public int _spawnableCapForNormal; - public int _spawnableCapForHard; + public int _spawnableCapForHard; - public int _spawnableCapForVeryHard; + public int _spawnableCapForVeryHard; - public int _spawnableCapForNightmare; + public int _spawnableCapForNightmare; - public int _spawnableCapForChaos; + public int _spawnableCapForChaos; }