Ejemplo n.º 1
0
        public void AddNode(PipNode NewNode)
        {
            Count++;
            //if (NewNode == null)
            //    throw new ArgumentNullException();

            if (Head == null || (Head.PipState > NewNode.PipState))
            {
                NewNode.NextNode = Head;
                Head             = NewNode;
                return;
            }

            PipNode prevNode = Head;
            PipNode nextNode = Head.NextNode;

            // walk through the LinkedList until it reaches the end or the new node is smaller than the next.
            // This keeps both the priority and integrity of insertion order.
            while (nextNode != null)
            {
                if (nextNode?.PipState > NewNode.PipState)
                {
                    prevNode.NextNode = NewNode;
                    NewNode.NextNode  = nextNode;
                    return;
                }
                prevNode = nextNode;
                nextNode = nextNode.NextNode;
            }

            prevNode.NextNode = PositionNode(prevNode, NewNode);
        }
Ejemplo n.º 2
0
        public void UpdateNodes(PlayerHealth playerHealth)
        {
            PipNode nodeWalker = Head;
            PipNode lastNode   = null;

            Count      = 0;
            nodeWalker = WalkThroughList(nodeWalker, playerHealth, PipNode.StatusKey.Real, ref lastNode);
            nodeWalker = WalkThroughList(nodeWalker, playerHealth, PipNode.StatusKey.Temp, ref lastNode);
            CheckStateOfTemp(lastNode);
            if (lastNode != null &&
                lastNode.PipState == PipNode.StatusKey.Temp)
            {
                LastTempPip = lastNode;
            }

            nodeWalker = WalkThroughList(nodeWalker, playerHealth, PipNode.StatusKey.Lent, ref lastNode);
            nodeWalker = WalkThroughList(nodeWalker, playerHealth, PipNode.StatusKey.Damaged, ref lastNode);
            if (nodeWalker != null)
            {
                if (lastNode.NextNode == LastTempPip)
                {
                    LastTempPip = null;
                }
                lastNode.NextNode = null;

                RemoveNodeRecursive(nodeWalker);
            }
        }
Ejemplo n.º 3
0
        private PipNode PositionNode(PipNode PreviousNode, PipNode NewNode)
        {
            RectTransform rectTransform = (RectTransform)PreviousNode.gameObject.transform;

            // unfortunately, something about setting the Vector 3 in the Instantiate is thrown off, and it ends up adding the Canvas transform to the new items transform
            // instead of the value passed in. Setting the anchored position afterworlds makes it so the Instantiated spawn exactly where they need to.
            RectTransform newrectTransform = null;

            if (NewNode == null)
            {
                NewNode = Instantiate(PipPrefab,
                                      new Vector3(rectTransform.anchoredPosition.x + rectTransform.rect.width + 5f,
                                                  rectTransform.anchoredPosition.y),
                                      rectTransform.transform.rotation,
                                      Hp_PipPool.transform).GetComponent <PipNode>();
                NewNode.gameObject.name = PipPrefab.name + Count.ToString();

                newrectTransform = (RectTransform)NewNode.gameObject.transform;
                newrectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + rectTransform.rect.width + 5f, rectTransform.anchoredPosition.y);

                return(NewNode);
            }

            NewNode.gameObject.transform.position = new Vector3(rectTransform.anchoredPosition.x + rectTransform.rect.width + 5f,
                                                                rectTransform.anchoredPosition.y);
            NewNode.gameObject.name           = PipPrefab.name + Count.ToString();
            newrectTransform                  = (RectTransform)NewNode.gameObject.transform;
            newrectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + rectTransform.rect.width + 5f, rectTransform.anchoredPosition.y);

            return(NewNode);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// PipPoolDisplay Rulees. There are so far 4 states which need to be taken into consideration.
        /// 1. Normal - Health is stable and will only changed if funnled to the PipPad or depleted by damaged. Is used after any temnp for damage
        /// 2. Damaged - Health that is empty and caused by enemy damage. Can be refilled by back to Nomral by killing enemies.
        /// 3. Funneled - Health that is empty and caused by being funneled to the pippad. Can be filled to normal by returning pips from the pippad.
        /// Can be filled by a temp by killing an enemy.
        /// 4. Temp - Health is unstable and cannot be funneled into the pippad. Usually only gained when there is no damaged health and killed an enemy
        /// while there is funneled Health. When taking damage, used before normal Health. Temp health degrades over time. Degrading time is reset to
        /// full if an enemy is hit before it is entirely depleted to funneled. If funneled health is returned while temp health exists, the temp stays
        /// as extra health but will not have its degrade time reset.
        /// Resets - 4 slots with extra temp NNDTT. one N gets filtered NFDTT and is in turn filled by temp NDTT. Since four slots and both temp are wirhin the max pool cap they can be reset
        /// Does Not Reset - 4 slots with extra temp NNDTT. one N gets filtered NFDTT and is in turn filled by temp NDTT. Since four slots and both temp are wirhin the max pool cap they can be reset
        /// </summary>
        /// <param name="pipModel"></param>
        public void UpdatePipPoolDisplay(PipNode pipModel)
        {
            PipNode walker = pipModel;

            while (walker != null)
            {
                switch (walker.PipState)
                {
                case PipNode.StatusKey.Real:
                    walker.PipDisplayImage.sprite = pipFullHPPrefab.GetComponent <Image>().sprite;
                    walker.PipDisplayImage.color  = Enabled;
                    break;

                case PipNode.StatusKey.Temp:
                    walker.PipDisplayImage.sprite = pipFullHPPrefab.GetComponent <Image>().sprite;
                    walker.PipDisplayImage.color  = Temp;
                    break;

                case PipNode.StatusKey.Damaged:
                    walker.PipDisplayImage.sprite = pipFullHPPrefab.GetComponent <Image>().sprite;
                    walker.PipDisplayImage.color  = Disabled;
                    break;

                case PipNode.StatusKey.Lent:
                    walker.PipDisplayImage.sprite = pipLentHPPrefab.GetComponent <Image>().sprite;
                    walker.PipDisplayImage.color  = Color.white;
                    break;

                default:
                    break;
                }

                walker = walker.NextNode;
            }
        }
