Ejemplo n.º 1
0
        public void HandleTransformations()
        {
            TransformationDefinition targetTransformation = null;
            TransformationDefinition transformation       = GetCurrentTransformation();

            if (ActiveTransformations.Count > 0 || PreviousTransformations.Count > 0)
            {
                PreviousTransformations = new List <TransformationDefinition>(ActiveTransformations);
            }

            // TODO Handle all of the multi-transformation aspects.
            // player has just pressed the normal transform button one time, which serves two functions.
            if (IsTransformingUpOneStep())
            {
                if (transformation != null && transformation.OnPlayerTryAscend(this))
                {
                    NodeTree <TransformationDefinition>       tree = TransformationDefinitionManager.Tree;
                    ManyToManyNode <TransformationDefinition> mtmn = tree[transformation];

                    if (mtmn.Next.Count == 0)
                    {
                        return;
                    }

                    // Find the first available transformation.
                    for (int i = 0; i < mtmn.Next.Count; i++)
                    {
                        // TODO Verify this is the actual method to use.
                        if (CanTransform(mtmn.Next[i]))
                        {
                            targetTransformation = mtmn.Next[i];
                            break;
                        }
                    }

                    // TODO Dynamicize this
                    // player is ascending transformation, pushing for ASSJ or USSJ depending on what form they're in.

                    /*if (IsAscendingTransformation() && CanAscend())
                     * {
                     *  if (transformation == TransformationDefinitionManager.SSJ1Definition)
                     *      targetTransformation = TransformationDefinitionManager.ASSJDefinition;
                     *  else if (transformation == TransformationDefinitionManager.ASSJDefinition)
                     *      targetTransformation = TransformationDefinitionManager.USSJDefinition;
                     * }*/
                }
                else
                {
                    // first attempt to step up to the selected form in the menu.
                    targetTransformation = SelectedTransformation;
                }

                // TODO Add this again maybe ?
                // if for any reason we haven't gotten our transformation target, try the next step instead.

                /*if (targetTransformation == null)
                 * {
                 *  targetTransformation = player.GetNextTransformationStep();
                 * }*/
            }
            else if (IsPoweringDownOneStep() && IsPlayerTransformed() && transformation.OnPlayerTryDescend(this) && transformation != TransformationDefinitionManager.KaiokenDefinition)
            {
                if (transformation.Parents.Length == 1)
                {
                    // player is powering down a transformation state.
                    targetTransformation = transformation.Parents[0];
                }
            }

            // if we made it this far without a target, it means for some reason we can't change transformations.
            if (targetTransformation == null)
            {
                return;
            }

            // finally, check that the transformation is really valid and then do it.
            if (CanTransform(targetTransformation))
            {
                TransformationDefinition lastTransformation = transformation;
                DoTransform(targetTransformation);

                if (lastTransformation != null)
                {
                    lastTransformation.OnTransformationEnded(this);
                }
            }
        }