Пример #1
0
        public void ShootCar(int IdCar)
        {
            Vector3 PosCar, PosBall;
            PosCar = CarObjPhy[IdCar].PhysicsWorldTransform.Translation;
            PosBall = new Vector3(PosCar.X, PosCar.Y, PosCar.Z + 4);
            //Call Function for Bullets
            GameLogic.SoundGame.Laser1.Play();
            GameLogic.SoundGame.Laser1.Volume = 0.5f;

            if (GameLogic.Players[IdCar].PlayerBullets.Count < GameLogic.MAX_NUM_BULLET)
            {
                Bullet Bala = new Bullet(PosBall, Manager3D.BulletModel, Manager3D.BulletrMat, CarObjPhy[IdCar].PhysicsWorldTransform.Left, groundMarkerNode);
                GameLogic.Players[IdCar].PlayerBullets.Add(Bala);
            }
            else
            {
                int Index = Bullet.SearchBall(GameLogic.Players[IdCar].PlayerBullets);
                if (Index > -1)
                {
                    //Adicciono Bala
                    GameLogic.Players[IdCar].PlayerBullets[Index].ReAddBullet(PosBall, CarObjPhy[IdCar].PhysicsWorldTransform.Left);
                }
            }
        }
Пример #2
0
        private void ControlCarCall(CmdNetwork Cmmd, int IdPlayer, Vector3 DirCar, bool[] Buttons)
        {
            //Control del carro
            switch(Cmmd)
            {
                case CmdNetwork.ADD_PLY:
                    if(GameLogic.CurrentGameState != Game_Logic.Game_States.PLAY)
                        GameLogic.AddPlayer("Player" + IdPlayer.ToString(), IdPlayer);
                    break;
                case CmdNetwork.RM_PLY:
                    GameLogic.RmPlayer(IdPlayer);
                    break;
                case CmdNetwork.DATA_ACEL:

                    if (GameLogic.StateScreen == Game_Logic.Game_SCR.RUNNING)
                    {
                        switch (GameLogic.CurrentGameState)
                        {
                            case Game_Logic.Game_States.PLAY:
                                // Control the car steering with right and left arrow keys
                                if ((DirCar.Y > 20) && (DirCar.Y < 35))
                                    CarObjPhy[IdPlayer].SetSteering(-0.2f);
                                if ((DirCar.Y > 35) && (DirCar.Y < 55))
                                    CarObjPhy[IdPlayer].SetSteering(-0.3f);
                                if (DirCar.Y > 55)
                                    CarObjPhy[IdPlayer].SetSteering(-0.4f);
                                if ((DirCar.Y < -20) && (DirCar.Y > -35))
                                    CarObjPhy[IdPlayer].SetSteering(0.2f);
                                if ((DirCar.Y < -35) && (DirCar.Y > -55))
                                    CarObjPhy[IdPlayer].SetSteering(0.3f);
                                if (DirCar.Y < -55)
                                    CarObjPhy[IdPlayer].SetSteering(0.4f);
                                if ((DirCar.Y < 20) && (DirCar.Y > -20))
                                    CarObjPhy[IdPlayer].SetSteering(0);

                                // Control the car's forward torque with up and down arrow keys
                                //if (DirCar.X < -15)
                                //    CarObjPhy[IdPlayer].SetTireTorque(1);
                                //else if (DirCar.X > 15)
                                //    CarObjPhy[IdPlayer].SetTireTorque(-5);
                                //else
                                //    CarObjPhy[IdPlayer].SetTireTorque(0);
                                
                                CarObjPhy[IdPlayer].SetTireTorque(0);
                                CarObjPhy[IdPlayer].ApplyHandBrakes(0);
                                if (Buttons[0])//Disparo
                                {
                                    Vector3 PosCar, PosBall;
                                    PosCar = CarObjPhy[IdPlayer].PhysicsWorldTransform.Translation;
                                    PosBall = new Vector3(PosCar.X, PosCar.Y, PosCar.Z + 4);
                                    //Call Function for Bullets
                                    GameLogic.SoundGame.Laser1.Play();
                                    GameLogic.SoundGame.Laser1.Volume = 0.5f;
                                    //Manager3D.CreateShootBullet(PosBall, CarObjPhy[0].PhysicsWorldTransform.Left, Color.Blue);

                                    if (GameLogic.Players[IdPlayer].PlayerBullets.Count < GameLogic.MAX_NUM_BULLET)
                                    {
                                        Bullet Bala = new Bullet(PosBall, Manager3D.BulletModel, Manager3D.BulletrMat, CarObjPhy[IdPlayer].PhysicsWorldTransform.Left, groundMarkerNode);
                                        GameLogic.Players[IdPlayer].PlayerBullets.Add(Bala);
                                    }
                                    else
                                    {
                                        int Index = Bullet.SearchBall(GameLogic.Players[IdPlayer].PlayerBullets);
                                        if (Index > -1)
                                        {
                                            //Adicciono Bala
                                            GameLogic.Players[IdPlayer].PlayerBullets[Index].ReAddBullet(PosBall, CarObjPhy[IdPlayer].PhysicsWorldTransform.Left);
                                        }
                                    }
                                }
                                
                                if (Buttons[1])//Gas
                                    CarObjPhy[IdPlayer].SetTireTorque(1);
                                if(Buttons[2])//Freno
                                {
                                    if(DirCar.X < -15)
                                        CarObjPhy[IdPlayer].SetTireTorque(-5); //Reversa
                                    else
                                        CarObjPhy[IdPlayer].ApplyHandBrakes(25);
                                }
                                
                                break;
                            case Game_Logic.Game_States.SEL_PLY:
                                ValidatemenuAcel(DirCar, IdPlayer, Buttons);
                                break;
                        }
                    }
                    break;
            }
        }
Пример #3
0
        public bool Dispara()
        {
            if (CountOfBullets < NumBullets)
            {
                if (CountToShoot < WaitBullet) //Wait for Reload Time in Frames/seg
                {
                    CountToShoot++;
                    return false;
                }

                float X, Y;

                X = Convert.ToSingle(Math.Cos(RadActAngle + RadOffset));
                Y = Convert.ToSingle(Math.Sin(RadActAngle + RadOffset));

                Vector3 DirBullet = new Vector3(X, Y, 0.0f);

                //Restart Counts
                CountToShoot = 0;

                //Increment Bullet Count
                CountOfBullets++;

                //Search if there are Free Bullets Slots
                if (WBullets.Count < Game_Logic.MAX_BULLET)
                {
                    Bullet Bala = new Bullet(ActPos + BulletOffset, BulletModel, BulletMat, DirBullet, GMarkerNode);
                    WBullets.Add(Bala);
                }
                else
                {
                    int Index = Bullet.SearchBall(WBullets);
                    if (Index > -1)
                    {
                        //Adicciono Bala
                        WBullets[Index].ReAddBullet(ActPos + BulletOffset, DirBullet);
                    }
                }

                return true;
            }
            else
            {
                if (CountToReload < ReloadTime) //Wait for Reload Time in Frames/seg
                    CountToReload++;
                else
                {
                    CountToReload = 0;
                    CountOfBullets = 0;
                }

                return false;
            }
        }