bool IsClose(StateMachineController controller) { bool close = false; var p = controller.transform.TransformPoint(Vector3.right * 0.5f); RaycastHit hit; float rayLength = 0f; if (Physics.Raycast(p, controller.transform.forward, out hit, controller.parameter.lookRange) && hit.transform.CompareTag("Blocks")) { if (hit.distance < controller.parameter.nearDistance) { close = true; } rayLength = hit.distance; } else { rayLength = controller.parameter.lookRange; } Debug.DrawRay(p, controller.transform.forward * rayLength, controller.currentState.stateColor); return(close); }
public void OnStart() { rand = new Random(); myZone = gameObject.RequireComponent <CZone>(); //mySound.AddSound("RadioStatic.vente"); //mySound.AddSound("BeginOutro.vente"); //mySound.AddSound("Heartbeat.vente"); //mySound.Loop(true, "static.vente"); mySound = gameObject.RequireComponent <CSound>(); //mySound.PlayIndependentEvent("static.vente"); smc = new StateMachineController(); unactive = new State(smc, null, State_unactive_Update, null); lightson = new State(smc, State_lightson_Start, State_lightson_Update, null, 1.0f); lightsoff = new State(smc, State_lightsoff_Start, null, null, 1.0f, lightson); lightsonwait = new State(smc, null, null, null, 1.0f, lightsoff); lightson.NextState = lightson; smc.SetState(unactive); foreach (GameObject g in GameObject.GetGameObjectsWithTag("TLight")) { lights.Add(g.RequireComponent <CLight>()); g.RequireComponent <CSound>(); //.AddSound("LightTurnOn.vente"); } foreach (GameObject g in GameObject.GetGameObjectsWithTag("FlickerLight")) { GetScriptClass <LightFlicker>(g).activated = true; } MonsterEncounter1 me = GetScript <MonsterEncounter1>(GameObject.GetGameObjectByName("Monster1")); me.gameObject.RequireComponent <CMeshRenderer>().setEnabled(false); }
/// <inheritdoc /> public void Deserialize(Stream stream, Controller controller) { StateMachineController smc = EnsureControllerType(controller); using (var reader = new BinaryReader(stream, FileEncoding.Default, true)) { smc.Unknown0 = reader.ReadInt32(); smc.GraphName = reader.ReadNullTerminatedString(); smc.Unknown1 = reader.ReadInt32(); int entryCount = reader.ReadInt32(); smc.Unknown2 = reader.ReadInt32(); smc.Unknown3 = reader.ReadInt32(); smc.StateEntries = new List <StateMachineEntry>(entryCount); for (int i = 0; i < entryCount; i++) { if (reader.ReadInt32() != Magics.Entry) { throw new SilentHunterParserException("Unexpected data encountered."); } smc.StateEntries.Add(ReadEntry(stream, reader)); } } }
bool IsNeighborCloseOrFar(StateMachineController controller) { bool neighborDistOutRange = false; RaycastHit hit; float rayLength = 0f; if (Physics.SphereCast(controller.transform.position, controller.parameter.sphereCastRadius, controller.transform.forward, out hit, controller.parameter.lookRange) && hit.transform.CompareTag("Blocks")) { if (hit.distance > controller.parameter.farDistance || hit.distance < controller.parameter.nearDistance) { neighborDistOutRange = true; } rayLength = hit.distance; } else { rayLength = controller.parameter.lookRange; } Debug.DrawRay(controller.transform.position, controller.transform.forward * rayLength, controller.currentState.stateColor); return(neighborDistOutRange); }
public static void RemoveIrrigation(GameObject plant) { StateMachineController controller = plant.GetComponent <StateMachineController>(); if (controller != null) { IrrigationMonitor.Def def = plant.GetDef <IrrigationMonitor.Def>(); if (def != null) { controller.cmpdef.defs.Remove(def); } FertilizationMonitor.Def def2 = plant.GetDef <FertilizationMonitor.Def>(); if (def2 != null) { controller.cmpdef.defs.Remove(def2); } } ManualDeliveryKG[] delivers = plant.GetComponents <ManualDeliveryKG>(); foreach (ManualDeliveryKG deliver in delivers) { UnityEngine.Object.DestroyImmediate(deliver); } }
bool IsAngleOutRange(StateMachineController controller) { bool outRange = false; foreach (var s in controller.sources) { var d = Vector3.Distance(controller.transform.position, s.position); if (d > controller.parameter.lookSourceRange) { continue; } var a = controller.transform.forward.normalized; var b = (s.position - controller.transform.position).normalized; DrawAngle(controller.transform.position, a, b); float angle = Vector3.Angle(a, b); if (s.position.x > controller.transform.position.x) { angle = -angle; } if (angle > controller.parameter.maxAngle || angle < controller.parameter.minAngle) { outRange = true; } } return(outRange); }
public void OnStart() { myZone = gameObject.RequireComponent <CZone>(); //mySound.AddSound("RadioStatic.vente"); //mySound.AddSound("BeginOutro.vente"); //mySound.AddSound("Heartbeat.vente"); //mySound.Loop(true, "static.vente"); mySound = gameObject.RequireComponent <CSound>(); //mySound.PlayIndependentEvent("static.vente"); smc = new StateMachineController(); unactive = new State(smc, null, State_unactive_Update, null); lightson = new State(smc, State_lightson_Start, State_lightson_Update, null, _lightson[0]); lightsoff = new State(smc, State_lightsoff_Start, null, null, 1.0f, lightson); finished = new State(smc); finale = new State(smc, State_finale_Start, null, State_finale_End, 5.0f, finished); lightsonwait = new State(smc, null, null, null, 1.0f, lightsoff); lightson.NextState = lightson; smc.SetState(unactive); foreach (GameObject g in GameObject.GetGameObjectsWithTag("TLight")) { lights.Add(g.RequireComponent <CLight>()); g.RequireComponent <CSound>(); //.AddSound("LightTurnOn.vente"); } foreach (CLight l in lights) { l.setEnabled(false); } }
public StateMachineControllerSerializerTests() { _sut = new StateMachineControllerSerializer(); _controller = new Mock <StateMachineController>().Object; _rawControllerData = GetType().Assembly.GetManifestResourceStream(GetType(), "StateMachineController.chunkdata").ToArray(); }
bool IsAngleSmall(StateMachineController controller) { bool small = false; foreach (var s in controller.sources) { var d = Vector3.Distance(controller.transform.position, s.position); if (d > controller.parameter.lookSourceRange) { continue; } var a = controller.transform.forward.normalized; var b = (s.position - controller.transform.position).normalized; LookSourceAngleDecision.DrawAngle(controller.transform.position, a, b); float angle = Vector3.Angle(a, b); if (s.position.x > controller.transform.position.x) { angle = -angle; } if (angle < controller.parameter.minAngle) { small = true; } } return(small); }
void RotateCw(StateMachineController controller) { //if (controller.CoolDownTime(controller.parameter.actionRate)) { controller.transform.Rotate(0, controller.parameter.rotateSpeed, 0); } }
/// <summary> /// Awake. /// </summary> private void Awake() { _stateMachineController = new StateMachineController(); _navMeshAgent = GetComponent <NavMeshAgent>(); _entity = GetComponent <Entity>(); EntityIdle entityIdle = new EntityIdle(); EntityChasePlayer entityChasePlayer = new EntityChasePlayer(_navMeshAgent); EntityAttack entityAttack = new EntityAttack(); EntityDead entityDead = new EntityDead(); _stateMachineController.Add(entityIdle); _stateMachineController.Add(entityChasePlayer); _stateMachineController.Add(entityAttack); _stateMachineController.AddAnyStateTransition(entityDead, () => _entity.IsDead); Player player = FindObjectOfType <Player>(); _stateMachineController.AddStateTransition(entityIdle, entityChasePlayer, () => FlatDistance(_navMeshAgent.transform.position, player.transform.position) < 5); _stateMachineController.AddStateTransition(entityChasePlayer, entityAttack, () => FlatDistance(_navMeshAgent.transform.position, player.transform.position) < 2); _stateMachineController.ChangeState(entityIdle); }
public void OnSpawn(GameObject go) { Sensors component = go.GetComponent <Sensors>(); component.Add(new PathProberSensor(component)); component.Add(new SafeCellSensor(component)); component.Add(new IdleCellSensor(component)); component.Add(new PickupableSensor(component)); component.Add(new ClosestEdibleSensor(component)); component.Add(new BreathableAreaSensor(component)); component.Add(new AssignableReachabilitySensor(component)); component.Add(new ToiletSensor(component)); component.Add(new MingleCellSensor(component)); StateMachineController component2 = go.GetComponent <StateMachineController>(); RationalAi.Instance instance = new RationalAi.Instance(component2); instance.StartSM(); if (go.GetComponent <OxygenBreather>().GetGasProvider() == null) { go.GetComponent <OxygenBreather>().SetGasProvider(new GasBreatherFromWorldProvider()); } Navigator component3 = go.GetComponent <Navigator>(); component3.transitionDriver.overrideLayers.Add(new BipedTransitionLayer(component3, 3.325f, 2.5f)); component3.transitionDriver.overrideLayers.Add(new DoorTransitionLayer(component3)); component3.transitionDriver.overrideLayers.Add(new TubeTransitionLayer(component3)); component3.transitionDriver.overrideLayers.Add(new LadderDiseaseTransitionLayer(component3)); component3.transitionDriver.overrideLayers.Add(new ReactableTransitionLayer(component3)); component3.transitionDriver.overrideLayers.Add(new SplashTransitionLayer(component3)); ThreatMonitor.Instance sMI = go.GetSMI <ThreatMonitor.Instance>(); if (sMI != null) { sMI.def.fleethresholdState = Health.HealthState.Critical; } }
public void OnStart() { _onTime = 1.0f; _transitionOffTime = 0.1f; _transitionOnfTime = 0.2f; _minOffHoldTime = 0.1f; _maxOffHoldTime = 0.5f; _minOnHoldTime = 0.1f; _maxOnHoldTime = 0.5f; _minoffinten = 0.1f; _maxoffinten = 0.5f; _minonintern = 0.8f; _maxonintern = 1.1f; smc = new StateMachineController(); light = gameObject.RequireComponent <CLight>(); timer += MMath.GetRandomFloat() * 2.0f; lighthold = new State(smc, null, null, null, MinOnHoldTime, null); lighton = new State(smc, S_LightOn_Start, S_Light_Update, null, TransitionOnTime, lighthold); lightoff = new State(smc, S_LightOff_Start, S_Light_Update, null, TransitionOffTime, lighthold); smc.SetState(lightoff); mSound = gameObject.RequireComponent <CSound>(); }
public void OnStart() { myZone = gameObject.RequireComponent<CZone>(); //mySound.AddSound("RadioStatic.vente"); //mySound.AddSound("BeginOutro.vente"); //mySound.AddSound("Heartbeat.vente"); //mySound.Loop(true, "static.vente"); mySound = gameObject.RequireComponent<CSound>(); //mySound.PlayIndependentEvent("static.vente"); smc = new StateMachineController(); unactive = new State(smc, null, State_unactive_Update, null); lightson = new State(smc, State_lightson_Start, State_lightson_Update, null, _lightson[0]); lightsoff = new State(smc, State_lightsoff_Start, null, null, 1.0f, lightson); finished = new State(smc); finale = new State(smc, State_finale_Start, null, State_finale_End, 5.0f, finished); lightsonwait = new State(smc, null, null, null, 1.0f, lightsoff); lightson.NextState = lightson; smc.SetState(unactive); foreach (GameObject g in GameObject.GetGameObjectsWithTag("TLight")) { lights.Add(g.RequireComponent<CLight>()); g.RequireComponent<CSound>(); //.AddSound("LightTurnOn.vente"); } foreach (CLight l in lights) l.setEnabled(false); }
bool IsNeighborTooFar(StateMachineController controller) { bool tooFar = false; RaycastHit hit; float rayLength = 0f; if (Physics.SphereCast(controller.transform.position, controller.parameter.sphereCastRadius, controller.transform.forward, out hit, controller.parameter.lookRange) && hit.transform.CompareTag("Blocks")) { if (hit.distance > controller.parameter.farDistance) { tooFar = true; } rayLength = hit.distance; } else { rayLength = controller.parameter.lookRange; } Debug.DrawRay(controller.transform.position, controller.transform.forward * rayLength, Color.blue); return(tooFar); }
public void OnStart() { rand = new Random(); myZone = gameObject.RequireComponent<CZone>(); //mySound.AddSound("RadioStatic.vente"); //mySound.AddSound("BeginOutro.vente"); //mySound.AddSound("Heartbeat.vente"); //mySound.Loop(true, "static.vente"); mySound = gameObject.RequireComponent<CSound>(); //mySound.PlayIndependentEvent("static.vente"); smc = new StateMachineController(); unactive = new State(smc, null, State_unactive_Update, null); lightson = new State(smc, State_lightson_Start, State_lightson_Update, null, 1.0f); lightsoff = new State(smc, State_lightsoff_Start, null, null, 1.0f, lightson); lightsonwait = new State(smc, null, null, null, 1.0f, lightsoff); lightson.NextState = lightson; smc.SetState(unactive); foreach (GameObject g in GameObject.GetGameObjectsWithTag("TLight")) { lights.Add(g.RequireComponent<CLight>()); g.RequireComponent<CSound>(); //.AddSound("LightTurnOn.vente"); } foreach (GameObject g in GameObject.GetGameObjectsWithTag("FlickerLight")) { GetScriptClass<LightFlicker>(g).activated = true; } MonsterEncounter1 me = GetScript<MonsterEncounter1>(GameObject.GetGameObjectByName("Monster1")); me.gameObject.RequireComponent<CMeshRenderer>().setEnabled(false); }
public void OnStart() { trans_ = gameObject.RequireComponent<CTransform>(); upperTrans_ = GameObject.GetGameObjectByName("spinner_upper").RequireComponent<CTransform>(); lowerTrans_ = GameObject.GetGameObjectByName("spinner_lower").RequireComponent<CTransform>(); trans_.SetPositionY(lowerTrans_.position.y); leftSound_ = GameObject.GetGameObjectByName("spinner_left").RequireComponent<CSound>(); rightSound_ = GameObject.GetGameObjectByName("spinner_right").RequireComponent<CSound>(); smc = new StateMachineController(); startup = new State(smc, null, State_startup_Update, null); riseup = new State(smc, State_riseup_OnStart, State_riseup_Update, null); lowerdown = new State(smc, State_lowerdown_OnStart, State_lowerdown_Update, null); end = new State(smc, null, State_end_Update, null); smc.SetState(startup); transitionTime_ = 3; startupTimer_ = 0; startupTime_ = 5; shutdownTime_ = 7; riseupTimer_ = 0; riseupTime_ = 5; revInitTime_ = 20.0f; revFinalTime_ = 1.0f; }
public void OnStart() { trans_ = gameObject.RequireComponent <CTransform>(); upperTrans_ = GameObject.GetGameObjectByName("spinner_upper").RequireComponent <CTransform>(); lowerTrans_ = GameObject.GetGameObjectByName("spinner_lower").RequireComponent <CTransform>(); trans_.SetPositionY(lowerTrans_.position.y); leftSound_ = GameObject.GetGameObjectByName("spinner_left").RequireComponent <CSound>(); rightSound_ = GameObject.GetGameObjectByName("spinner_right").RequireComponent <CSound>(); smc = new StateMachineController(); startup = new State(smc, null, State_startup_Update, null); riseup = new State(smc, State_riseup_OnStart, State_riseup_Update, null); lowerdown = new State(smc, State_lowerdown_OnStart, State_lowerdown_Update, null); end = new State(smc, null, State_end_Update, null); smc.SetState(startup); transitionTime_ = 3; startupTimer_ = 0; startupTime_ = 5; shutdownTime_ = 7; riseupTimer_ = 0; riseupTime_ = 5; revInitTime_ = 20.0f; revFinalTime_ = 1.0f; }
protected override void OnActivated() { base.OnActivated(); _stateMachineCacheController = Frame.GetController <StateMachineCacheController>(); _stateMachineController = Frame.GetController <StateMachineController>(); _stateMachineController.ChangeStateAction.ItemsChanged += ChangeStateActionOnItemsChanged; ObjectSpace.ObjectChanged += ObjectSpaceOnObjectChanged; }
void GetAway(StateMachineController controller) { var closetEnemy = controller.GetClosetEnemy(); var dir = -(closetEnemy.transform.position - controller.transform.position).normalized; controller.transform.Translate(new Vector3(dir.x, 0f, dir.z) * controller.parameter.moveSpeed); }
public State(StateMachineController smc, Action _OnEnter, Action _OnUpdate, Action _OnExit, float _MaxTimeInState = 0.0f, State _nextState = null) { MyStateMachineController = smc; OnEnter = _OnEnter; OnUpdate = _OnUpdate; OnExit = _OnExit; MaxTimeInState = _MaxTimeInState; NextState = _nextState; }
public static bool OnOpen(int instanceID, int line) { StateMachineController statemachine = EditorUtility.InstanceIDToObject(instanceID) as StateMachineController; if (statemachine != null) { OpenWindow(statemachine); return(true); } return(false); }
public void initial_change_state_switches_to_state() { StateMachineController stateMachineController = new StateMachineController(); IState firstState = Substitute.For <IState>(); stateMachineController.Add(firstState); stateMachineController.ChangeState(firstState); Assert.AreSame(firstState, stateMachineController.CurrentState); }
void Start() { // Initialise the accessable script components _agentData = GetComponent <AgentData>(); _agentActions = GetComponent <AgentActions>(); _agentSenses = GetComponentInChildren <Sensing>(); _agentInventory = GetComponentInChildren <InventoryController>(); StateMachine = new StateMachineController <AI>(this); //Creates a state machine for this AI Agent StateMachine.ChangeState(GotoEnemyBaseState.Instance); //Set the initial state of the AI Player }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public static void RemoveDef(GameObject go, StateMachine.BaseDef def) { StateMachineController controller = go.GetComponent <StateMachineController>(); if (controller != null) { if (def != null) { controller.cmpdef.defs.Remove(def); } } }
void GetClose(StateMachineController controller) { RaycastHit hit; if (Physics.SphereCast(controller.transform.position, controller.parameter.sphereCastRadius, controller.transform.forward, out hit, controller.parameter.lookRange)) { //if( controller.CoolDownTime(controller.parameter.actionRate)) { controller.transform.Translate((hit.transform.position - controller.transform.position).normalized * controller.parameter.moveSpeed); } } }
protected override void OnActivated() { base.OnActivated(); if (Application.CanBuildSecurityObjects()) { _stateMachineController = Frame.GetController <StateMachineController>(); _stateMachineController.TransitionExecuting += StateMachineControllerOnTransitionExecuting; if (_stateMachineController.ChangeStateAction.Active) { _stateMachineController.ChangeStateAction.ItemsChanged += ChangeStateActionOnItemsChanged; } } }
public static void RemoveDef <Def>(this GameObject go) where Def : StateMachine.BaseDef { StateMachineController controller = go.GetComponent <StateMachineController>(); if (controller != null) { var def = go.GetDef <Def>(); if (def != null) { controller.cmpdef.defs.Remove(def); } } }
public static DefType AddOrGetDef <DefType>(this GameObject go) where DefType : StateMachine.BaseDef { StateMachineController stateMachineController = go.AddOrGet <StateMachineController>(); DefType val = stateMachineController.GetDef <DefType>(); if (val == null) { val = Activator.CreateInstance <DefType>(); stateMachineController.AddDef(val); val.Configure(stateMachineController.gameObject); } return(val); }
protected override void OnSpawn() { base.OnSpawn(); StateMachineController component = GetComponent <StateMachineController>(); if (!((Object)component == (Object)null)) { DecompositionMonitor.Instance instance = new DecompositionMonitor.Instance(this, null, 1f, false); component.AddStateMachineInstance(instance); instance.StartSM(); instance.dirtyWaterMaxRange = 3; } }
public static void OpenWindow(StateMachineController stateMachine) { StateMachineWindow window = GetWindow <StateMachineWindow>(); window.titleContent = new GUIContent("State Machine"); window.minSize = new Vector2(800, 600); window.stateMachine = stateMachine; window.serializedObject = new SerializedObject(stateMachine); window.nodesInfo = (NodesInfo)AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(stateMachine), typeof(NodesInfo)); window.transitions = new List <List <int> >(StateMachineReflections.GetTransitions(stateMachine).Select(i => i.ToList())); window.startStateIndex = StateMachineReflections.GetStartStateIndex(stateMachine); }
void DoAction(StateMachineController controller) { if (controller.CoolDownTime(controller.parameter.actionRate)) { foreach (var action in actions) { action.Act(controller); } controller.OnActionDone(); } CheckTransition(controller); }
public void OnStart() { smc = new StateMachineController(); normal = new State(smc, Normal_Start, Normal_Update, null); runTo = new State(smc, null, runTo_Update, null); runAway = new State(smc, null, runAway_Update, null, 5.0f, normal); killing = new State(smc, killing_Start, killing_Update, null); smc.SetState(normal); player = Common.GetStealthPlayerCamera(); monster3 = GameObject.GetGameObjectByName("Monster3"); speed = 3.0f; timer = 0; beginY = gameObject.transform.position.y; }
public void OnStart() { smc = new StateMachineController(); idle = new State(smc); paperDisplayed = new State(smc, State_PaperDisplayed_Enter, null, null); transitionUp = new State(smc, null, State_TransitionUp_Update, null, 1.0f, paperDisplayed); transitionDown = new State(smc, null, State_TransitionDown_Update, null, 1.0f, idle); downPos = new Vector3(); downRot = new Vector3(); upPos = gameObject.transform.position; upRot = gameObject.transform.rotation.Angles; paperMesh = gameObject.RequireComponent<CMeshRenderer>(); paperMesh.setEnabled(false); smc.SetState(idle); }
public void OnStart() { smc = new StateMachineController(); lightsmc = new StateMachineController(); player = Common.GetStealthPlayer(); binds = GameObject.GetGameObjectByName("Monster4Binds"); attackParticle = GameObject.GetGameObjectByName("Monster4AttackParts").GetComponent<CParticleEmitter>(); attackParticle.setEnabled(false); poofParticle = GameObject.GetGameObjectByName("Monster4Poof").GetComponent<CParticleEmitter>(); mlight = gameObject.GetComponentInChildren<CLight>(); sound = gameObject.RequireComponent<CSound>(); screen = Common.GetConsoleScreenScript(); mesh = GameObject.GetGameObjectByName("M4Mesh").RequireComponent<CMeshRenderer>(); hunting = new State(smc, S_hunting_Start, S_hunting_Update, null); respawning = new State(smc, S_respawning_Start, null, S_respawning_End, RESPAWNTIME, hunting); attacking = new State(smc, S_attacking_Start, S_attacking_Update, S_attacking_End); attacking_intro = new State(smc, S_attacking_intro_Start, S_attacking_intro_Update, null, 1.0f, attacking); incoming = new State(smc, S_incoming_Start, S_incoming_Update, null, 3.0f, respawning); hurting = new State(smc, S_hurting_Start, S_hurting_Update, null, 1.0f, respawning); idle = new State(smc); dying = new State(smc, S_dying_Start, null, S_dying_End, 2.0f, idle); //light smc hold = new State(lightsmc, null, null, null); turningoff = new State(lightsmc, null, S_turningoff_Update, null, 0.5f, hold); turningon = new State(lightsmc, null, S_turningon_Update, null, 0.5f, hold); //binds smc bindssmc = new StateMachineController(); bindhold = new State(bindssmc, null, null, null); bindsmoveup = new State(bindssmc, S_bindsmoveup_Start, S_bindsmoveup_Update, null, 0.5f, bindhold); bindsmovedown = new State(bindssmc, null, S_bindsmovedown_Update, S_bindsmovedown_End, 0.5f, bindhold); helper = new MonsterHelper(); smc.SetState(respawning); lightsmc.SetState(hold); DisplayCorruption(); }
public void OnStart() { STALK_RANGE = DEFAULT_STALK_RANGE; //dependencies //cmesh = gameObject.RequireComponent<CMeshRenderer>(); stealth_player = Common.GetStealthPlayer(); monster3Woman = GetScript<Monster3Woman>(GameObject.GetGameObjectByName("Monster3Woman")); sound = gameObject.RequireComponent<CSound>(); //states smc = new StateMachineController(); inactive = new State(smc, null, null, null); incoming = new State(smc, State_Incoming_Start, State_Incoming_Update, null); stalking = new State(smc, State_Stalking_Start, State_Stalking_Update, null, 5.0f, incoming); resetting = new State(smc, State_Reset_Start, State_Reset_Update, null, 18.0f, stalking); attacking = new State(smc, State_Attacking_Start, State_Attacking_Update, State_Attacking_End, 4.0f, inactive); panicking = new State(smc, State_Panicking_Start, State_Panicking_Update, State_Panicking_End, 1.5f, resetting); helper = new MonsterHelper(); smc.SetState(resetting); }
public void OnStart() { _onTime = 1.0f; _transitionOffTime = 0.0f; _transitionOnTime = 0.1f; _minOffHoldTime = 1.05f; _maxOffHoldTime = 1.15f; _minOnHoldTime = 1.1f; _maxOnHoldTime = 1.9f; _minoffinten = 0.3f; _maxoffinten = 0.3f; _minoninten = 0.7f; _maxoninten = 1.0f; smc = new StateMachineController(); light = gameObject.RequireComponent<CLight>(); timer += MMath.GetRandomFloat() * 2.0f; lighthold = new State(smc, null, null, null, _minOnHoldTime, null); lighton = new State(smc, S_LightOn_Start, S_Light_Update, null, _transitionOnTime, lighthold); lightoff = new State(smc, S_LightOff_Start, S_Light_Update, null, _transitionOffTime, lighthold); smc.SetState(lightoff); }
protected override void OnActivated() { base.OnActivated(); AppearanceController.AppearanceApplied += AppearanceController_AppearanceApplied; var enabledStateMachines = GetEnabledStateMachines(); var stateMachines = enabledStateMachines as IStateMachine[] ?? enabledStateMachines.ToArray(); if (stateMachines.All(machine => machine.CanExecuteTransition())) return; var stateProperties = stateMachines.Select(machine => machine.StatePropertyName); _stateMachineController = Frame.GetController<StateMachineController>(); _propertyEditors = View.GetItems<PropertyEditor>().Where(editor => stateProperties.Contains(editor.PropertyName)).ToArray(); foreach (var item in _propertyEditors) { item.ControlCreated+=ItemOnControlCreated; } ObjectSpace.ObjectChanged+=ObjectSpaceOnObjectChanged; _stateMachineController.TransitionExecuted += OnTransitionExecuted; }
public State(StateMachineController smc) { MyStateMachineController = smc; }
public StateBehaviour(StateMachineController controller) { this.mController = controller; }