some old local changes
This commit is contained in:
1 parent
70a767cf09
commit
1c1dd5cab6
48 files changed
+1017
No files matched your search
+77
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbefa1d122cfc4c4e99bd1a82f65569d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Executable
+66
@@ -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,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a45c0e16e46018a40813f228d30baa43
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
+53
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d0fe551d8f6b114cb3bfc83d880377a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
+41
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70a08a1fe8836f0419bd1b03f05a906a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in new issue
Block a user