Exemplo n.º 1
0
    void OnCollision(GameObject other)
    {
        if (other == owner)
        {
            return;
        }

        if (other.tag == "Player")
        {
            PlayerController hitPlayer = other.GetComponent <PlayerModelController>().owner;

            hitPlayer.currentStats.TakeDamage(damage, this.movementDirection * moveSpeed);
            hitPlayer.playerModel.GetComponent <Rigidbody>().AddForce(firedFromGun.projectileSize * this.movementDirection.normalized * gameManager.gameSettings.baseKnockbackValue, ForceMode.Impulse);

            TextPopupHandler textPopup = GameObject.Instantiate(gameManager.TextPopupPrefab).GetComponent <TextPopupHandler>();
            string           textValue = "-" + damage.ToString();
            textPopup.Init(this.transform.position, textValue, TeamManager.Instance.GetTeamColor(owningPlayer.teamID), 0.5f);
            textPopup.lifetime = 0.5f;

            if (hitPlayer.currentStats.health <= 0)
            {
                FindObjectOfType <GameManager>().OnPlayerKilled(owningPlayer, hitPlayer);
            }
        }

        OnDestroy();
    }
Exemplo n.º 2
0
    public void OnPlayerKilled(PlayerController killer, PlayerController killed)
    {
        sessionData.score.PlayerKilled(killer.teamID);
        hud.Announcement($"<color={killer.teamID.ToString().ToLower()}>Player {currentPlayers.IndexOf(killer) + 1}</color> killed <color={killed.teamID.ToString().ToLower()}>Player {currentPlayers.IndexOf(killed) + 1}</color>!", 3);

        PlayerPostDeathHandler deathHandler = GameObject.Instantiate(DeathColliderPrefab).GetComponent <PlayerPostDeathHandler>();

        deathHandler.transform.position = killed.pawnPosition;
        deathHandler.targetTeam         = killer.teamID;

        TextPopupHandler textPopup = GameObject.Instantiate(TextPopupPrefab).GetComponent <TextPopupHandler>();
        string           textValue = "+" + gameSettings.pointsPerKill.ToString();

        textPopup.Init(killer.pawnPosition, textValue, teamManager.GetTeamColor(killer.teamID));
    }
Exemplo n.º 3
0
    public void DoScoreUpdate()
    {
        elapsedTime += Time.deltaTime;

        if (elapsedTime >= gameManager.gameSettings.KOTHInterval)
        {
            foreach (PlayerController player in currentPlayers)
            {
                gameManager.sessionData.score.currentTeams.Find(x => x.teamID == player.teamID).AddScore(gameManager.gameSettings.KOTHPoints);

                TextPopupHandler textPopup = GameObject.Instantiate(gameManager.TextPopupPrefab).GetComponent <TextPopupHandler>();
                string           textValue = "+" + gameManager.gameSettings.KOTHPoints.ToString();
                textPopup.Init(player.pawnPosition, textValue, TeamManager.Instance.GetTeamColor(player.teamID), 0.7f);
                textPopup.lifetime = 0.75f;
            }

            // Reset time + inform listeners of score change
            elapsedTime = 0f;
            gameManager.OnScoreUpdated.Invoke();
        }
    }