コード例 #1
0
    public void initSkill(string id, int mana, ESkillType type, object ability, object[] data)
    {
        if (dragonController.attribute.MP.Current < mana)
        {
            DeviceService.Instance.openToast("Not enough mana!");
            return;
        }
        else
        {
            dragonController.attribute.MP.Current -= mana;

            if (dragonController.attribute.MP.Current < 0)
            {
                dragonController.attribute.MP.Current = 0;
            }

            float valueTo = dragonController.attribute.MP.Current / (float)dragonController.attribute.MP.Max;
            dragonController.updateTextMP();
            EffectSupportor.Instance.runSliderValue(PlayDragonInfoController.Instance.sliderMP, valueTo, EffectSupportor.TimeValueRunMP);
        }

        GameObject skill = Instantiate(Resources.Load <GameObject>("Prefab/Skill/Skill")) as GameObject;

        if (type == ESkillType.GLOBAL)
        {
            skill.transform.parent = Camera.main.transform;
            skill.transform.GetChild(0).gameObject.layer = 5;
            skill.transform.position = Vector3.zero;
        }
        else //target
        {
            skill.transform.parent = PlayManager.Instance.Temp.Skill.transform;
        }

        skill.transform.localScale = Vector3.one;

        SkillController skillController = skill.GetComponent <SkillController>();

        skillController.Owner = PlayerDragon;
        skillController.initalize(id, type, ability, data);
    }