public static bool IsEffectiveChanger <InitialParamType, UpdateParamType>(Auto <InitialParamType, UpdateParamType> baseAuto) { var conditions = baseAuto.Conditions(); /* * comment for branchName1 */ if ( ConditionGateway.Contains(conditions, AutoConditions.Act.P0) ) { return(true); } return(false); }
public void _1_3_RunNotContainsSpecificConditionInTimeline() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "デフォルト状態", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "基本モーション", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "基礎行動", 0, AutomatineDefinitions.Tack.LIMIT_UNLIMITED, AutoConditions.Act.DEFAULT, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c.Default; return(c); } ) ) ); var conditions = auto.Conditions(); if (ConditionGateway.NotContains(conditions, AutoConditions.Act.SPAWN)) { // no problem } else { Debug.LogError("not contains act SPAWN"); } if (ConditionGateway.NotContains(conditions, AutoConditions.Anim.SPAWN)) { // no problem } else { Debug.LogError("not contains anim SPAWN"); } }
/** * export timelines which contains the type of specified condition. */ public List <Timeline <InitialParamType, UpdateParamType> > ExportTimelines(params Type[] conditionTypes) { var targetTypes = new List <int>(); for (var i = 0; i < conditionTypes.Length; i++) { var cond = conditionTypes[i]; var targetConditionIndex = ConditionGateway.IndexOfConditionType(cond); if (targetTypes.Contains(targetConditionIndex)) { continue; } targetTypes.Add(targetConditionIndex); } return(_MatchedTimelines(targetTypes)); }
TestRoute3 <InitialParamType, UpdateParamType> (Auto <InitialParamType, UpdateParamType> baseAuto, int frame, InitialParamType fixedContext) { var conditions = baseAuto.Conditions(); /* * comment for branchName0 */ if ( ConditionGateway.Contains(conditions, AutoConditions.Act.SPAWN) ) { var newAuto = new MoveAuto <InitialParamType, UpdateParamType>(frame, fixedContext); newAuto.InheritTimelines(baseAuto.ExportTimelines(new Type[] { typeof(AutoConditions.Move) })); return(newAuto); } /* * comment for branchName1 */ if ( ConditionGateway.Contains(conditions, AutoConditions.Act.SPAWN) ) { return(baseAuto); } var finallyAuto = new MoveAuto <InitialParamType, UpdateParamType>(frame, fixedContext); finallyAuto.InheritTimelines(baseAuto.ExportTimelines(new Type[] { typeof(AutoConditions.Move) })); return(finallyAuto); }
public Tack(string tackInfo, int start, int span, object conditionSource, params Func <RoutineBase <InitialParamType, UpdateParamType> >[] routineSources) { this.tackInfo = tackInfo; this.start = start; if (span < 0) { span = AutomatineDefinitions.Tack.LIMIT_UNLIMITED; } if (span == 0) { throw new Exception("tack span should be greater than 0 or AutomatineDefinitions.Tack.LIMIT_UNLIMITED."); } this.span = span; // ready condition value and type. this.conditionValue = (int)conditionSource; this.conditionType = ConditionGateway.GetIndexOfConditionType(conditionSource); this.routineSources = routineSources; }
ChangerForTest42_2 <InitialParamType, UpdateParamType> (Auto <InitialParamType, UpdateParamType> baseAuto, int frame, InitialParamType fixedContext) { var conditions = baseAuto.Conditions(); /* * comment for branchName0 */ if ( ConditionGateway.Contains(conditions, AutoConditions.Anim.DEFAULT) ) { var newAuto = new AutoForTest42_1 <InitialParamType, UpdateParamType>(frame, fixedContext); return(newAuto); } return(baseAuto); }
ConditionChange0 <InitialParamType, UpdateParamType> (Auto <InitialParamType, UpdateParamType> baseAuto, int frame, InitialParamType fixedContext) { var conditions = baseAuto.Conditions(); /* * comment for branchName0 */ if ( ConditionGateway.Contains(conditions, AutoConditions.Act.P0) ) { var newAuto = new ConditionChangeAuto0 <InitialParamType, UpdateParamType>(frame, fixedContext); return(newAuto); } return(baseAuto); }
public void _6_1_ConditionWithConsumeAllTimelineByBreackTimeline() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "6_1", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "6_1TL", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "6_1R", 0, 100, AutoConditions.Act.FIVEFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._BreakTimeline; return(c); } ) ) ); auto.Update(frame, dummyContexts); var conditions = auto.Conditions(); // AutoConditions.Act.FIVEFRAME_SPAN Timeline is over. if (ConditionGateway.NotContains(conditions, AutoConditions.Act.FIVEFRAME_SPAN)) { return; } Debug.LogError("failed to break timeline"); }
public void _6_3_ConditionShouldEmptyByBreakAllTack() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "ContinuationWithBreakTack", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "ContinuationWithBreakTackTL", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "ContinuationWithBreakTackRoutine", 0, 100, AutoConditions.Act.FIVEFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._BreakTack; return(c); } ) ) ); auto.Update(frame, dummyContexts); // breakTack is contained in routine. all tack & timelines are consumed but still on that tack. Auto returns condition of last frame. var conditions = auto.Conditions(); if (ConditionGateway.Contains(conditions, AutoConditions.Act.FIVEFRAME_SPAN)) { return; } Debug.LogError("failed to break tack."); }
public void _8_1_ConditionWithInheritTimelines() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto0 = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_0", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_0TL_0", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_0R_0", 0, 5, AutoConditions.Act.FIVEFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ) ), new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_0TL_1", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_0R_1", 0, 5, AutoConditions.Anim.DEFAULT, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ) ) ); // rest 4 frames for tack. auto0.Update(frame, dummyContexts); frame++; var auto1 = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_1", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_1TL", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "8_1_1R", 0, 5, AutoConditions.Anim.SPAWN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ) ) ); var inheritTimelines = auto0.ExportTimelines(typeof(AutoConditions.Act), typeof(AutoConditions.Anim)); auto1.InheritTimelines(inheritTimelines); var conditions = auto1.Conditions(); if (ConditionGateway.Contains(conditions, AutoConditions.Anim.SPAWN)) { if (ConditionGateway.NotContainsAll(conditions, AutoConditions.Act.FIVEFRAME_SPAN, AutoConditions.Anim.DEFAULT)) { return; } } Debug.LogError("not match"); }
/** * return function what returns auto which is constructed by RuntimeAutoData. */ public static Func <int, InitialParamType, Auto <InitialParamType, UpdateParamType> > RuntimeAutoGenerator(RuntimeAutoData runtimeAutoData) { return((int startFrame, InitialParamType initialParam) => { var autoInfo = "generated"; var newRootChangers = new List <IAutoChanger>(); for (var i = 0; i < runtimeAutoData.rootChangers.Count; i++) { var rootChangerSource = runtimeAutoData.rootChangers[i]; newRootChangers.Add(ChangerInstanceByName(rootChangerSource.changerName)); } var newChangers = new List <IAutoChanger>(); for (var i = 0; i < runtimeAutoData.changers.Count; i++) { var changerSource = runtimeAutoData.changers[i]; newChangers.Add(ChangerInstanceByName(changerSource.changerName)); } var newTimelines = new List <Timeline <InitialParamType, UpdateParamType> >(); for (var i = 0; i < runtimeAutoData.timelines.Count; i++) { var timelineSource = runtimeAutoData.timelines[i]; var timelineInfo = "generated"; var tacksSources = timelineSource.tacks; var tacks = new List <Tack <InitialParamType, UpdateParamType> >(); for (var j = 0; j < tacksSources.Count; j++) { var tackSource = tacksSources[j]; var tackInfo = "generated"; var tackStart = tackSource.start; var tackSpan = tackSource.span; var tackCondition = ConditionGateway.ConditionFromString(tackSource.conditionType, tackSource.conditionValue); var routines = new List <Func <RoutineBase <InitialParamType, UpdateParamType> > >(); for (var k = 0; k < tackSource.routines.Count; k++) { var routine = tackSource.routines[k]; var routineName = routine.routineName; routines.Add( () => { return new RoutineContexts <InitialParamType, UpdateParamType>(routineName); } ); } tacks.Add(new Tack <InitialParamType, UpdateParamType>(tackInfo, tackStart, tackSpan, tackCondition, routines.ToArray())); } newTimelines.Add(new Timeline <InitialParamType, UpdateParamType>(timelineInfo, tacks.ToArray())); } return new Auto <InitialParamType, UpdateParamType>( autoInfo, startFrame, initialParam, newRootChangers, newChangers, newTimelines.ToArray() ); }); }
public void ShowContextOfType() { var menu = new GenericMenu(); // update parent:ChangerPlate's conditions to latest. Emit(new OnAutomatineEvent(OnAutomatineEvent.EventType.EVENT_REFRESHTACKCONDITIONS, tackId)); if (!string.IsNullOrEmpty(conditionType)) { // current. menu.AddDisabledItem( new GUIContent(conditionType) ); menu.AddSeparator(string.Empty); // set empty. menu.AddItem( new GUIContent("Set Empty"), false, () => { EmitUndo("Change Condition Type"); conditionType = string.Empty; conditionValue = string.Empty; EmitSave(); Emit(new OnAutomatineEvent(OnAutomatineEvent.EventType.EVENT_REFRESHTACKCONDITIONS, tackId)); } ); menu.ShowAsContext(); return; } /* * condition type is empty. */ var selectableMenuItems = conditions .Select(conditonData => conditonData.conditionType) .ToList(); // new. menu.AddItem( new GUIContent("Add New Type"), false, () => { Emit(new OnAutomatineEvent(OnAutomatineEvent.EventType.EVENT_REFRESHTACKCONDITIONS, tackId)); Emit(new OnAutomatineEvent(OnAutomatineEvent.EventType.EVENT_ADDNEWTYPE, tackId)); } ); menu.AddSeparator(string.Empty); // other. foreach (var conditonData in selectableMenuItems.Select((val, index) => new { index, val })) { var currentType = conditonData.val; if (unselectableTypes.Contains(currentType)) { menu.AddDisabledItem(new GUIContent(currentType)); } else { menu.AddItem( new GUIContent(currentType), false, () => { EmitUndo("Change Condition Type"); conditionType = currentType; var valueCandidates = ConditionGateway.TypeValuesFromTypeConditionStr(conditionType); if (0 < valueCandidates.Length) { conditionValue = valueCandidates[0]; } EmitSave(); Emit(new OnAutomatineEvent(OnAutomatineEvent.EventType.EVENT_REFRESHTACKCONDITIONS, tackId)); } ); } } menu.ShowAsContext(); }
public void _1_1_RunContainsSpecificConditionInTimelines() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "spawn開始", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "Spawn処理", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "spawning", 0, AutomatineDefinitions.Tack.LIMIT_UNLIMITED, AutoConditions.Act.SPAWN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c.Spawn; return(c); } ) ), new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "Spawn時のモーション", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "まだ真面目にセットしてない、Spawn時のモーション", 0, 10, AutoConditions.Anim.SPAWN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c.SpawnMotion; return(c); } ) ) ); var conditions = auto.Conditions(); if (ConditionGateway.Contains(conditions, AutoConditions.Act.SPAWN)) { // no problem } else { Debug.LogError("not contains act SPAWN"); } if (ConditionGateway.Contains(conditions, AutoConditions.Anim.SPAWN)) { // no problem } else { Debug.LogError("not contains anim SPAWN"); } }
/** * 特定のconditionが特定のフレーム数存在している * 二つのTackにまたがり、中間に別のものが詰まっている場合 */ public void _2_4_ConditionContinuesIn15FrameBetween3Tack() { int frame = 0; var context = PlayerContext.Copy(dummyContext); var auto = new Auto <PlayerContext, Dictionary <string, PlayerContext> >( "10フレーム、特定のconditionを維持する", frame, context, new Timeline <PlayerContext, Dictionary <string, PlayerContext> >( "5フレーム、特定のconditionを維持するTL", new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "5フレーム、特定のconditionを維持するTack", 0, 5, AutoConditions.Act.TENFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ), new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "中間で5フレーム、特定のconditionを維持するTack", 5, 5, AutoConditions.Act.FIVEFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ), new Tack <PlayerContext, Dictionary <string, PlayerContext> >( "さらに5フレーム、特定のconditionを維持するTack", 10, 5, AutoConditions.Act.TENFRAME_SPAN, () => { var c = new RoutineContexts <PlayerContext, Dictionary <string, PlayerContext> >(); c.rContext = c._Infinity; return(c); } ) ) ); int count = 0; for (int i = 0; i < 15; i++) { auto.Update(frame, dummyContexts); var conditions = auto.Conditions(); if (ConditionGateway.Contains(conditions, AutoConditions.Act.TENFRAME_SPAN)) { count++; } frame = frame + 1; } if (count == 10) { } else { Debug.LogError("failed. not match count:" + count); } }
/** * returns RuntimeAutoData of this auto. */ public RuntimeAutoData RuntimeAutoData() { var runtimeRootChangers = new List <RuntimeChangerData>(); if (rootChangers != null) { for (var i = 0; i < rootChangers.Count; i++) { var rootChanger = rootChangers[i]; runtimeRootChangers.Add(new RuntimeChangerData(rootChanger.GetType().AssemblyQualifiedName)); } } var runtimeChangers = new List <RuntimeChangerData>(); if (changers != null) { for (var i = 0; i < changers.Count; i++) { var changer = changers[i]; runtimeChangers.Add(new RuntimeChangerData(changer.GetType().AssemblyQualifiedName)); } } var runtimeTimelineDatas = new List <RuntimeTimelineData>(); for (var i = 0; i < timelines.Count; i++) { var timeline = timelines[i]; var tacks = new List <RuntimeTackData>(); for (var j = 0; j < timeline.tacks.Count; j++) { var tack = timeline.tacks[j]; var routines = new List <RuntimeRoutineData>(); for (var k = 0; k < tack.routines.Count; k++) { var routine = tack.routines[k]; var routineName = routine.routineContext.routineName; routines.Add(new RuntimeRoutineData(routineName)); } tacks.Add( new RuntimeTackData( tack.start, tack.span, ConditionGateway.ConditionTypeString(tack.conditionType), ConditionGateway.ConditionValueString(tack.conditionType, tack.conditionValue), routines ) ); } runtimeTimelineDatas.Add( new RuntimeTimelineData( tacks ) ); } return(new RuntimeAutoData( runtimeRootChangers, runtimeChangers, runtimeTimelineDatas )); }
public bool SameConditions(int[] conditions) { var currentCondition = Conditions(); return(ConditionGateway.SameConditions(currentCondition, conditions)); }
/** * check if every part of conditions are not containd or containd. */ public bool NotContainsAllConditions(params object[] conditions) { var currentCondition = Conditions(); return(ConditionGateway.NotContainsAllConditions(currentCondition, conditions)); }
/** * check if the part of the condition is not containd or containd. */ public bool NotContainsCondition <T>(T condition) where T : IConvertible { var currentCondition = Conditions(); return(ConditionGateway.NotContainsCondition(currentCondition, condition)); }