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


C# Point.WalkTo方法代碼示例

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


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

示例1: TrainingCamp

        public TrainingCamp(GameWorld gameWorldRef, GamePlayer playerRef, Point Location)
            : base("building6", gameWorldRef, playerRef, Location)
        {
            // filling the occupied_cells_locations List
            // (the purpose is to make these cells not walkable)
            #region Occupied Cells Work

            const int cellsEast = 3;
            const int cellsWest = 4;

            Point westIndexer = Location;
            Point eastIndexer = Location;

            for (int i = 0; i < cellsWest; i++)
            {
                for (int j = 0; j < cellsEast; j++)
                {
                    OccupiedCellsLocations.Add(eastIndexer);
                    eastIndexer = eastIndexer.WalkTo(Direction.NE);
                }
                westIndexer = westIndexer.WalkTo(Direction.NW);
                eastIndexer = westIndexer;
            }

            // add the irregular occupied cells..
            Point indexer = Location;
            indexer = indexer.WalkTo(Direction.SW);
            indexer = indexer.WalkTo(Direction.NW);
            indexer = indexer.WalkTo(Direction.NW);
            OccupiedCellsLocations.Add(indexer);
            indexer = indexer.WalkTo(Direction.NW);
            OccupiedCellsLocations.Add(indexer);

            // now set the Mapcells at locations found to be not walkable..
            foreach (var location in OccupiedCellsLocations)
            {
                MapRef.MapCellAt(location).Walkable = false;
            }

            //setting depths of irregular occupied cells..
            float irregularDepth1;
            float irregularDepth2;
            indexer = Location.WalkTo(Direction.SW).WalkTo(Direction.NW).WalkTo(Direction.NW);
            irregularDepth1 = MapRef.MapCellAt(indexer).DrawDepth;
            indexer = indexer.WalkTo(Direction.NW);
            irregularDepth2 = MapRef.MapCellAt(indexer).DrawDepth;

            int segIndexer = (ImgSegmentsDepthsOrdered.Count / 2) - 3; // indexes segment no. 3 counting from middle segment leftwards
            SegDepth newSegment = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth1);
            ImgSegmentsDepthsOrdered[segIndexer] = newSegment;
            segIndexer--;
            SegDepth newSegment2 = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth1);
            ImgSegmentsDepthsOrdered[segIndexer] = newSegment2;
            segIndexer--;
            SegDepth newSegment3 = new SegDepth(ImgSegmentsDepthsOrdered[segIndexer].SegRect, irregularDepth2);
            ImgSegmentsDepthsOrdered[segIndexer] = newSegment3;
            #endregion

            #region Generating Custom Built Units Locations
               //remove last location
            BuiltUnitsLocations.RemoveAt(BuiltUnitsLocations.Count-1);
            //get the new last location
            var loc = BuiltUnitsLocations[BuiltUnitsLocations.Count-1];

            Vector2 cell = new Vector2(MapRef.WorldToMapCell(loc).X,
                    MapRef.WorldToMapCell(loc).Y);

            cell = cell.WalkTo(Direction.SW);
            BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);
            cell = cell.WalkTo(Direction.NW);
            BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);
            cell = cell.WalkTo(Direction.NW);
            BuiltUnitsLocations.Add(MapRef.MapCellAt(cell).CenterPosition);

            #endregion

            // making smoke on the roof
            #region smoke
            _smoke = new SpriteAnimation(GameGraphics.GetTexture("smoke").SourceTexture);
            _smoke.AddAnimation("normal", 0, 0, 30, 64, 16, 0.1f);
            _smoke.Position = Camera.WorldToScreen(new Vector2( this.BuildingOrigin.X+85, this.BuildingOrigin.Y-60));
            _smoke.CurrentAnimation = "normal";
            _smoke.DrawDepth = BuildingInfo.SmokeDrawDepth;
            _smoke.IsAnimating = true;
            #endregion

            selectionGroup = GroupMapper.CampGroup;

            SelectionLineTexture = GameGraphics.GetTexture("camp_selection_line");

            #region Setting Entity Properties
            MaxHealth = 800;
            MaxDefense = 300;
            MaxAttack = 0;

            Health = MaxHealth;
            Defense = MaxDefense;
            Attack = MaxAttack;
            #endregion
        }
開發者ID:osama-abuomar,項目名稱:TownDefenders-XNA4Game,代碼行數:100,代碼來源:TrainingCamp.cs

示例2: WalkTo

 public static Vector2 WalkTo(this Vector2 location, Direction direction)
 {
     var loc = new Point((int)location.X, (int)location.Y);
     var result = loc.WalkTo(direction);
     return new Vector2(result.X, result.Y);
 }
開發者ID:osama-abuomar,項目名稱:TownDefenders-XNA4Game,代碼行數:6,代碼來源:TileMapHelper.cs


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