Пример #1
0
        public bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount)
        {
            BallInfo ballInfo = BallMgr.FindBall(bombId);
            Tile     shape    = BallMgr.FindTile(bombId);
            BombType ballType = BallMgr.GetBallType(bombId);

            //if (ballInfo != null && shape != null)
            if (ballInfo != null)//某些炸弹无图
            {
                GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, Id);
                pkg.Parameter1 = Id;
                pkg.WriteByte((byte)eTankCmdType.FIRE);
                pkg.WriteInt(bombCount);

                float lifeTime = 0;
                for (int i = 0; i < bombCount; i++)
                {
                    double reforce = 1;
                    int    reangle = 0;
                    if (i == 1)
                    {
                        reforce = 0.9;
                        reangle = -5;
                    }
                    else if (i == 2)
                    {
                        reforce = 1.1;
                        reangle = 5;
                    }

                    int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI));
                    int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI));
                    //Console.WriteLine(string.Format("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< vx:{0}   vy:{1}", vx, vy));

                    SimpleBomb bomb = new SimpleBomb(m_game.PhysicalId++, ballType, this, m_game, ballInfo, shape, ControlBall);

                    bomb.SetXY(x, y);
                    bomb.setSpeedXY(vx, vy);
                    m_map.AddPhysical(bomb);
                    bomb.StartMoving();
                    pkg.WriteInt(0);
                    pkg.WriteInt(0);
                    pkg.WriteBoolean(bomb.DigMap);
                    pkg.WriteInt(bomb.Id);
                    pkg.WriteInt(x);
                    pkg.WriteInt(y);
                    pkg.WriteInt(vx);
                    pkg.WriteInt(vy);

                    ////FUnny gun
                    //var random = Game.Random.Next(0, 2);
                    //switch (random)
                    //{

                    //    case 0: pkg.WriteInt(51);
                    //        break;
                    //    case 1: pkg.WriteInt(67);
                    //        break;
                    //    case 2: pkg.WriteInt(16);
                    //        break;
                    //}

                    pkg.WriteInt(bomb.BallInfo.ID);
                    //FlyingPartical
                    //pkg.WriteString(bomb.BallInfo.FlyingPartical);
                    pkg.WriteString("");
                    pkg.WriteInt(5);
                    pkg.WriteInt(5);
                    //pkg.WriteInt(0);
                    pkg.WriteInt(bomb.Actions.Count);
                    foreach (BombAction ac in bomb.Actions)
                    {
                        pkg.WriteInt((ac.TimeInt != null) ? ac.TimeInt : 0);
                        pkg.WriteInt((ac.Type != null) ? ac.Type : 0);
                        pkg.WriteInt((ac.Param1 != null) ? ac.Param1 : 0);
                        pkg.WriteInt((ac.Param2 != null) ? ac.Param2 : 0);
                        pkg.WriteInt((ac.Param3 != null) ? ac.Param3 : 0);
                        pkg.WriteInt((ac.Param3 != null) ? ac.Param4 : 0);
                    }

                    lifeTime = Math.Max(lifeTime, bomb.LifeTime);
                }
                //TrieuLSL
                //pkg.WriteInt(new Random().Next(50)); pkg.WriteInt(new Random().Next(50));
                m_game.SendToAll(pkg);

                //客户端有爆炸效果,多等待2秒

                m_game.WaitTime((int)((lifeTime + 2 + bombCount / 3) * 1000));

                return(true);
            }

            return(false);
        }
Пример #2
0
        public bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount, int shootCount)
        {
            BallInfo ballInfo = BallMgr.FindBall(bombId);
            Tile     shape    = BallMgr.FindTile(bombId);
            BombType ballType = BallMgr.GetBallType(bombId);
            int      _wind    = (int)(m_map.wind * 10);

            if (ballInfo != null)//某些炸弹无图
            {
                GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, Id);
                pkg.Parameter1 = Id;
                pkg.WriteByte((byte)eTankCmdType.FIRE);

                pkg.WriteInt(_wind);
                pkg.WriteBoolean(_wind > 0);
                pkg.WriteByte(m_game.GetVane(_wind, 1));
                pkg.WriteByte(m_game.GetVane(_wind, 2));
                pkg.WriteByte(m_game.GetVane(_wind, 3));
                pkg.WriteInt(bombCount);

                float lifeTime = 0;
                for (int i = 0; i < bombCount; i++)
                {
                    double reforce = 1;
                    int    reangle = 0;
                    if (i == 1)
                    {
                        reforce = 0.9;
                        reangle = -5;
                    }
                    else if (i == 2)
                    {
                        reforce = 1.1;
                        reangle = 5;
                    }

                    int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI));
                    int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI));

                    SimpleBomb bomb = new SimpleBomb(m_game.PhysicalId++, ballType, this, m_game, ballInfo, shape, ControlBall);

                    bomb.SetXY(x, y);
                    bomb.setSpeedXY(vx, vy);
                    m_map.AddPhysical(bomb);
                    bomb.StartMoving();

                    pkg.WriteInt(1); //number = _loc_2.readInt();
                    pkg.WriteInt(1); //shootCount = _loc_2.readInt();
                    pkg.WriteBoolean(bomb.DigMap);
                    pkg.WriteInt(bomb.Id);
                    pkg.WriteInt(x);
                    pkg.WriteInt(y);
                    pkg.WriteInt(vx);
                    pkg.WriteInt(vy);
                    pkg.WriteInt(bomb.BallInfo.ID);
                    pkg.WriteString(bomb.BallInfo.FlyingPartical);
                    pkg.WriteInt((bomb.BallInfo.Radii * 1000) / 4); //trminhpc
                    pkg.WriteInt((int)bomb.BallInfo.Power * 1000);  //trminhpc
                    pkg.WriteInt(bomb.Actions.Count);
                    foreach (BombAction ac in bomb.Actions)
                    {
                        pkg.WriteInt(ac.TimeInt);
                        pkg.WriteInt(ac.Type);
                        pkg.WriteInt(ac.Param1);
                        pkg.WriteInt(ac.Param2);
                        pkg.WriteInt(ac.Param3);
                        pkg.WriteInt(ac.Param4);
                    }

                    lifeTime = Math.Max(lifeTime, bomb.LifeTime);
                }
                //pet Attack

                pkg.WriteInt(0);
                //foreach (BombAction ac in bombPet.Actions)
                //{
                pkg.WriteInt(1);    //_loc_27 = _loc_2.readInt();//target
                pkg.WriteInt(300);  //_loc_29 = _loc_2.readInt//damage
                pkg.WriteInt(500);  //_loc_30 = _loc_2.readInt();//hp
                pkg.WriteInt(10);   //_loc_31 = _loc_2.readInt();//dander

                //}

                pkg.WriteInt(102);//_loc_2.readInt();//attackid

                m_game.SendToAll(pkg);
                m_game.WaitTime((int)((lifeTime + 2 + bombCount / 3) * 1000));

                return(true);
            }

            return(false);
        }
