/// <summary> /// Updates the item's position in the turn order based upon its priority /// </summary> public void UpdatePriority(ITurnBased <T> item) { // TODO: Proceed to node following current prior to priorty change when end turn is called if (item == Current) { throw new NotImplementedException("Cannot update priority of current node"); } // Can't update item marked for removal if (currentToBeRemoved && currentNode.Value == item) { throw new ArgumentException("Order does not contain item"); } // Remove from order bool removed = Remove(item); // Can't update item if it doesn't exists in order if (removed == false) { throw new ArgumentException("Order does not contain item"); } // Re-insert into order in correct position Insert(item); }
/// <summary> /// Removes the item from the turn order /// </summary> public bool Remove(ITurnBased <T> item) { // Can't remove null item if (item == null) { throw new ArgumentNullException("item cannot be null"); } // Find item's node incase its the current node LinkedListNode <ITurnBased <T> > node = items.Find(item); if (node == null) { return(false); } // If current item is being removed, marked it as removed if (node == currentNode) { currentToBeRemoved = true; } else { items.Remove(node); } // Item successfully removed Count--; return(true); }
private void HandleOnTurnEnd(ITurnBased entity) { // If the last sequence is still in progress - force // it to be complete so we can start the next one. if (slideSequence != null && slideSequence.active) { slideSequence.Complete(true); } // Get the frame of the actor whose turn it just was. TurnOrderUIFrame lastActorFrame = GetLastFrame(); // Duplicate the frame at the start of the order. AddFrame(lastActorFrame.Actor, true); // Slide the order along to hide the actor who just went slideSequence = DOTween.Sequence(); if (horizontal) { slideSequence.Append(slideyBitRectTransform.DOAnchorPosX(FrameSize, slideDuration)); } else { slideSequence.Append(slideyBitRectTransform.DOAnchorPosY(FrameSize, slideDuration)); } slideSequence.AppendCallback(() => { // Get rid of the original previous actor's frame // and reset the position of the slider. DestroyImmediate(lastActorFrame.gameObject); slideyBitRectTransform.anchoredPosition = Vector2.zero; }); }
private void HandleOnTurnStart(ITurnBased obj) { if (focusOnCurrentActor) { Pawn actor = obj as Pawn; Vector3 actorWorldPosition = actor.WorldPosition; Vector3 freezeZPos = new Vector3(actorWorldPosition.x, actorWorldPosition.y, translationTransform.position.z); lookAtSequence = DOTween.Sequence(); lookAtSequence.Append(camera.DOOrthoSize(camera.orthographicSize * orthographicSizePunchFactor, movementDuration / 2).SetEase(orthographicSizePunchOutEasing)); lookAtSequence.Insert(movementDuration / 2f, camera.DOOrthoSize(startOrthographicSize, movementDuration / 2).SetEase(orthographicSizePunchReturnEasing)); lookAtSequence.Insert(0f, translationTransform.DOMove(freezeZPos, movementDuration).SetEase(movementEasing)); lookAtSequence.Play(); } }
/// <summary> /// Inserts the item in order based upon its priority /// </summary> public void Insert(ITurnBased <T> item) { // Can't insert null item if (item == null) { throw new ArgumentNullException("item cannot be null"); } // Can't have duplicates in order if (items.Contains(item)) { throw new ArgumentException("Order already contains item"); } // First item to be inserted if (items.Count == 0) { items.AddFirst(item); } else { var walker = items.First; // Walk until finding a smaller node while (walker != null && item.Priority.CompareTo(walker.Value.Priority) < 0) { walker = walker.Next; } // Add to end of order if (walker == null) { items.AddLast(item); } // Add in front of smaller node else { items.AddBefore(walker, item); } } Count++; }
/// <summary> /// Updates the given actors order in the turn. /// </summary> public void UpdatePosition(ITurnBased actor) { turnOrder.UpdatePosition(actor); }
/// <summary> /// Removes the given actor from the turn order. /// </summary> public bool Remove(ITurnBased actor) { return(turnOrder.Remove(actor)); }
/// <summary> /// Adds the given actor to the turn order. /// </summary> public void Add(ITurnBased actor) { turnOrder.Add(actor); }
private void HandleOnTurnStart(ITurnBased obj) { // Clear old actor, get the one whose turn it is. ActionManager.Instance.ClearSelectedActor(); ActionManager.Instance.SelectActor(obj as Pawn); }