Exemplo n.º 1
0
    private bool CellChangePartsMain(int idParts, int indexCellMap, int indexCell, Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute)
    {
        switch (DataAnimation.TableParts[idParts].Feature)
        {
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.ROOT:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.NULL:
            return(true);

        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.NORMAL_TRIANGLE2:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.NORMAL_TRIANGLE4:
            break;

        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.INSTANCE:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.EFFECT:
            return(true);

        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MASK_TRIANGLE2:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MASK_TRIANGLE4:
            break;

        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.JOINT:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.BONE:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MOVENODE:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.CONSTRAINT:
        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.BONEPOINT:
            return(true);

        case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MESH:
            return(true);
        }

        if ((0 > indexCellMap) || (0 > indexCell))
        {
            indexCellMap = -1;
            indexCell    = -1;
        }
        TableControlParts[idParts].ParameterSprite.DataCellApply.IndexCellMap = indexCellMap;
        TableControlParts[idParts].ParameterSprite.DataCellApply.IndexCell    = indexCell;
        TableControlParts[idParts].Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_UNREFLECTED;

        switch (ignoreAttribute)
        {
        case Library_SpriteStudio6.KindIgnoreAttribute.NON:
            TableControlParts[idParts].Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_ATTRIBUTE;
            TableControlParts[idParts].Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_NEWANIMATION;
            break;

        case Library_SpriteStudio6.KindIgnoreAttribute.NOW_ANIMATION:
            TableControlParts[idParts].Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_ATTRIBUTE;
            TableControlParts[idParts].Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_NEWANIMATION;
            break;

        case Library_SpriteStudio6.KindIgnoreAttribute.PERMANENT:
            TableControlParts[idParts].Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_ATTRIBUTE;
            TableControlParts[idParts].Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.CHANGE_CELL_IGNORE_NEWANIMATION;
            break;
        }

        return(true);
    }
Exemplo n.º 2
0
    /* ******************************************************** */
    //! Change Part's-Cell

    /*!
     * @param	idParts
     *      Parts-ID<br>
     *      -1 == All parts
     * @param	indexCellMap
     *      CellMap's index<br>
     *      -1 == Accorde to Animation-Data
     * @param	indexCell
     *      Cell's index in CellMap<br>
     *      -1 == Accorde to Animation-Data
     * @param	ignoreAttribute
     *      NON == Changed cell is overwritten when new "Reference Cell" attribute deecoded<br>
     *      NOW_ANIMATION == Ignore "Reference Cell" attribute until new animation starts playing<br>
     *      PERMANENT == Continue Ignoring "Reference Cell" attribute even if new animation starts playing
     * @retval	Return-Value
     *      true == Success <br>
     *      false == Failure (Error)
     *
     * Change the Cell that are displayed in the parts.<br>
     * <br>
     * This function must be called after "Start" and "Awake" are executed.<br>
     * <br>
     * When set part excepting "Draw-parts" to "idParts", this function returns true and ignore specifications.<br>
     * Also, if "idParts" is set to "-1", false is returned when error occurs in any of "Draw-parts" included in current animation.<br>
     *) "Draw-parts" mean "Normal(Sprite)"-parts and "Mask"-parts.<br>
     * <br>
     * Caution:<br>
     * This function returns error when animation with "Precalculation > Fix Sprite" set to "true" at import.<br>
     */
    public bool CellChangeParts(int idParts, int indexCellMap, int indexCell, Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute)
    {
        if ((null == DataAnimation) || (null == TableControlParts) || (null == TableControlTrack))
        {
            return(false);
        }

        if (0 > idParts)
        {               /* All Parts */
            int  countParts  = TableControlParts.Length;
            bool flagSuccess = true;
            for (int i = 0; i < countParts; i++)
            {
                flagSuccess &= CellChangePartsMain(i, indexCellMap, indexCell, ignoreAttribute);
            }

            return(flagSuccess);
        }

        if (TableControlParts.Length <= idParts)
        {
            return(false);
        }

        return(CellChangePartsMain(idParts, indexCellMap, indexCell, ignoreAttribute));
    }
