Exemplo n.º 1
0
    private static void SetCallbacks(StateChart.StateChartBuilder builder, string stateName, BehaviorMap behaviors)
    {
        builder.Init(() => CallBehavior(stateName + ":init", behaviors));

        builder.Enter(() => {
            CallBehavior(stateName + ":enter", behaviors);
        });

        builder.Exit(() => {
            CallBehavior(stateName + ":exit", behaviors);
        });

        builder.Update(() => {
            CallBehavior(stateName + ":update", behaviors);
        });
    }
Exemplo n.º 2
0
    private static void SetEvents(StateChart.StateChartBuilder builder, string stateName, EvtPair[] eventPairs)
    {
        if (eventPairs == null)
        {
            return;
        }

        for (int i = 0; i < eventPairs.Length; i++)
        {
            EvtPair pair = eventPairs[i];

            if (pair.stateName == stateName)
            {
                builder.Event(pair.type, (evt) => {
                    pair.callback(stateName + ":" + evt.GetType().Name, evt);
                });
            }
        }
    }
Exemplo n.º 3
0
        protected override void BuildStateChart(StateChart.StateChartBuilder builder)
        {
            Action <string, Action> State = builder.State;
            Action <Action>         Init  = builder.Init;

//            Goal goal = new Goal();
//            goal.goalLevel = GoalLevel.Faction;
//            goal.goalType = GoalType.Attack;
//
//            goal.ScoreAttackEntity = (entity) => {
//                if (entity.faction.Name == "Empire") return 1f;
//                return 0.5f;
//            };
//
//            goal.onSuccess = () => {
//                Debug.Log("Mission Accompilished");
//            };

//            db.GetFaction("Empire").GetFlightGroup("Alpha").AddGoal(goal);
//

            GameDatabase db = GameDatabase.ActiveInstance;

            //eventually want to nuke the scene + rebuild from scratch
            //Resources.FindObjectsOfTypeAll<Entity>().Where((e) => { });

            State("Mission Init", () => {
                Init(() => {
                });
            });

            State("Mission In Progress", () => { });

            State("Mission Failed", () => { });

            State("Mission Succeeded", () => { });
        }
Exemplo n.º 4
0
 protected abstract void BuildStateChart(StateChart.StateChartBuilder builder);