public MisilSmokeGenerator(Coordenada2D inicial, Coordenada2D final,
                            char pPlayer, float pX, float pY, float pZ)
 {
     vX       = pX; vY = pY; vZ = pZ;
     cInicial = inicial;
     cFinal   = final;
     player   = pPlayer;
 }
Ejemplo n.º 2
0
 public SmokeGenerator(int size, int pos, Coordenada2D pCoord, int player)
 {
     //Tengo que generar el humo a lo largo de todo el barco por lo que necesito el
     //tamaño (size) y la posicion del barco (pos)
     base.coordinate = new Vector3(pCoord.X, 0, pCoord.Y);
     if (player == 1)
     {
         boardSeparation = Game.BoardSeparation;
     }
     if (pos == 1)
     {
         x = size; // 1 acostado
         y = 0.5f;
     }
     else
     {
         y = size; // 0 parado
         x = 0.5f;
     }
 }
Ejemplo n.º 3
0
 public Misile(Coordenada2D inicial, Coordenada2D final, char pPlayer, PlayerShoot shoot)
 {
     this.shoot    = shoot;
     this.file     = "misil";
     this.cInicial = inicial;
     this.cFinal   = final;
     this.player   = pPlayer;
     locked        = true;
     x             = 0; y = 0; z = 0;
     CalculateCoord();
     Camara.MisileLocked = true;
     if (misilCamera)
     {
         manager.Camara.SaveCamaraPos(1);
         Camara.LockedMisileCamera = true;
     }
     else
     {
         manager.Escena.AddGenerator(new MisilSmokeGenerator(cInicial, cFinal, player, vX, vY, vZ));
         manager.Escena.AddParticle(new MisileFire(new Vector3(cInicial.X, 0, cInicial.Y)));
     }
 }
Ejemplo n.º 4
0
 public FireGenerator(Coordenada2D coordenada, Player pPlayer)
 {
     base.coordinate = new Vector3(coordenada.X, 0, coordenada.Y);
     player          = pPlayer;
 }
