浏览代码

Removed Graph Stuff + work on pickups

/main
Thomas ICHÉ 6 年前
当前提交
536d6807
共有 23 个文件被更改,包括 262 次插入61 次删除
  1. 4
      Editor/GameplayIngredients-Editor.asmdef
  2. 9
      Runtime/Pickup/PickupEffectBase.cs
  3. 9
      Runtime/Pickup/PickupOwnerBase.cs
  4. 2
      Runtime/Pickup/PickupItem.cs.meta
  5. 2
      Runtime/Factory/Factory.cs.meta
  6. 2
      Runtime/Factory/FactorySpawnAction.cs.meta
  7. 2
      Runtime/Rigs/DirectorControlRig.cs.meta
  8. 8
      Runtime/Factory.meta
  9. 12
      Runtime/Pickup/PickupItem.cs
  10. 65
      Runtime/Rigs/DirectorControlRig.cs
  11. 144
      Runtime/Factory/Factory.cs
  12. 18
      Runtime/Factory/FactorySpawnAction.cs
  13. 8
      Editor/SceneLogicEditor.meta
  14. 12
      Runtime/Pickup/SamplePickupEffect.cs
  15. 18
      Runtime/Pickup/SamplePickupOwner.cs
  16. 8
      NodeGraphProcessor.meta
  17. 0
      /Runtime/Pickup/PickupItem.cs.meta
  18. 0
      /Runtime/Factory/Factory.cs.meta
  19. 0
      /Runtime/Factory/FactorySpawnAction.cs.meta
  20. 0
      /Runtime/Rigs/DirectorControlRig.cs.meta

4
Editor/GameplayIngredients-Editor.asmdef


"name": "GameplayIngredients-Editor",
"references": [
"NaughtyAttributes",
"GameplayIngredients",
"com.alelievr.NodeGraphProcessor-Editor",
"com.alelievr.NodeGraphProcessor"
"GameplayIngredients"
],
"optionalUnityReferences": [],
"includePlatforms": [

9
Runtime/Pickup/PickupEffectBase.cs


namespace GameplayIngredients.Pickup
{
public abstract class PickupEffectBase : ScriptableObject
public abstract class PickupEffectBase : MonoBehaviour
public float Duration = 0.0f;
public void ApplyPickupEffect(PickupOwnerBase owner)
{
owner.ApplyEffect(this);
}
public abstract void ApplyPickupEffect(PickupOwnerBase owner);
}
}

9
Runtime/Pickup/PickupOwnerBase.cs


{
public abstract class PickupOwnerBase : MonoBehaviour
{
public abstract void ApplyEffect<T>(T effect) where T : PickupEffectBase;
public bool PickUp(PickupItem pickup)
{
foreach (var effect in pickup.effects)
{
effect.ApplyPickupEffect(this);
}
return true;
}
}
}

2
Runtime/Pickup/PickupItem.cs.meta


fileFormatVersion: 2
guid: d37b1e4e191100f4a9c6dcf738a1dd0c
guid: cb53d9aba8538c442b9d9dd0cd192fe0
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
Runtime/Factory/Factory.cs.meta


fileFormatVersion: 2
guid: 39322b75bba8c564ea36c0a2dac5fa5b
guid: d69cd00f40343984eaf286a54b36348c
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
Runtime/Factory/FactorySpawnAction.cs.meta


fileFormatVersion: 2
guid: f21114e0618fe3f46b38e1834c6157a7
guid: bc5c180f8bf863b4da50cd3ac688bda3
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
Runtime/Rigs/DirectorControlRig.cs.meta


fileFormatVersion: 2
guid: 743ad692893d70d47a1b79701b625d22
guid: 427bc2b8b7ec57044b3c989995a9bee2
MonoImporter:
externalObjects: {}
serializedVersion: 2

8
Runtime/Factory.meta


fileFormatVersion: 2
guid: f2898aea74971ab4b87f50fb01c8dfac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

12
Runtime/Pickup/PickupItem.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Pickup
{
public class PickupItem : MonoBehaviour
{
public PickupEffectBase[] effects { get { return GetComponents<PickupEffectBase>(); } }
}
}

65
Runtime/Rigs/DirectorControlRig.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
namespace GameplayIngredients.Rigs
{
public class DirectorControlRig : MonoBehaviour
{
[NonNullCheck]
public PlayableDirector director;
public bool Playing = false;
public bool Reverse = false;
public bool UnscaledGameTime = false;
public DirectorWrapMode wrapMode = DirectorWrapMode.Hold;
float nextPauseTime = -1.0f;
private void OnEnable()
{
if (director != null)
director.timeUpdateMode = DirectorUpdateMode.Manual;
}
public void Play(PlayableAsset asset = null, bool reverse = false, float time = 0.0f)
{
Playing = true;
Reverse = reverse;
director.time = time;
if(asset != null)
director.playableAsset = asset;
}
public void Play(PlayableAsset asset = null)
{
Play(asset, Reverse, (float)director.time);
}
public void Pause()
{
director.Pause();
}
public void SetTime(float time, bool Reverse = false)
{
director.time = time;
director.Evaluate();
}
public void Update()
{
if(Playing)
{
float dt = UnscaledGameTime? Time.unscaledDeltaTime : Time.deltaTime;
director.time += Reverse ? -1.0f : 1.0f * dt;
director.Evaluate();
}
}
}
}

