//Function called by objects with Camera_Weight component when they drop out of range public static void DropWeightedObject(CameraWeight objToDrop_, Players playerToDrop_) { //If the player to drop is p1 if (playerToDrop_ == Players.P1) { //makes sure the object being dropped is in the list of game objects in the first place if (p1GlobalReference.weightObjects.Contains(objToDrop_.gameObject)) { //Removes the weighted object from the list of game objects p1GlobalReference.weightObjects.Remove(objToDrop_.gameObject); //Subtracts the weighted object's weight from the sum of all of them p1GlobalReference.weightSum -= objToDrop_.weight; } } //If the player to drop is p2 else if (playerToDrop_ == Players.P2) { //makes sure the object being dropped is in the list of game objects in the first place if (p2GlobalReference.weightObjects.Contains(objToDrop_.gameObject)) { //Removes the weighted object from the list of game objects p2GlobalReference.weightObjects.Remove(objToDrop_.gameObject); //Subtracts the weighted object's weight from the sum of all of them p2GlobalReference.weightSum -= objToDrop_.weight; } } }
//Function called by objects with the Camera_Weight component when they come into range public static void AddWeightedObject(CameraWeight objToAdd_, Players playerToFollow_) { //If the player to follow is p1 if (playerToFollow_ == Players.P1) { //Adds the weighted object to the list of game objects p1GlobalReference.weightObjects.Add(objToAdd_.gameObject); //Adds the weighted object's weight to the sum of all of them p1GlobalReference.weightSum += objToAdd_.weight; } //If the player to follow is p2 else if (playerToFollow_ == Players.P2) { //Adds the weighted object to the list of game objects p2GlobalReference.weightObjects.Add(objToAdd_.gameObject); //Adds the weighted object's weight to the sum of all of them p2GlobalReference.weightSum += objToAdd_.weight; } }
public CameraWeightData(CameraWeight cameraWeight) { _cameraWeight = cameraWeight; position = cameraWeight.transform.position; weight = 0; }
public static void AddWeight(CameraWeight weight) { _instance._weights.Add(new CameraWeightData(weight)); }