Exemplo n.º 3
0
    /* ******************************************************** */
    //! Change "Instance"'s Animation (by name)

    /*!
     * @param	idParts
     *      Parts-ID ("Instance"-part)
     * @param	nameAnimation
     *      New "Instance"'s animation-name<br>
     *      "" or null == Change only "ignoreAttribute"
     * @param	ignoreAttribute
     *      NON == Restart animation when new "Instance" attribute deecoded<br>
     *      NOW_ANIMATION == Ignore "Instance" attribute until new animation starts playing<br>
     *      PERMANENT == Continue Ignoring "Instance" attribute even if new animation starts playing
     * @param	flagStartImmediate
     *      true == Animation is started immediate<br>
     *      false == Start playing according to "Instance" attribute
     * @param	timesPlay
     *      0 == Infinite-looping<br>
     *      1 == Not looping<br>
     *      2 <= Number of Plays
     * @param	rateTime
     *      Coefficient of time-passage of new animation.<br>
     *      Minus Value is given, Animation is played backwards.
     * @param	style
     *      Library_SpriteStudio6.KindStylePlay.NOMAL == Animation is played One-Way.<br>
     *      Library_SpriteStudio6.KindStylePlay.PINGPONG == Animation is played round-trip.
     * @param	labelRangeStart
     *      Label name to start playing animation.<br>
     *      "" or "_start" == Top frame of Animation ("_start" is reserved label-name)
     * @param	frameRangeOffsetStart
     *      Offset frame from labelRangeStart<br>
     *      Start frame of animation play range is "labelRangeStart + frameRangeOffsetStart".
     * @param	labelRangeEnd
     *      Label-name of the terminal in animation.<br>
     *      "" or "_end" == Last frame of Animation ("_end" is reserved label-name)
     * @param	frameRangeOffsetEnd
     *      Offset frame from labelRangeStart<br>
     *      End frame of animation play range is "labelRangeEnd + frameRangeOffsetEnd".
     * @retval	Return-Value
     *      true == Success<br>
     *      false == Failure (Error)
     *
     * Change "Instance"'s animation controled by part.<br>
     * <br>
     * To change "Instance"'s animation, use this function without calling "Instance"'s "Script_SpriteStudio6_Root.AnimationPlay".<br>
     * (Cause inconsistency with control from "Instance" part)<br>
     * <br>
     * As a general rule, no designation to "Do not change playing  parameters" like "AnimationPlay".<br>
     * The only exception is changing attribute-ignore setting(ignoreAttribute)  without changing the animation.<br>
     * When set null or "" to "nameAnimation", change only attribute-ignore setting.<br>
     * (The argument omission after "flagStartImmediate" is written to change only attribute-ignore setting)<br>
     * <br>
     * When "nameAnimation" is set normally animation name...<br>
     * If "flagStartImmediate" is set to true, "Instance"'s animation will be played immediately.<br>
     * In the case, "Instance" play behaves the same as when "Independent of time" is checked in the "Instance" attribute on SpriteStudio6.<br>
     * Conversely, If "flagStartImmediate" is set to false, forcefully wait for next data of "Instance" attribute and start playing at decoding new data.
     */
    public bool AnimationChangeInstance(int idParts,
                                        string nameAnimation,
                                        Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute,
                                        bool flagStartImmediate = false,
                                        int timesPlay           = 1,
                                        float rateTime          = 1.0f,
                                        Library_SpriteStudio6.KindStylePlay style = Library_SpriteStudio6.KindStylePlay.NORMAL,
                                        string labelRangeStart    = null,
                                        int frameRangeOffsetStart = 0,
                                        string labelRangeEnd      = null,
                                        int frameRangeOffsetEnd   = 0
                                        )
    {
        Script_SpriteStudio6_Root scriptRootInstance = InstanceGet(idParts);

        if (null == scriptRootInstance)
        {
            return(false);
        }

        int indexAnimation = -1;

        if (false == string.IsNullOrEmpty(nameAnimation))
        {
            indexAnimation = scriptRootInstance.IndexGetAnimation(nameAnimation);
            if (0 > indexAnimation)
            {
                return(false);
            }
        }

        return(AnimationChangeInstanceMain(ref TableControlParts[idParts],
                                           scriptRootInstance,
                                           indexAnimation,
                                           ignoreAttribute,
                                           flagStartImmediate,
                                           timesPlay,
                                           rateTime,
                                           style,
                                           labelRangeStart,
                                           frameRangeOffsetStart,
                                           labelRangeEnd,
                                           frameRangeOffsetEnd
                                           )
               );
    }
