SunsetHigh.Projectile.addCollideEvent C# (CSharp) Method

addCollideEvent() public method

public addCollideEvent ( ProjectileCollideEvent e ) : void
e ProjectileCollideEvent
return void
        public void addCollideEvent(ProjectileCollideEvent e)
        {
            mEvent += e;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Causes the Hero to create a projectile and fire it in the direction
        /// he is facing; Hero is then responsible for updating and drawing this projectile
        /// </summary>
        public void shoot()
        {
            if (canShoot)
            {
                int x = 0;
                int y = 0;
                if (this.getDirection().Equals(Direction.North))
                    y = -this.getHeight() / 2;
                if (this.getDirection().Equals(Direction.South))
                    y = this.getHeight() / 2;
                if (this.getDirection().Equals(Direction.East))
                    x = this.getWidth() / 2;
                if (this.getDirection().Equals(Direction.West))
                    x = -this.getWidth() / 2;

                Projectile bullet = new Projectile(this.getX() + x, this.getY() + y, 300.0f, this.getDirection());
                bullet.setImage(Sprite.getCommonImage(PROJECTILE_IMAGE_NAME));
                bullet.addCollideEvent(new ProjectileCollideEvent(heroBulletCollideEvent));
                WorldManager.enqueueObjectToCurrentRoom(bullet);

                canShoot = false;
                shootTimer = 0.0f;
            }
        }