public virtual void OnScoreIncrease(BaseNetworkGameCharacter character, int increaseAmount)
    {
        if (!CharacterCollectedScore.ContainsKey(character.ObjectId))
        {
            CharacterCollectedScore[character.ObjectId] = increaseAmount;
        }
        else
        {
            CharacterCollectedScore[character.ObjectId] += increaseAmount;
        }

        if (IsTeamGameplay)
        {
            // TODO: Improve team codes
            switch (character.playerTeam)
            {
            case 1:
                teamScoreA += increaseAmount;
                break;

            case 2:
                teamScoreB += increaseAmount;
                break;
            }
        }
    }
예제 #2
0
    public override bool RespawnCharacter(BaseNetworkGameCharacter character, params object[] extraParams)
    {
        var isWatchedAds = false;

        if (extraParams.Length > 0 && extraParams[0] is bool)
        {
            isWatchedAds = (bool)extraParams[0];
        }

        var targetCharacter = character as CharacterEntity;
        var gameplayManager = GameplayManager.Singleton;

        // For IO Modes, character stats will be reset when dead
        if (!isWatchedAds || targetCharacter.watchAdsCount >= gameplayManager.watchAdsRespawnAvailable)
        {
            targetCharacter.ResetScore();
            targetCharacter.ResetKillCount();
            targetCharacter.ResetAssistCount();
            targetCharacter.Exp           = 0;
            targetCharacter.level         = 1;
            targetCharacter.statPoint     = 0;
            targetCharacter.watchAdsCount = 0;
            targetCharacter.addStats      = new CharacterStats();
            targetCharacter.Armor         = 0;
        }
        else
        {
            ++targetCharacter.watchAdsCount;
        }

        return(true);
    }
 public virtual void OnKillIncrease(BaseNetworkGameCharacter character, int increaseAmount)
 {
     if (gameRule != null && Characters.Contains(character))
     {
         gameRule.OnKillIncrease(character, increaseAmount);
     }
 }
 public void OnUpdateCharacter(BaseNetworkGameCharacter character)
 {
     if (gameRule != null)
     {
         gameRule.OnUpdateCharacter(character);
     }
 }
예제 #5
0
 public virtual void OnScoreIncrease(BaseNetworkGameCharacter character, int increaseAmount)
 {
     if (gameRule != null)
     {
         gameRule.OnScoreIncrease(character, increaseAmount);
     }
 }
 public virtual void OnUpdateCharacter(BaseNetworkGameCharacter character)
 {
     if (gameRule != null && Characters.Contains(character))
     {
         gameRule.OnUpdateCharacter(character);
     }
 }
예제 #7
0
    public virtual void OnKillIncrease(BaseNetworkGameCharacter character, int increaseAmount)
    {
        if (!CharacterCollectedKill.ContainsKey(character.photonView.ViewID))
        {
            CharacterCollectedKill[character.photonView.ViewID] = increaseAmount;
        }
        else
        {
            CharacterCollectedKill[character.photonView.ViewID] += increaseAmount;
        }

        if (IsTeamGameplay)
        {
            // TODO: Improve team codes
            switch (character.playerTeam)
            {
            case 1:
                TeamKillA += increaseAmount;
                break;

            case 2:
                TeamKillB += increaseAmount;
                break;
            }
        }
    }
예제 #8
0
    public virtual void OnUpdateCharacter(BaseNetworkGameCharacter character)
    {
        int checkScore = character.Score;
        int checkKill  = character.KillCount;

        if (IsTeamGameplay)
        {
            // Use team score / kill as checker
            switch (character.playerTeam)
            {
            case PunTeams.Team.red:
                checkScore = TeamScoreA;
                checkKill  = TeamKillA;
                break;

            case PunTeams.Team.blue:
                checkScore = TeamScoreB;
                checkKill  = TeamKillB;
                break;
            }
        }

        if (HasOptionMatchScore && MatchScore > 0 && checkScore >= MatchScore)
        {
            IsMatchEnded = true;
            EndMatch();
        }

        if (HasOptionMatchKill && MatchKill > 0 && checkKill >= MatchKill)
        {
            IsMatchEnded = true;
            EndMatch();
        }
    }
예제 #9
0
    public override bool CanCharacterRespawn(BaseNetworkGameCharacter character, params object[] extraParams)
    {
        var gameplayManager = GameplayManager.Singleton;
        var targetCharacter = character as CharacterEntity;

        return(gameplayManager.CanRespawn(targetCharacter) && Time.unscaledTime - targetCharacter.deathTime >= gameplayManager.respawnDuration);
    }
예제 #10
0
    public virtual void OnKillIncrease(BaseNetworkGameCharacter character, int increaseAmount)
    {
        if (!CharacterCollectedKill.ContainsKey(character.photonView.viewID))
        {
            CharacterCollectedKill[character.photonView.viewID] = increaseAmount;
        }
        else
        {
            CharacterCollectedKill[character.photonView.viewID] += increaseAmount;
        }

        if (IsTeamGameplay)
        {
            switch (character.playerTeam)
            {
            case PunTeams.Team.red:
                TeamKillA += increaseAmount;
                break;

            case PunTeams.Team.blue:
                TeamKillB += increaseAmount;
                break;
            }
        }
    }
 public bool RespawnCharacter(BaseNetworkGameCharacter character, params object[] extraParams)
 {
     if (gameRule != null)
     {
         return(gameRule.RespawnCharacter(character, extraParams));
     }
     return(true);
 }
 public void RegisterCharacter(BaseNetworkGameCharacter character)
 {
     if (character == null || Characters.Contains(character))
     {
         return;
     }
     character.RegisterNetworkGameManager(this);
     Characters.Add(character);
 }
