protected override void SequenceStartBranch()
        {
            switch (SequenceStep)
            {
            case 0:
                SegmentTexUI        = new UICroppedTexture2D(SegmentTex);
                SegmentTexUI.Origin = new Vector2(.5f, .5f);

                User.BManager.battleUIManager.AddUIElement(SegmentTexUI);

                //Start it out being underneath, where the segment would be
                SegmentTexUI.Position = Camera.Instance.SpriteToUIPos(User.Position + new Vector2(0f, SegmentTex.SourceRect.Value.Height * SegmentBehavior.CurSegmentCount));

                //Remove a segment
                SegmentBehavior.HandleSegmentRemoved(1);

                //Move the segment above the user's head
                CurSequenceAction = new MoveToSeqAction(SegmentTexUI, Camera.Instance.SpriteToUIPos(User.GetDrawnPosAbove(new Vector2(0f, -SegmentTex.SourceRect.Value.Height))),
                                                        UpMoveTime, Interpolation.InterpolationTypes.Linear, Interpolation.InterpolationTypes.CubicInOut);

                break;

            case 1:
                //Wait a little bit
                CurSequenceAction = new WaitSeqAction(WaitTime);

                ChangeSequenceBranch(SequenceBranch.Main);
                break;

            default:
                PrintInvalidSequence();
                break;
            }
        }
        protected override void OnEnd()
        {
            base.OnEnd();

            if (SegmentTexUI != null)
            {
                User.BManager.battleUIManager.RemoveUIElement(SegmentTexUI);
                SegmentTexUI = null;
            }

            SegmentTex      = null;
            SegmentBehavior = null;
        }
        protected override void OnStart()
        {
            base.OnStart();

            //Ensure that we have a usable ItemAction
            //This can be null at this point if the Sequence's MoveAction
            //was passed in as null in the constructor and set later on
            if (itemAction == null)
            {
                itemAction = (ItemAction)Action;
            }

            if (itemAction.ItemUsed.Icon != null || itemAction.ItemUsed.Icon.Tex != null)
            {
                ItemShown = new UICroppedTexture2D(itemAction.ItemUsed.Icon.Copy());
            }
        }
        private void Initialize()
        {
            //Define the UI to display
            Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png");

            CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46));

            Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White);

            MarioHPIcon = new UICroppedTexture2D(new CroppedTexture2D(AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleHUD.png"),
                                                                      new Rectangle(2, 38, 45, 41)));
            FPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(179, 416, 40, 39)));

            MarioHPText = new UIText("0", Color.White);
            FPText      = new UIText("0", Color.Black);

            //Set UI properties
            MarioHPIcon.Position = MarioHPText.Position = ActionCmd.StartPosition + new Vector2(-10, -45);
            FPIcon.Position      = FPText.Position = ActionCmd.StartPosition + new Vector2(-45, -95);

            MarioHPText.Position += new Vector2(0f, 10f);
            FPText.Position      += new Vector2(0f, 10f);

            if (ShowPartnerInfo == true)
            {
                PartnerHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58)));
                PartnerHPText = new UIText("0", Color.White);

                PartnerHPIcon.Position  = PartnerHPText.Position = ActionCmd.StartPosition + new Vector2(-80, -45);
                PartnerHPText.Position += new Vector2(0f, 10f);
                PartnerHPIcon.Origin    = PartnerHPText.Origin = new Vector2(.5f, .5f);
                PartnerHPIcon.Depth     = .6f;
                PartnerHPText.Depth     = .61f;
            }

            MarioHPIcon.Depth = FPIcon.Depth = .6f;
            MarioHPText.Depth = FPText.Depth = .61f;

            MarioHPIcon.Origin = FPIcon.Origin = MarioHPText.Origin = FPText.Origin = new Vector2(.5f, .5f);

            //Set cursor position
            Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(ActionCmd.StartPosition, ActionCmd.CircleRadius), ActionCmd.CursorAngle, true);
        }
Exemple #5
0
        protected override void OnStart()
        {
            base.OnStart();

            //If the BattleEntity to be revived isn't currently in battle, don't wait
            if (RevivedEntity.IsInBattle == false)
            {
                EndTime = 0d;
                return;
            }

            //Show the item over the BattleEntity's head
            if (RevivalItem.Icon != null || RevivalItem.Icon.Tex != null)
            {
                RevivalItemShown          = new UICroppedTexture2D(RevivalItem.Icon.Copy());
                RevivalItemShown.Position = Camera.Instance.SpriteToUIPos(RevivedEntity.Position + new Vector2(0, -20));

                RevivedEntity.BManager.battleUIManager.AddUIElement(RevivalItemShown);
            }
        }
Exemple #6
0
        public override void EndInput()
        {
            base.EndInput();

            ElapsedTime = 0d;

            //Clean up any remaining stars
            for (int i = 0; i < StarsThrown.Count; i++)
            {
                BattleUIManager.Instance.RemoveUIElement(StarsThrown[i]);
                StarsThrown.RemoveAt(i);
                i--;
            }

            //Remove any UI we added
            BattleUIManager.Instance.RemoveUIElement(Cursor);
            BattleUIManager.Instance.RemoveUIElement(MarioHPIcon);
            BattleUIManager.Instance.RemoveUIElement(PartnerHPIcon);
            BattleUIManager.Instance.RemoveUIElement(FPIcon);
            BattleUIManager.Instance.RemoveUIElement(MarioHPText);
            BattleUIManager.Instance.RemoveUIElement(PartnerHPText);
            BattleUIManager.Instance.RemoveUIElement(FPText);

            Cursor = null;
            MarioHPIcon = null;
            PartnerHPIcon = null;
            FPIcon = null;
            MarioHPText = null;
            PartnerHPText = null;
            FPText = null;

            IconSpawner.CleanUp();
            IconSpawner = null;

            HealingResponse = default(SweetTreatResponse);
        }
