当前位置: 首页>>代码示例>>C#>>正文


C# IPlayer.GetPosition方法代码示例

本文整理汇总了C#中IPlayer.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.GetPosition方法的具体用法?C# IPlayer.GetPosition怎么用?C# IPlayer.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPlayer的用法示例。


在下文中一共展示了IPlayer.GetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleCollision

        public void HandleCollision(IPlayer player)
        {
            int playerRadius = (player.GetPosition().Width) / 2;

            // the center of the player's bounding circle
            int x1 = player.GetPosition().X + (player.GetPosition().Width/2);
            int y1 = player.GetPosition().Y + (player.GetPosition().Height/2);

            // the center of the torch's bounding circle for the nimbus
            int x2 = positionNimbus.X + (positionNimbus.Width/2);
            int y2 = positionNimbus.Y + (positionNimbus.Height/2);

            int dx = x1 - x2;
            int dy = y1 - y2;

            int distance = (int)Math.Sqrt((dx*dx) + (dy*dy));

            if (distance < playerRadius + nimbusRadius && player.HiddenPercent > 0)
            {
                // if the player is hitting a torch his hidden percent drops
                player.HiddenPercent -= 0.49f;
            }
        }
开发者ID:Terhands,项目名称:LazerSharktopus,代码行数:23,代码来源:Torch.cs

示例2: HandleVision

        //if he sees the player, the player should die.
        public void HandleVision(IPlayer player, IList<ITile> surroundingTiles)
        {
            //grab the position of the eyes(relative to guard) and make them relative to the map)
            Vector2  mapEyePos = new Vector2(this.position.X + eyePos.X, this.position.Y + eyePos.Y);

            //distance between the x and y position of the guards eyes and the middle of the player
            float dX = mapEyePos.X - (player.GetPosition().X + (player.GetPosition().Width / 2));
            float dY = mapEyePos.Y - (player.GetPosition().Y + (player.GetPosition().Height / 2));
            float distance = (float)Math.Sqrt(Math.Pow(dX, 2) + Math.Pow(dY, 2));

            float visibility = distance - ((1 - player.HiddenPercent) * LOSRadius);

            // if the player is behind the guard we don't care
            if ((facingDirection == Direction.left && player.GetPosition().Left <= mapEyePos.X) || (facingDirection == Direction.right && player.GetPosition().Right >= mapEyePos.X))
            {
                // is the player visible enough/close enough for the guard to be able to see
                if (visibility <= 0 && isVisible(player.GetPosition(), surroundingTiles))
                {
                    player.Kill();
                }
            }
        }
开发者ID:Terhands,项目名称:LazerSharktopus,代码行数:23,代码来源:Wizard.cs


注:本文中的IPlayer.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。