Пример #3
0
        public bool HandleCommand(TankGameLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            if (player.CurrentGame.Data.CurrentIndex == player && player.CurrentGame.Data.Players[player].State != TankGameState.DEAD)
            {
                if (player.CurrentGame.Data.CurrentFire == null)
                {
                    player.CurrentGame.Data.CurrentFire = player;
                }

                int x = packet.ReadInt();
                int y = packet.ReadInt();

                if (Math.Abs(player.CurrentGame.Data.Players[player].X - x) > 100)
                {
                    //player.Out.SendMessage(eMessageType.ALERT, LanguageMgr.GetTranslation("Game.Server.SceneGames.TankHandle"));
                    StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName,
                                           ItemRemoveType.FireError, player.CurrentGame.Data.Players[player].X.ToString() + " to " + x.ToString() + ",MapID:" + player.CurrentGame.Data.MapIndex);
                    player.Client.Disconnect();
                    return(false);;
                }

                int force = packet.ReadInt();
                int angle = packet.ReadInt();

                TankData   data  = player.CurrentGame.Data;
                Tile       shape = Managers.BallMgr.FindTile(data.CurrentBall.ID);
                GSPacketIn pkg   = new GSPacketIn((byte)ePackageType.GAME_CMD, player.PlayerCharacter.ID);
                pkg.WriteByte((byte)TankCmdType.FIRE);
                pkg.WriteInt(data.AddBall);
                for (int i = 0; i < data.AddBall; i++)
                {
                    if (player.CurrentGame.Data.ReduceFireBombs)
                    {
                        if (data.IsFastSpeed())
                        {
                            StatMgr.LogErrorPlayer(player.PlayerCharacter.ID, player.PlayerCharacter.UserName, player.PlayerCharacter.NickName,
                                                   ItemRemoveType.FastError, "MapID:" + player.CurrentGame.Data.MapIndex);
                            player.Client.Disconnect();
                            return(false);;
                        }

                        data.FireLogin = true;
                        double reforce = 1;
                        int    reangle = 0;
                        if (i == 1)
                        {
                            reforce = 0.9;
                            reangle = -5;
                        }
                        else if (i == 2)
                        {
                            reforce = 1.1;
                            reangle = 5;
                        }

                        int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI));
                        int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI));

                        data.PhyID++;

                        BombObject bomb = new BombObject(data.PhyID, BallMgr.GetBallType(data.CurrentBall.ID), data.Players[player], shape, data.CurrentBall.Radii, data.AddMultiple < 1,
                                                         data.CurrentBall.Mass, data.CurrentBall.Weight, data.CurrentBall.Wind, data.CurrentBall.DragIndex, data.BallPower);

                        bomb.SetXY(x, y);
                        bomb.setSpeedXY(vx, vy);
                        data.CurrentMap.AddPhysical(bomb);
                        pkg.WriteBoolean(bomb.IsHole);
                        pkg.WriteInt(bomb.Id);
                        pkg.WriteInt(x);
                        pkg.WriteInt(y);
                        pkg.WriteInt(vx);
                        pkg.WriteInt(vy);
                        pkg.WriteInt(bomb.Actions.Count);
                        foreach (BombAction action in bomb.Actions)
                        {
                            pkg.WriteInt(action.TimeInt);
                            pkg.WriteInt(action.Type);
                            pkg.WriteInt(action.Param1);
                            pkg.WriteInt(action.Param2);
                            pkg.WriteInt(action.Param3);
                            pkg.WriteInt(action.Param4);
                        }

                        data.SetRunTime((int)bomb.RunTime);
                    }
                }

                player.CurrentGame.SendToAll(pkg);

                data.FireLogin = false;
                if (data.Bombs || data.Players[player].State == TankGameState.DEAD)
                {
                    data.TotalDelay += data.CurrentBall.Delay;
                    process.SendArk(player.CurrentGame, player);
                    player.PropInventory.AddItemTemplate(PropItemMgr.GetRandomFightProp(data.MapIndex));
                    data.Players[player].SetDander(20);

                    process.SendPlayFinish(player.CurrentGame, player);
                    //GSPacketIn pkgMsg = new GSPacketIn((byte)ePackageType.GAME_CMD);
                    //pkgMsg.WriteByte((byte)TankCmdType.PLAYFINISH);
                    //pkgMsg.WriteInt(player.CurrentGame.Data.TurnNum);
                    //player.CurrentGame.SendToAll(pkgMsg);
                }
                return(true);
            }
            return(false);
        }
