コード例 #1
0
ファイル: Alien.cs プロジェクト: rumkugel13/SpaceInvaders
        public override void OnCollision(CollidableEntity other)
        {
            base.OnCollision(other);

            if (other is Projectile p && p.MovingUp)
            {
                this.Collection.Get <GroundCannon>().Get <ScoreComponent>().Score += size == Size.Small ? 30 : size == Size.Medium ? 20 : 10;
                this.Destroy();
            }
        }
コード例 #2
0
        public override void OnCollision(CollidableEntity other)
        {
            base.OnCollision(other);

            if (other is Projectile p && p.MovingUp)
            {
                this.Collection.Get <GroundCannon>().Get <ScoreComponent>().Score += 100;
                MotionComponent motion = this.Get <MotionComponent>();
                motion.Velocity *= -1.1f;   //reverse and speed up
                this.Position    = new Vector2(-this.MaxPos * System.Math.Sign(motion.Velocity.X), this.Position.Y);
            }
        }
コード例 #3
0
        public override void OnCollision(CollidableEntity other)
        {
            base.OnCollision(other);

            // note: optionally check type of other gameobject for more specific reaction if using different layers
            if (this.Get <ReservesComponent>().Reserves-- > 0)
            {
                // just respawn for now
                this.Position = new Vector2(480, 440);
            }
            else
            {
                this.Destroy();
            }
        }
コード例 #4
0
        public override void OnCollision(CollidableEntity other)
        {
            base.OnCollision(other);

            if (MovingUp)
            {
                // moving up only when shot from groundcannon
                this.Collection.Get <GroundCannon>().CanShoot = true;
                this.Destroy();
            }
            else if (!(other is Alien || other is Mothership))
            {
                this.Destroy();
            }
        }
コード例 #5
0
 public virtual void OnCollision(CollidableEntity other)
 {
 }
コード例 #6
0
        public override void OnCollision(CollidableEntity other)
        {
            base.OnCollision(other);

            this.Destroy();
        }