示例#1
0
 /// <summary>
 /// Set the Active hand of the Player to be the AttachedContainer passed in parameter.
 /// Do nothing if the parameter is the already active parameter.
 /// </summary>
 /// <param name="selectedContainer">This AttachedContainer should only be a hand.</param>
 public void SetActiveHand(AttachedContainer selectedContainer)
 {
     if (selectedContainer == SelectedHand)
     {
         return;
     }
     else
     {
         SelectedHandIndex = HandContainers.ToList().IndexOf(selectedContainer);
         if (SelectedHandIndex != -1)
         {
             HandChanged?.Invoke(SelectedHandIndex);
             CmdSetActiveHand(SelectedHandIndex);
         }
         else
         {
             Debug.LogError("selectedContainer is not in HandContainers.");
             return;
         }
     }
 }
示例#2
0
        public override void Update()
        {
            base.Update();

            if (!isLocalPlayer)
            {
                return;
            }

            // Hand-related buttons
            if (Input.GetButtonDown("Swap Active") && HandContainers.Length > 0)
            {
                SelectedHandIndex = (SelectedHandIndex + 1) % HandContainers.Length;
                HandChanged?.Invoke(SelectedHandIndex);
                CmdSetActiveHand(SelectedHandIndex);
            }

            if (Input.GetButtonDown("Drop Item"))
            {
                CmdDropHeldItem();
            }
        }
示例#3
0
 /// <summary>
 /// Method for HandChanged event triggering.
 /// </summary>
 /// <param name="args">HandChangedEventArgs object.</param>
 protected virtual void OnHandChanged(HandChangedEventArgs args)
 {
     // Uses null-conditional operator.
     HandChanged?.Invoke(this, args);
 }