Ejemplo n.º 1
0
        public void MovePips(PipModel PipSection)
        {
            if (Updated == null)
            {
                throw new ArgumentNullException(nameof(Updated));
            }

            // if there are not enough pips to give or the pip in question is locked or the max cap has been reached, return.
            if (PipSection.MaxCap <= 0 ||
                PipSection.Locked)
            {
                return;
            }

            // If the left trigger or num pad plus is held then return all pips
            if (Refunding)
            {
                Damageable.GetBackLoanHealth(PipSection);
                if (playerHealth.CurHealth > playerHealth.MaxHP)
                {
                    RectTransform rectTransform = new RectTransform();
                    for (int tempPipsToAdd = playerHealth.CurHealth - playerHealth.MaxHP;
                         tempPipsToAdd > 0; tempPipsToAdd--)
                    {
                        // Just add the largest key so it is added to the end of the LL. The visuals will be updated later.
                        pipLinkedList.AddNode(new PipNode(PipNode.StatusKey.Damaged));
                    }
                }
                Updated.Invoke(PipSection, PipPadTextHolder, PipPadImageHolder);
                UpdateHPPips(playerHealth);
                PipSection.ApplyPipModifications(PlayerCharacter);
                return;
            }


            if (playerHealth.RealHp > playerHealth.MinRealHp &&
                PipSection.Allocated < PipSection.MaxCap)
            {
                // Call Pip Display to remove a pip and replace it with an empty one
                // Call the Damagable script lose a perm health
                PipSection.Allocated++;
                Damageable.LoanHealth(1);
                Updated.Invoke(PipSection, PipPadTextHolder, PipPadImageHolder);
                PipSection.ApplyPipModifications(PlayerCharacter);
            }
        }