Exemplo n.º 4
0
    private bool AnimationChangeInstanceMain(ref Library_SpriteStudio6.Control.Animation.Parts controlParts,
                                             Script_SpriteStudio6_Root scriptRootInstance,
                                             int indexAnimation,
                                             Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute,
                                             bool flagStartImmediate,
                                             int timesPlay,
                                             float rateTime,
                                             Library_SpriteStudio6.KindStylePlay style,
                                             string labelRangeStart,
                                             int frameRangeOffsetStart,
                                             string labelRangeEnd,
                                             int frameRangeOffsetEnd
                                             )
    {
        if (null == TableControlTrack)
        {
            return(false);
        }
        if (0 > timesPlay)
        {
            return(false);
        }
        if (true == float.IsNaN(rateTime))
        {
            return(false);
        }

        Library_SpriteStudio6.Data.Animation.Attribute.Instance dataInstance = new Library_SpriteStudio6.Data.Animation.Attribute.Instance();
        dataInstance.Flags = Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.CLEAR;
        switch (style)
        {
        case Library_SpriteStudio6.KindStylePlay.NO_CHANGE:
            return(false);

        case Library_SpriteStudio6.KindStylePlay.NORMAL:
            break;

        case Library_SpriteStudio6.KindStylePlay.PINGPONG:
            dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.PINGPONG;
            break;
        }

        controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA;
        switch (ignoreAttribute)
        {
        case Library_SpriteStudio6.KindIgnoreAttribute.NON:
            controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE;
            controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION;

            dataInstance.Flags &= ~Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT;
            break;

        case Library_SpriteStudio6.KindIgnoreAttribute.NOW_ANIMATION:
            controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE;
            controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION;

            dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT;
            break;

        case Library_SpriteStudio6.KindIgnoreAttribute.PERMANENT:
            controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE;
            controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION;

            dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT;
            break;
        }

        dataInstance.PlayCount   = timesPlay;
        dataInstance.RateTime    = rateTime;
        dataInstance.LabelStart  = labelRangeStart;
        dataInstance.OffsetStart = frameRangeOffsetStart;
        dataInstance.LabelEnd    = labelRangeEnd;
        dataInstance.OffsetEnd   = frameRangeOffsetEnd;

        if (false == flagStartImmediate)
        {
            controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA;
        }
        else
        {
            controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA;

            /* MEMO: When does not start immediately, necessary to always decode next data, so turn off "Independent time" status. */
            controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_PLAY_INDEPENDENT;

            controlParts.IndexAnimationUnderControl = indexAnimation;
            controlParts.DataInstance = dataInstance;

            int indexTrack = controlParts.IndexControlTrack;
            if (0 <= indexTrack)
            {
                float rateTimeControlTrack = TableControlTrack[indexTrack].RateTime * ((true == TableControlTrack[indexTrack].StatusIsPlayingReverse) ? -1.0f : 1.0f);
                return(controlParts.InstancePlayStart(this, rateTimeControlTrack));
            }
        }

        return(true);
    }