Ejemplo n.º 5
0
        public void Update(Cursor cursor)
        {
            base.manager.Camara.Update();

            #region Show routines

            if (Showed == false)
            {
                Showed = true;
                if (FirstShowed == false)
                {
                    FirstShowed = true;
                    Camara.LocateCamara(new Vector3(10.5f, 7, 23), new Vector3(10.5f, 0, 7.5f));
                }
                else
                {
                    base.manager.Camara.RestoreCamaraPos(0);
                }
            }

            #endregion

            #region keyboard routines

            KeyboardState kb = Keyboard.GetState();

            if (kb.IsKeyDown(Keys.A))
            {
                Camara.Move = CameraMove.Left;
            }

            if (kb.IsKeyDown(Keys.D))
            {
                Camara.Move = CameraMove.Right;
            }

            if (kb.IsKeyDown(Keys.Escape))  //escape key
            {
                //Sound.StopLoop("cameraRotate.wav");
                base.EnterMenuScreen();
                return;
            }
//#if DEBUG
            if (kb.IsKeyDown(Keys.R))
            {
                base.EnterWinScreen();
                return;
            }
//#endif
            if (kb.IsKeyDown(Keys.E))
            {
                if (shipsShowed == true)
                {
                    shipsShowed = false;
                }
                else
                {
                    shipsShowed = true;
                }
                base.manager.Game.ShowComputerShips(shipsShowed);
            }

            #endregion

            #region mouse routines

            MouseState m = manager.Cursor.MouseState;

            if (m.ScrollWheelValue != deltaScroll)
            {
                Camara.Scrolling = true;
                int delta = deltaScroll - m.ScrollWheelValue;
                if (delta < 0)
                {
                    Camara.Move = CameraMove.ZoomIn;
                }
                else
                {
                    Camara.Move = CameraMove.ZoomOut;
                }
                deltaScroll = m.ScrollWheelValue;
            }

            Point point = manager.Cursor.Position;
            if (viewArea.Contains(point))
            {
                boardCount++;
                if (boardCount == 5)
                {
                    boardCount = 0;
                    if (manager.Escena.BoardMouse(point.X, point.Y) == true && base.manager.Game.CurrentPlayer == Player.Person)
                    {
                        manager.Cursor.CurrentCursor = ECursor.Aim;
                    }
                    else
                    {
                        manager.Cursor.CurrentCursor = ECursor.Arrow;
                    }
                }
                if (manager.Cursor.MouseState.LeftButton == ButtonState.Pressed)
                {
                    Coordenada2D shoot = base.manager.Escena.BoardSelection(point.X, point.Y);

                    if (shoot.X != -1)
                    {
                        int boardCell = base.manager.Game.GetCoordenada(shoot.X, shoot.Y, 1);
                        if (base.manager.Game.CurrentPlayer == Player.Person && boardCell != 7 && boardCell != 9 &&
                            boardCell != 11 && Misile.Locked == false && Game.Finished == false && Camara.IsShaking == false)
                        {
                            //AudioPlayback.Play("misile1.wav");
                            Coordenada2D inicial = manager.Game.GetLaunchCoord();
                            manager.Escena.AddModel(new Misile(inicial, shoot, 'P', PlayerShoot));
                        }
                    }
                }
            }
            else
            {
                manager.Cursor.CurrentCursor = ECursor.Arrow;
            }

            #endregion

            #region Cambio de turno

            switch (state)
            {
            case 1:
                Change();
                break;

            case 2:
                Computer();
                break;

            default:
                break;
            }

            #endregion

            #region Ganador

            if (base.manager.Game.Winner != Player.None)
            {
                winnerCount--;
                if (winnerCount == 0)
                {
                    base.EnterWinScreen();
                }
            }

            #endregion

            base.manager.Escena.Update();
            base.manager.Escena.UpdateShipModels();
            base.UpdateControls(cursor);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// This function performs all the logic when a player (CPU or human)
 /// make a shot to the other
 /// <summary>
 void PlayerShoot(int x, int y, Player player)
 {
     if (player == Player.Person)//si es el jugador
     {
         int ship = base.manager.Game.GetCoordenada(x, y, 1);
         if (ship != 0) //si di en el blanco
         {
             manager.Escena.AddModel(new ExplosionSquare(x, y, 1, Player.Computer));
             manager.Escena.AddModel(new ExplosionWave(x, y, Player.Computer, 1));
             manager.Escena.AddGenerator(new FireGenerator(new Coordenada2D(x, y), Player.Computer));
             manager.Game.SetCoordenada(x, y, 9, 1);
             manager.Game.SetHit(Player.Computer, ship);
             if (manager.Game.ShipsComputer[Game.Convertir(ship)].GetLife == 0)
             {
                 int          shipPos  = (int)manager.Game.ShipsComputer[Game.Convertir(ship)].Posicion;
                 int          shipSize = manager.Game.ShipsComputer[Game.Convertir(ship)].Size;
                 Coordenada2D coord2D  = manager.Game.ShipsComputer[Game.Convertir(ship)].Coordenada;
                 base.manager.Escena.AddGenerator(new SmokeGenerator(shipSize, shipPos, coord2D, 1));
             }
             //AudioPlayback.PlayAny("explosion.wav", "misileExplode.wav");
             // si no queda ningun barco enemigo, (gané)
             if (manager.Game.RemainingShips(Player.Computer) == 0)
             {
                 base.manager.AddText(Game.GameStrings.GetString("Victory"), Globals.ScreenWidthOver2, Sprite.SpriteFont, Color.Blue, Globals.ScreenWidthOver2);
                 base.manager.Game.Winner        = Player.Person;
                 base.manager.Game.FinishMessage = Game.GameStrings.GetString("WinMessage");
                 Game.Finished = true;
             }
         }
         else // si di en el agua
         {
             manager.Escena.AddModel(new ExplosionSquare(x, y, 0, Player.Computer));
             manager.Escena.AddModel(new ExplosionWave(x, y, Player.Computer, 0));
             manager.Game.SetCoordenada(x, y, 7, 1);
             //AudioPlayback.Play("waterexplosion.wav");
             manager.Game.CurrentPlayer = Player.Computer;
             state = 1;
             manager.AddText(Game.GameStrings.GetString("CPUTurn"), 85, Sprite.SpriteFont, Color.Red, Globals.ScreenWidthOver2);
         }
     }
     else //si es la computadora
     {
         int ship = base.manager.Game.GetCoordenada(x, y, 0);
         if (ship != 0 && ship != 7 && ship != 9)
         {
             // si me sonó la cacharra
             manager.Escena.AddModel(new ExplosionSquare(x, y, 1, 0));
             manager.Escena.AddModel(new ExplosionWave(x, y, 0, 1));
             manager.Escena.AddGenerator(new FireGenerator(new Coordenada2D(x, y), 0));
             manager.Game.SetCoordenada(x, y, 9, 0);
             manager.Game.SetHit(Player.Person, ship);
             if (manager.Game.ShipsPlayer[Game.Convertir(ship)].GetLife == 0)
             {
                 int          shipPos  = (int)manager.Game.ShipsPlayer[Game.Convertir(ship)].Posicion;
                 int          shipSize = manager.Game.ShipsPlayer[Game.Convertir(ship)].Size;
                 Coordenada2D coord2D  = manager.Game.ShipsPlayer[Game.Convertir(ship)].Coordenada;
                 base.manager.Escena.AddGenerator(new SmokeGenerator(shipSize, shipPos, coord2D, 0));
             }
             //AudioPlayback.PlayAny("explosion.wav", "misileExplode.wav");
             manager.Game.ComputerAi.LastHit(true);
             // si no me queda ningun barco, (perdí)
             if (manager.Game.RemainingShips(Player.Person) == 0)
             {
                 base.manager.AddText(Game.GameStrings.GetString("Defeat"), 220, Sprite.SpriteFont, Color.Red, Globals.ScreenWidthOver2);
                 base.manager.Game.Winner        = Player.Person;
                 base.manager.Game.FinishMessage = Game.GameStrings.GetString("LooseMessage");
                 Game.Finished = true;
             }
             else
             {
                 state = 2;
             }
         }
         else
         {
             // si se fue en blanco
             manager.Escena.AddModel(new ExplosionSquare(x, y, 0, 0));
             manager.Escena.AddModel(new ExplosionWave(x, y, 0, 0));
             manager.Game.SetCoordenada(x, y, 7, 0);
             //AudioPlayback.Play("waterexplosion.wav");
             manager.Game.ComputerAi.LastHit(false);
             manager.Game.CurrentPlayer = Player.Person;
             state = 1;
             manager.AddText(Game.GameStrings.GetString("PlayerTurn"), 85, Sprite.SpriteFont, Color.Red, Globals.ScreenWidthOver2);
         }
     }
 }