Пример #1
0
    void initSkill()
    {
        //Stretch skill selected
        float ratio = GameSupportor.getRatioAspect(PlayDragonInfoController.Instance.tempSkill, PlayDragonInfoController.Instance.renderUlti) * 100;

        PlayDragonInfoController.Instance.renderUlti.transform.localScale = new Vector3(ratio, ratio, ratio);

        bool   hasUlti = false;
        string branch  = PlayerInfo.Instance.dragonInfo.id;
        int    length  = PlayDragonInfoController.Instance.Skills.Length;
        int    count   = ReadDatabase.Instance.DragonInfo.Player[branch].Skills.Count - 1;

        if (ReadDatabase.Instance.DragonInfo.Player[branch].Skills.Count > 0)
        {
            for (int i = 0; i < length; i++)
            {
                PlayDragonInfoController.Instance.Skills[i].gameObject.SetActive(true);
            }

            foreach (DragonPlayerSkillData skillData in ReadDatabase.Instance.DragonInfo.Player[branch].Skills)
            {
                PlayDragonInfoSkillController skill = PlayDragonInfoController.Instance.Skills[count].GetComponent <PlayDragonInfoSkillController>();
                SkillData data = ReadDatabase.Instance.SkillInfo[skillData.ID.ToUpper()];
                skill.ID           = skillData.ID;
                skill.CooldownTime = data.Cooldown;
                skill.Type         = data.Type;
                skill.Ability      = data.Ability;
                skill.ManaValue    = data.Mana;

                skill.initalize();

                string path = "Image/Dragon/Player/" + ConvertSupportor.convertUpperFirstChar(branch) + "/Skill/" + skillData.ID;
                skill.sprite.mainTexture = Resources.Load <Texture>(path);
                count--;

                if (skillData.Ulti)
                {
                    PlayDragonInfoController.Instance.renderUlti.gameObject.SetActive(true);
                    UIAnchor anchor = PlayDragonInfoController.Instance.renderUlti.GetComponent <UIAnchor>();
                    anchor.container = skill.gameObject;
                    anchor.enabled   = true;
                    hasUlti          = true;
                }
            }
        }

        if (hasUlti == false && PlayDragonInfoController.Instance.renderUlti.gameObject.activeSelf)
        {
            PlayDragonInfoController.Instance.renderUlti.gameObject.SetActive(false);
        }

        count = ReadDatabase.Instance.DragonInfo.Player[branch].Skills.Count;
        if (count < length)
        {
            for (int i = count; i < length; i++)
            {
                PlayDragonInfoController.Instance.Skills[i].gameObject.SetActive(false);
            }
        }
    }
    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);
        }
    }
    public void updateSkill(string branch)
    {
        int  count   = 0;
        bool hasUlti = false;
        int  length  = attribute.Skills.Length;

        if (ReadDatabase.Instance.DragonInfo.Player[branch].Skills.Count > 0)
        {
            for (int i = 0; i < length; i++)
            {
                attribute.Skills[i].gameObject.SetActive(true);
            }

            foreach (DragonPlayerSkillData skillData in ReadDatabase.Instance.DragonInfo.Player[branch].Skills)
            {
                UITexture texture = attribute.Skills[count].GetComponent <UITexture>();
                string    path    = "Image/Dragon/Player/" + ConvertSupportor.convertUpperFirstChar(branch) + "/Skill/" + skillData.ID;
                texture.mainTexture = Resources.Load <Texture>(path);
                count++;

                if (skillData.Ulti)
                {
                    renderUlti.gameObject.SetActive(true);
                    UIAnchor anchor = renderUlti.GetComponent <UIAnchor>();
                    anchor.container = texture.gameObject;
                    anchor.enabled   = true;
                    hasUlti          = true;
                }
            }
        }


        if (hasUlti == false && renderUlti.gameObject.activeSelf)
        {
            renderUlti.gameObject.SetActive(false);
        }

        if (count < length)
        {
            for (int i = count; i < length; i++)
            {
                attribute.Skills[i].gameObject.SetActive(false);
            }
        }
    }
    object getValueFromDatabase(EAnimationDataType type)
    {
        object result = null;

        if (type == EAnimationDataType.TIME_FRAME)
        {
            result = ReadDatabase.Instance.SkillInfo[controller.ID.ToUpper()].States[currentState.ToString().ToUpper()].TimeFrame;
        }
        else if (type == EAnimationDataType.EVENT)
        {
            if (ReadDatabase.Instance.SkillInfo[controller.ID.ToUpper()].States[currentState.ToString().ToUpper()].listKeyEventFrame.Count > 0)
            {
                System.Collections.Generic.List <object> listEvent = null;
                listEvent = ReadDatabase.Instance.SkillInfo[controller.ID.ToUpper()].States[currentState.ToString().ToUpper()].listKeyEventFrame;

                int length = listEvent.Count;
                for (int i = 0; i < length; i++)
                {
                    if (listEvent[i].Equals("end"))
                    {
                        listEvent[i] = animationFrames.keyEnd;
                    }
                }

                result = listEvent.ToArray();
            }
        }
        else if (type == EAnimationDataType.RESOURCE_PATH)
        {
            string s = ReadDatabase.Instance.SkillInfo[controller.ID.ToUpper()].States[currentState.ToString().ToUpper()].ResourcePath;
            if ((ESkillAction)currentState == ESkillAction.EXPLOSION) // Explosion texture
            {
                string[] arr = s.Split(' ');
                result = ConvertSupportor.convertUpperFirstChar(arr[0]) + "/" + arr[1];
            }
            else // Skill texture
            {
                result = s;
            }
        }
        else if (type == EAnimationDataType.SPECIFIC_LOOP)
        {
            bool  boolResult = false;
            int[] arrResult  = null;

            AnimationEventState eventState = ReadDatabase.Instance.SkillInfo[controller.ID.ToUpper()].States[currentState.ToString().ToUpper()];
            boolResult = eventState.isSpecificLoop;

            if (boolResult)
            {
                arrResult = new int[eventState.SpecificLoopIndex.Length];
                for (int i = 0; i < eventState.SpecificLoopIndex.Length; i++)
                {
                    arrResult[i] = eventState.SpecificLoopIndex[i];
                }
            }

            result = new object[] { boolResult, arrResult };
        }
        return(result);
    }