You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
- 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;
- }
- }
- }
|