Esempio n. 1
0
        public bool CheckShootPoint(int x, int y)
        {
            if (Math.Abs(X - x) > 100)
            {
                string username = m_player.PlayerCharacter.UserName;
                string nickname = m_player.PlayerCharacter.NickName;

                StatMgr.LogErrorPlayer(Id, username, nickname, ItemRemoveType.FireError, string.Format("error shoot pos: {0} -> {1} mapId:{2}", X, x, m_game.Map.Info.ID));
                m_player.Client.Disconnect();
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public override void SetXY(int x, int y)
        {
            if (m_x == x && m_y == y)
            {
                return;
            }

            m_x = x;
            m_y = y;

            if (IsLiving)
            {
                m_energy -= Math.Abs(m_x - x);
                if (m_energy < -20)
                {
                    StatMgr.LogErrorPlayer(m_player.PlayerCharacter.ID, m_player.PlayerCharacter.UserName, m_player.PlayerCharacter.NickName, ItemRemoveType.MoveError, m_x.ToString() + " to " + x.ToString() + ",MapID:" + m_map.Info.ID);
                    GameServer.log.Error("move is error,player state: move energy:" + m_energy);
                }
            }
            else
            {
                Rectangle rect = m_rect;
                rect.Offset(m_x, m_y);

                Physics[] phys = m_map.FindPhysicalObjects(rect, this);
                foreach (Physics p in phys)
                {
                    if (p is Box)
                    {
                        Box b = p as Box;
                        PickBox(b, true);
                        //立刻开箱子给客户端
                        OpenBox(b.Id);
                    }
                }
            }
        }
Esempio n. 3
0
        public override void SetXY(int x, int y)
        {
            if (state != TankGameState.DEAD)
            {
                _energy -= Math.Abs(_x - x);
            }
            //else
            //{
            //    _energy -= (int)Math.Sqrt(((_x - x) * (_x - x) + (_y - y) * (_y - y)));
            //}

            if (_energy < -20)
            {
                StatMgr.LogErrorPlayer(_player.PlayerCharacter.ID, _player.PlayerCharacter.UserName, _player.PlayerCharacter.NickName,
                                       ItemRemoveType.MoveError, _x.ToString() + " to " + x.ToString() + ",MapID:" + _player.CurrentGame.Data.MapIndex);

                GameServer.log.Error("move is error,player state:" + state.ToString() + "  move energy:" + _energy);
                _player.Client.Disconnect();
            }

            _x = x;
            _y = y;
            //StartMoving();
        }
Esempio n. 4
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);
        }