Пример #1
0
    void Start()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        if (dataManager != null)
        {
            spriteRenderer.sprite = dataManager.selectedObject.sprite;
            charName = dataManager.selectedObject.charName;
            speed    = dataManager.selectedObject.speed;
        }
        rb2d = GetComponent <Rigidbody2D>();

        screenBounds = mainCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, mainCamera.transform.position.z));
        objectWidth  = spriteRenderer.bounds.extents.x;
        objectHeight = spriteRenderer.bounds.extents.y;

        dataManager.AddPlayer(this);
        dataManager.score   = 0;
        scoreText.faceColor = new Color32(0, 0, 0, 255);

        panelHeight = screenBounds.y * hud.rect.size.y / canvas.pixelRect.size.y;
        dataManager.SetPanelHeightBottom(panelHeight);
        dataManager.ActivateAlienSpawner();
        Weapon weaponStats = WeaponObject.GetComponent <Weapon>();

        weaponStats.shootCooldown = dataManager.selectedObject.attackRate;
        weaponStats.ammunitionMax = dataManager.selectedObject.ammunition;
        weaponStats.reloadTime    = dataManager.selectedObject.reloadTime;
        WeaponObject.SetActive(true);
    }