public bool IsPairedWith(LearningConstructorTeammate partner) { //Condition to check that a Teammate is stored in the variable partner if (teammate != null) { //Statement to check that the passed partner variable is thhe same as the stored teammate if (partner == this.teammate) { return(true); } //If the teammate is in a team with another player else { return(false); } } //If the teammate variable has an unassigned value //The player is unmatched with no teammate else { return(false); } }
void Start() { //Constructed objects with the properties of player name, role and class type seun = new LearningConstructorTeammate("BlazinkidHD", "DPS", "Technoblader"); soraya = new LearningConstructorTeammate("FenixLady", "Buffer", "Sorcerer"); //Assignement of teammate property to the objects seun.teammate = soraya; soraya.teammate = seun; //Statements to determine the nature of the teammate property in this context if (seun.IsPairedWith(soraya) && soraya.IsPairedWith(seun)) { Debug.Log(seun.playerName + " is paired with " + soraya.playerName); } else if (seun.IsPairedWith(soraya) && !soraya.IsPairedWith(seun)) { Debug.Log(seun.playerName + " is no longer paired with " + soraya.playerName); } else { Debug.Log(seun.playerName + " and " + soraya.playerName + " have yet to find teammates"); } }