144
Runtime/Factory/Factory.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace GameplayIngredients
{
public class Factory : MonoBehaviour
{
public enum BlueprintSelectionMode
{
Random,
Sequential,
Shuffle
}
public enum SpawnTargetSelection
{
OneSequential,
OneRandom,
All
}
[ReorderableList, NonNullCheck]
public GameObject[] FactoryBlueprints;
[NonNullCheck]
public GameObject SpawnTarget;
public BlueprintSelectionMode blueprintSelecionMode = BlueprintSelectionMode.Random;
public bool RespawnTarget = true;
public float RespawnDelay = 3.0f;
[Min(1), SerializeField]
private int MaxInstances = 1;
[ReorderableList]
public Callable[] OnSpawn;
[ReorderableList]
public Callable[] OnRespawn;
List<GameObject> m_Instances;
public void Spawn()
{
if(SpawnTarget == null || FactoryBlueprints == null || FactoryBlueprints.Length == 0)
{
Debug.LogWarning(string.Format("Factory '{0}' : Cannot spawn as there are no spawn target or factory blueprints", gameObject.name));
return;
}
if (m_Instances == null)
m_Instances = new List<GameObject>();
if (m_Instances.Count <= MaxInstances)
{
GameObject newInstance = Spawn(SelectBlueprint(), SpawnTarget);
m_Instances.Add(newInstance);
Callable.Call(OnSpawn, newInstance);
}
}
private void Update()
{
if(m_Instances != null)
{
List<int> todelete = new List<int>();
for(int i = 0; i < m_Instances.Count; i++)
{
if(m_Instances[i] == null)
{
todelete.Add(i);
}
}
foreach (var index in todelete)
{
m_Instances.RemoveAt(index);
AddRespawnCoroutine();
}
}
}
private List<Coroutine> m_RespawnCoroutines;
private void AddRespawnCoroutine()
{
if (m_RespawnCoroutines == null)
m_RespawnCoroutines = new List<Coroutine>();
else
{
m_RespawnCoroutines.RemoveAll(o => o == null);
}
m_RespawnCoroutines.Add(StartCoroutine("Respawn", RespawnDelay));
}
private IEnumerable Respawn(float time)
{
yield return new WaitForSeconds(time);
Callable.Call(OnRespawn, this.gameObject);
Spawn();
}
private GameObject Spawn(GameObject blueprint, GameObject target)
{
var Go = Instantiate(blueprint, target.transform.position, target.transform.rotation);
Go.name = (blueprint.name);
return Go;
}
int currentBlueprintIndex = -1;
private GameObject SelectBlueprint()
{
switch(blueprintSelecionMode)
{
case BlueprintSelectionMode.Random:
currentBlueprintIndex = Random.Range(0, FactoryBlueprints.Length);
break;
case BlueprintSelectionMode.Sequential:
currentBlueprintIndex = (currentBlueprintIndex++) % FactoryBlueprints.Length;
break;
case BlueprintSelectionMode.Shuffle:
currentBlueprintIndex = Shuffle(currentBlueprintIndex);
break;
}
return FactoryBlueprints[currentBlueprintIndex];
}
List<int> shuffleIndices;
private int Shuffle(int i)
{
if(shuffleIndices == null || shuffleIndices.Count != FactoryBlueprints.Length)
{
shuffleIndices = Enumerable.Range(0, FactoryBlueprints.Length).OrderBy(x => Random.value).ToList();
}
return shuffleIndices[(shuffleIndices.IndexOf(i) + 1) % shuffleIndices.Count];
}
}
}

18
Runtime/Factory/FactorySpawnAction.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Actions
{
public class FactorySpawnAction : ActionBase
{
[NonNullCheck]
public Factory factory;
public override void Execute(GameObject instigator = null)
{
if (factory != null)
factory.Spawn();
}
}
}

8
Editor/SceneLogicEditor.meta


fileFormatVersion: 2
guid: ce6e750433f84154e8e85e8fcc025290
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

12
Runtime/Pickup/SamplePickupEffect.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Pickup
{
public class SamplePickupEffect : PickupEffectBase
{
public int Toto;
}
}

18
Runtime/Pickup/SamplePickupOwner.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SamplePickupOwner : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

8
NodeGraphProcessor.meta


fileFormatVersion: 2
guid: a7f14529a2d38974cb3d53b8d5014fb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

/Runtime/Pickup/SamplePickupEffect.cs.meta → /Runtime/Pickup/PickupItem.cs.meta

/Runtime/Pickup/SamplePickupOwner.cs.meta → /Runtime/Factory/Factory.cs.meta

/Editor/SceneLogicEditor/SceneLogicEditor.cs.meta → /Runtime/Factory/FactorySpawnAction.cs.meta

/Editor/SceneLogicEditor/SceneLogicHookNode.cs.meta → /Runtime/Rigs/DirectorControlRig.cs.meta

正在加载...
取消
保存