public void changeResources(EDragonStateAction stateAction)
    {
        string        branch    = ConvertSupportor.convertUpperFirstChar(PlayerInfo.Instance.dragonInfo.id);
        float         timeFrame = (float)getValueFromDatabase(EAnimationDataType.TIME_FRAME);
        EventDelegate callback  = null;

        switch (stateAction)
        {
        case EDragonStateAction.IDLE:
            animationFrames.createAnimation(EDragonStateAction.IDLE, "Image/Dragon/Player/" + branch + "/Idle", timeFrame, true);
            break;

        case EDragonStateAction.MOVE:
            animationFrames.createAnimation(EDragonStateAction.MOVE, "Image/Dragon/Player/" + branch + "/Move", timeFrame, true);
            break;

        case EDragonStateAction.ATTACK:
            animationFrames.createAnimation(EDragonStateAction.ATTACK, "Image/Dragon/Player/" + branch + "/Attack", timeFrame, true);
            callback = new EventDelegate(controller.stateAttack.attackEnemy);
            break;

        case EDragonStateAction.DIE:
            animationFrames.createAnimation(EDragonStateAction.DIE, "Image/Dragon/Player/" + branch + "/Die", timeFrame, true);
            callback = new EventDelegate(controller.stateDie.fadeOutSprites);
            //animationFrames.addEventLastKey(new EventDelegate(controller.stateDie.fadeOutSprites), false);
            break;
        }

        object[] events = (object[])getValueFromDatabase(EAnimationDataType.EVENT);
        if (events.Length != 0)
        {
            animationFrames.addEvent(events, callback, false);
        }
    }
Example #2
0
    public void changeResources()
    {
        float         timeFrame = (float)getValueFromDatabase(EAnimationDataType.TIME_FRAME);
        EventDelegate callback  = null;

        switch (controller.StateAction)
        {
        case EEnemyStateAction.ATTACK:
            animationFrames.createAnimation(EEnemyStateAction.ATTACK, "Image/Enemy/" + controller.ID + "/Attack", timeFrame, true);
            if (controller.stateAttack.target.GetComponent <DragonController>() != null)
            {
                callback = new EventDelegate(controller.stateAttack.attackDragon);
            }
            else
            {
                callback = new EventDelegate(controller.stateAttack.attackDragonBaby);
            }
            currentKey = controller.StateAction;
            break;

        case EEnemyStateAction.DIE:
            animationFrames.createAnimation(EEnemyStateAction.DIE, "Image/Enemy/" + controller.ID + "/Die", timeFrame, true);
            callback   = new EventDelegate(GetComponent <AutoDestroy>().destroyParent);
            currentKey = controller.StateAction;
            break;

        case EEnemyStateAction.MOVE:
            switch (controller.StateDirection)
            {
            case EDirection.BOTTOM:
                animationFrames.createAnimation(EEnemyStateAction.MOVE.ToString() + "_" + EDirection.BOTTOM.ToString(), "Image/Enemy/" + controller.ID + "/Bottom", timeFrame, true);
                break;

            case EDirection.LEFT:
                animationFrames.createAnimation(EEnemyStateAction.MOVE.ToString() + "_" + EDirection.LEFT.ToString(), "Image/Enemy/" + controller.ID + "/Left", timeFrame, true);
                break;

            case EDirection.RIGHT:
                animationFrames.createAnimation(EEnemyStateAction.MOVE.ToString() + "_" + EDirection.RIGHT.ToString(), "Image/Enemy/" + controller.ID + "/Right", timeFrame, true);
                break;

            case EDirection.UP:
                animationFrames.createAnimation(EEnemyStateAction.MOVE.ToString() + "_" + EDirection.UP.ToString(), "Image/Enemy/" + controller.ID + "/Up", timeFrame, true);
                break;
            }
            currentKey = EEnemyStateAction.MOVE.ToString() + "_" + controller.StateDirection.ToString();
            break;
        }

        object[] events = (object[])getValueFromDatabase(EAnimationDataType.EVENT);
        if (events.Length != 0)
        {
            animationFrames.addEvent(events, callback, false);
        }
    }
    public void changeResources(ESkillAction stateAction)
    {
        if (stateAction == ESkillAction.DESTROY)
        {
            MonoBehaviour.Destroy(controller.gameObject);
            return;
        }

        currentState = stateAction;
        float  timeFrame    = (float)getValueFromDatabase(EAnimationDataType.TIME_FRAME);
        string resourcePath = getValueFromDatabase(EAnimationDataType.RESOURCE_PATH).ToString().Trim();

        object[]      specificLoop = (object[])getValueFromDatabase(EAnimationDataType.SPECIFIC_LOOP);
        EventDelegate callback     = null;

        switch (stateAction)
        {
        case ESkillAction.ONCE:
            animationFrames.createAnimation(ESkillAction.ONCE, "Image/Skill/" + resourcePath, timeFrame, false,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            callback = new EventDelegate(controller.listState[stateAction].goNextState);
            break;

        case ESkillAction.DROP:
            animationFrames.createAnimation(ESkillAction.DROP, "Image/Skill/" + resourcePath, timeFrame, true,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            break;

        case ESkillAction.TRAP:
            animationFrames.createAnimation(ESkillAction.TRAP, "Image/Skill/" + resourcePath, timeFrame, true,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            break;

        case ESkillAction.BUFF:
            animationFrames.createAnimation(ESkillAction.BUFF, "Image/Skill/" + resourcePath, timeFrame, true,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            break;

        case ESkillAction.ARMAGGEDDON:
            animationFrames.createAnimation(ESkillAction.ARMAGGEDDON, "Image/Skill/" + resourcePath, timeFrame, true,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            break;

        case ESkillAction.EXPLOSION:
            animationFrames.createAnimation(ESkillAction.EXPLOSION, "Image/Explosion/" + resourcePath, timeFrame, true,
                                            (bool)specificLoop[0], (int[])specificLoop[1]);
            callback = new EventDelegate(((SkillStateExplosion)controller.listState[ESkillAction.EXPLOSION]).destroy);
            break;

        case ESkillAction.FADE:
            break;
        }

        //set render queue
        //if (stateAction == ESkillAction.EXPLOSION)
        //{
        //    SpriteRenderer render = this.GetComponent<SpriteRenderer>();
        //}
        //else
        //{
        GetComponent <SpriteRenderer>().material.renderQueue = GameConfig.RenderQueueSkill;
        //}

        object result = getValueFromDatabase(EAnimationDataType.EVENT);

        if (result != null)
        {
            object[] events = (object[])result;
            if (events.Length != 0)
            {
                animationFrames.addEvent(events, callback, false);
            }
        }

        if (controller.getCurrentState().hasCollider)
        {
            controller.getCurrentState().initCollider(animationFrames.frameLength, animationFrames.timeFrame);
        }
    }
 public void addEventForCurrentState(object[] key, EventDelegate callback, bool runOnlyOnce)
 {
     animationFrames.addEvent(key, callback, runOnlyOnce);
 }