Пример #4
0
        public bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount, int shootCount)
        {
            BallInfo ballInfo = BallMgr.FindBall(bombId);
            Tile     shape    = BallMgr.FindTile(bombId);
            BombType ballType = BallMgr.GetBallType(bombId);
            int      num      = (int)(this.m_map.wind * 10f);

            if (ballInfo != null)
            {
                GSPacketIn gSPacketIn = new GSPacketIn(91, base.Id);
                gSPacketIn.Parameter1 = base.Id;
                gSPacketIn.WriteByte(2);
                gSPacketIn.WriteInt(num);
                gSPacketIn.WriteBoolean(num > 0);
                gSPacketIn.WriteByte(this.m_game.GetVane(num, 1));
                gSPacketIn.WriteByte(this.m_game.GetVane(num, 2));
                gSPacketIn.WriteByte(this.m_game.GetVane(num, 3));
                gSPacketIn.WriteInt(bombCount);
                float      num2       = 0f;
                SimpleBomb simpleBomb = null;
                for (int i = 0; i < bombCount; i++)
                {
                    double num3 = 1.0;
                    int    num4 = 0;
                    if (i == 1)
                    {
                        num3 = 0.9;
                        num4 = -5;
                    }
                    else
                    {
                        if (i == 2)
                        {
                            num3 = 1.1;
                            num4 = 5;
                        }
                    }
                    int num5 = (int)((double)force * num3 * Math.Cos((double)(angle + num4) / 180.0 * 3.1415926535897931));
                    int num6 = (int)((double)force * num3 * Math.Sin((double)(angle + num4) / 180.0 * 3.1415926535897931));
                    simpleBomb = new SimpleBomb(this.m_game.PhysicalId++, ballType, this, this.m_game, ballInfo, shape, this.ControlBall);
                    simpleBomb.SetXY(x, y);
                    simpleBomb.setSpeedXY(num5, num6);
                    this.m_map.AddPhysical(simpleBomb);
                    simpleBomb.StartMoving();
                    gSPacketIn.WriteInt(0);
                    gSPacketIn.WriteInt(0);
                    gSPacketIn.WriteBoolean(simpleBomb.DigMap);
                    gSPacketIn.WriteInt(simpleBomb.Id);
                    gSPacketIn.WriteInt(x);
                    gSPacketIn.WriteInt(y);
                    gSPacketIn.WriteInt(num5);
                    gSPacketIn.WriteInt(num6);
                    gSPacketIn.WriteInt(simpleBomb.BallInfo.ID);
                    gSPacketIn.WriteString(simpleBomb.BallInfo.FlyingPartical);
                    gSPacketIn.WriteInt(simpleBomb.BallInfo.Radii * 1000 / 4);
                    gSPacketIn.WriteInt((int)simpleBomb.BallInfo.Power * 1000);
                    gSPacketIn.WriteInt(simpleBomb.Actions.Count);
                    foreach (BombAction current in simpleBomb.Actions)
                    {
                        gSPacketIn.WriteInt(current.TimeInt);
                        gSPacketIn.WriteInt(current.Type);
                        gSPacketIn.WriteInt(current.Param1);
                        gSPacketIn.WriteInt(current.Param2);
                        gSPacketIn.WriteInt(current.Param3);
                        gSPacketIn.WriteInt(current.Param4);
                    }
                    num2 = Math.Max(num2, simpleBomb.LifeTime);
                }
                int num7  = 0;
                int count = simpleBomb.PetActions.Count;
                if (count > 0 && this.PetBaseAtt > 0)
                {
                    gSPacketIn.WriteInt(count);
                    foreach (BombAction current2 in simpleBomb.PetActions)
                    {
                        gSPacketIn.WriteInt(current2.Param1);
                        gSPacketIn.WriteInt(current2.Param2);
                        gSPacketIn.WriteInt(current2.Param4);
                        gSPacketIn.WriteInt(current2.Param3);
                    }
                    gSPacketIn.WriteInt(1);
                    num7 = 2;
                }
                else
                {
                    gSPacketIn.WriteInt(0);
                    gSPacketIn.WriteInt(0);
                }
                this.m_game.SendToAll(gSPacketIn);
                this.m_game.WaitTime((int)((num2 + 2f + (float)num7 + (float)(bombCount / 3)) * 1000f));
                return(true);
            }
            return(false);
        }
