// Use this for initialization void Start() { HPAttack = new MaxCondition(); HPDefend = new MinCondition(); MoveForward = new Action(); MoveBackward = new Action(); Attack.AddAction(MoveForward); Defend.AddAction(MoveBackward); MoveForward.SetDirection(-Vector3.right); MoveBackward.SetDirection(Vector3.right); SwitchStanceDefend = new Transition(); SwitchStanceAttack = new Transition(); HPAttack.SetTestValue(PlayerHp, MaxHp / 2); HPDefend.SetTestValue(PlayerHp, MaxHp / 2); SwitchStanceDefend.AddCondition(HPDefend); SwitchStanceDefend.SetTargetState(Attack); SwitchStanceAttack.AddCondition(HPAttack); SwitchStanceAttack.SetTargetState(Defend); Attack = new State(SwitchStanceAttack); Defend = new State(SwitchStanceDefend); FSM = new FiniteStateMachine(Attack); }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("Value", true, out subEle); subEle.Value = Value.ToString(); ele.TryPathTo("MaxCondition", true, out subEle); subEle.Value = MaxCondition.ToString(); ele.TryPathTo("Weight", true, out subEle); subEle.Value = Weight.ToString("G15"); }