• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Infiniminer.Player类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Infiniminer.Player的典型用法代码示例。如果您正苦于以下问题:C# Player类的具体用法?C# Player怎么用?C# Player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Player类属于Infiniminer命名空间,在下文中一共展示了Player类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

        public bool Start()
        {
            //Setup the variable toggles
            varBindingsInitialize();
            int tmpMaxPlayers = 16;

            // Read in from the config file.
            DatafileWriter dataFile = new DatafileWriter("server.config.txt");
            if (dataFile.Data.ContainsKey("winningcash"))
                winningCashAmount = uint.Parse(dataFile.Data["winningcash"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("includelava"))
                includeLava = bool.Parse(dataFile.Data["includelava"]);
            if (dataFile.Data.ContainsKey("includewater"))
                includeLava = bool.Parse(dataFile.Data["includewater"]);
            if (dataFile.Data.ContainsKey("orefactor"))
                oreFactor = uint.Parse(dataFile.Data["orefactor"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("maxplayers"))
                tmpMaxPlayers = (int)Math.Min(32, uint.Parse(dataFile.Data["maxplayers"], System.Globalization.CultureInfo.InvariantCulture));
            if (dataFile.Data.ContainsKey("public"))
                varSet("public", bool.Parse(dataFile.Data["public"]), true);
            if (dataFile.Data.ContainsKey("servername"))
                varSet("name", dataFile.Data["servername"], true);
            if (dataFile.Data.ContainsKey("sandbox"))
                varSet("sandbox", bool.Parse(dataFile.Data["sandbox"]), true);
            if (dataFile.Data.ContainsKey("notnt"))
                varSet("tnt", !bool.Parse(dataFile.Data["notnt"]), true);
            if (dataFile.Data.ContainsKey("sphericaltnt"))
                varSet("stnt", bool.Parse(dataFile.Data["sphericaltnt"]), true);
            if (dataFile.Data.ContainsKey("insane"))
                varSet("insane", bool.Parse(dataFile.Data["insane"]), true);
            if (dataFile.Data.ContainsKey("roadabsorbs"))
                varSet("roadabsorbs", bool.Parse(dataFile.Data["roadabsorbs"]), true);
            if (dataFile.Data.ContainsKey("minelava"))
                varSet("minelava", bool.Parse(dataFile.Data["minelava"]), true);
            if (dataFile.Data.ContainsKey("levelname"))
                levelToLoad = dataFile.Data["levelname"];
            if (dataFile.Data.ContainsKey("greeter"))
                varSet("greeter", dataFile.Data["greeter"],true);

            bool autoannounce = true;
            if (dataFile.Data.ContainsKey("autoannounce"))
                autoannounce = bool.Parse(dataFile.Data["autoannounce"]);

            // Load the ban-list.
            banList = LoadBanList();

            // Load the admin-list
            admins = LoadAdminList();

            if (tmpMaxPlayers>=0)
                varSet("maxplayers", tmpMaxPlayers, true);

            // Initialize the server.
            NetConfiguration netConfig = new NetConfiguration("InfiniminerPlus");
            netConfig.MaxConnections = (int)varGetI("maxplayers");
            netConfig.Port = 5565;
            netServer = new InfiniminerNetServer(netConfig);
            netServer.SetMessageTypeEnabled(NetMessageType.ConnectionApproval, true);

            //netServer.SimulatedMinimumLatency = 0.5f;
               // netServer.SimulatedLatencyVariance = 0.05f;
               // netServer.SimulatedLoss = 0.2f;
               // netServer.SimulatedDuplicates = 0.05f;
            //netServer.Configuration.SendBufferSize = 2048000;
            //netServer.Start();//starts too early
            // Initialize variables we'll use.
            NetBuffer msgBuffer = netServer.CreateBuffer();
            NetMessageType msgType;
            NetConnection msgSender;

            // Store the last time that we did a flow calculation.
            DateTime lastFlowCalc = DateTime.Now;
            DateTime lastFlowCalcZ = DateTime.Now;//temporary
            DateTime sysTimer = DateTime.Now;
            //Check if we should autoload a level
            if (dataFile.Data.ContainsKey("autoload") && bool.Parse(dataFile.Data["autoload"]))
            {
                blockList = new BlockType[MAPSIZE, MAPSIZE, MAPSIZE];
                blockCreatorTeam = new PlayerTeam[MAPSIZE, MAPSIZE, MAPSIZE];
                LoadLevel(levelToLoad);

                lavaBlockCount = 0;
                waterBlockCount = 0;
                int burstBlockCount = 0;

                for (ushort i = 0; i < MAPSIZE; i++)
                    for (ushort j = 0; j < MAPSIZE; j++)
                        for (ushort k = 0; k < MAPSIZE; k++)
                        {
                            if (blockList[i, j, k] == BlockType.Lava)
                            {
                                lavaBlockCount += 1;
                            }
                            else if (blockList[i, j, k] == BlockType.Water)
                            {
                                waterBlockCount += 1;
                            }
                            else if (blockList[i, j, k] == BlockType.MagmaBurst)
                            {
                                burstBlockCount += 1;
//.........这里部分代码省略.........
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例2: CheckSpeed

        /***************
        // Start of mods for detecting client mods
        ***************/
        // Checks the players speed over last 10 updates and trys to figure out if they are above expected speed - DCaudill
        public bool CheckSpeed(Player player)
        {
            // Calculate expected max avg distance
            double maxDistance = 0;
            for (int i = 0; i < player.positionList.Count; i++)
            {
                Vector3 footPosition = player.positionList[i].position + new Vector3(0f, -1.5f, 0f);
                BlockType standingOnBlock = BlockAtPoint(new Vector3(footPosition.X, footPosition.Y, footPosition.Z));

                if (standingOnBlock == BlockType.Road)
                    maxDistance += .5;
                else
                    maxDistance += .3;
            }
            maxDistance = maxDistance / player.positionList.Count;

            // Calculate the players avg distance
            double distance = 0;
            bool oddDistance = false;
            for (int i = 0; i < player.positionList.Count; i++)
            {
                if (player.positionList[i].distanceFromLast > .3 && !oddDistance)
                {
                    oddDistance = true;
                    continue;
                }

                distance += player.positionList[i].distanceFromLast;
            }

            distance = distance / player.positionList.Count;

            if (distance > maxDistance)
                return true;
            else
                return false;
        }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:41,代码来源:InfiniminerServer.cs


示例3: DepositCash

        public void DepositCash(Player player)
        {
            if (player.Cash <= 0)
                return;

            player.Score += player.Cash;

            if (!varGetB("sandbox"))
            {
                if (player.Team == PlayerTeam.Red)
                    teamCashRed += player.Cash;
                else
                    teamCashBlue += player.Cash;
                SendServerMessage("SERVER: " + player.Handle + " HAS EARNED $" + player.Cash + " FOR THE " + GetTeamName(player.Team) + " TEAM!");
            }

            PlaySound(InfiniminerSound.CashDeposit, player.Position);
            ConsoleWrite("DEPOSIT_CASH: " + player.Handle + ", " + player.Cash);

            player.Cash = 0;
            player.Weight = 0;

            foreach (Player p in playerList.Values)
                SendResourceUpdate(p);
        }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:25,代码来源:InfiniminerServer.cs


示例4: UseDeconstructionGun

        public void UseDeconstructionGun(Player player, Vector3 playerPosition, Vector3 playerHeading)
        {
            bool actionFailed = false;

            // If there's no surface within range, bail.
            Vector3 hitPoint = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;
            if (!RayCollision(playerPosition, playerHeading, 6, 25, ref hitPoint, ref buildPoint))
                actionFailed = true;
            ushort x = (ushort)hitPoint.X;
            ushort y = (ushort)hitPoint.Y;
            ushort z = (ushort)hitPoint.Z;

            // If this is another team's block, bail.
            if (blockCreatorTeam[x, y, z] != player.Team)
                actionFailed = true;

            BlockType blockType = blockList[x, y, z];
            if (!(blockType == BlockType.SolidBlue ||
                blockType == BlockType.SolidRed ||
                blockType == BlockType.BankBlue ||
                blockType == BlockType.BankRed ||
                blockType == BlockType.Jump ||
                blockType == BlockType.Ladder ||
                blockType == BlockType.Road ||
                blockType == BlockType.Shock ||
                blockType == BlockType.BeaconRed ||
                blockType == BlockType.BeaconBlue ||
                blockType == BlockType.TransBlue ||
                blockType == BlockType.TransRed))
                actionFailed = true;

            if (actionFailed)
            {
                // Decharge the player's gun.
                TriggerConstructionGunAnimation(player, -0.2f);
            }
            else
            {
                // Fire the player's gun.
                TriggerConstructionGunAnimation(player, 0.5f);

                // Remove the block.
                SetBlock(x, y, z, BlockType.None, PlayerTeam.None);
                PlaySound(InfiniminerSound.ConstructionGun, player.Position);
            }
        }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:47,代码来源:InfiniminerServer.cs


示例5: UsePickaxe

        public void UsePickaxe(Player player, Vector3 playerPosition, Vector3 playerHeading)
        {
            player.QueueAnimationBreak = true;

            // Figure out what we're hitting.
            Vector3 hitPoint = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;
            if (!RayCollision(playerPosition, playerHeading, 2, 10, ref hitPoint, ref buildPoint))
                return;
            ushort x = (ushort)hitPoint.X;
            ushort y = (ushort)hitPoint.Y;
            ushort z = (ushort)hitPoint.Z;

            // Figure out what the result is.
            bool removeBlock = false;
            uint giveOre = 0;
            uint giveCash = 0;
            uint giveWeight = 0;
            InfiniminerSound sound = InfiniminerSound.DigDirt;

            switch (BlockAtPoint(hitPoint))
            {
                case BlockType.Lava:
                    if (varGetB("minelava"))
                    {
                        removeBlock = true;
                        sound = InfiniminerSound.DigDirt;
                    }
                    break;
                case BlockType.Dirt:
                case BlockType.DirtSign:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;

                case BlockType.Ore:
                    removeBlock = true;
                    giveOre = 20;
                    sound = InfiniminerSound.DigMetal;
                    break;

                case BlockType.Gold:
                    removeBlock = true;
                    giveWeight = 1;
                    giveCash = 100;
                    sound = InfiniminerSound.DigMetal;
                    break;

                case BlockType.Diamond:
                    removeBlock = true;
                    giveWeight = 1;
                    giveCash = 1000;
                    sound = InfiniminerSound.DigMetal;
                    break;
            }

            if (giveOre > 0)
            {
                if (player.Ore < player.OreMax)
                {
                    player.Ore = Math.Min(player.Ore + giveOre, player.OreMax);
                    SendResourceUpdate(player);
                }
            }

            if (giveWeight > 0)
            {
                if (player.Weight < player.WeightMax)
                {
                    player.Weight = Math.Min(player.Weight + giveWeight, player.WeightMax);
                    player.Cash += giveCash;
                    SendResourceUpdate(player);
                }
                else
                    removeBlock = false;
            }

            if (removeBlock)
            {
                SetBlock(x, y, z, BlockType.None, PlayerTeam.None);
                PlaySound(sound, player.Position);
            }
        }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:83,代码来源:InfiniminerServer.cs


示例6: CheckNoClipping

 // Checks to see if the player has 4 consecutive no clipping flags - DCaudill
 public bool CheckNoClipping(Player player)
 {
     int counter = 0;
     for (int i = 0; i < player.positionList.Count; i++)
     {
         if (BlockAtPoint(player.positionList[i].position) != BlockType.None &&
         BlockAtPoint(player.positionList[i].position) != BlockType.TransBlue &&
         BlockAtPoint(player.positionList[i].position) != BlockType.TransRed &&
         BlockAtPoint(player.positionList[i].position) != BlockType.Lava)
         {
             counter++;
             if (counter > 4)
                 return true;
         }
         else
             counter = 0;
     }
     return false;
 }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:20,代码来源:InfiniminerServer.cs


示例7: TriggerConstructionGunAnimation

        public void TriggerConstructionGunAnimation(Player player, float animationValue)
        {
            if (player.NetConn.Status != NetConnectionStatus.Connected)
                return;

            // ore, cash, weight, max ore, max weight, team ore, red cash, blue cash, all uint
            NetBuffer msgBuffer = netServer.CreateBuffer();
            msgBuffer.Write((byte)InfiniminerMessage.TriggerConstructionGunAnimation);
            msgBuffer.Write(animationValue);
            netServer.SendMessage(msgBuffer, player.NetConn, NetChannel.ReliableInOrder1);
        }
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:11,代码来源:InfiniminerServer.cs


示例8: UseRemote

 public void UseRemote(Player player)
 {
     if (player.Content[5] > 0)
     {
         PlayerInteract(player, (uint)(player.Content[5]), (uint)(player.Content[6]), (uint)(player.Content[7]), (uint)(player.Content[8]));
     }
     else
     {
         SendServerMessageToPlayer("Remote is not attached to anything.", player.NetConn);
     }
 }
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:11,代码来源:InfiniminerServer.cs


示例9: UseSmash

 public void UseSmash(Player player, Vector3 playerPosition, Vector3 playerHeading)
 {
 }
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:3,代码来源:InfiniminerServer.cs


示例10: UseDeconstructionGun

        public void UseDeconstructionGun(Player player, Vector3 playerPosition, Vector3 playerHeading)
        {
            bool actionFailed = false;

            // If there's no surface within range, bail.
            Vector3 hitPoint = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;
            if (!RayCollision(playerPosition, playerHeading, 6, 25, ref hitPoint, ref buildPoint, BlockType.Water))
                actionFailed = true;
            ushort x = (ushort)hitPoint.X;
            ushort y = (ushort)hitPoint.Y;
            ushort z = (ushort)hitPoint.Z;

            // If this is another team's block, bail.
            if (blockCreatorTeam[x, y, z] != player.Team)
                actionFailed = true;

            BlockType blockType = blockList[x, y, z];
            if (!(blockType == BlockType.SolidBlue ||
                blockType == BlockType.SolidRed ||
                blockType == BlockType.SolidBlue2 ||
                blockType == BlockType.SolidRed2 ||
                blockType == BlockType.BankBlue ||
                blockType == BlockType.BankRed ||
                blockType == BlockType.ArtCaseR ||
                blockType == BlockType.ArtCaseB ||
                blockType == BlockType.Jump ||
                blockType == BlockType.Ladder ||
                blockType == BlockType.Road ||
                blockType == BlockType.Shock ||
                blockType == BlockType.ResearchR ||
                blockType == BlockType.ResearchB ||
                blockType == BlockType.BeaconRed ||
                blockType == BlockType.BeaconBlue ||
                blockType == BlockType.Water ||
                blockType == BlockType.TransBlue ||
                blockType == BlockType.TransRed ||
                blockType == BlockType.GlassR ||
                blockType == BlockType.GlassB ||
                blockType == BlockType.Generator ||
                blockType == BlockType.Pipe ||
                blockType == BlockType.Pump ||
                blockType == BlockType.RadarBlue ||
                blockType == BlockType.RadarRed ||
                blockType == BlockType.Barrel ||
                blockType == BlockType.Hinge ||
                blockType == BlockType.Lever ||
                blockType == BlockType.Plate ||
                blockType == BlockType.Controller ||
                blockType == BlockType.Water ||
                blockType == BlockType.StealthBlockB ||
                blockType == BlockType.StealthBlockR ||
                blockType == BlockType.TrapB ||
                blockType == BlockType.TrapR
                ))
                actionFailed = true;

            if (actionFailed)
            {
                // Decharge the player's gun.
                TriggerConstructionGunAnimation(player, -0.2f);
            }
            else
            {
                // Fire the player's gun.
                TriggerConstructionGunAnimation(player, 0.5f);

                if (blockType == BlockType.RadarRed)//requires special remove
                {
                    foreach (Player p in playerList.Values)
                    {
                        if (p.Alive && p.Team == PlayerTeam.Blue)
                            {
                                if (p.Content[1] == 1)
                                {
                                    p.Content[1] = 0;//goes off radar again
                                    SendPlayerContentUpdate(p, 1);
                                }
                            }
                    }
                }
                else if (blockType == BlockType.RadarBlue)//requires special remove
                {
                    foreach (Player p in playerList.Values)
                    {
                        if (p.Alive && p.Team == PlayerTeam.Red)
                        {
                            if (p.Content[1] == 1)
                            {
                                p.Content[1] = 0;//goes off radar again
                                SendPlayerContentUpdate(p, 1);
                            }
                        }
                    }
                }
                else if (blockType == BlockType.ConstructionR || blockType == BlockType.ConstructionB)
                {
                    if (blockListContent[x, y, z, 0] == (byte)BlockType.ArtCaseR || blockListContent[x, y, z, 0] == (byte)BlockType.ArtCaseB)
                    {
                        if (y < MAPSIZE - 1)
//.........这里部分代码省略.........
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例11: UsePickaxe

        public void UsePickaxe(Player player, Vector3 playerPosition, Vector3 playerHeading)
        {
            player.QueueAnimationBreak = true;

            // Figure out what we're hitting.
            Vector3 hitPoint = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;

            if (artifactActive[(byte)player.Team, 4] > 0 || player.Content[10] == 4)
            {
                if (!RayCollision(playerPosition, playerHeading, 2, 10, ref hitPoint, ref buildPoint, BlockType.Water))
                {
                    //ConsoleWrite(player.Handle + " lost a block sync.");
                    return;
                }
            }
            else
            {
                if (!RayCollision(playerPosition, playerHeading, 2, 10, ref hitPoint, ref buildPoint, BlockType.None))
                {
                    //ConsoleWrite(player.Handle + " lost a block sync.");
                    return;
                }
            }
            ushort x = (ushort)hitPoint.X;
            ushort y = (ushort)hitPoint.Y;
            ushort z = (ushort)hitPoint.Z;

            if (player.Alive == false || player.playerToolCooldown > DateTime.Now)
            {
                //ConsoleWrite("fixed " + player.Handle + " synchronization");
                SetBlockForPlayer(x, y, z, blockList[x, y, z], blockCreatorTeam[x, y, z], player);
                return;
            }
            else
            {
                player.playerToolCooldown = DateTime.Now + TimeSpan.FromSeconds((float)(player.GetToolCooldown(PlayerTools.Pickaxe)));
            }
            // Figure out what the result is.
            bool removeBlock = false;
            uint giveOre = 0;
            uint giveCash = 0;
            uint giveWeight = 0;
            int Damage = 2 + ResearchComplete[(byte)player.Team, 5];
            InfiniminerSound sound = InfiniminerSound.DigDirt;
            BlockType block = BlockAtPoint(hitPoint);
            switch (block)
            {
                case BlockType.Lava:
                    if (varGetB("minelava"))
                    {
                        removeBlock = true;
                        sound = InfiniminerSound.DigDirt;
                    }
                    break;
                case BlockType.Water:
                    if (varGetB("minelava"))
                    {
                        removeBlock = true;
                        sound = InfiniminerSound.DigDirt;
                    }
                    break;
                case BlockType.Dirt:
                case BlockType.Mud:
                case BlockType.Grass:
                case BlockType.Sand:
                case BlockType.DirtSign:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;
                case BlockType.StealthBlockB:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;
                case BlockType.StealthBlockR:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;
                case BlockType.TrapB:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;
                case BlockType.TrapR:
                    removeBlock = true;
                    sound = InfiniminerSound.DigDirt;
                    break;
                case BlockType.Ore:
                    removeBlock = true;
                    giveOre = 20;
                    sound = InfiniminerSound.DigMetal;
                    break;

                case BlockType.Gold:
                    Damage = 2;
                    giveWeight = 1;
                    giveCash = 10;
                    sound = InfiniminerSound.DigMetal;
                    break;

                case BlockType.Diamond:
//.........这里部分代码省略.........
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例12: UseConstructionGun

        public void UseConstructionGun(Player player, Vector3 playerPosition, Vector3 playerHeading, BlockType blockType)
        {
            bool actionFailed = false;
            bool constructionRequired = false;
            // If there's no surface within range, bail.
            Vector3 hitPoint = Vector3.Zero;
            Vector3 buildPoint = Vector3.Zero;
            if (!RayCollision(playerPosition, playerHeading, 6, 25, ref hitPoint, ref buildPoint,BlockType.Water))
                actionFailed = true;

            // If the block is too expensive, bail.
            uint blockCost = BlockInformation.GetCost(blockType);

            if (varGetB("sandbox") && blockCost <= player.OreMax)
                blockCost = 0;
            if (blockCost > player.Ore)
                actionFailed = true;
            if (!allowBlock[(byte)player.Team, (byte)player.Class, (byte)blockType])
                actionFailed = true;
            // If there's someone there currently, bail.
            ushort x = (ushort)buildPoint.X;
            ushort y = (ushort)buildPoint.Y;
            ushort z = (ushort)buildPoint.Z;
            foreach (Player p in playerList.Values)
            {
                if ((int)p.Position.X == x && (int)p.Position.Z == z && ((int)p.Position.Y == y || (int)p.Position.Y - 1 == y))
                    actionFailed = true;
            }

            // If it's out of bounds, bail.
            if (x <= 0 || y <= 0 || z <= 0 || (int)x > MAPSIZE - 1 || (int)y >= MAPSIZE - 1 || (int)z > MAPSIZE - 1)//y >= prevent blocks going too high on server
                actionFailed = true;

            // If it's near a base, bail.
            //if (LocationNearBase(x, y, z))
            //    actionFailed = true;

            // If it's lava, don't let them build off of lava.
            if (blockList[(ushort)hitPoint.X, (ushort)hitPoint.Y, (ushort)hitPoint.Z] == BlockType.Lava || blockList[(ushort)hitPoint.X, (ushort)hitPoint.Y, (ushort)hitPoint.Z] == BlockType.Water)
                actionFailed = true;

            if(!actionFailed)
                if (blockType == BlockType.ArtCaseR || blockType == BlockType.ArtCaseB)
            {//space above must be cleared
                constructionRequired = true;
                //if (blockList[(ushort)hitPoint.X, (ushort)hitPoint.Y + 1, (ushort)hitPoint.Z] != BlockType.None)
                //{
                //    actionFailed = true;
                //}
                //else
                //{
                //    SetBlock(x, (ushort)(y+1), z, BlockType.Vacuum, player.Team);//space for artifact
                //}
            }

            if (actionFailed)
            {
                // Decharge the player's gun.
                TriggerConstructionGunAnimation(player, -0.2f);
            }
            else
            {
                // Fire the player's gun.
                TriggerConstructionGunAnimation(player, 0.5f);

                // Build the block.
               // if (blockType == BlockType.Lava)
                    //blockType = BlockType.Fire;

                if (constructionRequired == true)//block changes into construction block with blocktype on content[0]
                {
                    if (blockType == BlockType.ArtCaseR || blockType == BlockType.ArtCaseB)
                    {
                        //check above for space
                        if (blockList[x, y+1, z] == BlockType.None)
                        {
                            blockList[x, y+1, z] = BlockType.Vacuum;//player cant see, dont bother updating for client
                        }
                        else
                        {
                            return;//wasnt space for the glass
                        }
                    }

                    if (player.Team == PlayerTeam.Red)
                    {
                        SetBlock(x, y, z, BlockType.ConstructionR, player.Team);
                    }
                    else if (player.Team == PlayerTeam.Blue)
                    {
                        SetBlock(x, y, z, BlockType.ConstructionB, player.Team);
                    }
                    blockListHP[x, y, z] = BlockInformation.GetHP(blockType);//base block hp
                    blockListContent[x, y, z, 0] = (byte)blockType;

                    if (blockType == BlockType.ArtCaseR || blockType == BlockType.ArtCaseB)
                    {
                        blockListContent[x, y, z, 6] = 0;
                    }
                }
//.........这里部分代码省略.........
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例13: Trigger

        public bool Trigger(int x, int y, int z, int ox, int oy, int oz, int btn, Player player)
        {
            //if object can be manipulated by levers, it should always return true if the link should remain persistent
            //if the Trigger function returns false, it will remove the link
            if (player != null)
            if (player.Content[2] > 0)//player is attempting to link something
            {
                if (player.Content[9] == 1 && player.Class == PlayerClass.Engineer)
                {
                    if (x > 0 && x < MAPSIZE - 1 && y > 0 && y < MAPSIZE - 1 && z > 0 && z < MAPSIZE - 1)
                    {
                        if (blockList[x, y, z] == BlockType.ResearchB || blockList[x, y, z] == BlockType.ResearchR || blockList[x, y, z] == BlockType.BaseBlue || blockList[x, y, z] == BlockType.BaseRed || blockList[x, y, z] == BlockType.ArtCaseR || blockList[x, y, z] == BlockType.ArtCaseB || blockList[x, y, z] == BlockType.BankRed || blockList[x, y, z] == BlockType.BankBlue)
                        {
                            player.Content[2] = 0;
                            player.Content[3] = 0;
                            player.Content[4] = 0;
                            player.Content[5] = 0;
                            player.Content[9] = 0;
                            SendServerMessageToPlayer("The remote cannot function on " + blockList[x, y, z] + ".", player.NetConn);
                        }
                        else
                        {
                            player.Content[5] = (int)btn;
                            player.Content[6] = (int)x;
                            player.Content[7] = (int)y;
                            player.Content[8] = (int)z;
                            player.Content[2] = 0;
                            player.Content[3] = 0;
                            player.Content[4] = 0;
                            //player.Content[5] = 0;
                            SendServerMessageToPlayer("Linked remote to action " + btn + " on " + blockList[x, y, z] + ".", player.NetConn);
                            player.Content[9] = 0;
                        }
                        return true;
                    }
                }
                if (x == player.Content[2] && y == player.Content[3] && z == player.Content[4])
                {
                    player.Content[2] = 0;
                    player.Content[3] = 0;
                    player.Content[4] = 0;
                    SendContentSpecificUpdate(player, 2);
                    SendContentSpecificUpdate(player, 3);
                    SendContentSpecificUpdate(player, 4);
                    SendServerMessageToPlayer("Cancelled link.", player.NetConn);
                    return true;
                }

                int freeslot = 9;
                int nb = 0;
                for (nb = 2; nb < 7; nb++)
                {
                    if (blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 1] == x && blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 2] == y && blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 3] == z)
                    {

                        blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6] = 0;
                        blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 1] = 0;
                        blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 2] = 0;
                        blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 3] = 0;
                        blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 4] = 0;//unlinked

                        player.Content[2] = 0;
                        player.Content[3] = 0;
                        player.Content[4] = 0;
                        SendContentSpecificUpdate(player, 2);
                        SendContentSpecificUpdate(player, 3);
                        SendContentSpecificUpdate(player, 4);

                        SendServerMessageToPlayer(blockList[x, y, z] + " was unlinked.", player.NetConn);

                        return true;
                    }
                    else if (blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6] == 0 && freeslot == 9)
                    {
                        freeslot = nb;
                        break;//makes sure that we arent reattaching links over and over
                    }
                }

                if (freeslot == 9)
                    return false;

                if (nb != 7)//didnt hit end of switch-link limit
                {//should check teams and connection to itself
                    //range check

                    if (Distf(new Vector3(x, y, z), new Vector3(player.Content[2], player.Content[3], player.Content[4])) < 10)
                    {
                        //Vector3 heading = new Vector3(player.Content[2], player.Content[3], player.Content[4]);
                        //heading -= new Vector3(x, y, z);
                        //heading.Normalize();
                        //if (RayCollision(new Vector3(x, y, z) + heading * 0.4f, heading, (float)(Distf(new Vector3(x, y, z), new Vector3(player.Content[2], player.Content[3], player.Content[4]))), 10, blockList[x, y, z]))
                        //{
                            blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 1] = (int)(x);
                            blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 2] = (int)(y);
                            blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 3] = (int)(z);
                            blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6 + 4] = (int)(btn);
                            blockListContent[player.Content[2], player.Content[3], player.Content[4], nb * 6] = 100;
                            SendServerMessageToPlayer(blockList[player.Content[2], player.Content[3], player.Content[4]] + " linked action " + btn + " on " + blockList[x, y, z] + ".", player.NetConn);
                        //}
//.........这里部分代码省略.........
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例14: ThrowRope

        //private bool LocationNearBase(ushort x, ushort y, ushort z)
        //{
        //    for (int i=0; i<MAPSIZE; i++)
        //        for (int j=0; j<MAPSIZE; j++)
        //            for (int k = 0; k < MAPSIZE; k++)
        //                if (blockList[i, j, k] == BlockType.HomeBlue || blockList[i, j, k] == BlockType.HomeRed)
        //                {
        //                    double dist = Math.Sqrt(Math.Pow(x - i, 2) + Math.Pow(y - j, 2) + Math.Pow(z - k, 2));
        //                    if (dist < 3)
        //                        return true;
        //                }
        //    return false;
        //}
        public void ThrowRope(Player player, Vector3 playerPosition, Vector3 playerHeading)
        {
            bool actionFailed = false;

            if (player.Alive == false || player.playerToolCooldown > DateTime.Now)
            {
                actionFailed = true;
            }
            else if (player.Ore > 49)
            {
                player.Ore -= 50;
                SendOreUpdate(player);
            }
            else
            {
                actionFailed = true;
            }
            // If there's no surface within range, bail.
            Vector3 hitPoint = playerPosition;
            Vector3 buildPoint = playerPosition;
            Vector3 exactPoint = playerPosition;

            ushort x = (ushort)buildPoint.X;
            ushort y = (ushort)buildPoint.Y;
            ushort z = (ushort)buildPoint.Z;

            if (x <= 0 || y <= 0 || z <= 0 || (int)x > MAPSIZE - 1 || (int)y > MAPSIZE - 1 || (int)z > MAPSIZE - 1)
                actionFailed = true;

            if (blockList[(ushort)hitPoint.X, (ushort)hitPoint.Y, (ushort)hitPoint.Z] == BlockType.Lava || blockList[(ushort)hitPoint.X, (ushort)hitPoint.Y, (ushort)hitPoint.Z] == BlockType.Water)
                actionFailed = true;

            if (actionFailed)
            {
                // Decharge the player's gun.
                //    TriggerConstructionGunAnimation(player, -0.2f);
            }
            else
            {
                player.playerToolCooldown = DateTime.Now + TimeSpan.FromSeconds((float)(player.GetToolCooldown(PlayerTools.ThrowRope)));
                // Fire the player's gun.
                //    TriggerConstructionGunAnimation(player, 0.5f);

                // Build the block.
                //hitPoint = RayCollision(playerPosition, playerHeading, 6, 25, ref hitPoint, ref buildPoint, 1);

                exactPoint.Y = exactPoint.Y + (float)0.25;//0.25 = items height

                uint ii = SetItem(ItemType.Rope, exactPoint, playerHeading, playerHeading * 5, player.Team, 0);
                itemList[ii].Content[6] = (byte)player.Team;//set teamsafe
                // player.Ore -= blockCost;
                // SendResourceUpdate(player);

                // Play the sound.
                PlaySound(InfiniminerSound.ConstructionGun, player.Position);
            }
        }
开发者ID:bobisfat,项目名称:Infiniminer,代码行数:70,代码来源:InfiniminerServer.cs


示例15: Start

        public bool Start()
        {
            //Setup the variable toggles
            varBindingsInitialize();

            int tmpMaxPlayers = 16;

            // Read in from the config file.
            DatafileWriter dataFile = new DatafileWriter("server.config.txt");
            if (dataFile.Data.ContainsKey("winningcash"))
                winningCashAmount = uint.Parse(dataFile.Data["winningcash"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("includelava"))
                includeLava = bool.Parse(dataFile.Data["includelava"]);
            if (dataFile.Data.ContainsKey("orefactor"))
                oreFactor = uint.Parse(dataFile.Data["orefactor"], System.Globalization.CultureInfo.InvariantCulture);
            if (dataFile.Data.ContainsKey("maxplayers"))
                tmpMaxPlayers = (int)Math.Min(32, uint.Parse(dataFile.Data["maxplayers"], System.Globalization.CultureInfo.InvariantCulture));
            if (dataFile.Data.ContainsKey("public"))
                varSet("public", bool.Parse(dataFile.Data["public"]), true);
            if (dataFile.Data.ContainsKey("servername"))
                varSet("name", dataFile.Data["servername"], true);
            if (dataFile.Data.ContainsKey("sandbox"))
                varSet("sandbox", bool.Parse(dataFile.Data["sandbox"]), true);
            if (dataFile.Data.ContainsKey("notnt"))
                varSet("tnt", !bool.Parse(dataFile.Data["notnt"]), true);
            if (dataFile.Data.ContainsKey("sphericaltnt"))
                varSet("stnt", bool.Parse(dataFile.Data["sphericaltnt"]), true);
            if (dataFile.Data.ContainsKey("insanelava"))
                varSet("insanelava", bool.Parse(dataFile.Data["insanelava"]), true);
            if (dataFile.Data.ContainsKey("shockspreadslava"))
                varSet("sspreads", bool.Parse(dataFile.Data["shockspreadslava"]), true);
            if (dataFile.Data.ContainsKey("roadabsorbs"))
                varSet("roadabsorbs", bool.Parse(dataFile.Data["roadabsorbs"]), true);
            if (dataFile.Data.ContainsKey("minelava"))
                varSet("minelava", bool.Parse(dataFile.Data["minelava"]), true);
            if (dataFile.Data.ContainsKey("levelname"))
                levelToLoad = dataFile.Data["levelname"];
            if (dataFile.Data.ContainsKey("greeter"))
                varSet("greeter", dataFile.Data["greeter"], true);

            bool autoannounce = true;
            if (dataFile.Data.ContainsKey("autoannounce"))
                autoannounce = bool.Parse(dataFile.Data["autoannounce"]);

            // Load the ban-list.
            banList = LoadBanList();

            // Load the admin-list
            admins = LoadAdminList();

            if (tmpMaxPlayers >= 0)
                varSet("maxplayers", tmpMaxPlayers, true);

            // Initialize the server.
            NetConfiguration netConfig = new NetConfiguration("InfiniminerPlus");
            netConfig.MaxConnections = (int)varGetI("maxplayers");
            netConfig.Port = 5565;
            netServer = new InfiniminerNetServer(netConfig);
            netServer.SetMessageTypeEnabled(NetMessageType.ConnectionApproval, true);
            //netServer.SimulatedMinimumLatency = 0.1f;
            //netServer.SimulatedLatencyVariance = 0.05f;
            //netServer.SimulatedLoss = 0.1f;
            //netServer.SimulatedDuplicates = 0.05f;
            netServer.Start();

            // Initialize variables we'll use.
            NetBuffer msgBuffer = netServer.CreateBuffer();
            NetMessageType msgType;
            NetConnection msgSender;

            // Store the last time that we did a flow calculation.
            DateTime lastFlowCalc = DateTime.Now;

            //Check if we should autoload a level
            if (dataFile.Data.ContainsKey("autoload") && bool.Parse(dataFile.Data["autoload"]))
            {
                blockList = new BlockType[MAPSIZE, MAPSIZE, MAPSIZE];
                blockCreatorTeam = new PlayerTeam[MAPSIZE, MAPSIZE, MAPSIZE];
                LoadLevel(levelToLoad);
            }
            else
            {
                // Calculate initial lava flows.
                ConsoleWrite("CALCULATING INITIAL LAVA FLOWS");
                ConsoleWrite("TOTAL LAVA BLOCKS = " + newMap());
            }

            //Caculate the shape of spherical tnt explosions
            CalculateExplosionPattern();

            // Send the initial server list update.
            if (autoannounce)
                PublicServerListUpdate(true);

            lastMapBackup = DateTime.Now;

            // Main server loop!
            ConsoleWrite("SERVER READY");
            while (keepRunning)
            {
//.........这里部分代码省略.........
开发者ID:Eamnon,项目名称:Infiniminer,代码行数:101,代码来源:InfiniminerServer.cs


示例16: UseStrongArm

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DataModels.InfoManageDataContext类代码示例发布时间:2022-05-26
下一篇:
C# PhysxPhysics.PhysxPrim类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap