private Vector2 GetTargetPosition(Direction direction, Point spawnPositionInGrid) { var cellSize = PlayerPrefs.Get <int>("CellSize"); var width = PlayerPrefs.Get <int>("Width"); var height = PlayerPrefs.Get <int>("Height"); var targetPosition = spawnPositionInGrid.ToVector2() * cellSize; switch (direction) { case Direction.Up: targetPosition.Y = -cellSize; break; case Direction.Down: targetPosition.Y = height * (cellSize + 1); break; case Direction.Left: targetPosition.X = -cellSize; break; case Direction.Right: targetPosition.X = width * (cellSize + 1); break; } return(targetPosition); }
/// <summary> /// 读取用户数据 /// </summary> public void LoadPlayerData() { LV = PlayerPrefs.Get("LV"); Strong = PlayerPrefs.Get("Strong"); Intelligence = PlayerPrefs.Get("Intelligence"); Agility = PlayerPrefs.Get("Agility"); Luckys = PlayerPrefs.Get("Luckys"); }
private void PlaceDestroyer(Entity?destroyerEntity, Point spawnPositionInGrid, Transform parent) { var destroyerTransform = new Transform(); destroyerTransform.Parent = parent; destroyerTransform.LocalPosition = spawnPositionInGrid.ToVector2() * PlayerPrefs.Get <int>("CellSize"); destroyerTransform.Origin = new Vector2(40, 40); destroyerEntity.Value.Set(destroyerTransform); }
private void CreateTimerBoard(World world) { _timerCounter = new Counter(new CounterArgs { Title = "Time", World = world, Position = new Vector2(510, 30), InitialValue = PlayerPrefs.Get <int>("RoundTime") }); }
public static Vector2 Get(string key, Vector2 defaultValue = default(Vector2)) { var ret = default(Vector2); ret.x = PlayerPrefs <float> .Get(key + "x", defaultValue.x); ret.y = PlayerPrefs <float> .Get(key + "y", defaultValue.y); return(ret); }
private int CalculatePartialPosition(float value, Direction direction) { int partialPosition; if (direction == Direction.Left || direction == Direction.Up) { partialPosition = (int)Math.Ceiling(value / PlayerPrefs.Get <int>("CellSize")); } else { partialPosition = (int)Math.Floor(value / PlayerPrefs.Get <int>("CellSize")); } return(partialPosition); }
private void CreateScoreText() { var entity = _textFactory.Create( new TextArgs { FontName = "font", Text = $"Score: {PlayerPrefs.Get<int>("Score")}", Color = new Color(161, 63, 16) } ); var position = SceneUtil.GetCenterFor(entity, _game.GraphicsDevice); entity.Set(new Transform { Position = position }); }
public override void Setup(World world, out ISystem <float> systems) { _imageFactory = new ImageFactory(world); _gridFactory = new GridFactory( world, _game.GraphicsDevice, PlayerPrefs.Get <int>("Width"), PlayerPrefs.Get <int>("Height"), PlayerPrefs.Get <int>("CellSize") ); _cellPool = new CellPool(new CellFactory(world, PlayerPrefs.Get <int>("CellSize"))); InitLayers(world); InitializeSystems(world, out systems); SetupWorld(world); world.Subscribe(this); }
private Vector2 GetLocalPosition(Cell cell) => cell.PositionInGrid.ToVector2() * PlayerPrefs.Get <int>("CellSize");
public T Get() { return(PlayerPrefs <T> .Get(key, defaultValue)); }