Format code

This commit is contained in:
Sollace 2018-11-21 22:16:20 +02:00
parent 84efb53960
commit 894aa095cc
24 changed files with 696 additions and 701 deletions

View file

@ -1,14 +1,28 @@
public enum CloudRegionCode
{ /// <summary>
/// Country region codes for the remote cloud server
/// </summary>
public enum CloudRegionCode {
// Europe
eu = 0, eu = 0,
// United States
us = 1, us = 1,
// Asia
asia = 2, asia = 2,
// Japone
jp = 3, jp = 3,
// Australia
au = 5, au = 5,
// ???
usw = 6, usw = 6,
// Saddle Arabia
sa = 7, sa = 7,
// ???
cae = 8, cae = 8,
// ???
kr = 9, kr = 9,
// India
@in = 10, @in = 10,
// None/Offline
none = 4 none = 4
} }

View file

@ -1,8 +1,6 @@
using Fie.Object; using Fie.Object;
namespace Fie.AI namespace Fie.AI {
{ public class FieAIControllerBase : FieInputControllerBase {
public class FieAIControllerBase : FieInputControllerBase
{
} }
} }

View file

@ -3,97 +3,84 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public class FieAIHateController : FieAIControllerBase {
public class FieAIHateController : FieAIControllerBase
{ private float MAXIMUM_STACKED_HATE = 6;
private float MAXIMUM_STACKED_HATE = 6f;
private Dictionary<int, IEnumerator> _hateCorutine = new Dictionary<int, IEnumerator>(); private Dictionary<int, IEnumerator> _hateCorutine = new Dictionary<int, IEnumerator>();
private Dictionary<int, float> _hateList = new Dictionary<int, float>(); private Dictionary<int, float> _hateList = new Dictionary<int, float>();
private void Start() private void Start() {
{ _ownerCharacter.damageSystem.damagedEvent += delegate (FieGameCharacter attacker, FieDamage damage) {
_ownerCharacter.damageSystem.damagedEvent += delegate(FieGameCharacter attacker, FieDamage damage) if (attacker != null && damage != null && PhotonNetwork.isMasterClient) {
{
if (!(attacker == null) && damage != null && PhotonNetwork.isMasterClient)
{
AddHate(attacker, damage.hate); AddHate(attacker, damage.hate);
} }
}; };
} }
private void AddHate(FieGameCharacter attaker, float hate) private void AddHate(FieGameCharacter attaker, float hate) {
{ if (!(attaker == null)) {
if (!(attaker == null))
{
int instanceID = attaker.GetInstanceID(); int instanceID = attaker.GetInstanceID();
if (_hateCorutine.ContainsKey(instanceID))
{ if (_hateCorutine.ContainsKey(instanceID)) {
StopCoroutine(_hateCorutine[instanceID]); StopCoroutine(_hateCorutine[instanceID]);
} }
if (!_hateList.ContainsKey(instanceID))
{ if (!_hateList.ContainsKey(instanceID)) {
_hateList[instanceID] = hate; _hateList[instanceID] = hate;
} } else {
else
{
_hateList[instanceID] = Mathf.Min(_hateList[instanceID] + hate, MAXIMUM_STACKED_HATE); _hateList[instanceID] = Mathf.Min(_hateList[instanceID] + hate, MAXIMUM_STACKED_HATE);
} }
_hateCorutine[instanceID] = CalculateHateCoroutine(instanceID); _hateCorutine[instanceID] = CalculateHateCoroutine(instanceID);
StartCoroutine(_hateCorutine[instanceID]); StartCoroutine(_hateCorutine[instanceID]);
} }
} }
private void Update() private void Update() {
{
updateLockonTargetByHate(); updateLockonTargetByHate();
} }
private void updateLockonTargetByHate() private void updateLockonTargetByHate() {
{ if (_hateList.Count > 0) {
if (_hateList.Count > 0)
{
bool flag = false; bool flag = false;
int instanceId = 0; int instanceId = 0;
float num = 0f; float num = 0;
foreach (KeyValuePair<int, float> hate in _hateList)
{ foreach (KeyValuePair<int, float> hate in _hateList) {
if (num < hate.Value) if (num < hate.Value) {
{
instanceId = hate.Key; instanceId = hate.Key;
flag = true; flag = true;
} }
num = Mathf.Max(num, hate.Value); num = Mathf.Max(num, hate.Value);
} }
if (flag)
{ if (flag) {
_ownerCharacter.detector.ChangeLockonTargetByInstanceID(instanceId); _ownerCharacter.detector.ChangeLockonTargetByInstanceID(instanceId);
} }
} }
} }
private IEnumerator CalculateHateCoroutine(int attackerInstanceId) private IEnumerator CalculateHateCoroutine(int attackerInstanceId) {
{ if (_hateList.ContainsKey(attackerInstanceId)) {
if (_hateList.ContainsKey(attackerInstanceId))
{ _hateList[attackerInstanceId] -= Time.deltaTime;
Dictionary<int, float> hateList;
int key; if (_hateList[attackerInstanceId] > 0) {
(hateList = _hateList)[key = attackerInstanceId] = hateList[key] - Time.deltaTime; yield return 0;
if (!(_hateList[attackerInstanceId] <= 0f))
{
yield return (object)0;
/*Error: Unable to find new state assignment for yield return*/;
} }
_hateList.Remove(attackerInstanceId); _hateList.Remove(attackerInstanceId);
} }
if (_hateCorutine.ContainsKey(attackerInstanceId))
{ if (_hateCorutine.ContainsKey(attackerInstanceId)) {
_hateCorutine.Remove(attackerInstanceId); _hateCorutine.Remove(attackerInstanceId);
} }
yield return (object)null;
/*Error: Unable to find new state assignment for yield return*/; yield return null;
} }
} }
} }

