some old local changes

This commit is contained in:
i.korystin
2019-08-04 00:45:18 +03:00
parent 70a767cf09
commit 1c1dd5cab6
48 changed files with 1017 additions and 0 deletions

View File

@@ -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;
}
}
}

View File

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

View File

@@ -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);
}
}

View File

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