コード例 #1
0
ファイル: ObjectPlacer.cs プロジェクト: Flaysen/Platformer
 public void RemoveLevelObject(GridPosition gridPosition, LevelGrid grid)
 {
     for (int i = 0; i < LevelGrid.LevelObjects.Count; i++)
     {
         if (LevelGrid.LevelObjects[i].transform.position == gridPosition.Position)
         {
             grid.ToggleGridPositionUsage(gridPosition);
             LevelGrid.LevelObjects[i].gameObject.SetActive(false);
             LevelGrid.LevelObjects.RemoveAt(i);
             return;
         }
     }
 }
コード例 #2
0
        public PlaceLevelObjectCommand(LevelObject levelObject, GridPosition gridPosition, LevelGrid grid)
        {
            _levelObject  = levelObject;
            _gridPosition = gridPosition;
            _grid         = grid;

            _placer = new ObjectPlacer();
        }
コード例 #3
0
ファイル: ObjectPlacer.cs プロジェクト: Flaysen/Platformer
        public void PlaceLeveleObject(LevelObject objectToPlace, GridPosition gridPosition, LevelGrid grid)
        {
            grid.ToggleGridPositionUsage(gridPosition);
            LevelObject placedLevelObject = Instantiate(objectToPlace, gridPosition.Position, Quaternion.identity, grid.transform);

            LevelGrid.LevelObjects.Add(placedLevelObject);
            placedLevelObject.gameObject.SetActive(true);
        }