void GetOriginalValues() { for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the cohesion steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(SmoothedCohesionSteering)) { //Set the weight cohesionWeight = steering.correspondingWeights[i]; } //If we find the separation steering else if (steering.flockSteeringBehaviours[i].GetType() == typeof(SeparationSteering)) { //Set the weight separationWeight = steering.correspondingWeights[i]; } //If we find the group alignment steering else if (steering.flockSteeringBehaviours[i].GetType() == typeof(GroupAlignmentSteering)) { //Set the weight groupAlignmentWeight = steering.correspondingWeights[i]; } //If we find the avoid edge steering else if (steering.flockSteeringBehaviours[i].GetType() == typeof(AvoidEdgeSteering)) { //Set the weight avoidEdgeWeight = steering.correspondingWeights[i]; //Set the radius AvoidEdgeSteering avoidance = (AvoidEdgeSteering)steering.flockSteeringBehaviours[i]; avoidEdgeRadius = avoidance.radius; } //If we find the obstacle avoidance steering else if (steering.flockSteeringBehaviours[i].GetType() == typeof(ObstacleAvoidanceSteering)) { //Set the weight obstacleAvoidanceWeight = steering.correspondingWeights[i]; //Set the detection depth and the avoidance strength ObstacleAvoidanceSteering avoidance = (ObstacleAvoidanceSteering)steering.flockSteeringBehaviours[i]; obstacleDetectionDepth = avoidance.detectionDepth; obstacleAvoidanceStrength = avoidance.avoidanceStrength; } } }
void CheckForNewValues() { //Cohesion weight if (cohesionWeight != originalCohesionWeight) { //Find the index of the cohesion for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the cohesion steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(SmoothedCohesionSteering)) { //Set the weight steering.correspondingWeights[i] = cohesionWeight; } } } //Separation weight if (separationWeight != originalSeparationWeight) { //Find the index of the separation for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the separation steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(SeparationSteering)) { //Set the weight steering.correspondingWeights[i] = separationWeight; } } } //Group alignment weight if (groupAlignmentWeight != originalGroupAlignmentWeight) { //Find the index of the group alignment for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the group alignment steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(GroupAlignmentSteering)) { //Set the weight steering.correspondingWeights[i] = groupAlignmentWeight; } } } //Avoid edge weight if (avoidEdgeWeight != originalAvoidEdgeWeight) { //Find the index of the avoid edge for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the avoid edge steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(AvoidEdgeSteering)) { //Set the weight steering.correspondingWeights[i] = avoidEdgeWeight; } } } //Avoid edge radius if (avoidEdgeRadius != originalAvoidEdgeRadius) { //Find the index of the avoid edge for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the avoid edge steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(AvoidEdgeSteering)) { //Set the radius AvoidEdgeSteering avoidance = (AvoidEdgeSteering)steering.flockSteeringBehaviours[i]; avoidance.radius = avoidEdgeRadius; } } } //Obstacle avoidance weight if (obstacleAvoidanceWeight != originalObstacleAvoidanceWeight) { //Find the index of the avoid edge for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the avoid edge steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(ObstacleAvoidanceSteering)) { //Set the weight steering.correspondingWeights[i] = obstacleAvoidanceWeight; } } } //Obstacle detection depth if (obstacleDetectionDepth != originalObstacleDetectionDepth) { //Find the index of the avoid edge for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the avoid edge steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(ObstacleAvoidanceSteering)) { //Set the depth ObstacleAvoidanceSteering avoidance = (ObstacleAvoidanceSteering)steering.flockSteeringBehaviours[i]; avoidance.detectionDepth = obstacleDetectionDepth; } } } //Obstacle detection depth if (obstacleAvoidanceStrength != originalObstacleAvoidanceStrength) { //Find the index of the avoid edge for (int i = 0; i < steering.flockSteeringBehaviours.Length; i++) { //If we find the avoid edge steering if (steering.flockSteeringBehaviours[i].GetType() == typeof(ObstacleAvoidanceSteering)) { //Set the depth ObstacleAvoidanceSteering avoidance = (ObstacleAvoidanceSteering)steering.flockSteeringBehaviours[i]; avoidance.avoidanceStrength = obstacleAvoidanceStrength; } } } }