DTKCWM4J7PFNWAAES3RZHQGDA6PTDNX4TZVOXAKF5V7LCZBI3XUAC
List<Rune> runes;
float currentTime;
float latRuneTime;
int currentRuneIdx;
EffectContext context;
public void Reset() {
currentTime = 0;
latRuneTime = 0;
currentRuneIdx = 0;
// TODO : need to set caster / target
context = new EffectContext() { /* caster = caster, effectLocation = effectLocation */ };
}
// TODO: how are we supposed to return the effects?
fileFormatVersion: 2
guid: 077d31efe3dbc264a9acbf5afae25640
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TagColor {
Red, Green, Blue
}
public class TagSlot {
public TagColor color;
public float amount;
}
public class TagCounter {
TagSlot[] currentTags;
public TagCounter() {
currentTags = new TagSlot[Enum.GetNames(typeof(TagColor)).Length];
for (var i = 0; i < currentTags.Length ; i++) {
var tagSlot = new TagSlot();
tagSlot.color = (TagColor)i;
tagSlot.amount = 0;
currentTags[i] = tagSlot;
}
}
public IEnumerable<TagSlot> AsEnumerable() => currentTags;
public float this[string colorName]
{
get {
TagColor color;
bool isValidEnum = Enum.TryParse(colorName, out color);
if (!isValidEnum) {
throw new IndexOutOfRangeException();
}
return this[color];
}
set {
TagColor color;
bool isValidEnum = Enum.TryParse(colorName, out color);
if (!isValidEnum) {
throw new IndexOutOfRangeException();
}
this[color] = value;
}
}
public float this[TagColor color]
{
get {
int slotNum = (int)(color);
return currentTags[slotNum].amount;
}
set {
int slotNum = (int)(color);
currentTags[slotNum].amount = value;
}
}
}
fileFormatVersion: 2
guid: 1801fe9742a37094bab2dc27eac0e202
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c4299eb7af6691f4a82ce6a25fd96981
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Rune", menuName = "Combat/Rune")]
public class RuneRef : ScriptableObject
{
[SerializeField] Rune rune;
public static implicit operator Rune(RuneRef runeRef) => runeRef.rune;
private void OnEnable() {
if (rune != null) {
rune.Populate();
}
}
private void OnDisable() {
if (rune != null) {
rune.Clear();
}
}
}
fileFormatVersion: 2
guid: 8379cd5aee576e249a61013786e96118
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
[Serializable]
public class Rune
{
[SerializeField]
List<IEffect> effects;
List<IEffect> _effects = new List<IEffect>();
[SerializeField]
public float speed { get; set; }
[SerializeField]
public float manaCost { get; set; }
public Rune() {
Populate();
}
public void Populate() {
Clear();
if (_effects != null) {
_effects.AddRange(effects);
}
}
public void Clear() {
if (_effects != null) {
_effects.Clear();
}
}
public void Cast(EffectContext context) {
foreach ( var effect in _effects) {
effect.Effect(context);
}
}
}
fileFormatVersion: 2
guid: e52dc910970718c4486f81b64ba11f39
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d5e2a4a772bd54e40b9e51267815eab7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RemoveTagsEffect : IEffect
{
[SerializeField]
TagColor color {get; set;}
[SerializeField]
float divider {get; set;} = 1;
[SerializeField]
float flat {get; set;}
[SerializeField]
bool devideBeforeSubtract {get; set;}
public void Effect(EffectContext context) {
if (devideBeforeSubtract) {
context.addedTags[color] = context.addedTags[color] / divider - flat;
} else {
context.addedTags[color] = (context.addedTags[color] - flat) * divider;
}
}
}
fileFormatVersion: 2
guid: 1cac0320ee0a6cc42b5c0018b9772721
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.Serialization;
public interface IEffect
{
void Effect(EffectContext context);
}
fileFormatVersion: 2
guid: 0eac41ea94e25c948b420b67703ff9c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EffectContext
{
public TagCounter currentTags {get; set;} = new TagCounter();
public TagCounter addedTags {get; set;} = new TagCounter();
public TagCounter removedTags {get; set;} = new TagCounter();
public float currentDamage {get; set;}
public Transform caster {get; set;}
public Transform effectLocation {get; set;}
}
fileFormatVersion: 2
guid: 89ef4ba6de097824f9a8ba6ace237e79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CountTagsEffect : IEffect
{
[SerializeField]
TagColor color {get; set;}
[SerializeField]
AreaOfEffect area {get; set;}
[SerializeField]
bool friendOrFoeOff { get; set;}
public void Effect(EffectContext context) {
var targets = area.GetEffectedUnits(context.caster);
// TODO: Apply friendOrFoeOff
float amount = 0;
foreach (Transform traget in targets) {
TaggableUnit taggableUnit = traget.gameObject.GetComponent<TaggableUnit>();
amount += taggableUnit.currentTags[color];
}
context.currentTags[color] += amount;
}
}
fileFormatVersion: 2
guid: c9d51a91c63c57846b17fdacb95f1386
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public enum AoeShape {
SingleTarget, Radius, Cone, Path
}
public class AreaOfEffect
{
// TODO: might want to set it in context?
[SerializeField]
float length {get; set;}
[SerializeField]
float width {get; set;}
[SerializeField]
AoeShape shape {get; set;}
public IEnumerable<Transform> GetEffectedUnits(Transform origin) {
switch (shape) {
case AoeShape.SingleTarget: return AffectSingle(origin);
case AoeShape.Radius: return AffectRadius(origin);
case AoeShape.Cone: return AffectCone(origin);
case AoeShape.Path: return AffectPath(origin);
default:
throw new IndexOutOfRangeException();
}
}
IEnumerable<Transform> AffectSingle(Transform origin) {
return new Transform[] {origin};
}
IEnumerable<Transform> AffectRadius(Transform origin) {
float radius = Mathf.Max(length, width);
RaycastHit[] hits = Physics.SphereCastAll(origin.position, radius, origin.forward, 0, LayerMask.NameToLayer("units"));
return hits.Select(x=>x.transform);
}
IEnumerable<Transform> AffectCone(Transform origin) {
float radius = width;
float coneAngle = Mathf.Asin(width / 2 * length);
// Its problematic to cast a real cone, so we cast the full path and later
// calculate if the potential target is withint the cone.
RaycastHit[] hits = Physics.SphereCastAll(origin.position, radius, origin.forward, length, LayerMask.NameToLayer("units"));
return hits.Select(x=>x.transform).Where(unit => {
var angleBetween = origin.eulerAngles.z - unit.eulerAngles.z;
return (angleBetween <= coneAngle);
});
}
IEnumerable<Transform> AffectPath(Transform origin) {
float radius = width;
RaycastHit[] hits = Physics.SphereCastAll(origin.position, radius, origin.forward, length, LayerMask.NameToLayer("units"));
return hits.Select(x => x.transform);
}
}
fileFormatVersion: 2
guid: 1a9842bc57d8715478ee16c1721c2930
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ApplyDamage : IEffect
{
[SerializeField]
AreaOfEffect area {get; set;}
[SerializeField]
bool friendOrFoeOff { get; set;}
public void Effect(EffectContext context) {
var targets = area.GetEffectedUnits(context.caster);
// TODO: Do damage
}
}
fileFormatVersion: 2
guid: cb70d05d12788114ab0bd0d627425cfd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class AddTagsEffect : IEffect
{
[SerializeField]
TagColor color {get; set;}
[SerializeField]
float multiplier {get; set;}
[SerializeField]
float flat {get; set;}
[SerializeField]
bool multiplyBeforeAdd {get; set;}
public void Effect(EffectContext context) {
if (multiplyBeforeAdd) {
context.addedTags[color] = context.addedTags[color] * multiplier + flat;
} else {
context.addedTags[color] = (context.addedTags[color] + flat) * multiplier;
}
}
}
fileFormatVersion: 2
guid: 09fd81e877086164c84715b32d79d803
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class AccumulateDamageByTagEffect : IEffect
{
[SerializeField]
TagColor color {get; set;}
[SerializeField]
float multiplier {get; set;} = 1;
public void Effect(EffectContext context) {
context.currentDamage += multiplier * context.currentTags[color];
}
}