private void CheckNewPathAttached(Patrol patrol, PATROL_TYPE type) { switch (type) { case (PATROL_TYPE.NEUTRAL): { if (old_neutral_path != patrol.path_attached) { rhandor.LoadNeutralPatrol(); old_neutral_path = patrol.path_attached; } break; } case (PATROL_TYPE.ALERT): { if (old_alert_path != patrol.path_attached) { rhandor.LoadAlertPatrol(); old_alert_path = patrol.path_attached; } break; } } }
public void Set(Patrol patrol) { size = patrol.size; type = patrol.type; path = patrol.path; stop_times = patrol.stop_times; trigger_movement = patrol.trigger_movement; recieve_trigger = patrol.recieve_trigger; }
public bool[] recieve_trigger; // Response to a trigger movement from the synchronzied Rhandor public Patrol(int _size, PATROL_TYPE _type) { size = _size; type = _type; path = new Vector3[_size]; stop_times = new float[_size]; trigger_movement = new bool[_size]; recieve_trigger = new bool[_size]; }
public Patrol GetPatrolByType(PATROL_TYPE type) { Patrol sync_patrol = null; switch (type) { case (PATROL_TYPE.NEUTRAL): { sync_patrol = neutral_patrol; break; } case (PATROL_TYPE.ALERT): { sync_patrol = alert_patrol; break; } } return(sync_patrol); }
private void PatrolInspectorInfo(Patrol patrol, PATROL_TYPE type) { // ---- Patrol editor information --- // Info will be hide or expanded depending on expanded boolean. switch (type) { case (PATROL_TYPE.NEUTRAL): patrol.expanded = EditorGUILayout.Foldout(patrol.expanded, "Neutral patrol"); break; case (PATROL_TYPE.ALERT): patrol.expanded = EditorGUILayout.Foldout(patrol.expanded, "Alert patrol"); break; } if (patrol.expanded) { // Checking for static or non-static patrol configuration patrol.static_patrol = EditorGUILayout.Toggle("Static", patrol.static_patrol); if (patrol.static_patrol) { // Static: Only one waypoint (initial position) and speed information depending on alarm state EditorGUILayout.LabelField("Waypoints: 1"); switch (type) { case (PATROL_TYPE.NEUTRAL): rhandor.patrol_speed = EditorGUILayout.FloatField("Patrol speed", rhandor.patrol_speed, GUILayout.Width(160)); rhandor.neutral_patrol.path_attached = null; break; case (PATROL_TYPE.ALERT): EditorGUILayout.BeginHorizontal(); rhandor.alert_speed = EditorGUILayout.FloatField("Alert speed", rhandor.alert_speed, GUILayout.Width(160)); rhandor.spotted_speed = EditorGUILayout.FloatField("Spotted speed", rhandor.spotted_speed, GUILayout.Width(160)); EditorGUILayout.EndHorizontal(); rhandor.alert_patrol.path_attached = null; break; } } else { // Non-static: A lot of options, explained next to each one EditorGUILayout.BeginHorizontal(); // Path attached that represents neutral or alert patrol route patrol.path_attached = EditorGUILayout.ObjectField("Path", patrol.path_attached, typeof(GameObject), true) as GameObject; CheckNewPathAttached(patrol, type); // Is the patrol path looped? Different information shown if (patrol.loop) { EditorGUILayout.LabelField("Waypoints: " + ((2 * patrol.Length) - 2)); } else { EditorGUILayout.LabelField("Waypoints: " + patrol.Length); } EditorGUILayout.EndHorizontal(); // Speeds information and patrol loop option EditorGUILayout.BeginHorizontal(); switch (type) { case (PATROL_TYPE.NEUTRAL): rhandor.patrol_speed = EditorGUILayout.FloatField("Patrol speed", rhandor.patrol_speed, GUILayout.Width(160)); if (patrol.Length > 2) { patrol.loop = EditorGUILayout.Toggle("Loop", patrol.loop); } else { patrol.loop = false; } EditorGUILayout.EndHorizontal(); break; case (PATROL_TYPE.ALERT): rhandor.alert_speed = EditorGUILayout.FloatField("Alert speed", rhandor.alert_speed, GUILayout.Width(160)); rhandor.spotted_speed = EditorGUILayout.FloatField("Spotted speed", rhandor.spotted_speed, GUILayout.Width(160)); EditorGUILayout.EndHorizontal(); if (patrol.Length > 2) { patrol.loop = EditorGUILayout.Toggle("Loop", patrol.loop); } else { patrol.loop = false; } break; } if (patrol.is_synchronized = EditorGUILayout.Toggle("Patrol synchronized", patrol.is_synchronized)) { patrol.synchronized_Rhandor = EditorGUILayout.ObjectField("Synchronized Rhandor", patrol.synchronized_Rhandor, typeof(GameObject), true) as GameObject; if (patrol.synchronized_Rhandor != null) { if (old_sync_Rhandor != patrol.synchronized_Rhandor) { if (patrol.synchronized_Rhandor == rhandor.gameObject || patrol.synchronized_Rhandor.GetComponent <RhandorController>() == null) { Debug.Log("You cannot synchronize this Rhandor itself or " + patrol.synchronized_Rhandor + "is not a Rhandor!"); patrol.synchronized_Rhandor = null; } else { old_sync_Rhandor = rhandor_sync = patrol.synchronized_Rhandor.GetComponent <RhandorController>(); if (rhandor_sync.GetPatrolByType(type).synchronized_Rhandor != null) { if (rhandor_sync.GetPatrolByType(type).synchronized_Rhandor != rhandor.gameObject) { Debug.Log(rhandor.name + " has not previously linked with " + rhandor_sync.name + "or is already linked with other Rhandor"); patrol.synchronized_Rhandor = null; } else { sync_correct = true; } } } } if (sync_correct) { EditorGUILayout.HelpBox(rhandor.name + " properly synchronized with " + rhandor_sync.name, MessageType.Info); } else { EditorGUILayout.HelpBox(rhandor_sync.name + " is pending for synchronization with " + rhandor.name, MessageType.Error); } } else { patrol.synchronized_Rhandor = null; sync_correct = false; } } else { sync_correct = false; patrol.synchronized_Rhandor = null; } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (patrol.static_patrol) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Waypoint 1:", GUILayout.Width(80)); EditorGUILayout.Vector3Field("", rhandor.transform.position, GUILayout.Width(240)); EditorGUILayout.EndHorizontal(); } else { for (int i = 0; i < patrol.Length; ++i) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Waypoint " + (i + 1).ToString() + ":", GUILayout.Width(80)); EditorGUILayout.Vector3Field("", patrol.path[i], GUILayout.Width(240)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Stop time", GUILayout.Width(75)); patrol.stop_times[i] = EditorGUILayout.FloatField(patrol.stop_times[i], GUILayout.Width(75)); if (GUILayout.Button("Reset", GUILayout.MaxHeight(15), GUILayout.MaxWidth(55))) { patrol.stop_times[i] = 0.0f; } EditorGUILayout.EndHorizontal(); if (patrol.is_synchronized) { EditorGUILayout.BeginHorizontal(); if (patrol.trigger_movement[i] = EditorGUILayout.Toggle("Trigger move", patrol.trigger_movement[i])) { CheckOneOptionTrigger(patrol, i); } if (patrol.recieve_trigger[i] = EditorGUILayout.Toggle("Recieve trigger", patrol.recieve_trigger[i])) { CheckOneOptionReciever(patrol, i); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } } if (patrol.loop) { for (int i = patrol.Length - 2; i > 0; --i) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Waypoint " + (i + 1).ToString() + ":", GUILayout.Width(80)); EditorGUILayout.Vector3Field("", patrol.path[i], GUILayout.Width(240)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Stop time", GUILayout.Width(75)); patrol.stop_times[i] = EditorGUILayout.FloatField(patrol.stop_times[i], GUILayout.Width(75)); if (GUILayout.Button("Reset", GUILayout.Width(55))) { patrol.stop_times[i] = 0.0f; } EditorGUILayout.EndHorizontal(); //if (patrol.is_synchronized) //{ // EditorGUILayout.BeginHorizontal(); // patrol.trigger_movement[i] = EditorGUILayout.Toggle("Trigger move", patrol.trigger_movement[i]); // patrol.recieve_trigger[i] = EditorGUILayout.Toggle("Recieve trigger", patrol.recieve_trigger[i]); // EditorGUILayout.EndHorizontal(); // EditorGUILayout.Space(); //} } } } } }