示例#1
0
    public CAndy()
    {
        setFrames(Resources.LoadAll <Sprite> ("Sprites/nina"));
        setName("Nina");
        setSortingLayerName("Player");

        setScale(0.5f);

        setRegistration(CSprite.REG_TOP_LEFT);

        setWidth(WIDTH);
        setHeight(HEIGHT);

        // TODO: PASAR A LA CAMARA CUANDO SE IMPLEMENTE.
        CAudioManager.Inst.setAudioListener(this);
        CAudioManager.Inst.setPrimaryParent(this.getGameObject());

        // Agregate al audio manager como audio source.
        // Este objeto emite sonido.
        CAudioManager.Inst.addAudioSource(this).gameObject.transform.SetParent(this.getGameObject().transform);

        setState(STATE_STAND);

        if (this.debug)
        {
            mRect = new CSprite();
            mRect.setImage(Resources.Load <Sprite> ("Sprites/ui/pixel"));
            mRect.setSortingLayerName("Player");
            mRect.setSortingOrder(20);
            mRect.setAlpha(0.5f);
            mRect.setName("player_debug_rect");

            mRect2 = new CSprite();
            mRect2.setImage(Resources.Load <Sprite> ("Sprites/ui/pixel"));
            mRect2.setSortingLayerName("Player");
            mRect2.setSortingOrder(20);
            mRect2.setColor(Color.red);
            mRect2.setAlpha(0.5f);
            mRect2.setName("player_debug_rect2");
        }

        this.powers = new List <Power>();
        this.powers.Add(new Earth());
        this.powers.Add(new Air(this));
        this.powers.Add(new Water(this));
        this.powers.Add(new Fire(this));

        this.selectedPower = 0;

        this.powers[this.selectedPower].setActive();

        textoPoderes = new CText(this.powers[this.selectedPower].getName());
        textoPoderes.setWidth(this.getWidth());
        textoPoderes.setWrapping(false);
        textoPoderes.setFontSize(40f);
        textoPoderes.setXY(this.getX(), this.getY() - textoPoderes.getHeight());
        textoPoderes.setAlignment(TMPro.TextAlignmentOptions.Center);

        this.setBounds(0, 0, CTileMap.Instance.getMapWidth() * CTileMap.Instance.getTileWidth(), CTileMap.Instance.getMapHeight() * CTileMap.Instance.getTileHeight());
        this.setBoundAction(CGameObject.BOUNCE);
    }