當前位置: 首頁>>代碼示例>>C#>>正文


C# Model.Last方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Model.Last方法的典型用法代碼示例。如果您正苦於以下問題:C# Model.Last方法的具體用法?C# Model.Last怎麽用?C# Model.Last使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.Model的用法示例。


在下文中一共展示了Model.Last方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FillEmptyBorderRange

        /// <summary>
        /// Fills empty range of town quarter border with buildings. It takes it by dimension X - first fit.
        /// </summary>
        /// <param name="buildingModels">Availible models</param>
        /// <param name="borderPosition">Position of border - specifies side of rectangle</param>
        /// <param name="range">Empty range for filling</param>
        /// <param name="offset">Already filled part of range</param>
        private int FillEmptyBorderRange(Model[] buildingModels, TownQuarterInterfacePosition borderPosition, Range range, float offset, bool lastOne)
        {
            float emptySpace = (range.Length - 1) * SquareWidth - offset;
            foreach(Model model in buildingModels)
            {
                if (model.GetSize(game.Drawer.WorldTransformMatrix).X <= emptySpace)
                {
                    Model usedModel = model;
                    Vector3 usedModelSize = usedModel.GetSize(game.Drawer.WorldTransformMatrix);

                    float angle = 0;
                    Vector3 position = Vector3.Zero;
                    float newOffset = offset + usedModelSize.X;
                    switch (borderPosition)
                    {
                        case TownQuarterInterfacePosition.Top:
                            position = new Vector3(range.Begin * SquareWidth + SquareWidth + offset, 0, BlockWidth * SquareWidth - SquareWidth - usedModelSize.Z);
                            break;
                        case TownQuarterInterfacePosition.Right:
                            position = new Vector3(BlockWidth * SquareWidth - SquareWidth - usedModelSize.X / 2 + usedModelSize.Z / 2 + +(bitmapSize.Width - 2 * (BlockWidth - 1)) * SquareWidth, 0, range.Begin * SquareWidth + SquareWidth + offset + usedModelSize.X / 2 - usedModelSize.Z / 2);
                            angle = MathHelper.PiOver2;
                            break;
                        case TownQuarterInterfacePosition.Bottom:
                            position = new Vector3(range.Begin * SquareWidth + SquareWidth + offset, 0, BlockWidth * SquareWidth - SquareWidth + (bitmapSize.Height - 2 * (BlockWidth - 1)) * SquareWidth);
                            break;
                        case TownQuarterInterfacePosition.Left:
                            position = new Vector3(BlockWidth * SquareWidth - SquareWidth - usedModelSize.X / 2 - usedModelSize.Z / 2, 0, range.Begin * SquareWidth + SquareWidth + offset + usedModelSize.X / 2 - usedModelSize.Z / 2);
                            angle = MathHelper.PiOver2;
                            break;
                        default:
                            break;
                    }

                    SpatialObject borderBuilding = new SpatialObject(usedModel, this, position, angle, game.Drawer.WorldTransformMatrix);
                    solidObjects.AddLast(borderBuilding);
                    int recRes = 0;
                    if (!lastOne)
                    {
                        recRes = FillEmptyBorderRange(buildingModels, borderPosition, range, newOffset, false);
                    }
                    if (recRes == 0 && !lastOne)
                    {
                        Range overflowedRange = range;
                        overflowedRange.End++;
                        recRes = FillEmptyBorderRange(new Model[] {buildingModels.Last()}, borderPosition, overflowedRange, newOffset, true);
                    }
                    return recRes + 1;
                    //break;
                }
            }
            return 0;
        }
開發者ID:havri,項目名稱:ActionGame,代碼行數:59,代碼來源:TownQuarter.Generator.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Model.Last方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。