예제 #1
0
    public override void loadResources()
    {
        bullet       = (GameObject)Resources.Load("Prefabs/WeaponPrefabs/SniperBullet", typeof(GameObject));
        myBullet     = bullet.GetComponent <SniperBullet>();
        sniperBullet = bullet.GetComponent <SniperBullet>();

        Sprite    temp = Resources.Load <Sprite>("Images/Weapons/RifleBuff1");
        Transform t    = Instantiate(BuffPrefab, transform.position, Quaternion.identity).transform;

        buffIcon1 = t.gameObject.GetComponent <PlayerBuff>();
        buffIcon1.buffImage.sprite = temp;
        myUI.addBuffChild(t);

        temp      = Resources.Load <Sprite>("Images/Weapons/RifleBuff1");
        t         = Instantiate(BuffPrefab, transform.position, Quaternion.identity).transform;
        buffIcon2 = t.gameObject.GetComponent <PlayerBuff>();
        buffIcon2.buffImage.sprite = temp;
        myUI.addBuffChild(t);

        temp      = Resources.Load <Sprite>("Images/Weapons/RifleBuff1");
        t         = Instantiate(BuffPrefab, transform.position, Quaternion.identity).transform;
        buffIcon3 = t.gameObject.GetComponent <PlayerBuff>();
        buffIcon3.buffImage.sprite = temp;
        myUI.addBuffChild(t);
    }
예제 #2
0
 // Use this for initialization
 void Start()
 {
     _sr   = this.GetComponent <SpriteRenderer> ();
     hero  = GameObject.Find("Hero");
     _sb   = this.GetComponent <SniperBullet> ();
     shoot = false;
 }
예제 #3
0
        public override void Fire(float rotation)
        {
            Globals.audioManager.PlayGameSound("sniper");

            SniperBullet b = Globals.gameInstance.projectileManager.sniperBulletPool.Provide();

            b.Construct(emmitterPosition, rotation);

            base.Fire(rotation);
        }
예제 #4
0
    override public void Shoot(PlayerAction shootAction)
    {
        if (shootAction.IsPressed && active)
        {
            particle.SetActive(true);
            if (currentBullet == null)
            {
                this.chargePlayerToken = SfxManager.instance.PlaySound(SoundType.BEAN_CHARGE, 1, true);

                this.currentBullet       = Instantiate(bullet).GetComponent <SniperBullet>();
                this.currentBullet.power = 0.1f;
                this.currentBullet.transform.localScale = (Vector3)Vector2.one * 0.1f;
                this.currentBullet.GetComponent <Collider2D>().enabled = false;
                this.currentBullet.owner = this.type;
                //currentBullet.gameObject.SetActive(false);
            }
            if (currentBullet.power < 3f)
            {
                currentBullet.power += chargeSpeed * 2;
            }
            else
            {
                currentBullet.power = 3;
            }
            if (currentBullet.transform.localScale.x < 1.5f)
            {
                currentBullet.transform.localScale += (Vector3)Vector2.one * chargeSpeed;
            }
            currentBullet.lifetime           = 1;
            currentBullet.transform.position = this.transform.position + Vector3.right * 1.4f + Vector3.down * 0.7f;
        }
        else
        {
            particle.SetActive(false);
        }
        if (shootAction.WasReleased)
        {
            SfxManager.instance.StopLoopingSound(SoundType.BEAN_CHARGE, this.chargePlayerToken);
            //currentBullet.gameObject.SetActive(true);
            //this.energy -= currentBullet.power * 5;
            SfxManager.instance.PlaySound(SoundType.BEAN_SHOOT, MathUtil.Map(currentBullet.power, 0, 3, 0, 1));
            currentBullet.velocity  = Vector2.right * this.bulletSpeed;
            currentBullet.shrinking = true;
            this.velocity          += Vector2.left * currentBullet.power * Time.deltaTime;
            Camera.main.Kick(Vector2.left);
            this.currentBullet.GetComponent <Collider2D>().enabled = true;

            currentBullet = null;
        }
    }
예제 #5
0
    // Update is called once per frame
    override public void DoUpdate()
    {
        base.DoUpdate();
        startDelay       -= Time.deltaTime;
        this.sprite.color = Color.white;
        if (startDelay <= 0)
        {
            if (currentBullet == null)
            {
                this.bulletDelayTimer -= Time.deltaTime;
                if (bulletDelayTimer <= 0)
                {
                    this.sprite.sprite = this.angledSprite;
                    particle.SetActive(true);
                    this.chargePlayerToken   = SfxManager.instance.PlaySound(SoundType.BEAN_CHARGE, 1, true);
                    this.currentBullet       = Instantiate(bullet).GetComponent <SniperBullet>();
                    this.currentBullet.power = 0.1f;
                    this.currentBullet.transform.localScale = (Vector3)Vector2.one * 0.1f;
                    this.currentBullet.GetComponent <Collider2D>().enabled = false;
                    this.currentBullet.owner         = this.type;
                    currentBullet.transform.position = this.transform.position + Vector3.left * this.sprite.bounds.extents.x;
                    this.bulletDelayTimer            = bulletDelay;
                }
            }
            else
            {
                currentBullet.lifetime = 1;
                if (currentBullet.power < 3f)
                {
                    currentBullet.power += chargeSpeed * 2;
                }
                else
                {
                    currentBullet.power = 3;
                }

                if (currentBullet.transform.localScale.x < 1.5f)
                {
                    currentBullet.transform.localScale += (Vector3)Vector2.one * chargeSpeed;


                    if (currentBullet.transform.localScale.x > 1.25f)
                    {
                        this.sprite.color = Color.red;
                    }
                }
                else
                {
                    this.sprite.sprite = normalSprite;

                    SfxManager.instance.StopLoopingSound(SoundType.BEAN_CHARGE, chargePlayerToken);
                    SfxManager.instance.PlaySound(SoundType.BEAN_SHOOT);

                    particle.SetActive(false);
                    currentBullet.velocity         = Vector2.left * 0.4f;
                    currentBullet.shrinkMultiplier = 0.4f;
                    currentBullet.shrinking        = true;
                    Camera.main.Kick(Vector2.left);

                    this.currentBullet.GetComponent <Collider2D>().enabled = true;
                    currentBullet = null;
                }
            }
        }
    }