public void UnequipTool(UnitTool tool) { if (tools.Remove(tool)) { tool.IsEquipped = false; tool.OnUnequip(); } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public PlayerHoldSwordState() { weaponAnimation = GameData.ANIM_SWORD_HOLD; nextState = null; weapon = null; chargeTimer = 0; direction = Directions.Right; playerTool = null; }
public void EquipTool(UnitTool tool) { if (tools.Add(tool)) { tool.Unit = this; tool.IsEquipped = true; tool.OnEquip(); } }
//----------------------------------------------------------------------------- // Tools //----------------------------------------------------------------------------- public bool IsToolEquipped(UnitTool tool) { return tools.Contains(tool); }
private void Swing(int direction) { swingDirection = direction; swingAngleDirection = swingWindingOrders[swingDirection]; swingAngleStart = Directions.ToAngle(swingDirection); swingAngleStart = Angles.Subtract(swingAngleStart, swingAnglePullBack, swingAngleDirection); swingAngle = swingAngleStart; swingAngleIndex = 0; player.Direction = direction; playerTool = GetSwingTool(); player.EquipTool(playerTool); playerTool.AnimationPlayer.SubStripIndex = direction; if (player.IsInMinecart) { playerTool.PlayAnimation(weaponSwingAnimation); player.Graphics.PlayAnimation(playerSwingAnimationInMinecart); swingCollisionBoxes = swingCollisionBoxesNoLunge; } else if (lunge) { playerTool.PlayAnimation(weaponSwingAnimationLunge); player.Graphics.PlayAnimation(playerSwingAnimationLunge); swingCollisionBoxes = swingCollisionBoxesLunge; } else { playerTool.PlayAnimation(weaponSwingAnimation); player.Graphics.PlayAnimation(playerSwingAnimation); swingCollisionBoxes = swingCollisionBoxesNoLunge; } OnSwingBegin(); // Perform an initial swing tile peak. Vector2F hitPoint = player.Center + (Angles.ToVector(swingAngle, false) * 13); Point2I hitTileLocation = player.RoomControl.GetTileLocation(hitPoint); OnSwingTilePeak(swingAngle, hitTileLocation); // Invoke any actions set to occur at time 0. if (timedActions.ContainsKey(0)) timedActions[0].Invoke(); Rectangle2I toolBox = swingCollisionBoxes[swingDirection, Math.Min(swingCollisionBoxes.Length - 1, swingAngleIndex)]; toolBox.Point += (Point2I) player.CenterOffset; playerTool.CollisionBox = toolBox; }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnBegin(PlayerState previousState) { player.Movement.MoveCondition = PlayerMoveCondition.OnlyInAir; playerTool = player.ToolVisual; Swing(player.UseDirection); }
//----------------------------------------------------------------------------- // Tools //----------------------------------------------------------------------------- public bool IsToolEquipped(UnitTool tool) { return(tools.Contains(tool)); }