public TargetingDummy(IPlayerManager playerManager, INetworkManager networkManager,
                              IResourceManager resourceManager)
        {
            _networkManager  = networkManager;
            _playerManager   = playerManager;
            _resourceManager = resourceManager;

            var head  = new TargetingDummyElement("dummy_head", BodyPart.Head, _resourceManager);
            var torso = new TargetingDummyElement("dummy_torso", BodyPart.Torso, _resourceManager);
            var groin = new TargetingDummyElement("dummy_groin", BodyPart.Groin, _resourceManager);
            var armL  = new TargetingDummyElement("dummy_arm_l", BodyPart.Left_Arm, _resourceManager);
            var armR  = new TargetingDummyElement("dummy_arm_r", BodyPart.Right_Arm, _resourceManager);
            var legL  = new TargetingDummyElement("dummy_leg_l", BodyPart.Left_Leg, _resourceManager);
            var legR  = new TargetingDummyElement("dummy_leg_r", BodyPart.Right_Leg, _resourceManager);

            _elements.Add(head);
            _elements.Add(torso);
            _elements.Add(groin);
            _elements.Add(armL);
            _elements.Add(armR);
            _elements.Add(legL);
            _elements.Add(legR);
            head.Clicked  += Selected;
            torso.Clicked += Selected;
            groin.Clicked += Selected;
            armL.Clicked  += Selected;
            armR.Clicked  += Selected;
            legL.Clicked  += Selected;
            legR.Clicked  += Selected;
            Update(0);
            UpdateHealthIcon();
        }
        public override bool MouseDown(MouseButtonEventArgs e)
        {
            if (!ClientArea.Contains(new Point((int)e.X, (int)e.Y)))
            {
                return(false);
            }

            TargetingDummyElement prevSelection = (from element in _elements
                                                   where element.IsSelected()
                                                   select element).FirstOrDefault();

            foreach (TargetingDummyElement toClear in _elements)
            {
                toClear.ClearSelected();
            }

            foreach (TargetingDummyElement current in _elements.ToArray())
            //To array because list order changes in loop.
            {
                if (current.MouseDown(e))
                {
                    _elements = (from a in _elements
                                 orderby(a == current) ascending
                                 select a).ToList();
                    return(true);
                }
            }

            if (prevSelection != null)
            {
                prevSelection.Select();
            }

            return(false);
        }
        public TargetingDummy(IPlayerManager playerManager, INetworkManager networkManager,
                              IResourceManager resourceManager)
        {
            _networkManager = networkManager;
            _playerManager = playerManager;
            _resourceManager = resourceManager;

            var head = new TargetingDummyElement("dummy_head", BodyPart.Head, _resourceManager);
            var torso = new TargetingDummyElement("dummy_torso", BodyPart.Torso, _resourceManager);
            var groin = new TargetingDummyElement("dummy_groin", BodyPart.Groin, _resourceManager);
            var armL = new TargetingDummyElement("dummy_arm_l", BodyPart.Left_Arm, _resourceManager);
            var armR = new TargetingDummyElement("dummy_arm_r", BodyPart.Right_Arm, _resourceManager);
            var legL = new TargetingDummyElement("dummy_leg_l", BodyPart.Left_Leg, _resourceManager);
            var legR = new TargetingDummyElement("dummy_leg_r", BodyPart.Right_Leg, _resourceManager);

            _elements.Add(head);
            _elements.Add(torso);
            _elements.Add(groin);
            _elements.Add(armL);
            _elements.Add(armR);
            _elements.Add(legL);
            _elements.Add(legR);
            head.Clicked += Selected;
            torso.Clicked += Selected;
            groin.Clicked += Selected;
            armL.Clicked += Selected;
            armR.Clicked += Selected;
            legL.Clicked += Selected;
            legR.Clicked += Selected;
            Update(0);
            UpdateHealthIcon();
        }
 private void Selected(TargetingDummyElement sender)
 {
     //Send server targeted location
     NetOutgoingMessage msg = _networkManager.CreateMessage();
     msg.Write((byte) NetMessage.PlayerSessionMessage);
     msg.Write((byte) PlayerSessionMessage.SetTargetArea);
     msg.Write((byte) sender.BodyPart);
     _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
 }
 private void Selected(TargetingDummyElement sender)
 {
     //Send server targeted location
     NetOutgoingMessage msg = _networkManager.CreateMessage();
     msg.Write((byte) NetMessage.PlayerSessionMessage);
     msg.Write((byte) PlayerSessionMessage.SetTargetArea);
     msg.Write((byte) sender.BodyPart);
     _networkManager.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
 }