void Start() { width = 10; height = 10; animationScript = GetComponent <g_AIAnimationScript>(); FindClosestPlayer(); attackTarget = closestPlayer; ActionFunctionsDict.Add(AIAction.ActionState.Spawn, Spawn); ActionFunctionsDict.Add(AIAction.ActionState.Idle, Idle); ActionFunctionsDict.Add(AIAction.ActionState.Runforward, RunForward); ActionFunctionsDict.Add(AIAction.ActionState.Melee, Melee); ActionFunctionsDict.Add(AIAction.ActionState.TakeDamage, TakeDamage); ActionFunctionsDict.Add(AIAction.ActionState.Animation, Animation); ActionFunctionsDict.Add(AIAction.ActionState.WalkForward, WalkForward); ActionFunctionsDict.Add(AIAction.ActionState.Roar, Roar); ActionFunctionsDict.Add(AIAction.ActionState.Taunt, Taunt); ActionFunctionsDict.Add(AIAction.ActionState.WalkLeft, WalkLeft); ActionFunctionsDict.Add(AIAction.ActionState.WalkRight, WalkRight); ActionFunctionsDict.Add(AIAction.ActionState.MoveLeft, MoveLeft); ActionFunctionsDict.Add(AIAction.ActionState.MoveRight, MoveRight); ActionFunctionsDict.Add(AIAction.ActionState.FireArrow, FireArrow); ActionFunctionsDict.Add(AIAction.ActionState.Patrol, Patrol); aIBehavior.Initialize(); currentState = aIBehavior.StatesDict[aIBehavior.firstState]; SetupCurrentActionFunc(); currentState.SetActionTime(); }
public override void OnInspectorGUI() { //base.DrawDefaultInspector(); AIBehavior.name = EditorGUILayout.TextField("State", AIBehavior.name); AIBehavior.firstState = EditorGUILayout.TextField("First State", AIBehavior.firstState); for (int i = 0; i < AIBehavior.StatesList.Count; i++) { DrawList(serializedObject.FindProperty("StatesList").GetArrayElementAtIndex(i)); } if (GUILayout.Button("Add AI State")) { AIState tempState = new AIState(); tempState.Switches.Add(new Switch()); tempState.Name = "NULL"; for (int i = 0; i < tempState.Actions.Count; i++) { if (i == tempState.Actions.Count - 1) { tempState.Actions[i].ActionSettings.StartTime = 0; tempState.Actions[i].ActionSettings.EndTime = Mathf.Infinity; } } AIBehavior.StatesList.Add(tempState); tempState.Index = AIBehavior.StatesList.Count - 1; if (tempState.Index < 0) { tempState.Index = 0; } } if (GUILayout.Button("Remove AI State")) { AIBehavior.StatesList.Remove(AIBehavior.StatesList[AIBehavior.StatesList.Count - 1]); } for (int i = 0; i < AIBehavior.StatesList.Count; i++) { AIBehavior.Initialize(); } if (GUILayout.Button("Reorder List")) { for (int i = 0; i < AIBehavior.StatesList.Count; i++) { if (i != AIBehavior.StatesList[i].Index) { SwitchItemInList(AIBehavior, i, AIBehavior.StatesList[i].Index); //break; } } } serializedObject.ApplyModifiedProperties(); serializedObject.Update(); Repaint(); }