private void LoadMainCharacter() { Character player = CharactersManager.GetCharacter(2); if (player == null) { CloseScene?.Invoke(); } _mainCharacter = new CharacterBody(player); _mainCharacter.CharacterPic = character_pic_left; _mainCharacter.Sprites = SpritesHelper.CreateSprite(player); character_pic_left.Height = _mainCharacter.Sprites.SpriteHeight; character_pic_left.Width = _mainCharacter.Sprites.SpriteWidth; _mainCharacter.MoveTransform = new TranslateTransform(0, 0); _mainCharacter.Direction = DirectionEnum.IDLERight; _mainCharacter.MoveSpriteIndex = 0; character_pic_left.RenderTransform = _mainCharacter.MoveTransform; character_pic_left.Source = _mainCharacter.Sprites.IDLERight[0].ImageSource; this.KeyDown += PlayerKeyDown; this.KeyUp += PlayerKeyUp; dialog_pic.Height = 30; dialog_pic.Width = _mainCharacter.Sprites.SpriteWidth; }
private void LoadSceneCharacters() { foreach (OpenWorldCharacter character in _characters) { if (character.Scene == _scene.ID) { Character player = CharactersManager.GetCharacter(character.Character); if (player == null) { break; } CharacterBody newCharacter = new CharacterBody(player); newCharacter.Sprites = SpritesHelper.CreateSprite(player); newCharacter.CharacterPic = new Image(); newCharacter.CharacterPic.Stretch = Stretch.Uniform; newCharacter.CharacterPic.Margin = new Thickness(0, 5, 0, 5); newCharacter.CharacterPic.HorizontalAlignment = HorizontalAlignment.Left; newCharacter.CharacterPic.VerticalAlignment = VerticalAlignment.Center; newCharacter.CharacterDialogPic = dialog_pic; main_grid.Children.Add(newCharacter.CharacterPic); Grid.SetRow(newCharacter.CharacterPic, 2); Grid.SetZIndex(newCharacter.CharacterPic, 2); newCharacter.MoveTransform = new TranslateTransform(new Random().Next(30, (int)this.ActualWidth - 2 * newCharacter.Sprites.SpriteWidth), 0); newCharacter.CharacterPic.RenderTransform = newCharacter.MoveTransform; newCharacter.Direction = new Random().Next(2) == 0 ? DirectionEnum.IDLELeft : DirectionEnum.IDLERight; newCharacter.MoveSpriteIndex = 0; _currentCharacters.Add(newCharacter); } } }
private void LoadCharacters() { for (int i = 0; i < 2; i++) { _sprites[i] = SpritesHelper.CreateSprite(_scene.Characters[i]); _charactersPics[i].Height = _sprites[i].SpriteHeight; _charactersPics[i].Width = _sprites[i].SpriteWidth; _moveTransform[i] = new TranslateTransform(0, 0); _charactersPics[i].RenderTransform = _moveTransform[i]; } _direction[0] = DirectionEnum.IDLERight; _direction[1] = DirectionEnum.IDLELeft; character_pic_left.Source = _sprites[0].IDLERight[0].ImageSource; character_pic_right.Source = _sprites[1].IDLELeft[0].ImageSource; this.KeyDown += PlayerKeyDown; this.KeyUp += PlayerKeyUp; }