//private IList<Material> // Use this for initialization void Start() { //Convert to ILists. These are not visible in the inspector, but easier to use. IList <Material> team1List = new List <Material>(team1Materials); IList <Material> team2List = new List <Material>(team2Materials); //Check own team //Make a list of material NAMES to replace, because direct comparison is hard in Unity :( if (TeamHelper.GetTeamNumber(transform.gameObject.layer) == 1) { IList <string> matNames = new List <string>(); foreach (Material mat in team2List) { matNames.Add(mat.name); } ReplaceMaterialsWith(matNames, team1List); } else { IList <string> matNames = new List <string>(); foreach (Material mat in team1List) { matNames.Add(mat.name); } ReplaceMaterialsWith(matNames, team2List); } }
public static void RemoveNpc(GameObject npc) { int team = TeamHelper.GetTeamNumber(npc.layer); if (team == 1) { Team1Npcs.Remove(npc); } else { Team2Npcs.Remove(npc); } }
public void ObjectDestroyed(GameObject obj) { ObjectSync objSync = obj.GetComponent <ObjectSync>(); if (objSync == null) { throw new UnityException("Given GameObject must contain an ObjectSync component"); } if (objSync.Type == ObjectSyncType.Mothership) { MatchResult result = TeamHelper.GetTeamNumber(obj.layer) == 1 ? MatchResult.Team2Win : MatchResult.Team1Win; this.EndMatch(result); } }
private void OnPlayerDisconnected(NetworkPlayer player) { Player disconnectedPlayer = null; foreach (Player p in base.Players.Values) { if (p.NetworkPlayerInfo == player) { disconnectedPlayer = p; break; } } Debug.Log("Team " + TeamHelper.GetTeamNumber((int)disconnectedPlayer.Team) + " has been disconnected!"); MatchResult result = disconnectedPlayer.Team == Layers.Team1Actor ? MatchResult.Team2Win : MatchResult.Team1Win; MatchControl matchControl = GameObject.Find(GlobalSettings.MatchControlName).GetComponent <MatchControl>(); matchControl.EndMatch(result); }
void Start() { CurrentDistance = MaxDistance; int teamNumber = TeamHelper.GetTeamNumber(gameObject.layer); int teamXActorMask; if (teamNumber == 1) { teamXActorMask = 1 << 8; } else { teamXActorMask = 1 << 11; } int projectileMask = (1 << 10) | (1 << 13) | (1 << 2) | (1 << 3); layerMask = ~(teamXActorMask | projectileMask); ThreeDimensionalCrosshair = new Vector3(0, 0, 0); //crosshairPosition = new Vector2(0, 0); }
protected override void Initialize() { team = TeamHelper.GetTeamNumber(gameObject.layer); dead = false; }
void Start() { team = TeamHelper.GetTeamNumber(gameObject.layer); this.Crosshair = GunSwitcher.Crosshair; }