private PlayerComponentSet AddCommonComponents(IEntity player) { var playerAnimationComponent = new PlayerAnimationComponent { HeadAnimator = new Animator(ContentChest.Heads[1].Animations) }; var inventoryComponent = player.AddComponent(new InventoryComponent()); var inventoryBar = inventoryComponent.AddInventory(new Inventory(8)); var mainInventory = inventoryComponent.AddInventory(new Inventory(24)); return(new PlayerComponentSet { MoveComponent = player.AddComponent(new MoveComponent { PositionChanged = PacketManager.SendPositionPacket, MoveDirectionChanged = PacketManager.SendMoveDirectionPacket }), GravityComponent = player.AddComponent(new GravityComponent()), JumpComponent = player.AddComponent(new JumpComponent()), MainInventory = mainInventory, BarInventory = inventoryBar, ItemPickerComponent = player.AddComponent(new ItemPickerComponent(_gameWorld.GameAreas[0].WorldItems, _updateResolver)), PlayerAnimationComponent = player.AddComponent(playerAnimationComponent) }); }
private void InitComponent() { // 애니메이션 _animationComponent = new PlayerAnimationComponent(this.GetComponent <Animator>(), new string[] { "IsIdle", "IsMove", "IsDead" }); ((PlayerAnimationComponent)_animationComponent).Player = this.transform; // 인풋 _inputGetKeyComponent = new InputComponent(KeyKind.GETKEY); _inputGetKeyComponent.Bind(KeyCode.W, MoveTop); _inputGetKeyComponent.Bind(KeyCode.A, MoveLeft); _inputGetKeyComponent.Bind(KeyCode.S, MoveDown); _inputGetKeyComponent.Bind(KeyCode.D, MoveRight); _inputGetKeyComponent.Bind(KeyCode.Mouse0, Attack); _inputGetKeyComponent.Idle = Idle; _inputGetKeyDownComponent = new InputComponent(KeyKind.GETKEY_DOWN); _inputGetKeyDownComponent.Bind(KeyCode.T, Toggle); _inputGetKeyDownComponent.Bind(KeyCode.Space, UseItem); _inputGetKeyDownComponent.Bind(KeyCode.Mouse1, Teleportation); }
private void UpdateWeapons() { if (animationComponent == null) { animationComponent = Entity.GetComponent <PlayerAnimationComponent>(); } Vector2 weaponOffset; if (animationComponent.Animator.CurrentFrame == 1) { weaponOffset = new Vector2(0, -15); } else { weaponOffset = new Vector2(0, -16); } foreach (Weapon w in weapons) { w.Position = Entity.Position + weaponOffset; } }