Ejemplo n.º 5
0
 private void CheckStateOfTemp(PipNode LastNode)
 {
     // The Temp pip has changed set the last temp pip to its original size
     if (LastTempPip != null && LastTempPip != LastNode)
     {
         LastTempPip.gameObject.transform.localScale = new Vector3(1, 1, 1);
     }
 }
Ejemplo n.º 6
0
        private void RemoveNodeRecursive(PipNode pipNode)
        {
            if (pipNode.NextNode != null)
            {
                RemoveNodeRecursive(pipNode.NextNode);
            }

            Destroy(pipNode.gameObject);
        }
Ejemplo n.º 7
0
 public PipLinkedList(
     PipNode head,
     GameObject pipPrefab,
     GameObject hp_PipPool,
     Queue <GameObject> hpPips)
 {
     Head = head;
     Count++;
     PipPrefab  = pipPrefab;
     Hp_PipPool = hp_PipPool;
     HpPips     = hpPips;
 }
Ejemplo n.º 8
0
        private PipNode WalkThroughList(PipNode nodeWalker, PlayerHealth playerHealth, PipNode.StatusKey statusKey, ref PipNode lastNode)
        {
            int valueToWalk = 0;

            switch (statusKey)
            {
            case PipNode.StatusKey.Real:
                valueToWalk = playerHealth.RealHp;
                break;

            case PipNode.StatusKey.Temp:
                valueToWalk = playerHealth.TempHp;
                break;

            case PipNode.StatusKey.Lent:
                // If for every temp hp, use a lent HPs spot
                valueToWalk = playerHealth.LentHp - playerHealth.TempHp;
                break;

            case PipNode.StatusKey.Damaged:
                valueToWalk = playerHealth.DamagedHealth;
                break;
            }

            for (int walker = 0; walker < valueToWalk; walker++)
            {
                if (nodeWalker == null)
                {
                    AddNode(new PipNode(statusKey));
                    continue;
                }
                // Count is updated in the add node function so other functionality can add nodes and the count will still be updated properly.
                Count++;
                nodeWalker.PipState = statusKey;
                lastNode            = nodeWalker;
                nodeWalker          = nodeWalker.NextNode;
            }

            return(nodeWalker);
        }
Ejemplo n.º 9
0
        //public PipNode PreviousNode { get; set; }

        public PipNode(StatusKey pipState, PipNode nextNode = null)//, PipNode previousNode = null)
        {
            PipState = pipState;
            NextNode = nextNode;
            //PreviousNode = previousNode;
        }