View file

@ -2,12 +2,9 @@ using Fie.Object;
using Fie.Ponies.Applejack; using Fie.Ponies.Applejack;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public class FieAITaskApplejackBackstep : FieAITaskBase {
public class FieAITaskApplejackBackstep : FieAITaskBase private enum StepState {
{
private enum StepState
{
STATE_PREPARE, STATE_PREPARE,
STATE_STEP STATE_STEP
} }
@ -18,42 +15,42 @@ namespace Fie.AI
private StepState _stepState; private StepState _stepState;
public override void Initialize(FieAITaskController manager) public override void Initialize(FieAITaskController manager) {
{
_isEndState = false; _isEndState = false;
_stepState = StepState.STATE_PREPARE; _stepState = StepState.STATE_PREPARE;
} }
public override bool Task(FieAITaskController manager) public override bool Task(FieAITaskController manager) {
{ if (manager.ownerCharacter.groundState != 0) {
if (manager.ownerCharacter.groundState != 0)
{
return true; return true;
} }
switch (_stepState) switch (_stepState) {
{ case StepState.STATE_PREPARE: {
case StepState.STATE_PREPARE: Vector3 directionalVec = new Vector3(
{ Random.Range(-1f, 1f),
Vector3 directionalVec = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f)); Random.Range(-1f, 1f),
Random.Range(-1f, 1f)
);
manager.ownerCharacter.RequestToChangeState<FieStateMachineApplejackEvasion>(directionalVec, 1f, FieGameCharacter.StateMachineType.Base); manager.ownerCharacter.RequestToChangeState<FieStateMachineApplejackEvasion>(directionalVec, 1f, FieGameCharacter.StateMachineType.Base);
FieStateMachineInterface currentStateMachine = manager.ownerCharacter.getStateMachine().getCurrentStateMachine(); FieStateMachineInterface currentStateMachine = manager.ownerCharacter.getStateMachine().getCurrentStateMachine();
if (currentStateMachine is FieStateMachineApplejackEvasion || currentStateMachine is FieStateMachineApplejackBackstep || currentStateMachine is FieStateMachineApplejackCharge)
{ if (currentStateMachine is FieStateMachineApplejackEvasion
currentStateMachine.stateChangeEvent += delegate || currentStateMachine is FieStateMachineApplejackBackstep
{ || currentStateMachine is FieStateMachineApplejackCharge) {
currentStateMachine.stateChangeEvent += delegate {
_isEndState = true; _isEndState = true;
}; };
_stepState = StepState.STATE_STEP; _stepState = StepState.STATE_STEP;
} } else {
else
{
_isEndState = true; _isEndState = true;
} }
break; break;
} }
case StepState.STATE_STEP: case StepState.STATE_STEP:
if (_isEndState) if (_isEndState) {
{
return true; return true;
} }
break; break;

View file

@ -2,33 +2,36 @@ using Fie.Ponies;
using Fie.Ponies.Applejack; using Fie.Ponies.Applejack;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public class FieAITaskApplejackEnemyTracking : FieAITaskBase {
public class FieAITaskApplejackEnemyTracking : FieAITaskBase public override bool Task(FieAITaskController manager) {
{ if (manager.ownerCharacter.detector.lockonTargetObject == null) {
public override bool Task(FieAITaskController manager)
{
if (manager.ownerCharacter.detector.lockonTargetObject == null)
{
return true; return true;
} }
float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position);
if (!(num > 2f))
{ if (!(num > 2f)) {
Vector3 position = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position; Vector3 position = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position;
float y = position.y; float y = position.y;
Vector3 position2 = manager.ownerCharacter.transform.position; Vector3 position2 = manager.ownerCharacter.transform.position;
if (y > position2.y + 5f && manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackRope>() <= 0f)
{ if (y > position2.y + 5f && manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackRope>() <= 0f) {
nextStateWeightList[typeof(FieStateMachineApplejackRope)] = 100; nextStateWeightList[typeof(FieStateMachineApplejackRope)] = 100;
return true; return true;
} }
return true; return true;
} }
Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position;
vector.y = vector.z; vector.y = vector.z;
vector.z = 0f; vector.z = 0f;
manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base); manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base);
return false; return false;
} }
} }

View file

@ -4,78 +4,63 @@ using Fie.Ponies;
using Fie.Ponies.Applejack; using Fie.Ponies.Applejack;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public class FieAITaskApplejackIdle : FieAITaskBase {
public class FieAITaskApplejackIdle : FieAITaskBase
{
private FieGameCharacter injuryCharacter; private FieGameCharacter injuryCharacter;
public override void Initialize(FieAITaskController manager) public override void Initialize(FieAITaskController manager) {
{ if (Random.Range(0f, 100f) > 50f) {
if (Random.Range(0f, 100f) > 50f)
{
FieGameCharacter randomEnemyGameCharacter = manager.ownerCharacter.detector.getRandomEnemyGameCharacter(); FieGameCharacter randomEnemyGameCharacter = manager.ownerCharacter.detector.getRandomEnemyGameCharacter();
if (randomEnemyGameCharacter != null) if (randomEnemyGameCharacter != null) {
{
manager.ownerCharacter.detector.ChangeLockonTargetByInstanceID(randomEnemyGameCharacter.GetInstanceID()); manager.ownerCharacter.detector.ChangeLockonTargetByInstanceID(randomEnemyGameCharacter.GetInstanceID());
} }
} }
injuryCharacter = FieManagerBehaviour<FieInGameCharacterStatusManager>.I.GetNearbyInjuryAllyCharacter(manager.ownerCharacter); injuryCharacter = FieManagerBehaviour<FieInGameCharacterStatusManager>.I.GetNearbyInjuryAllyCharacter(manager.ownerCharacter);
} }
public override bool Task(FieAITaskController manager) public override bool Task(FieAITaskController manager) {
{ if (manager.ownerCharacter.groundState != 0) {
if (manager.ownerCharacter.groundState != 0)
{
return false; return false;
} }
if (manager.ownerCharacter.damageSystem.isDead) if (manager.ownerCharacter.damageSystem.isDead) {
{ if (manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 3) {
if (manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 3)
{
(manager.ownerCharacter as FiePonies).TryToRevive(); (manager.ownerCharacter as FiePonies).TryToRevive();
} }
return true; return true;
} }
if (injuryCharacter != null && manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 2) if (injuryCharacter != null && manager.ownerCharacter.friendshipStats.getCurrentFriendshipPoint() >= 2) {
{
nextStateWeightList[typeof(FieAITaskPoniesRescue)] = 100; nextStateWeightList[typeof(FieAITaskPoniesRescue)] = 100;
return true; return true;
} }
float num = Vector3.Distance(manager.ownerCharacter.transform.position, FieManagerBehaviour<FieUserManager>.I.gameOwnerCharacter.transform.position); float num = Vector3.Distance(manager.ownerCharacter.transform.position, FieManagerBehaviour<FieUserManager>.I.gameOwnerCharacter.transform.position);
if (manager.ownerCharacter.detector.lockonTargetObject == null) if (manager.ownerCharacter.detector.lockonTargetObject == null) {
{ if (num > 2.5f) {
if (num > 2.5f)
{
nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100;
return true; return true;
} }
return false; return false;
} }
float num2 = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.position); float num2 = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.position);
if (num2 > 4.5f) if (num2 > 4.5f) {
{
nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100; nextStateWeightList[typeof(FieAITaskPoniesOwnerTracking)] = 100;
return true; return true;
} }
if (num2 > 2.5f) if (num2 > 2.5f) {
{
nextStateWeightList[typeof(FieAITaskApplejackEnemyTracking)] = 500; nextStateWeightList[typeof(FieAITaskApplejackEnemyTracking)] = 500;
if (manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackRope>() <= 0f) if (manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackRope>() <= 0f) {
{
nextStateWeightList[typeof(FieAITaskApplejackRope)] = 500; nextStateWeightList[typeof(FieAITaskApplejackRope)] = 500;
} }
return true; return true;
} }
if (manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackStomp>() <= 0f && manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackYeehaw>() <= 0f) if (manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackStomp>() <= 0f && manager.ownerCharacter.abilitiesContainer.GetCooltime<FieStateMachineApplejackYeehaw>() <= 0f) {
{
nextStateWeightList[typeof(FieAITaskApplejackStomp)] = (int)Mathf.Max(1000f * manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax, 100f); 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); nextStateWeightList[typeof(FieAITaskApplejackYeehaw)] = (int)Mathf.Max(2000f * (1f - manager.ownerCharacter.healthStats.nowHelthAndShieldRatePerMax), 500f);
return true; return true;
} }
nextStateWeightList[typeof(FieAITaskApplejackBackstep)] = 200; nextStateWeightList[typeof(FieAITaskApplejackBackstep)] = 200;
if (manager.ownerCharacter.groundState == FieObjectGroundState.Grounding)
{ if (manager.ownerCharacter.groundState == FieObjectGroundState.Grounding) {
nextStateWeightList[typeof(FieAITaskApplejackJump)] = 200; nextStateWeightList[typeof(FieAITaskApplejackJump)] = 200;
} }
nextStateWeightList[typeof(FieAITaskApplejackMelee)] = 200; nextStateWeightList[typeof(FieAITaskApplejackMelee)] = 200;

View file

@ -1,14 +1,23 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fie.AI namespace Fie.AI {
{ /// <summary>
public interface FieAITaskInterface /// An AI task that a character can perform. Called to handle movement/targetting/etc.
{ /// </summary>
public interface FieAITaskInterface {
/// <summary>
/// Runs this task.
/// </summary>
/// <param name="manager">The manager responsible for calling this task</param>
/// <returns></returns>
bool TaskExec(FieAITaskController manager); bool TaskExec(FieAITaskController manager);
bool Task(FieAITaskController manager); bool Task(FieAITaskController manager);
/// <summary>
/// Gets a relative importance mapping for this task given different targets and contexts.
/// </summary>
Dictionary<Type, int> GetWeight(); Dictionary<Type, int> GetWeight();
} }
} }

View file

@ -1,25 +1,25 @@
using Fie.Ponies; using Fie.Ponies;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public class FieAITaskRainbowDashEnemyTracking : FieAITaskBase {
public class FieAITaskRainbowDashEnemyTracking : FieAITaskBase public override bool Task(FieAITaskController manager) {
{ if (manager.ownerCharacter.detector.lockonTargetObject == null) {
public override bool Task(FieAITaskController manager)
{
if (manager.ownerCharacter.detector.lockonTargetObject == null)
{
return true; return true;
} }
float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position); float num = Vector3.Distance(manager.ownerCharacter.transform.position, manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position);
if (!(num > 2f))
{ if (num <= 2) {
return true; return true;
} }
Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position; Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.centerTransform.position - manager.ownerCharacter.transform.position;
vector.y = vector.z; vector.y = vector.z;
vector.z = 0f; vector.z = 0f;
manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base);
manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1, FieGameCharacter.StateMachineType.Base);
return false; return false;
} }
} }

