public int teamID; //Team who owns this capture point and can score points here void OnTriggerEnter(Collider other) { if (!BoltNetwork.isServer) { return; } IGameMode currentGameMode = GameManager.instance.gameMode; if (GameManager.instance.gameMode.Mode == GameModes.CAPTURE_THE_FLAG) { CaptureTheFlagMode mode = (CaptureTheFlagMode)currentGameMode; Flag f = other.gameObject.GetComponent <Flag>(); if (f != null) { if (f.player != null && f.player.Team == teamID) { if (f.teamID == teamID) { //We are returning the flag to our base mode.setFlagAtBase(teamID, true); f.ReturnFlag(); } else { //The flag we are returning is not ours. Check and see if ours is returned and if so, you score! if (mode.isFlagAtBaseForTeam(teamID)) { //update scores if (ServerConnectionEventListener.IndexMap.ContainsPlayer(f.player.Username)) { int playerStatIndex = ServerConnectionEventListener.IndexMap[f.player.Username]; GameStats.SetIntegerStat(playerStatIndex, "Flags", GameStats.GetIntegerStat(playerStatIndex, "Flags") + 1); } GameManager.instance.CheckForGameOver(); f.ReturnFlag(); } } } } } }
void OnTriggerEnter(Collider other) { if (!isEnabled || !BoltNetwork.isServer) { return; } AbstractPlayer p = other.gameObject.GetComponentInParent <AbstractPlayer>(); CaptureTheFlagMode mode = (CaptureTheFlagMode)GameManager.instance.gameMode; //You can only pick up this flag if // - you are a player // - there is not already someone picking up this flag // - either you are // - on the enemy team, so you can pick it up wherever // - or your a friendly player but the flag is not at spawn if (p != null && player == null && (p.Team != teamID || (p.Team == teamID && !mode.isFlagAtBaseForTeam(teamID)))) { //Update who is holding flag this.gameObject.transform.parent = other.gameObject.transform; player = p; state.Holder = player.Username; isEnabled = false; } }