示例#1
0
 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;
 }
示例#3
0
 public void EquipTool(UnitTool tool)
 {
     if (tools.Add(tool))
     {
         tool.Unit       = this;
         tool.IsEquipped = true;
         tool.OnEquip();
     }
 }
示例#4
0
 public void UnequipTool(UnitTool tool)
 {
     if (tools.Remove(tool)) {
         tool.IsEquipped = false;
         tool.OnUnequip();
     }
 }
示例#5
0
 //-----------------------------------------------------------------------------
 // Tools
 //-----------------------------------------------------------------------------
 public bool IsToolEquipped(UnitTool tool)
 {
     return tools.Contains(tool);
 }
示例#6
0
 public void EquipTool(UnitTool tool)
 {
     if (tools.Add(tool)) {
         tool.Unit = this;
         tool.IsEquipped = true;
         tool.OnEquip();
     }
 }
        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);
 }
示例#9
0
        //-----------------------------------------------------------------------------
        // Tools
        //-----------------------------------------------------------------------------

        public bool IsToolEquipped(UnitTool tool)
        {
            return(tools.Contains(tool));
        }