public static PointsPopUp Create(Vector3 loc, int pointsValue)
    {
        Transform @object = Instantiate(GameAssets.i.PointsPopup) as Transform;

        @object.position = loc;
        PointsPopUp script = @object.GetComponent <PointsPopUp>();

        script.SetUp(pointsValue);
        return(script);
    }
Exemple #2
0
    public void TakeDamage()
    {
        if (_health == 1)
        {
            GameObject.FindGameObjectWithTag(StringUtils.SceneManager).GetComponent <GameModeController>().TargetGameOver(this.transform.parent.gameObject);
            Destroy(this.transform.parent.gameObject);
            return;
        }

        _hearts[_health - 1].sprite = GameAssets.i.EmptyHeart;

        _health--;

        GameObject.FindGameObjectWithTag(StringUtils.SceneManager).GetComponent <PlayerScore>().UpdateScore(-10, id);
        PointsPopUp.Create(transform.position + new Vector3(0, 1, 0), -10);
        id = Guid.NewGuid().ToString();
    }
    private void OnDestroy()
    {
        //GameObject.FindObjectOfType<WaveController>().Agents.Remove(this.gameObject);
        var temp = GameObject.FindGameObjectWithTag(StringUtils.SceneManager).GetComponent <GameModeController>().GameMode;

        if (temp._gameOver && gameObject.tag != StringUtils.GameObjective)
        {
            return;
        }

        if (temp.GetType() == typeof(WaveGameMode_SO))
        {
            WaveGameMode_SO t = (WaveGameMode_SO)temp;
            t.RemoveAgent(gameObject);
        }

        if (_pointsValue < 0)
        {
            PointsPopUp.Create(transform.position, _pointsValue);
        }
        else
        {
            PointsPopUp.Create(transform.position, (_pointsValue * _playerScore.GetMultiplier));
        }

        _playerScore.UpdateScore(_pointsValue, _uniqueToken);

        if (_hasMultiplier)
        {
            _playerScore.UpdateMultiplier(_multiplierValue);
        }

        if (temp._gameOver)
        {
            return;
        }
    }