Exemplo n.º 1
0
    //Call this when changing weapons
    public void UpdateWeapon(WeaponName wn)
    {
        switch (wn)
        {
        case WeaponName.WEAPON0:
        default:
            weaponId = 0;
            break;

        case WeaponName.WEAPON1:
            weaponId = 1;
            break;

        case WeaponName.WEAPON2:
            weaponId = 2;
            break;
        }
        SpriteRenderer sprite    = GetComponent <SpriteRenderer>();
        SpriteRenderer retSprite = reticle.GetComponent <SpriteRenderer>();

        sprite.sprite    = wdata[weaponId].weaponsprite;
        sprite.color     = wdata[weaponId].bullettype.element.primary;
        retSprite.sprite = wdata[weaponId].bullettype.element.reticleSprite;
        retSprite.color  = wdata[weaponId].bullettype.element.primary;

        //Attempt to turn on glow animation on reticle
        GlowAnimation g = reticle.GetComponent <GlowAnimation>();

        if (g)
        {
            g.c0 = wdata[weaponId].bullettype.element.primary;
        }
    }
Exemplo n.º 2
0
    //Sets reticle scale and position when locked on
    public void SetReticleTarget(GameObject t)
    {
        if (t == null)
        {
            Debug.Log("Setting null target");

            return;
        }

        //if the target changes, notify the current target
        if (reticle.transform.parent != null)
        {
            if (
                reticle.transform.parent.gameObject != this.gameObject &&
                reticle.transform.gameObject != t
                )
            {
                reticle.transform.parent.GetComponent <EnemyStateMachine>().UnregisterReticle();
            }
        }

        t.GetComponent <EnemyStateMachine>().RegisterReticle(reticle);
        reticle.transform.SetParent(t.transform);
        reticle.transform.localPosition = new Vector2(0, 0);
        reticle.transform.localScale    = new Vector3(reticleMaxScale, Mathf.Sign(transform.localScale.y) * reticleMaxScale, 1);

        //Attempt to turn on glow animation on reticle
        GlowAnimation g = reticle.GetComponent <GlowAnimation>();

        if (g)
        {
            g.SetActive(true);
        }
    }
Exemplo n.º 3
0
    public void ResetReticle()
    {
        if (reticle.transform.parent == gameObject.transform)
        {
            return;
        }
        reticle.transform.position = this.transform.position;
        reticle.transform.SetParent(this.transform);
        reticle.transform.localPosition = new Vector2(defaultReticleDistance, 0);
        reticle.transform.localScale    = new Vector3(reticleMinScale, reticleMinScale, 1);

        //Attempt to turn off glow animation on reticle
        GlowAnimation g = reticle.GetComponent <GlowAnimation>();

        if (g)
        {
            g.SetActive(false);
        }
    }