Ejemplo n.º 1
0
 public override void ThrowWeapon(List <GameObject> list)
 {
     if (_timer.Ticks > 900 && NumOfWeapons > 0 && new System.Random().Next(1, 100) < 30)
     {
         NumOfWeapons = NumOfWeapons - 1;
         list.Add(new Torpedo(PositionX, PositionY + SwinGame.BitmapHeight(Image) / 2));
         _timer.Reset();
     }
 }
Ejemplo n.º 2
0
 public override void ThrowWeapon(List <GameObject> list)
 {
     if (_timer.Ticks > new System.Random().Next(300, 30000) && NumOfWeapons > 0)
     {
         NumOfWeapons = NumOfWeapons - 1;
         list.Add(new Supply(PositionX, PositionY + SwinGame.BitmapHeight(Image) / 2));
         _timer.Reset();
         _timer.Start();
     }
 }
        public ScrollingBackground()
        {
            _backgroundHeight = SwinGame.BitmapHeight(_background);
            int heightCoverage = SwinGame.ScreenHeight() + _backgroundHeight;
            int backgrounds    = 1 + (int)Math.Ceiling((double)(heightCoverage / _backgroundHeight));

            for (int i = 0; i < backgrounds; i++)
            {
                _backgrounds.Add(i * _backgroundHeight);
            }
        }
        /// <summary>
        /// Creates an Entity with an Animation component and adds it to the world.
        /// This is primarily used for Entities which are just animations so they can be processed
        /// by the Animation Rendering System.
        /// </summary>
        /// <param name="x">The x coordinate the Entity will be created at.</param>
        /// <param name="y">The y coordinate the Entity will be created at.</param>
        /// <param name="anim">The name of the animation to be played.</param>
        /// <param name="img">The Bitmap the animation will operate on.</param>
        /// <param name="animScript">The animation script containing the animation details.</param>
        public static void CreateAnimationEntity(float x, float y, Animation anim, Bitmap img, AnimationScript animScript)
        {
            //Create Entity and add to world
            ulong newEntity = _world.NextEntityID;

            int width  = SwinGame.BitmapWidth(img);
            int height = SwinGame.BitmapHeight(img);

            //Create components and pass to world to send to Systems
            List <Component> components = new List <Component>();

            components.Add(new CPosition(x, y, width, height));
            components.Add(new CAnimation(img, anim, animScript));

            _world.AddEntity(newEntity, components);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This wraps the object around the screen.
        /// </summary>
        public void WrapObject()
        {
            if (XShip < -((SwinGame.BitmapWidth(base.Type))))
            {
                XShip = SwinGame.ScreenWidth();
            }

            else if (XShip > SwinGame.ScreenWidth())
            {
                XShip = -SwinGame.BitmapWidth(base.Type);
            }

            if (YShip < (-(SwinGame.BitmapHeight(base.Type))))
            {
                YShip = (SwinGame.ScreenHeight());
            }

            else if (YShip > SwinGame.ScreenHeight())
            {
                YShip = -(SwinGame.BitmapHeight(base.Type));
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Draw the end of the game screen, shows the win/lose state
    /// </summary>
    public static void DrawEndOfGame()
    {
        DrawField(ComputerPlayer.PlayerGrid, ComputerPlayer, true);
        DrawSmallField(HumanPlayer.PlayerGrid, HumanPlayer);

        if (HumanPlayer.IsDestroyed)
        {
            SwinGame.LoadBitmapNamed("loser", "YouLose.png");
            Bitmap bmp  = SwinGame.BitmapNamed("loser");
            float  bmpX = (((float)SwinGame.ScreenWidth() / 2) - ((float)SwinGame.BitmapWidth(bmp) / 2));
            float  bmpY = (((float)SwinGame.ScreenHeight() / 2) - ((float)SwinGame.BitmapHeight(bmp) / 2));
            SwinGame.DrawBitmap(bmp, bmpX, bmpY);
            //SwinGame.DrawTextLines("YOU LOSE!", Color.White, Color.Transparent, GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }
        else
        {
            SwinGame.LoadBitmapNamed("winner", "YouWin.png");
            Bitmap bmp  = SwinGame.BitmapNamed("winner");
            float  bmpX = (((float)SwinGame.ScreenWidth() / 2) - ((float)SwinGame.BitmapWidth(bmp) / 2));
            float  bmpY = (((float)SwinGame.ScreenHeight() / 2) - ((float)SwinGame.BitmapHeight(bmp) / 2));
            SwinGame.DrawBitmap(bmp, bmpX, bmpY);
            //SwinGame.DrawTextLines("-- WINNER --", Color.White, Color.Transparent, GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }
    }
Ejemplo n.º 7
0
 public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip)
 {
     this.Move();
     //このCollisionDetectionをGameObjects List内のすべてのSubmarineに対して行う必要がある。
     for (int j = GameObjects.Count - 1; j >= 0; j--)
     {
         if (GameObjects[j] is Submarine && this.Disappear == false)
         {
             Submarine sub = GameObjects[j] as Submarine;
             if (this.CollisionDetection(GameObjects[j].PositionX, GameObjects[j].PositionY, SwinGame.BitmapWidth(sub.Image), SwinGame.BitmapHeight(sub.Image)))
             {
                 sub.Disappear = true;
                 myShip.Hit++;
             }
         }
     }
 }
Ejemplo n.º 8
0
 public override void Draw()
 {
     SwinGame.FillCircle(Color.Blue, (X + (SwinGame.BitmapWidth(Sprite) / 2)), (Y + (SwinGame.BitmapHeight(Sprite) / 2)), Size / 2);
     SwinGame.DrawBitmap("sprite3", X, Y);
     //SwinGame.FillCircle(Color.BlueViolet, X, Y, Size/2);
 }
Ejemplo n.º 9
0
        public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip)
        {
            this.Move();

            if (_explodeTime == null && this.Disappear == false && this.CollisionDetection(myShip.PositionX, myShip.PositionY, SwinGame.BitmapWidth(myShip.Image), SwinGame.BitmapHeight(myShip.Image)))
            {
                myShip.Hp--;
            }
        }
Ejemplo n.º 10
0
 public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip)
 {
     this.Move();
     if (myShip.Hp > 0 && this.CollisionDetection(myShip.PositionX, myShip.PositionY, SwinGame.BitmapWidth(myShip.Image), SwinGame.BitmapHeight(myShip.Image)))
     {
         myShip.HitEffect();
         myShip.Hp           = myShip.Hp + 2;
         myShip.NumOfWeapons = myShip.NumOfWeapons + 2;
     }
 }
Ejemplo n.º 11
0
 public int BlockHeight(BlockData block)
 {
     return(SwinGame.BitmapHeight(block.bmp));
 }
Ejemplo n.º 12
0
 public int PlayerHeight()
 {
     return(SwinGame.BitmapHeight(player.bmp));
 }
Ejemplo n.º 13
0
 public int itemHeight(itemData item)
 {
     return(SwinGame.BitmapHeight(item.bmp));
 }
Ejemplo n.º 14
0
 public int BallHeight(BallData ball)
 {
     return(SwinGame.BitmapHeight(ball.bmp));
 }