コード例 #1
0
        public override void HandleMessage(ComponentMessage message, IComponent component)
        {
            base.HandleMessage(message, component);

            switch (message)
            {
            case PlayerAttachedMsg _:
                if (_gui == null)
                {
                    _gui = new HandsGui();
                }
                else
                {
                    _gui.Parent?.RemoveChild(_gui);
                }

                _gameHud.HandsContainer.AddChild(_gui);
                _gui.UpdateHandIcons();
                break;

            case PlayerDetachedMsg _:
                _gui.Parent?.RemoveChild(_gui);
                break;
            }
        }
コード例 #2
0
        public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
                                           IComponent component = null)
        {
            base.HandleMessage(message, netChannel, component);

            switch (message)
            {
            case PlayerAttachedMsg _:
                if (_gui == null)
                {
                    _gui = new HandsGui();
                }
                else
                {
                    _gui.Parent?.RemoveChild(_gui);
                }

                _userInterfaceManager.StateRoot.AddChild(_gui);
                _gui.UpdateHandIcons();
                break;

            case PlayerDetachedMsg _:
                _gui.Parent?.RemoveChild(_gui);
                break;
            }
        }
コード例 #3
0
        public override void HandleComponentState(ComponentState state)
        {
            var cast = (HandsComponentState)state;

            hands.Clear();
            foreach (var hand in cast.Hands)
            {
                IEntity entity = null;
                try
                {
                    entity = Owner.EntityManager.GetEntity(hand.Value);
                }
                catch
                {
                    // Nothing.
                }
                hands[hand.Key] = entity;
            }

            ActiveIndex = cast.ActiveIndex;
            // Tell UI to update.
            var uiMgr = IoCManager.Resolve <IUserInterfaceManager>();

            if (!uiMgr.StateRoot.TryGetChild <HandsGui>("HandsGui", out var control))
            {
                control = new HandsGui();
                uiMgr.StateRoot.AddChild(control);
            }
            control.UpdateHandIcons();
        }
コード例 #4
0
 public void TestCalculateCooldownLevel()
 {
     Assert.AreEqual(HandsGui.CalculateCooldownLevel(0.5f), 4);
     Assert.AreEqual(HandsGui.CalculateCooldownLevel(1), 8);
     Assert.AreEqual(HandsGui.CalculateCooldownLevel(0), 0);
 }