View file

@ -1,20 +1,19 @@
using Fie.Ponies; using Fie.Ponies;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ public abstract class FieAITaskTwilightBase : FieAITaskBase {
public abstract class FieAITaskTwilightBase : FieAITaskBase protected bool AdjustDirectionByBasicMovement(FieAITaskController manager) {
{ if (manager.ownerCharacter.detector.lockonTargetObject.flipDirectionVector != manager.ownerCharacter.flipDirectionVector) {
protected bool AdjustDirectionByBasicMovement(FieAITaskController manager)
{
if (manager.ownerCharacter.detector.lockonTargetObject.flipDirectionVector != manager.ownerCharacter.flipDirectionVector)
{
return false; return false;
} }
Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.position - manager.ownerCharacter.transform.position; Vector3 vector = manager.ownerCharacter.detector.lockonTargetObject.position - manager.ownerCharacter.transform.position;
vector.y = vector.z; vector.y = vector.z;
vector.z = 0f; vector.z = 0;
manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1f, FieGameCharacter.StateMachineType.Base);
manager.ownerCharacter.RequestToChangeState<FieStateMachinePoniesGallop>(vector.normalized, 1, FieGameCharacter.StateMachineType.Base);
return true; return true;
} }
} }

View file

@ -2,48 +2,39 @@ using Fie.Object;
using Fie.Ponies.Twilight; using Fie.Ponies.Twilight;
using UnityEngine; using UnityEngine;
namespace Fie.AI namespace Fie.AI {
{ /// <summary>
public class FieAITaskTwilightSummonArrow : FieAITaskTwilightBase /// Summons a magic bold
{ /// </summary>
public class FieAITaskTwilightSummonArrow : FieAITaskTwilightBase {
private bool _isEnd; private bool _isEnd;
public override void Initialize(FieAITaskController manager) public override void Initialize(FieAITaskController manager) {
{
_isEnd = false; _isEnd = false;
manager.ownerCharacter.damageSystem.staggerEvent += healthSystem_staggerEvent; manager.ownerCharacter.damageSystem.staggerEvent += healthSystem_staggerEvent;
manager.ownerCharacter.damageSystem.damagedEvent += HealthSystem_damagedEvent; manager.ownerCharacter.damageSystem.damagedEvent += HealthSystem_damagedEvent;
} }
public override void Terminate(FieAITaskController manager) public override void Terminate(FieAITaskController manager) {
{
manager.ownerCharacter.damageSystem.staggerEvent -= healthSystem_staggerEvent; manager.ownerCharacter.damageSystem.staggerEvent -= healthSystem_staggerEvent;
manager.ownerCharacter.damageSystem.damagedEvent -= HealthSystem_damagedEvent; manager.ownerCharacter.damageSystem.damagedEvent -= HealthSystem_damagedEvent;
} }
private void HealthSystem_damagedEvent(FieGameCharacter attacker, FieDamage damage) private void HealthSystem_damagedEvent(FieGameCharacter attacker, FieDamage damage) {
{
nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100;
_isEnd = true; _isEnd = true;
} }
private void healthSystem_staggerEvent(FieDamage damageObject) private void healthSystem_staggerEvent(FieDamage damageObject) {
{
nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100; nextStateWeightList[typeof(FieAITaskTwilightEnemyEvade)] = 100;
_isEnd = true; _isEnd = true;
} }
public override bool Task(FieAITaskController manager) public override bool Task(FieAITaskController manager) {
{ if (!_isEnd && manager.ownerCharacter.detector.lockonTargetObject != null) {
if (_isEnd) manager.ownerCharacter.RequestToChangeState<FieStateMachineTwilightSummonArrow>(Vector3.zero, 0, FieGameCharacter.StateMachineType.Attack);
{
return true;
} }
if (manager.ownerCharacter.detector.lockonTargetObject == null)
{
return true;
}
manager.ownerCharacter.RequestToChangeState<FieStateMachineTwilightSummonArrow>(Vector3.zero, 0f, FieGameCharacter.StateMachineType.Attack);
return true; return true;
} }
} }

View file

@ -2,20 +2,32 @@ using Fie.Manager;
using Fie.Scene; using Fie.Scene;
using UnityEngine; using UnityEngine;
namespace Fie.Core namespace Fie.Core {
{ /// <summary>
public class FieBootstrap : MonoBehaviour /// Entry-point for Fie. Everything starts here.
{ /// </summary>
private static bool _isBootedFromBootStrap; public class FieBootstrap : MonoBehaviour {
public static bool isBootedFromBootStrap { get; private set; };
public static bool isBootedFromBootStrap => _isBootedFromBootStrap; /// <summary>
/// Starts the game. Loads the title screen.
private void Start() /// </summary>
{ private void Start() {
FieManagerFactory.I.StartUp(); FieManagerFactory.I.StartUp();
FieManagerBehaviour<FieSceneManager>.I.LoadScene(new FieSceneTitle(), allowSceneActivation: true, FieFaderManager.FadeType.OUT_TO_WHITE, FieFaderManager.FadeType.IN_FROM_WHITE, 1.5f); FieManagerBehaviour<FieSceneManager>.I.LoadScene(new FieSceneTitle(), allowSceneActivation: true,
_isBootedFromBootStrap = true; FieFaderManager.FadeType.OUT_TO_WHITE,
FieManagerBehaviour<FieAudioManager>.I.ChangeMixerVolume(0f, 0.5f, FieAudioManager.FieAudioMixerType.BGM, FieAudioManager.FieAudioMixerType.Voice, FieAudioManager.FieAudioMixerType.SE); FieFaderManager.FadeType.IN_FROM_WHITE,
1.5f
);
isBootedFromBootStrap = true;
FieManagerBehaviour<FieAudioManager>.I.ChangeMixerVolume(0f, 0.5f,
FieAudioManager.FieAudioMixerType.BGM,
FieAudioManager.FieAudioMixerType.Voice,
FieAudioManager.FieAudioMixerType.SE
);
UnityEngine.Object.Destroy(base.gameObject); UnityEngine.Object.Destroy(base.gameObject);
} }
} }

View file

@ -5,10 +5,8 @@ using GameDataEditor;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Fie.DebugUtility namespace Fie.DebugUtility {
{ public class FieDebugGameSceneBoot : MonoBehaviour {
public class FieDebugGameSceneBoot : MonoBehaviour
{
[Range(1f, 3f)] [Range(1f, 3f)]
[SerializeField] [SerializeField]
private int playerNum = 1; private int playerNum = 1;
@ -25,12 +23,15 @@ namespace Fie.DebugUtility
[SerializeField] [SerializeField]
private List<FieConstValues.FieSkill> _debugSkills = new List<FieConstValues.FieSkill>(); private List<FieConstValues.FieSkill> _debugSkills = new List<FieConstValues.FieSkill>();
private void Awake() private void Awake() {
{ if (!FieBootstrap.isBootedFromBootStrap
if (!FieBootstrap.isBootedFromBootStrap && _debugCharacters.Count == _debugCharactersIntelligenceTypes.Count && _debugCharactersIntelligenceTypes.Count == _debugCharactersNames.Count && _debugCharacters.Count == _debugCharactersNames.Count) && _debugCharacters.Count == _debugCharactersIntelligenceTypes.Count
{ && _debugCharactersIntelligenceTypes.Count == _debugCharactersNames.Count
&& _debugCharacters.Count == _debugCharactersNames.Count) {
PhotonNetwork.offlineMode = true; PhotonNetwork.offlineMode = true;
PhotonNetwork.InstantiateInRoomOnly = false; PhotonNetwork.InstantiateInRoomOnly = false;
FieManagerFactory.I.currentSceneType = FieSceneType.INGAME; FieManagerFactory.I.currentSceneType = FieSceneType.INGAME;
FieManagerBehaviour<FieSceneManager>.I.StartUp(); FieManagerBehaviour<FieSceneManager>.I.StartUp();
FieManagerBehaviour<FieSaveManager>.I.StartUp(); FieManagerBehaviour<FieSaveManager>.I.StartUp();
@ -38,29 +39,25 @@ namespace Fie.DebugUtility
FieManagerBehaviour<FieEnvironmentManager>.I.StartUp(); FieManagerBehaviour<FieEnvironmentManager>.I.StartUp();
FieManagerBehaviour<FieUserManager>.I.nowPlayerNum = playerNum; FieManagerBehaviour<FieUserManager>.I.nowPlayerNum = playerNum;
FieManagerBehaviour<FieUserManager>.I.StartUp(); FieManagerBehaviour<FieUserManager>.I.StartUp();
List<GDESkillTreeData> list = FieMasterData<GDESkillTreeData>.FindMasterDataList(delegate(GDESkillTreeData data)
{ List<GDESkillTreeData> list = FieMasterData<GDESkillTreeData>.FindMasterDataList(delegate (GDESkillTreeData data) {
if (_debugSkills.Contains((FieConstValues.FieSkill)data.ID)) return _debugSkills.Contains((FieConstValues.FieSkill)data.ID);
{
return true;
}
return false;
}); });
for (int i = 0; i < playerNum; i++)
{ for (int i = 0; i < playerNum; i++) {
_debugCharacters[i].intelligenceType = _debugCharactersIntelligenceTypes[i]; _debugCharacters[i].intelligenceType = _debugCharactersIntelligenceTypes[i];
if (list != null && list.Count > 0)
{ if (list != null && list.Count > 0) {
FieSaveManager.debugSkills = list; FieSaveManager.debugSkills = list;
} }
FieManagerBehaviour<FieUserManager>.I.SetUserName(i, _debugCharactersNames[i]); FieManagerBehaviour<FieUserManager>.I.SetUserName(i, _debugCharactersNames[i]);
FieManagerBehaviour<FieUserManager>.I.SetUserCharacterPrefab(i, _debugCharacters[i]); FieManagerBehaviour<FieUserManager>.I.SetUserCharacterPrefab(i, _debugCharacters[i]);
} }
} }
} }
private void Start() private void Start() {
{
FieManagerBehaviour<FieInGameStateManager>.I.StartUp(); FieManagerBehaviour<FieInGameStateManager>.I.StartUp();
} }
} }

View file

@ -1,11 +1,8 @@
using Fie.Object; using Fie.Object;
namespace Fie.Enemies namespace Fie.Enemies {
{ public class FieEnemiesAnimationContainer : FieAnimationContainerBase {
public class FieEnemiesAnimationContainer : FieAnimationContainerBase public FieEnemiesAnimationContainer() {
{
public FieEnemiesAnimationContainer()
{
addAnimationData(0, new FieSkeletonAnimationObject(0, "idle")); addAnimationData(0, new FieSkeletonAnimationObject(0, "idle"));
} }
} }

View file

@ -1,17 +1,13 @@
using Fie.Object; using Fie.Object;
namespace Fie.Enemies namespace Fie.Enemies {
{ public class FieEnemiesHoovesRacesAnimationContainer : FieEnemiesAnimationContainer {
public class FieEnemiesHoovesRacesAnimationContainer : FieEnemiesAnimationContainer public enum HoovesRacesAnimTrack {
{
public enum HoovesRacesAnimTrack
{
HORN = 2, HORN = 2,
MAX_HOOVES_RACES_TRACK MAX_HOOVES_RACES_TRACK
} }
public enum HoovesRacesAnimList public enum HoovesRacesAnimList {
{
WALK = 1, WALK = 1,
GALLOP, GALLOP,
STAGGER, STAGGER,
@ -22,8 +18,7 @@ namespace Fie.Enemies
MAX_HOOVES_RACES_ANIMATION MAX_HOOVES_RACES_ANIMATION
} }
public FieEnemiesHoovesRacesAnimationContainer() public FieEnemiesHoovesRacesAnimationContainer() {
{
addAnimationData(1, new FieSkeletonAnimationObject(0, "walk")); addAnimationData(1, new FieSkeletonAnimationObject(0, "walk"));
addAnimationData(2, new FieSkeletonAnimationObject(0, "gallop")); addAnimationData(2, new FieSkeletonAnimationObject(0, "gallop"));
addAnimationData(3, new FieSkeletonAnimationObject(0, "stagger")); addAnimationData(3, new FieSkeletonAnimationObject(0, "stagger"));

View file

@ -5,6 +5,9 @@ using UnityEngine.UI;
namespace Fie.Fader namespace Fie.Fader
{ {
/// <summary>
/// Fader used to white out the screen whilst the game is loading.
/// </summary>
public class FieFader : MonoBehaviour public class FieFader : MonoBehaviour
{ {
[SerializeField] [SerializeField]
@ -13,52 +16,61 @@ namespace Fie.Fader
[SerializeField] [SerializeField]
private Image faderPlaneObject; private Image faderPlaneObject;
/// <summary>
/// The loading icon that appears in the lower right corner.
/// </summary>
[SerializeField] [SerializeField]
private SkeletonGraphic _loadingIcon; private SkeletonGraphic _loadingIcon;
private Tweener<TweenTypesInOutSine> faderTweener = new Tweener<TweenTypesInOutSine>(); private Tweener<TweenTypesInOutSine> faderTweener = new Tweener<TweenTypesInOutSine>();
/// <summary>
/// True if the loading screen is currently visible.
/// </summary>
private bool isDrawFader; private bool isDrawFader;
public void Initialize() public void Initialize() {
{
faderCameraRootObject.transform.gameObject.SetActive(value: false); faderCameraRootObject.transform.gameObject.SetActive(value: false);
} }
public void HideFader() public void HideFader() {
{
isDrawFader = false; isDrawFader = false;
faderCameraRootObject.transform.gameObject.SetActive(value: false); faderCameraRootObject.transform.gameObject.SetActive(value: false);
} }
public void InitFader(Vector4 startColor, Vector4 endColor, float time) /// <summary>
{ /// Creates this view, sets it to visible, and starts showing the loading screen.
/// </summary>
public void InitFader(Vector4 startColor, Vector4 endColor, float time) {
isDrawFader = true; isDrawFader = true;
faderTweener.InitTweener(time, startColor, endColor); faderTweener.InitTweener(time, startColor, endColor);
faderCameraRootObject.transform.gameObject.SetActive(value: true); faderCameraRootObject.transform.gameObject.SetActive(value: true);
} }
public bool IsEndUpdateFader() /// <summary>
{ /// Checks if the loading screen is still fading in/our and returns false otherwise.
/// </summary>
public bool IsEndUpdateFader() {
return faderTweener == null || faderTweener.IsEnd(); return faderTweener == null || faderTweener.IsEnd();
} }
private void Update() /// <summary>
{ /// Draws the loading screen. Currently just a plain white background.
if (isDrawFader) /// </summary>
{ private void Update() {
if (isDrawFader) {
Color color = faderTweener.UpdateParameterVec4(Time.deltaTime); Color color = faderTweener.UpdateParameterVec4(Time.deltaTime);
faderPlaneObject.color = color; faderPlaneObject.color = color;
_loadingIcon.color = new Color(1f, 1f, 1f, color.a); _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
} }
} }
} }

View file

@ -2,41 +2,53 @@ using Fie.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Fie.Footstep namespace Fie.Footstep {
{ /// <summary>
public class FieFootstepMaterial : MonoBehaviour /// Plays the footstep animations created as players or enemies move around.
{ /// </summary>
public class FieFootstepMaterial : MonoBehaviour {
[SerializeField] [SerializeField]
private float _audioVolume = 0.5f; private float _audioVolume = 0.5f;
[SerializeField] [SerializeField]
private List<AudioClip> _audioClips = new List<AudioClip>(); private List<AudioClip> _audioClips = new List<AudioClip>();
/// <summary>
/// The particle material to spawn under an entity's hooves as they walk.
/// </summary>
[SerializeField] [SerializeField]
private Material _footStepParticleMaterial; private Material _footStepParticleMaterial;
/// <summary>
/// A lotto of audio clips to play. Provides a random one when queried.
/// </summary>
private Lottery<AudioClip> _lottery = new Lottery<AudioClip>(); private Lottery<AudioClip> _lottery = new Lottery<AudioClip>();
/// <summary>
/// The pool of sounds that can be played by this material.
/// </summary>
public List<AudioClip> audioClips => _audioClips; public List<AudioClip> audioClips => _audioClips;
private void Awake() private void Awake() {
{ foreach (AudioClip audioClip in _audioClips) {
foreach (AudioClip audioClip in _audioClips) _lottery.AddItem(audioClip); // add each audio clip to the lottery
{
_lottery.AddItem(audioClip);
} }
} }
public void playFootstepAudio(FieFootstepPlayer player) /// <summary>
{ /// Attempts to play an audio clip for the given footstep player.
if (!(player == null) && _lottery.IsExecutable()) /// Accepts nulls.
{ /// </summary>
public void playFootstepAudio(FieFootstepPlayer player) {
if (!(player == null) && _lottery.IsExecutable()) {
AudioClip audioClip = _lottery.Lot(); AudioClip audioClip = _lottery.Lot();
if (!(audioClip == null))
{ if (!(audioClip == null)) {
player.SetMaterial(_footStepParticleMaterial); player.SetMaterial(_footStepParticleMaterial);
player.audioSource.pitch = player.pitchOffset; player.audioSource.pitch = player.pitchOffset;
player.audioSource.PlayOneShot(audioClip, _audioVolume); player.audioSource.PlayOneShot(audioClip, _audioVolume);
player.EmitFootstepParticle(audioClip.length); player.EmitFootstepParticle(audioClip.length);
} }
} }

View file

@ -2,10 +2,11 @@ using ParticlePlayground;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace Fie.Footstep namespace Fie.Footstep {
{ /// <summary>
public class FieFootstepPlayer : MonoBehaviour /// An audio player for playing audio clips under a player.
{ /// </summary>
public class FieFootstepPlayer : MonoBehaviour {
[SerializeField] [SerializeField]
private AudioSource _audioSource; private AudioSource _audioSource;
@ -21,35 +22,31 @@ namespace Fie.Footstep
public float pitchOffset => _pitchOffset; public float pitchOffset => _pitchOffset;
public void EmitFootstepParticle(float duration) public void EmitFootstepParticle(float duration) {
{
_particleDuration = duration; _particleDuration = duration;
} }
public void SetMaterial(Material material) public void SetMaterial(Material material) {
{
_particle.particleSystemRenderer.material = material; _particle.particleSystemRenderer.material = material;
} }
private void Update() private void Update() {
{ bool flag = _particleDuration > 0;
bool flag = _particleDuration > 0f;
_particle.emit = flag; _particle.emit = flag;
if (flag) if (flag) {
{
_particleDuration -= Time.deltaTime; _particleDuration -= Time.deltaTime;
} }
} }
private void Awake() private void Awake() {
{
SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.sceneLoaded += SceneManager_sceneLoaded;
} }
private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene arg0, LoadSceneMode arg1) /// <summary>
{ /// Called when the scene is loaded.
if ((bool)_particle) /// </summary>
{ private void SceneManager_sceneLoaded(UnityEngine.SceneManagement.Scene scene, LoadSceneMode mode) {
if ((bool)_particle) {
_particle.Start(); _particle.Start();
} }
} }

View file

@ -1,40 +1,44 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Fie.Object namespace Fie.Object {
{
public abstract class FieAnimationContainerBase public abstract class FieAnimationContainerBase {
{ public enum BaseAnimTrack {
public enum BaseAnimTrack
{
MOTION, MOTION,
EMOTION, EMOTION,
MAX_BASE_TRACK MAX_BASE_TRACK
} }
public enum BaseAnimList public enum BaseAnimList {
{
IDLE, IDLE,
MAX_BASE_ANIMATION MAX_BASE_ANIMATION
} }
private Dictionary<int, FieSkeletonAnimationObject> animationList = new Dictionary<int, FieSkeletonAnimationObject>(); private Dictionary<int, FieSkeletonAnimationObject> animationList = new Dictionary<int, FieSkeletonAnimationObject>();
public Dictionary<int, FieSkeletonAnimationObject> getAnimationList() /// <summary>
{ /// Gets the list of all animations registered to this container.
/// </summary>
public Dictionary<int, FieSkeletonAnimationObject> getAnimationList() {
return animationList; return animationList;
} }
public FieSkeletonAnimationObject getAnimation(int animationId) /// <summary>
{ /// Gets the skeleton animation for the provided animation id.
if (animationList.ContainsKey(animationId)) /// Returns null of one such animation exists (????)
{ /// </summary>
public FieSkeletonAnimationObject getAnimation(int animationId) {
// TODO: Shouldn't this be inverted?
if (animationList.ContainsKey(animationId)) {
return null; return null;
} }
return animationList[animationId]; return animationList[animationId];
} }
public void addAnimationData(int animationID, FieSkeletonAnimationObject animationObject) /// <summary>
{ /// Registers animation details for the given id to this container.
/// </summary>
public void addAnimationData(int animationID, FieSkeletonAnimationObject animationObject) {
animationList.Add(animationID, animationObject); animationList.Add(animationID, animationObject);
} }
} }

View file

@ -1,15 +1,12 @@
using UnityEngine; using UnityEngine;
namespace Fie.Object namespace Fie.Object {
{ public class FieInputControllerBase : MonoBehaviour {
public class FieInputControllerBase : MonoBehaviour
{
public FieGameCharacter _ownerCharacter; public FieGameCharacter _ownerCharacter;
public FieGameCharacter ownerCharacter => _ownerCharacter; public FieGameCharacter ownerCharacter => _ownerCharacter;
public void SetOwner(FieGameCharacter character) public void SetOwner(FieGameCharacter character) {
{
_ownerCharacter = character; _ownerCharacter = character;
} }
} }

View file

@ -1,11 +1,8 @@
using UnityEngine; using UnityEngine;
namespace Fie.Utility namespace Fie.Utility {
{ public class Wiggler {
public class Wiggler public enum WiggleTemplate {
{
public enum WiggleTemplate
{
WIGGLE_TYPE_MINIMUM, WIGGLE_TYPE_MINIMUM,
WIGGLE_TYPE_SMALL, WIGGLE_TYPE_SMALL,
WIGGLE_TYPE_MIDDLE, WIGGLE_TYPE_MIDDLE,
@ -38,8 +35,7 @@ namespace Fie.Utility
public bool isEnd => nowWiggleCount >= totalWiggleCount; public bool isEnd => nowWiggleCount >= totalWiggleCount;
public Wiggler(Vector3 normal, float initTotalTime, int initWiggleCount, Vector3 initWiggleScale) public Wiggler(Vector3 normal, float initTotalTime, int initWiggleCount, Vector3 initWiggleScale) {
{
totalTime = Mathf.Max(initTotalTime, 0f); totalTime = Mathf.Max(initTotalTime, 0f);
totalWiggleCount = Mathf.Max(initWiggleCount, 1); totalWiggleCount = Mathf.Max(initWiggleCount, 1);
wiggleScale = initWiggleScale; wiggleScale = initWiggleScale;
@ -47,13 +43,11 @@ namespace Fie.Utility
InitializeGeneralParams(); InitializeGeneralParams();
} }
public Wiggler(Vector3 normal, WiggleTemplate template) public Wiggler(Vector3 normal, WiggleTemplate template) {
{
float num = 0f; float num = 0f;
int num2 = 1; int num2 = 1;
Vector3 zero = Vector3.zero; Vector3 zero = Vector3.zero;
switch (template) switch (template) {
{
default: default:
num = 0.15f; num = 0.15f;
num2 = 4; num2 = 4;
@ -82,16 +76,13 @@ namespace Fie.Utility
InitializeGeneralParams(); InitializeGeneralParams();
} }
public Vector3 UpdateWiggler(float updateTime) public Vector3 UpdateWiggler(float updateTime) {
{ if (nowTime >= totalTime) {
if (nowTime >= totalTime)
{
return Vector3.zero; return Vector3.zero;
} }
Vector3 result = (!(wiggleSegmentTime > 0f)) ? Vector3.zero : Vector3.Lerp(nowWigglePoint, nextWigglePoint, Mathf.Min(nowTime / wiggleSegmentTime, 1f)); Vector3 result = (!(wiggleSegmentTime > 0f)) ? Vector3.zero : Vector3.Lerp(nowWigglePoint, nextWigglePoint, Mathf.Min(nowTime / wiggleSegmentTime, 1f));
nowTime += updateTime; nowTime += updateTime;
if (nowTime > wiggleSegmentTime && nowWiggleCount < totalWiggleCount) if (nowTime > wiggleSegmentTime && nowWiggleCount < totalWiggleCount) {
{
nowWiggleCount++; nowWiggleCount++;
SetNextWigglePoint(nowWiggleCount); SetNextWigglePoint(nowWiggleCount);
nowTime = 0f; nowTime = 0f;
@ -99,23 +90,27 @@ namespace Fie.Utility
return result; return result;
} }
private void InitializeGeneralParams() private void InitializeGeneralParams() {
{
nowTime = 0f; nowTime = 0f;
wiggleSegmentTime = totalTime / (float)totalWiggleCount; wiggleSegmentTime = totalTime / (float)totalWiggleCount;
nowWiggleCount = 0; nowWiggleCount = 0;
SetNextWigglePoint(nowWiggleCount); SetNextWigglePoint(nowWiggleCount);
} }
private void SetNextWigglePoint(int count) private void SetNextWigglePoint(int count) {
{
nowWigglePoint = new Vector3(nextWigglePoint.x, nextWigglePoint.y); nowWigglePoint = new Vector3(nextWigglePoint.x, nextWigglePoint.y);
float num = ((float)totalWiggleCount - (float)count) / (float)totalWiggleCount; float num = ((float)totalWiggleCount - (float)count) / (float)totalWiggleCount;
float angle = nowAngle + Random.Range(120f, 240f); float angle = nowAngle + Random.Range(120f, 240f);
Quaternion rotation = Quaternion.AngleAxis(angle, wiggleNormal); Quaternion rotation = Quaternion.AngleAxis(angle, wiggleNormal);
Vector3 vector = rotation * Vector3.up; Vector3 vector = rotation * Vector3.up;
vector.Normalize(); vector.Normalize();
nextWigglePoint = new Vector3(wiggleScale.x * (vector.x * num), wiggleScale.y * (vector.y * num));
nextWigglePoint = new Vector3(wiggleScale.x * vector.x * num, wiggleScale.y * vector.y * num);
nowAngle = angle; nowAngle = angle;
} }
} }

View file

@ -1,16 +1,14 @@
using UnityEngine; using UnityEngine;
public class TwilightMagicSphere : MonoBehaviour public class TwilightMagicSphere : MonoBehaviour {
{
private float angle; private float angle;
private void Start() private void Start() {
{
} }
private void Update() private void Update() {
{
angle += 60f * Time.deltaTime; angle += 60f * Time.deltaTime;
base.transform.rotation = Quaternion.AngleAxis(angle, Vector3.up);
transform.rotation = Quaternion.AngleAxis(angle, Vector3.up);
} }
} }

View file

@ -1,17 +1,14 @@
using UnityEngine; using UnityEngine;
public class TwilightMagicSphereNormal : MonoBehaviour public class TwilightMagicSphereNormal : MonoBehaviour {
{
private float angle; private float angle;
private void Start() private void Start() {
{
} }
private void Update() private void Update() {
{ angle = Mathf.Repeat(angle + 0.9f * Time.deltaTime, 1f);
angle += 0.9f * Time.deltaTime;
angle = Mathf.Repeat(angle, 1f); gameObject.GetComponent<Renderer>().material.SetTextureOffset("_BumpMap", new Vector2(0 - angle, 1));
base.gameObject.GetComponent<Renderer>().material.SetTextureOffset("_BumpMap", new Vector2(0f - angle, 1f));
} }
} }

View file

@ -2,8 +2,7 @@ using Fie.Enemies;
using System; using System;
[Serializable] [Serializable]
public class ValueList public class ValueList {
{
public FieObjectEnemies _enemy; public FieObjectEnemies _enemy;
public int _spawnableCapForEasy; public int _spawnableCapForEasy;