예제 #13
0
    public override bool RespawnCharacter(BaseNetworkGameCharacter character, params object[] extraParams)
    {
        var brGameplayManager = GameplayManager.Singleton as BRGameplayManager;

        // Can spawn player when the game is waiting for players state only
        if (brGameplayManager != null && brGameplayManager.currentState == BRState.WaitingForPlayers)
        {
            return(true);
        }
        return(false);
    }
예제 #14
0
    public virtual void OnUpdateCharacter(BaseNetworkGameCharacter character)
    {
        if (HasOptionMatchScore && matchScore > 0 && character.Score >= matchScore)
        {
            IsMatchEnded = true;
            EndMatch();
        }

        if (HasOptionMatchKill && matchKill > 0 && character.KillCount >= matchKill)
        {
            IsMatchEnded = true;
            EndMatch();
        }
    }
예제 #15
0
    public override bool RespawnCharacter(BaseNetworkGameCharacter character, params object[] extraParams)
    {
        var targetCharacter = character as CharacterEntity;

        // In death match mode will not reset score, kill, assist, death
        targetCharacter.Exp           = 0;
        targetCharacter.level         = 1;
        targetCharacter.statPoint     = 0;
        targetCharacter.watchAdsCount = 0;
        targetCharacter.addStats      = new CharacterStats();
        targetCharacter.Armor         = 0;

        return(true);
    }
예제 #16
0
    public virtual void AdjustBots()
    {
        if (!HasOptionBotCount)
        {
            return;
        }

        int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
        int maxPlayers  = PhotonNetwork.CurrentRoom.MaxPlayers;

        if (networkManager.isConnectOffline)
        {
            maxPlayers = networkManager.maxConnections;
        }

        // Remove bots if needed, will remove bots if player count + added bots > max players
        List <BaseNetworkGameCharacter> bots = GetBots();
        int count = bots.Count;

        while (count > 0 && playerCount + count > maxPlayers)
        {
            int index = bots.Count - 1;
            BaseNetworkGameCharacter botCharacter = bots[index];
            PhotonNetwork.Destroy(botCharacter.photonView);
            count--;
        }

        // Add bots if needed, will add bots if added bots < bot count && player count + added bots < max players
        while (count < BotCount && playerCount + count < maxPlayers)
        {
            var character = NewBot();
            if (IsTeamGameplay)
            {
                int countA;
                int countB;
                networkManager.CountTeamPlayers(out countA, out countB);
                character.playerTeam = (byte)(countA > countB ? 2 : 1);
            }
            networkManager.RegisterCharacter(character);
            count++;
        }
    }
예제 #17
0
    public virtual void AdjustBots()
    {
        if (!HasOptionBotCount)
        {
            return;
        }
        // Add bots if needed
        int maxPlayers = PhotonNetwork.room.MaxPlayers;

        if (networkManager.isConnectOffline)
        {
            maxPlayers = networkManager.maxConnections;
        }
        if (Bots.Count < BotCount && PhotonNetwork.room.PlayerCount + Bots.Count < maxPlayers)
        {
            int addAmount = BotCount;
            // Adjust bot count
            if (PhotonNetwork.room.PlayerCount + addAmount > maxPlayers)
            {
                addAmount = maxPlayers - PhotonNetwork.room.PlayerCount;
            }
            for (var i = 0; i < addAmount; ++i)
            {
                var character = NewBot();
                if (IsTeamGameplay)
                {
                    character.playerTeam = tempTeam = (tempTeam == PunTeams.Team.red ? PunTeams.Team.blue : PunTeams.Team.red);
                }
                networkManager.RegisterCharacter(character);
                Bots.Add(character);
            }
        }
        // Remove bots if needed
        while (PhotonNetwork.room.PlayerCount + Bots.Count > maxPlayers)
        {
            int index = Bots.Count - 1;
            BaseNetworkGameCharacter botCharacter = Bots[index];
            PhotonNetwork.Destroy(botCharacter.photonView);
            Bots.RemoveAt(index);
        }
    }
 public void RegisterCharacter(BaseNetworkGameCharacter character, string deviceUniqueIdentifier = "")
 {
     if (character == null || Characters.Contains(character))
     {
         return;
     }
     character.RegisterNetworkGameManager(this);
     Characters.Add(character);
     if (!string.IsNullOrEmpty(deviceUniqueIdentifier))
     {
         PlayerCharacterObjectIds[deviceUniqueIdentifier] = character.ObjectId;
         NetworkGameScore gameScore;
         if (!doNotKeepPlayerScore && PlayerScores.TryGetValue(deviceUniqueIdentifier, out gameScore))
         {
             character.score       = gameScore.score;
             character.killCount   = gameScore.killCount;
             character.assistCount = gameScore.assistCount;
             character.dieCount    = gameScore.dieCount;
         }
     }
 }
    public virtual void OnUpdateCharacter(BaseNetworkGameCharacter character)
    {
        if (IsMatchEnded)
        {
            return;
        }

        int checkScore = character.Score;
        int checkKill  = character.KillCount;

        if (IsTeamGameplay)
        {
            // Use team score / kill as checker
            switch (character.playerTeam)
            {
            case 1:
                checkScore = teamScoreA;
                checkKill  = teamKillA;
                break;

            case 2:
                checkScore = teamScoreB;
                checkKill  = teamKillB;
                break;
            }
        }

        if (HasOptionMatchScore && matchScore > 0 && checkScore >= matchScore)
        {
            IsMatchEnded = true;
        }

        if (HasOptionMatchKill && matchKill > 0 && checkKill >= matchKill)
        {
            IsMatchEnded = true;
        }
    }
예제 #20
0
 public abstract bool RespawnCharacter(BaseNetworkGameCharacter character, params object[] extraParams);