Пример #5
0
        public bool ShootImp(int bombId, int x, int y, int force, int angle, int bombCount)
        {
            BallInfo ballInfo = BallMgr.FindBall(bombId);
            Tile     shape    = BallMgr.FindTile(bombId);
            BombType ballType = BallMgr.GetBallType(bombId);
            bool     result;

            if (ballInfo != null)
            {
                GSPacketIn pkg = new GSPacketIn(91);
                pkg.Parameter1 = base.Id;
                pkg.WriteByte(2);
                pkg.WriteInt(bombCount);
                float lifeTime = 0f;
                for (int i = 0; i < bombCount; i++)
                {
                    double reforce = 1.0;
                    int    reangle = 0;
                    if (i == 1)
                    {
                        reforce = 0.9;
                        reangle = -5;
                    }
                    else
                    {
                        if (i == 2)
                        {
                            reforce = 1.1;
                            reangle = 5;
                        }
                    }
                    int        vx   = (int)((double)force * reforce * Math.Cos((double)(angle + reangle) / 180.0 * 3.1415926535897931));
                    int        vy   = (int)((double)force * reforce * Math.Sin((double)(angle + reangle) / 180.0 * 3.1415926535897931));
                    SimpleBomb bomb = new SimpleBomb(this.m_game.physicalId++, ballType, this, this.m_game, ballInfo, shape, this.ControlBall || this.GemControlBall);
                    bomb.SetXY(x, y);
                    bomb.setSpeedXY(vx, vy);
                    this.m_map.AddPhysical(bomb);
                    bomb.StartMoving();
                    pkg.WriteBoolean(bomb.DigMap);
                    pkg.WriteInt(bomb.Id);
                    pkg.WriteInt(x);
                    pkg.WriteInt(y);
                    pkg.WriteInt(vx);
                    pkg.WriteInt(vy);
                    pkg.WriteInt(bomb.BallInfo.ID);
                    if (this.FlyingPartical != 0)
                    {
                        pkg.WriteString(this.FlyingPartical.ToString());
                    }
                    else
                    {
                        pkg.WriteString(ballInfo.FlyingPartical);
                    }
                    pkg.WriteInt(bomb.Actions.Count);
                    foreach (BombAction ac in bomb.Actions)
                    {
                        pkg.WriteInt(ac.TimeInt);
                        pkg.WriteInt(ac.Type);
                        pkg.WriteInt(ac.Param1);
                        pkg.WriteInt(ac.Param2);
                        pkg.WriteInt(ac.Param3);
                        pkg.WriteInt(ac.Param4);
                    }
                    lifeTime = Math.Max(lifeTime, bomb.LifeTime);
                }
                this.m_game.SendToAll(pkg);
                this.m_game.WaitTime((int)((lifeTime + 2f + (float)(bombCount / 3)) * 1000f));
                result = true;
            }
            else
            {
                Living.log.Error(string.Format("Living ShootImpl ballInfo is null. bombId : {0}", bombId));
                result = false;
            }
            return(result);
        }
Пример #6
0
        public void Shoot(int x, int y, int force, int angle)
        {
            if (m_shootCount > 0)
            {
                m_shootCount--;

                GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_CMD, Id);

                pkg.WriteByte((byte)TankCmdType.FIRE);
                pkg.WriteInt(BallCount);

                Tile     shape    = BallMgr.FindTile(m_currentBall.ID);
                BombType ballType = BallMgr.GetBallType(m_currentBall.ID);

                float lifeTime = 0;
                for (int i = 0; i < BallCount; i++)
                {
                    double reforce = 1;
                    int    reangle = 0;
                    if (i == 1)
                    {
                        reforce = 0.9;
                        reangle = -5;
                    }
                    else if (i == 2)
                    {
                        reforce = 1.1;
                        reangle = 5;
                    }

                    int vx = (int)(force * reforce * Math.Cos((double)(angle + reangle) / 180 * Math.PI));
                    int vy = (int)(force * reforce * Math.Sin((double)(angle + reangle) / 180 * Math.PI));

                    SimpleBomb bomb = new SimpleBomb(m_game.PhysicalId++, ballType, this, m_game, m_currentBall, shape, ControlBall);

                    bomb.SetXY(x, y);
                    bomb.setSpeedXY(vx, vy);
                    m_game.Map.AddPhysical(bomb);
                    bomb.StartMoving();

                    pkg.WriteInt(bomb.Id);
                    pkg.WriteInt(x);
                    pkg.WriteInt(y);
                    pkg.WriteInt(vx);
                    pkg.WriteInt(vy);
                    pkg.WriteInt(bomb.Actions.Count);
                    foreach (BombAction action in bomb.Actions)
                    {
                        pkg.WriteInt(action.TimeInt);
                        pkg.WriteInt(action.Type);
                        pkg.WriteInt(action.Param1);
                        pkg.WriteInt(action.Param2);
                        pkg.WriteInt(action.Param3);
                        pkg.WriteInt(action.Param4);
                    }

                    lifeTime = Math.Max(lifeTime, bomb.LifeTime);
                }

                m_game.SendToAll(pkg);

                if (m_shootCount <= 0 || IsLiving == false)
                {
                    StopAttacking();

                    AddDelay(m_currentBall.Delay);
                    AddDander(20, true);

                    m_game.WaitTime((int)(lifeTime * 1000));
                }
            }
        }