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


C# Area.getTileRectangle方法代码示例

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


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

示例1: changeActiveArea

        /// <summary>
        /// Moves the player from one area to another.
        /// </summary>
        /// <param name="arrivingArea">New area.</param>
        /// <param name="targetTile">Tile in that area the player should appear on.</param>
        public static void changeActiveArea(Area arrivingArea, Point targetTile)
        {
            Area departingArea = GameplayManager.ActiveArea;

            if (arrivingArea == departingArea)
                return;

            departingArea.remove(GameplayManager.Player);

            Rectangle targetRectangle = arrivingArea.getTileRectangle(targetTile.X, targetTile.Y);
            Vector2 newPos = new Vector2(
                targetRectangle.X + arrivingArea.TileSet.tileWidth / 2,
                targetRectangle.Y + arrivingArea.TileSet.tileHeight / 2);

            Player.getCollider().move(newPos - Player.getCollider().Bounds.Center());

            arrivingArea.add(GameplayManager.Player);

            activeArea = arrivingArea;
        }
开发者ID:gripp,项目名称:psychic-octo-nemesis,代码行数:25,代码来源:GameplayManager.cs

示例2: changeActiveArea

        /// <summary>
        /// Moves the player from one area to another.
        /// </summary>
        /// <param name="arrivingArea">New area.</param>
        /// <param name="targetTile">Tile in that area the player should appear on.</param>
        public static void changeActiveArea(Area arrivingArea, Point targetTile)
        {
            Area departingArea = GameplayManager.ActiveArea;

            if (arrivingArea == departingArea)
                return;

            if (departingArea.exists(GameplayManager.Companion))
            {
                //GameplayManager.Companion.getCollider().setCollider(ColliderType.PC);
                departingArea.remove(GameplayManager.Companion);
            }

            departingArea.remove(GameplayManager.Player);

            Rectangle targetRectangle = arrivingArea.getTileRectangle(targetTile.X, targetTile.Y);
            Vector2 newPos = new Vector2(
                targetRectangle.X + arrivingArea.TileSet.tileWidth / 2,
                targetRectangle.Y + arrivingArea.TileSet.tileHeight / 2);

            Player.getCollider().move(newPos - Player.getCollider().Bounds.Center());
            if (Quest.talkedToCompanion)
            //if(true)
            {
                Companion.getCollider().move(newPos - Companion.getCollider().Bounds.Center());
                ((CompanionController)Companion).learnNewInfo(CharacterController.currPlan);
                CharacterController.currPlan = null;
                //Player.brew.extract(CharacterController.ALL_BREW);
                //Companion.brew.extract(CharacterController.ALL_BREW);
            }
            arrivingArea.add(GameplayManager.Player);

            if (!Quest.talkedToCompanion && arrivingArea.Equals(WorldManager.GetArea(Area.START)))
            {
                arrivingArea.add(GameplayManager.Companion);
                //ADD AND ALSO IF FIRST QUEST IS UNDONE!
                GameplayManager.Companion.setAbsPos(new Vector2(500, 50));
            }
            else if(Quest.talkedToCompanion)
            {
                arrivingArea.add(GameplayManager.Companion);
            }

            activeArea = arrivingArea;

            if (activeArea.GlobalLocation == Area.PARTY)
            {
                // place the companion and player into new default start locales
                double xdiff = GameplayManager.Player.m_position.X - GameplayManager.Player.m_collider.m_bounds.X;
                double ydiff = GameplayManager.Player.m_position.Y - GameplayManager.Player.m_collider.m_bounds.Y;
                GameplayManager.Player.m_position = new Vector2(Area.TILE_WIDTH * 3 + 20, Area.TILE_HEIGHT * 3);
                GameplayManager.Player.m_collider.move(new Vector2((float)(-GameplayManager.Player.m_collider.m_bounds.X + GameplayManager.Player.m_position.X - xdiff), (float)(-GameplayManager.Player.m_collider.m_bounds.Y + GameplayManager.Player.m_position.Y - ydiff)));
                GameplayManager.Player.m_position = new Vector2(Area.TILE_WIDTH * 3 + 20, Area.TILE_HEIGHT * 3);

                xdiff = GameplayManager.Companion.m_position.X - GameplayManager.Companion.m_collider.m_bounds.X;
                ydiff = GameplayManager.Companion.m_position.Y - GameplayManager.Companion.m_collider.m_bounds.Y;
                GameplayManager.Companion.m_position = new Vector2(Area.TILE_WIDTH * 3 + 20, Area.TILE_HEIGHT * 9);
                GameplayManager.Companion.m_collider.move(new Vector2((float)(-GameplayManager.Companion.m_collider.m_bounds.X + GameplayManager.Companion.m_position.X - xdiff), (float)(-GameplayManager.Companion.m_collider.m_bounds.Y + GameplayManager.Companion.m_position.Y - ydiff)));
                GameplayManager.Companion.m_position = new Vector2(Area.TILE_WIDTH * 3 + 20, Area.TILE_HEIGHT * 9);
                GameplayManager.Companion.m_collider.m_type = ColliderType.NPC;
            }
            else
            {
                GameplayManager.Companion.m_collider.m_type = ColliderType.PC;
            }
        }
开发者ID:BNHeadrick,项目名称:Bros,代码行数:71,代码来源:GameplayManager.cs


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