瀏覽代碼

some old local changes

master
i.korystin 5 年之前
父節點
當前提交
1c1dd5cab6
共有 48 個文件被更改,包括 1017 次插入0 次删除
  1. +0
    -0
      Assets/scripts/coa4u/ActionsBase/ActionInstant.cs
  2. +0
    -0
      Assets/scripts/coa4u/ActionsInstant/ActionSelectRoamingPoint.cs
  3. +0
    -0
      Assets/scripts/coa4u/ActionsInterval/ActionMoveForward.cs
  4. +5
    -0
      Assets/scripts/coa4uext/Actions.meta
  5. +77
    -0
      Assets/scripts/coa4uext/Actions/ActionHolder.cs
  6. +8
    -0
      Assets/scripts/coa4uext/Actions/ActionHolder.cs.meta
  7. +66
    -0
      Assets/scripts/coa4uext/Actions/ActionIf.cs
  8. +8
    -0
      Assets/scripts/coa4uext/Actions/ActionIf.cs.meta
  9. +53
    -0
      Assets/scripts/coa4uext/Actions/ActionPlayer.cs
  10. +8
    -0
      Assets/scripts/coa4uext/Actions/ActionPlayer.cs.meta
  11. +41
    -0
      Assets/scripts/coa4uext/Actions/ActionSwitchState.cs
  12. +8
    -0
      Assets/scripts/coa4uext/Actions/ActionSwitchState.cs.meta
  13. +5
    -0
      Assets/scripts/coa4uext/Calcers.meta
  14. +15
    -0
      Assets/scripts/coa4uext/Calcers/Calcer.cs
  15. +8
    -0
      Assets/scripts/coa4uext/Calcers/Calcer.cs.meta
  16. +44
    -0
      Assets/scripts/coa4uext/Calcers/CalcerDirection.cs
  17. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerDirection.cs.meta
  18. +68
    -0
      Assets/scripts/coa4uext/Calcers/CalcerFloat.cs
  19. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerFloat.cs.meta
  20. +48
    -0
      Assets/scripts/coa4uext/Calcers/CalcerFloatCalc.cs
  21. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerFloatCalc.cs.meta
  22. +36
    -0
      Assets/scripts/coa4uext/Calcers/CalcerPosition.cs
  23. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerPosition.cs.meta
  24. +46
    -0
      Assets/scripts/coa4uext/Calcers/CalcerRandomDirection.cs
  25. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerRandomDirection.cs.meta
  26. +70
    -0
      Assets/scripts/coa4uext/Calcers/CalcerVector.cs
  27. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerVector.cs.meta
  28. +42
    -0
      Assets/scripts/coa4uext/Calcers/CalcerVectorCalc.cs
  29. +8
    -0
      Assets/scripts/coa4uext/Calcers/CalcerVectorCalc.cs.meta
  30. +5
    -0
      Assets/scripts/coa4uext/CoreClasses.meta
  31. +26
    -0
      Assets/scripts/coa4uext/CoreClasses/State.cs
  32. +8
    -0
      Assets/scripts/coa4uext/CoreClasses/State.cs.meta
  33. +5
    -0
      Assets/scripts/coa4uext/Predicates.meta
  34. +11
    -0
      Assets/scripts/coa4uext/Predicates/Predicate.cs
  35. +8
    -0
      Assets/scripts/coa4uext/Predicates/Predicate.cs.meta
  36. +29
    -0
      Assets/scripts/coa4uext/Predicates/PredicateDistanceGreater.cs
  37. +8
    -0
      Assets/scripts/coa4uext/Predicates/PredicateDistanceGreater.cs.meta
  38. +29
    -0
      Assets/scripts/coa4uext/Predicates/PredicateDistanceLess.cs
  39. +8
    -0
      Assets/scripts/coa4uext/Predicates/PredicateDistanceLess.cs.meta
  40. +14
    -0
      Assets/scripts/coa4uext/Predicates/PredicateFalse.cs
  41. +8
    -0
      Assets/scripts/coa4uext/Predicates/PredicateFalse.cs.meta
  42. +14
    -0
      Assets/scripts/coa4uext/Predicates/PredicateTrue.cs
  43. +8
    -0
      Assets/scripts/coa4uext/Predicates/PredicateTrue.cs.meta
  44. +5
    -0
      Assets/scripts/coa4uext/UnityComponents.meta
  45. +59
    -0
      Assets/scripts/coa4uext/UnityComponents/SeqActor.cs
  46. +8
    -0
      Assets/scripts/coa4uext/UnityComponents/SeqActor.cs.meta
  47. +44
    -0
      Assets/scripts/coa4uext/UnityComponents/SeqTest.cs
  48. +8
    -0
      Assets/scripts/coa4uext/UnityComponents/SeqTest.cs.meta

Assets/Scripts/coa4u/ActionsBase/ActionInstant.cs → Assets/scripts/coa4u/ActionsBase/ActionInstant.cs 查看文件


Assets/Scripts/coa4u/ActionsInstant/ActionSelectRoamingPoint.cs → Assets/scripts/coa4u/ActionsInstant/ActionSelectRoamingPoint.cs 查看文件


Assets/Scripts/coa4u/ActionsInterval/ActionMoveForward.cs → Assets/scripts/coa4u/ActionsInterval/ActionMoveForward.cs 查看文件


+ 5
- 0
Assets/scripts/coa4uext/Actions.meta 查看文件

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 47f23d1678e988842ba4d66cdde3c4f8
folderAsset: yes
DefaultImporter:
userData:

+ 77
- 0
Assets/scripts/coa4uext/Actions/ActionHolder.cs 查看文件

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
/// <summary>
/// Creates the and starts the given action instance at Start. If you're using calcers for parameters, they will be also calculated at start.
/// </summary>
class ActionHolder<T> : ActionInstant
where T : ActionInstant
{
protected T action;
protected object[] args;

public ActionHolder(params object[] args) : base()
{
this.args = args;
}

public override void Start()
{
if (target == null)
throw new Exception("Can start the action only after it's atached to the actor");
object[] nargs = new object[args.Length];
for (int i = 0; i < args.Length; i++)
{
if (args[i] is CalcerFloat)
{
nargs[i] = ((CalcerFloat)args[i]).value;
}
else if (args[i] is CalcerVector)
{
nargs[i] = ((CalcerVector)args[i]).value;
}
else
{
nargs[i] = args[i];
}
}

action = (T)Activator.CreateInstance(typeof(T), nargs);
action.SetActor(target);
action.locks = locks;
action.Start();
duration = action.duration;
if (action.running)
running = true;
}

public override void StepTimer(float dt)
{
if (target == null)
throw new Exception("Can update the action only after it's atached to the actor");
action.StepTimer(dt);
if (!action.running)
{
dtr = action.dtr;
Stop();
}
}

public override void Stop()
{
if (target == null)
throw new Exception("Can stop the action only after it's atached to the actor");
if (action.running)
action.Stop();
running = false;
}

public override ActionInstant Clone()
{
return new ActionHolder<T>(args);
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Actions/ActionHolder.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bbefa1d122cfc4c4e99bd1a82f65569d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 66
- 0
Assets/scripts/coa4uext/Actions/ActionIf.cs 查看文件

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
class ActionIf : ActionInterval
{
protected ActionInstant action;
protected Predicate predicate;
protected bool started;

public ActionIf(Predicate targetPredicate, ActionInstant targetAction)
: base(0)
{
action = targetAction;
predicate = targetPredicate;
}

public override ActionInstant Clone()
{
return new ActionIf(predicate, action);
}

public override ActionInstant Reverse()
{
return new ActionIf(predicate, action.Reverse());
}

public override void Start()
{
base.Start();
if (predicate.check())
{
started = true;
action.SetActor(target);
action.Start();
duration = action.duration;
}
else
{
running = false;
}
}

public override void StepTimer(float dt)
{
if (!started)
return;
dt *= timeScale;
if (action.running)
action.StepTimer(dt);
if (!action.running)
{
Stop();
dtr = action.dtr;
}
}

public override void Stop()
{
base.Stop();
action.Stop();
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Actions/ActionIf.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a45c0e16e46018a40813f228d30baa43
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 53
- 0
Assets/scripts/coa4uext/Actions/ActionPlayer.cs 查看文件

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
/// <summary>
/// Plays the action on another actor;
/// </summary>
class ActionPlayer : ActionInterval
{
protected ActionInstant action;
protected Actor actor;

public ActionPlayer(ActionInstant targetAction, Actor targetActor)
: base(0)
{
action = targetAction;
actor = targetActor;
}

public override ActionInstant Clone()
{
return new ActionPlayer(action, actor);
}

public override void Start()
{
base.Start();
actor.AttachAction(action);
if (!action.running)
running = false;
}

public override void StepTimer(float dt)
{
if (target == null)
throw new Exception("Can update the action only after it's atached to the actor");
action.StepTimer(dt);
if (!action.running)
{
dtr = action.dtr;
Stop();
}
}

public override void Step(float dt)
{
if (!action.running)
running = false;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Actions/ActionPlayer.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d0fe551d8f6b114cb3bfc83d880377a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 41
- 0
Assets/scripts/coa4uext/Actions/ActionSwitchState.cs 查看文件

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
class ActionSwitchState : ActionInstant
{
string stateName;
int stateIndex;

public ActionSwitchState(int targetIndex)
: base()
{
stateIndex = targetIndex;
}

public ActionSwitchState(string targetName)
: base()
{
stateName = targetName;
}

public override void Start()
{
base.Start();
if (!(target is SeqActor))
{
throw new Exception("Target is not capable of switching states.");
}
if (stateIndex != null)
{
((SeqActor)target).SetState(stateIndex);
}
else
{
((SeqActor)target).SetState(stateName);
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Actions/ActionSwitchState.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 70a08a1fe8836f0419bd1b03f05a906a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 5
- 0
Assets/scripts/coa4uext/Calcers.meta 查看文件

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 5a9b2c3311eddf04c861c0f8a385a3a0
folderAsset: yes
DefaultImporter:
userData:

+ 15
- 0
Assets/scripts/coa4uext/Calcers/Calcer.cs 查看文件

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public abstract class Calcer
{
}

public abstract class Calcer<T> : Calcer
{
public abstract T value {get;}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/Calcer.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c50d149e0d2dab4bb3a6114abdeb7e8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 44
- 0
Assets/scripts/coa4uext/Calcers/CalcerDirection.cs 查看文件

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerDirection : CalcerVector
{
Actor selfActor;
Actor targetActor;
Transform selfTransform;
Transform targetTransform;

public CalcerDirection(Actor self, Actor target)
: base()
{
selfActor = self;
targetActor = target;
}

public CalcerDirection(Transform self, Transform target)
: base()
{
selfTransform = self;
targetTransform = target;
}

public override Vector3 value
{
get
{
if (targetTransform != null)
{
return Quaternion.LookRotation(targetTransform.position - selfTransform.position).eulerAngles;
}
else
{
return Quaternion.LookRotation(targetActor.transformCached.position - selfActor.transformCached.position).eulerAngles;
}
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerDirection.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0a0a80ede5ea3dc42a372d76d2004cd0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 68
- 0
Assets/scripts/coa4uext/Calcers/CalcerFloat.cs 查看文件

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerFloat : Calcer<float>
{
private float internalValue;

public CalcerFloat()
{
}

public CalcerFloat(float value)
{
internalValue = value;
}

public CalcerFloat(int value)
{
internalValue = (float)value;
}

public CalcerFloat(double value)
{
internalValue = (float)value;
}

public override float value
{
get
{
return internalValue;
}
}

public static implicit operator CalcerFloat(float val)
{
return new CalcerFloat(val);
}

public static implicit operator float(CalcerFloat calc)
{
return calc.value;
}

public static CalcerFloat operator +(CalcerFloat first, CalcerFloat second)
{
return new CalcerFloatCalc(first, second, CalcerFloatCalc.Operation.Add);
}

public static CalcerFloat operator -(CalcerFloat first, CalcerFloat second)
{
return new CalcerFloatCalc(first, second, CalcerFloatCalc.Operation.Sub);
}

public static CalcerFloat operator *(CalcerFloat first, CalcerFloat second)
{
return new CalcerFloatCalc(first, second, CalcerFloatCalc.Operation.Mul);
}

public static CalcerFloat operator /(CalcerFloat first, CalcerFloat second)
{
return new CalcerFloatCalc(first, second, CalcerFloatCalc.Operation.Div);
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerFloat.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7e93dc2f49487544fa3a9b1468d66779
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 48
- 0
Assets/scripts/coa4uext/Calcers/CalcerFloatCalc.cs 查看文件

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerFloatCalc : CalcerFloat
{
public enum Operation
{
Add,
Sub,
Mul,
Div
}

private Operation operation;
private CalcerFloat first;
private CalcerFloat second;

public CalcerFloatCalc(CalcerFloat first, CalcerFloat second, Operation operation = Operation.Add)
{
this.first = first;
this.second = second;
this.operation = operation;
}

public float value
{
get
{
switch (operation)
{
case Operation.Add:
return first.value + second.value;
case Operation.Sub:
return first.value - second.value;
case Operation.Mul:
return first.value * second.value;
case Operation.Div:
return first.value / second.value;
default:
throw new Exception("Operation not found.");
}
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerFloatCalc.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45cbf8512a210f942a10b844f2000826
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 36
- 0
Assets/scripts/coa4uext/Calcers/CalcerPosition.cs 查看文件

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerPosition : CalcerVector
{
Actor targetActor;
Transform targetTransform;

public CalcerPosition(Actor target)
: base()
{
this.targetActor = target;
}

public CalcerPosition(Transform target)
: base()
{
this.targetTransform = target;
}

public override Vector3 value
{
get
{
if (targetTransform != null)
return (Vector3)targetTransform.position;
else
return (Vector3)targetActor.transformCached.position;
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerPosition.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6f377903d22e64e409c946c5ec777bb9
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 46
- 0
Assets/scripts/coa4uext/Calcers/CalcerRandomDirection.cs 查看文件

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerRandomDirection : CalcerVector
{
Axises axises;

public CalcerRandomDirection(Axises axises)
{
this.axises = axises;
}

public override Vector3 value
{
get
{
float x = UnityEngine.Random.Range(-360.0F, 360.0F);
float y = UnityEngine.Random.Range(-360.0F, 360.0F);
float z = UnityEngine.Random.Range(-360.0F, 360.0F);
switch (axises)
{
case Axises.x:
return new Vector3(x, 0, 0);
case Axises.y:
return new Vector3(0, y, 0);
case Axises.z:
return new Vector3(0, 0, z);
case Axises.xy:
return new Vector3(x, y, 0);
case Axises.xz:
return new Vector3(x, 0, z);
case Axises.yz:
return new Vector3(0, y, z);
case Axises.xyz:
return new Vector3(x, y, z);
default:
return Vector3.zero;
}
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerRandomDirection.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5ad17ef81ba6b9944bf5aa283e4be908
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 70
- 0
Assets/scripts/coa4uext/Calcers/CalcerVector.cs 查看文件

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerVector : Calcer<Vector3>
{
private Vector3 internalValue;
private int dimensions;

public CalcerVector()
{
}

public CalcerVector(Vector3 value)
{
internalValue = value;
dimensions = 3;
}

public CalcerVector(Vector2 value)
{
internalValue = value;
dimensions = 2;
}

public override Vector3 value
{
get
{
switch (dimensions)
{
case 3:
return (Vector3)internalValue;
case 2:
return (Vector2)internalValue;
default:
return internalValue;
}
}
}

public static implicit operator CalcerVector(Vector3 val)
{
return new CalcerVector(val);
}

public static implicit operator CalcerVector(Vector2 val)
{
return new CalcerVector(val);
}

public static implicit operator Vector3(CalcerVector calc)
{
return calc.value;
}

public static CalcerVector operator +(CalcerVector first, CalcerVector second)
{
return new CalcerVectorCalc(first, second, CalcerVectorCalc.Operation.Add);
}

public static CalcerVector operator -(CalcerVector first, CalcerVector second)
{
return new CalcerVectorCalc(first, second, CalcerVectorCalc.Operation.Sub);
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerVector.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6c04bfd357341874e8be24608bfd976e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 42
- 0
Assets/scripts/coa4uext/Calcers/CalcerVectorCalc.cs 查看文件

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace coa4u
{
public class CalcerVectorCalc : CalcerVector
{
public enum Operation
{
Add,
Sub
}

private Operation operation;
private CalcerVector first;
private CalcerVector second;

public CalcerVectorCalc(CalcerVector first, CalcerVector second, Operation operation = Operation.Add)
{
this.first = first;
this.second = second;
this.operation = operation;
}

public override Vector3 value
{
get
{
switch (operation)
{
case Operation.Add:
return first.value + second.value;
case Operation.Sub:
return first.value - second.value;
default:
throw new Exception("Operation not found.");
}
}
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Calcers/CalcerVectorCalc.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 78a730b682beb8d4180d80db8bdc6537
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 5
- 0
Assets/scripts/coa4uext/CoreClasses.meta 查看文件

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 38016d14a3449b7478e2c667c72063f6
folderAsset: yes
DefaultImporter:
userData:

+ 26
- 0
Assets/scripts/coa4uext/CoreClasses/State.cs 查看文件

@@ -0,0 +1,26 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public class State
{
public readonly ActionInstant action;
public readonly Predicate trigger;
public readonly string name;

public State(ActionInstant targetAction, string targetName = "")
{
action = targetAction;
name = targetName;
}

public State(Predicate targetTrigger, ActionInstant targetAction, string targetName = "")
{
trigger = targetTrigger;
action = targetAction;
name = targetName;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/CoreClasses/State.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ebc37cf537501dd4f9290a911cb5b757
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 5
- 0
Assets/scripts/coa4uext/Predicates.meta 查看文件

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 470c1cdb0ca2c1a4895bc641646f9474
folderAsset: yes
DefaultImporter:
userData:

+ 11
- 0
Assets/scripts/coa4uext/Predicates/Predicate.cs 查看文件

@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public abstract class Predicate
{
public abstract bool check();
}
}

+ 8
- 0
Assets/scripts/coa4uext/Predicates/Predicate.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 97583e10785bec74c939caf211b248b8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 29
- 0
Assets/scripts/coa4uext/Predicates/PredicateDistanceGreater.cs 查看文件

@@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public class PredicateDistanceGreater : Predicate
{
protected CalcerVector first;
protected CalcerVector second;
protected float distance;

public PredicateDistanceGreater(CalcerVector one, CalcerVector other, float dist)
: base()
{
first = one;
second = other;
distance = dist;
}

public override bool check()
{
if (Vector3.Distance(first.value, second.value) > distance)
return true;
else
return false;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Predicates/PredicateDistanceGreater.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17a24fb6b2830f24fb10e079734a432f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 29
- 0
Assets/scripts/coa4uext/Predicates/PredicateDistanceLess.cs 查看文件

@@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public class PredicateDistanceLess : Predicate
{
protected CalcerVector first;
protected CalcerVector second;
protected float distance;

public PredicateDistanceLess(CalcerVector one, CalcerVector other, float dist)
: base()
{
first = one;
second = other;
distance = dist;
}

public override bool check()
{
if (Vector3.Distance(first.value, second.value) <= distance)
return true;
else
return false;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Predicates/PredicateDistanceLess.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1f98bec35befcf141bfda4291e7aea41
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 14
- 0
Assets/scripts/coa4uext/Predicates/PredicateFalse.cs 查看文件

@@ -0,0 +1,14 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public class PredicateFalse : Predicate
{
public override bool check()
{
return false;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Predicates/PredicateFalse.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c046509f9d6d55b45a9643e86a29c95c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 14
- 0
Assets/scripts/coa4uext/Predicates/PredicateTrue.cs 查看文件

@@ -0,0 +1,14 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;

namespace coa4u
{
public class PredicateTrue : Predicate
{
public override bool check()
{
return true;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/Predicates/PredicateTrue.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f6a4b0a53e20504fa28937299d4df63
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 5
- 0
Assets/scripts/coa4uext/UnityComponents.meta 查看文件

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 45d3e250968191147aeb6b6346456173
folderAsset: yes
DefaultImporter:
userData:

+ 59
- 0
Assets/scripts/coa4uext/UnityComponents/SeqActor.cs 查看文件

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using coa4u;

[System.Serializable]
public class SeqActor : Actor
{
protected State[] states;
protected int index;
protected List<int> stateLog = new List<int>();
protected ActionInstant currentStateAction;

public void SetState(int idx)
{
if (idx < states.Length)
{
stateLog.Add(idx);
index = idx;
if (currentStateAction != null)
RemoveAction(currentStateAction);
currentStateAction = states[idx].action;
AttachAction(currentStateAction);
}
else
{
throw new Exception("Actor doesn't have the state " + idx.ToString());
}
}

public void SetState(string name)
{
SetState(Array.FindIndex<State>(states, x => x.name == name));
}

public int currentStateIndex
{
get
{
return index;
}
}

public string currentStateName
{
get
{
return states[index].name;
}
}

public List<int> log
{
get
{
return stateLog;
}
}
}

+ 8
- 0
Assets/scripts/coa4uext/UnityComponents/SeqActor.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fe7dfa7af5880d044b663b7fce129ce4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

+ 44
- 0
Assets/scripts/coa4uext/UnityComponents/SeqTest.cs 查看文件

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using coa4u;

[System.Serializable]
public class SeqTest : SeqActor
{
public Actor enemy;
Vector3 startPosition;

void Start()
{
startPosition = transformCached.position;
CalcerVector endPosition = new CalcerPosition(enemy) + new CalcerVector(new Vector3(-2F, transformCached.position.y, 0F));

ActionInstant stateDefault = new ActionSequence(
new ActionInstant[]
{
new ActionDelay(3),
new ActionSwitchState(1)
});
ActionInstant stateRoam = new ActionSequence(
new ActionInstant[] {
new ActionHolder<ActionSetDirection>(new CalcerPosition(enemy)),
new ActionHolder<ActionJumpTo>(endPosition, 5, 1, 1),
new ActionDelay(0.5F),
new ActionHolder<ActionMoveTo>(new CalcerPosition(enemy), 0.1F),
new ActionHolder<ActionMoveTo>(endPosition, 0.1F),
new ActionDelay(0.5F),
new ActionJumpTo(startPosition, 5, 1, 1),
new ActionSwitchState(0)
});
states = new State[]
{
new State(stateDefault, "wait"),
new State(stateRoam, "attack")
};

SetState(0);
}
}

+ 8
- 0
Assets/scripts/coa4uext/UnityComponents/SeqTest.cs.meta 查看文件

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a97027e8b127e5049be5e16c73c87275
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: