コード例 #1
0
        public bool ShootMissile()
        {
            if (_missile == null)
            {
                Rectangle inRect = ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).getRectangle();
                _missile = GameObjMananger.getInstance().CreateMissile(new Rectangle(inRect.X + inRect.Width / 2 - 10 / 2, inRect.Y, 10, 16));
                _missile.setStatus(false);

                Sound Effect = SoundManager.getInstance().Find(SoundName.Missile);
                Effect.PlaySound();

                return(true);
            }
            else
            {
                if (!_missile.getStatus())
                {
                    _missile.Position.Y = Position.Y - 2;
                    _missile.setStatus(true);


                    Sound Effect = SoundManager.getInstance().Find(SoundName.Missile);
                    Effect.PlaySound();

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public Missile CreateMissile(Rectangle inRect)
        {
            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Missile);
            ColObj        _colobj = new ColObj(inRect, ColObjName.Missile, SpriteName.BBox);
            Missile       Obj     = new Missile(GameObjName.Missile, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Missile);

            ColGroup X = ColGroupManager.getInstance().find(Obj.TempColGroupName);

            if (X == null)
            {
                ColGroupManager.getInstance().find(ColGroupName.Missile);
            }

            ColObjManager.getInstance().Add(_colobj);
            SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text);

            ColGroupManager.getInstance().find(Obj.TempColGroupName).Add(Obj);

            GameObjMananger.getInstance().Add(Obj);
            Obj.setStatus(false);
            ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).setMissile(Obj);

            return(Obj);
        }