Exemple #7
0
        protected override void OnEnd()
        {
            base.OnEnd();

            //Remove the item over the BattleEntity's head
            if (RevivalItemShown != null)
            {
                RevivedEntity.BManager.battleUIManager.RemoveUIElement(RevivalItemShown);
                RevivalItemShown = null;
            }

            //Revive the BattleEntity only if it's currently in battle
            if (RevivedEntity.IsInBattle == true)
            {
                //Get revival data from the item
                IRevivalItem revivalData = RevivalItem as IRevivalItem;
                if (revivalData != null)
                {
                    //If the revival item heals 0 or fewer HP, log a warning
                    if (revivalData.RevivalHPRestored <= 0)
                    {
                        Debug.LogWarning($"{RevivalItem.Name} heals 0 or fewer HP, so {RevivedEntity.Name} won't actually be revived!");
                    }

                    //Heal HP
                    RevivedEntity.HealHP(revivalData.RevivalHPRestored);

                    //Play the idle animation
                    RevivedEntity.AnimManager.PlayAnimation(RevivedEntity.GetIdleAnim());

                    //Remove the item
                    //For players, remove it from the inventory
                    if (RevivedEntity.EntityType == Enumerations.EntityTypes.Player)
                    {
                        Inventory.Instance.RemoveItem(RevivalItem);
                    }
                    //It has to be an enemy, so remove its held item
                    else
                    {
                        BattleEnemy revivedEnemy = (BattleEnemy)RevivedEntity;
                        revivedEnemy.SetHeldCollectible(null);
                    }
                }
                else
                {
                    Debug.LogError($"{RevivalItem.Name} does not implement {nameof(IRevivalItem)}, so {RevivedEntity.Name} can't be revived!");
                }

                //Failsafe; handle a dead BattleEntity in the event the RevivalItem doesn't actually revive or heal
                if (RevivedEntity.IsDead == true)
                {
                    RevivedEntity.BManager.HandleEntityDeath(RevivedEntity);
                }
            }
            else
            {
                Debug.LogWarning($"{RevivedEntity.Name} isn't in battle and thus won't be revived!");
            }

            //Clear references
            RevivedEntity = null;
            RevivalItem   = null;
        }
Exemple #8
0
        public override void StartInput(params object[] values)
        {
            base.StartInput(values);

            ElapsedTime = 0d;
            PrevThrow = 0d;

            StartPosition = Camera.Instance.SpriteToUIPos((Vector2)values[0]);

            //Count how many BattleEntities are affected
            //If there's only one, then don't add any of the Partner information
            int entitiesAffected = (int)values[1];

            CursorAngle = MinCursorAngle;

            //Define the UI to display
            Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png");

            CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46));
            Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White);

            MarioHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58)));
            FPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(179, 416, 40, 39)));

            MarioHPText = new UIText("0", Color.Black);
            FPText = new UIText("0", Color.Black);

            //Set UI properties
            MarioHPIcon.Position = MarioHPText.Position = StartPosition + new Vector2(-10, -45);
            FPIcon.Position = FPText.Position = StartPosition + new Vector2(-45, -95);

            MarioHPText.Position += new Vector2(0f, 10f);
            FPText.Position += new Vector2(0f, 10f);

            if (entitiesAffected > 1)
            {
                PartnerHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58)));
                PartnerHPText = new UIText("0", Color.Black);

                PartnerHPIcon.Position = PartnerHPText.Position = StartPosition + new Vector2(-80, -45);
                PartnerHPText.Position += new Vector2(0f, 10f);
                PartnerHPIcon.Origin = PartnerHPText.Origin = new Vector2(.5f, .5f);
                PartnerHPIcon.Depth = .6f;
                PartnerHPText.Depth = .61f;
            }

            MarioHPIcon.Depth = FPIcon.Depth = .6f;
            MarioHPText.Depth = FPText.Depth = .61f;

            MarioHPIcon.Origin = FPIcon.Origin = MarioHPText.Origin = FPText.Origin = new Vector2(.5f, .5f);

            //Set cursor position
            Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(StartPosition, CircleRadius), CursorAngle, true);

            //Define the spawner
            Vector2 startPos = new Vector2(500, 15);
            Vector2 endPos = new Vector2(startPos.X, BattleManager.Instance.PartnerPos.Y + 350f);

            RestoreTypes[] restoreTypes = null;
            int[] restoreTypeCounts = null;
            if (entitiesAffected <= 1)
            {
                restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom };
                restoreTypeCounts = new int[] { 14, 6, 2 };
            }
            else
            {
                restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.PartnerHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom };
                restoreTypeCounts = new int[] { 7, 7, 6, 2 };
            }

            IconSpawner = new SweetTreatElementSpawner(4, 40f, 5000d, 750d, startPos, endPos, restoreTypes, restoreTypeCounts);

            //Add the cursor and other UI elements
            BattleUIManager.Instance.AddUIElement(Cursor);
            BattleUIManager.Instance.AddUIElement(MarioHPIcon);
            BattleUIManager.Instance.AddUIElement(FPIcon);
            BattleUIManager.Instance.AddUIElement(MarioHPText);
            BattleUIManager.Instance.AddUIElement(FPText);

            if (entitiesAffected > 1)
            {
                BattleUIManager.Instance.AddUIElement(PartnerHPIcon);
                BattleUIManager.Instance.AddUIElement(PartnerHPText);
            }

            HealingResponse = default(SweetTreatResponse);
        }