コード例 #1
0
ファイル: Monster.cs プロジェクト: hiki-long/unity_pracise
 public void Attack()
 {
     System.Random rd = new System.Random();
     atktime = rd.Next(1, 5);
     for (int i = 0; i < skillplace.childCount; i++)
     {
         Destroy(skillplace.GetChild(i).gameObject);
     }
     for (int i = 0; i < atktime; i++)
     {
         int           skillnum = rd.Next(1, 11);//随机行动次数,最多3次
         SkillBaseInfo info     = CardInfo.getSkill("Ms" + skillnum.ToString());
         list[i] = info;
         string prefix    = "pm06_1c_0";
         int    img_index = 0;
         // .Debug.Log(info.type);
         img_index = dict[info.type];
         var sprite = Resources.Load <Sprite>(prefix + img_index.ToString());
         if (img_index != 0 && sprite)
         {
             var img = new GameObject("Image").AddComponent <Image>();
             img.rectTransform.SetParent(skillplace);
             img.sprite = sprite;
             img.SetNativeSize();
         }
     }
 }
コード例 #2
0
    public void UseSkill(SkillBaseInfo skillBaseInfo)
    {
        switch (skillBaseInfo.Type)
        {
        case SkillBaseInfo.ReleaseType.Self:
            SkillSelf skillSelf = skillBaseInfo as SkillSelf;
            UseSelfSkill(skillSelf);
            break;

        case SkillBaseInfo.ReleaseType.SelfRange:
            SkillSelfRange skillSelfRange = skillBaseInfo as SkillSelfRange;
            UseSelfRangeSkill(skillSelfRange);
            break;

        case SkillBaseInfo.ReleaseType.Multi:
            SkillMulti skillMulti = skillBaseInfo as SkillMulti;
            UseMultiSkill(skillMulti);
            break;

        case SkillBaseInfo.ReleaseType.Single:
            SkillSingle skillSingle = skillBaseInfo as SkillSingle;
            UseSingleSkill(skillSingle);
            break;

        case SkillBaseInfo.ReleaseType.Trajectory:
            SkillTrajectory skillTrajectory = skillBaseInfo as SkillTrajectory;
            UseTraSkill(skillTrajectory);
            break;
        }
    }
コード例 #3
0
 public void JudgeObejct(GameObject gameObject, SkillBaseInfo skillBaseInfo)
 {
     if (gameObject.tag == "Player" || gameObject.tag == "Pet")
     {
         if (skillBaseInfo.Releaseobject == SkillBaseInfo.ReleaseObject.Ally)
         {
             TestObjectMode = 1;
         }
         else
         {
             TestObjectMode = 2;
         }
     }
     if (gameObject.tag == "Enemy")
     {
         if (skillBaseInfo.Releaseobject == SkillBaseInfo.ReleaseObject.Ally)
         {
             TestObjectMode = 2;
         }
         else
         {
             TestObjectMode = 1;
         }
     }
     SelfGameObject = gameObject;
     mSkillBaseInfo = skillBaseInfo;
 }
コード例 #4
0
        public static void InitSkillBaseList()
        {
            int currentGroup = 1;
            int currentId    = 0;

            foreach (SkillModel model in skillModelList)
            {
                string [] skill_level = model.Skill.Split(';');
                for (int i = 0; i < skill_level.Length; i++)
                {
                    //int skillId=int.Parse(skill_level[i])/100;
                    //int level=int.Parse (skill_level[i])%10;
                    //int skillType=(skillId-1)+level;
                    int           skillId   = int.Parse(skill_level[i]);
                    SkillBaseInfo skillbase = skillBaseInfoList.Find(x => x.SkillGroup == currentGroup && x.SkillId == skillId);
                    if (skillbase == null)
                    {
                        currentId++;
                        skillBaseInfoList.Add(new SkillBaseInfo()
                        {
                            Id = currentId, SkillGroup = currentGroup, SkillId = skillId, Priority = 1
                        });
                    }
                    else
                    {
                        skillbase.Priority++;
                    }
                }

                currentGroup++;
            }
        }
コード例 #5
0
 public void SetSkill(int id)
 {
     mID   = id;
     mInfo = SkillManager.Instance.GetSkillByID(id);
     mIcon.gameObject.SetActive(true);
     mIcon.sprite = Resources.Load <Sprite>(mInfo.Sprite);
     type         = ShortcutType.Skill;
 }
コード例 #6
0
        public static SkillBaseInfo FindSkillBaseInfoFromId(int id)
        {
            SkillBaseInfo data = null;

            data = skillBaseInfoList.Find(x => x.Id == id);
            if (data == null)
            {
                Debugger.Log("Error : Not Found In SkillBaseInfo. ID :" + id);
            }
            return(data);
        }
コード例 #7
0
        public static SkillBaseInfo FindSkillBaseInfoFromSkillId(int skillid)
        {
            SkillBaseInfo data = null;

            data = skillBaseInfoList.Find(x => x.SkillId == skillid);
            if (data == null)
            {
                Debug.Log("Error : Not Found In SkillBaseInfo. SKillID :" + skillid);
            }
            return(data);
        }
コード例 #8
0
    public SkillBaseInfo GetSkillByID(int id)
    {
        SkillBaseInfo info = null;

        mSkillInfoDict.TryGetValue(id, out info);
        if (info == null)
        {
            Debug.LogError("没有id为" + id + "的技能!");
        }
        return(info);
    }
コード例 #9
0
    public void SetID(int id)
    {
        mIcon              = UITool.FindChild <Image>(gameObject, "Icon");
        mName              = UITool.FindChild <Text>(gameObject, "Name");
        mDes               = UITool.FindChild <Text>(gameObject, "Des");
        mCost              = UITool.FindChild <Text>(gameObject, "Cost");
        mIcon_Mask         = UITool.FindChild <Image>(gameObject, "Icon_Mask");
        mIcon_Mask.enabled = false;

        mInfo        = SkillManager.Instance.GetSkillByID(id);
        mIcon.sprite = Resources.Load <Sprite>(mInfo.Sprite);
        mName.text   = mInfo.Name;
        mDes.text    = mInfo.Des;
        mCost.text   = "ep" + mInfo.EP + " mp" + mInfo.MP;
    }
コード例 #10
0
    IEnumerator StartSkillCD(SkillBaseInfo skillBaseInfo)
    {
        float curTime = 0;

        while (1 > 0)
        {
            yield return(new WaitForSeconds(0.1f));

            curTime            += 0.1f;
            CoolTime.text       = (skillBaseInfo.CoolTime - curTime).ToString("F1") + "s";
            MaskIcon.fillAmount = 1 - (curTime / skillBaseInfo.CoolTime);
            if (curTime >= skillBaseInfo.CoolTime)
            {
                CoolTime.enabled = false;
                break;
            }
        }
    }
コード例 #11
0
ファイル: Card.cs プロジェクト: hiki-long/unity_pracise
    public void UseEffect(GameObject skillbutton)
    {
        //gameobject和gameObject有本质区别,gameObject代表使用的哪个对象的函数,这里是Canvas(Card)对象
        //gameobject是自己指定的类型
        buttonobj = skillbutton;
        Team team      = Team.GetComponent <Team>();
        int  skillcost = skillbutton.GetComponent <Skill>().skillinfo.cost + (skillbutton.GetComponent <Skill>().skillinfo.used ? 1 : 0);

        if (skillcost <= team.power)
        {
            SkillBaseInfo    info = skillbutton.GetComponent <Skill>().skillinfo;
            CardAndSkillinfo cardskill;
            cardskill.info = info;
            skillbutton.GetComponent <Skill>().UpdateCardcost(true);
            cardskill.cardatk = this.attack;
            team.power       -= skillcost;
            SendMessageUpwards("ReDraw", SendMessageOptions.DontRequireReceiver);
            SendMessageUpwards("TeamFirst", cardskill, SendMessageOptions.DontRequireReceiver);
            gameobject.SetActive(false);
            ShowUsed.SetActive(true);
        }
    }
コード例 #12
0
 public void SetSkill(SkillBaseInfo baseInfo)
 {
     Serial              = baseInfo.Pos;
     MaxCoolDown         = baseInfo.CoolDown;
     DefaultImage.sprite = baseInfo.SkillImage;
     EffectImage.sprite  = baseInfo.SkillImage;
     _type = baseInfo.SkillType;
     if (_type.Equals(SkillType.AutoTarget))
     {
         Drag.enabled = false;
         Owner.gameObject.GetComponentInChildren <LineRenderer>().enabled   = false;
         Owner.gameObject.GetComponentInChildren <SpriteRenderer>().enabled = false;
     }
     else
     {
         Debug.Log("是指向性技能");
         Click.enabled = false;
         Drag.Init(Owner, baseInfo.SkillType.Equals(SkillType.LineTarget));
         Owner.gameObject.GetComponentInChildren <LineRenderer>().enabled   = false;
         Owner.gameObject.GetComponentInChildren <SpriteRenderer>().enabled = false;
     }
 }
コード例 #13
0
    void ParseSkillJson()
    {
        mSkillInfoDict = new Dictionary <int, SkillBaseInfo>();
        //文本为在Unity里面是 TextAsset类型
        TextAsset  skillText = Resources.Load <TextAsset>("Json/SkillInfo");
        string     itemsJson = skillText.text;//物品信息的Json格式
        JSONObject j         = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            int    id              = (int)temp["id"].n;
            string name            = temp["name"].str;
            string sprite          = temp["sprite"].str;
            string des             = temp["des"].str;
            int    mp              = (int)temp["mp"].n;
            int    ep              = (int)temp["ep"].n;
            int    demandlv        = (int)temp["demandlv"].n;
            float  cooltime        = temp["coolTime"].n;
            string str_releasetype = temp["releaseType"].str;
            SkillBaseInfo.ReleaseType   releaseType   = (SkillBaseInfo.ReleaseType)System.Enum.Parse(typeof(SkillBaseInfo.ReleaseType), str_releasetype);
            SkillBaseInfo.ReleaseObject releaseObject = (SkillBaseInfo.ReleaseObject)System.Enum.Parse(typeof(SkillBaseInfo.ReleaseObject), temp["releaseObject"].str);

            List <ApplyAttrEffect> applyAttrEffects = new List <ApplyAttrEffect>();
            JSONObject             j2 = temp["applyAttr"];
            foreach (JSONObject temp2 in j2.list)
            {
                AttrType            attrType      = (AttrType)System.Enum.Parse(typeof(AttrType), temp2["attrType"].str);
                int                 fixvalue      = (int)temp2["fixValue"].n;
                List <AddAttrValue> addAttrValues = new List <AddAttrValue>();
                if (temp2["addValue"] != null)
                {
                    JSONObject j3 = temp2["addValue"];
                    foreach (JSONObject temp3 in j3.list)
                    {
                        AttrType     addattrtype = (AttrType)System.Enum.Parse(typeof(AttrType), temp3["addAttrType"].str);
                        float        ap          = temp3["addpoint"].n;
                        AddAttrValue add         = new AddAttrValue(addattrtype, ap);
                        addAttrValues.Add(add);
                    }
                }

                int count = 1;
                if (temp2["count"] != null)
                {
                    count = (int)temp2["count"].n;
                }
                float time = 0;
                if (temp2["time"] != null)
                {
                    time = temp2["time"].n;
                }
                ApplyAttrEffect attrEffect = new ApplyAttrEffect(attrType, fixvalue, addAttrValues, time, count);
                applyAttrEffects.Add(attrEffect);
            }

            SkillBaseInfo skill = null;
            switch (releaseType)
            {
            case SkillBaseInfo.ReleaseType.Self:

                skill = new SkillSelf(id, name, sprite, des, mp, ep, demandlv, cooltime, releaseObject, releaseType, applyAttrEffects);
                break;

            case SkillBaseInfo.ReleaseType.SelfRange:
                float selfRange = temp["range"].n;
                skill = new SkillSelfRange(id, name, sprite, des, mp, ep, demandlv, cooltime, releaseObject, releaseType, selfRange, applyAttrEffects);
                break;

            case SkillBaseInfo.ReleaseType.Multi:
                float multiDistance = temp["distance"].n;
                float multiRange    = temp["range"].n;
                skill = new SkillMulti(id, name, sprite, des, mp, ep, demandlv, cooltime, releaseObject, releaseType, multiRange, multiDistance, applyAttrEffects);
                break;

            case SkillBaseInfo.ReleaseType.Single:
                float singleDistance = temp["distance"].n;
                skill = new SkillSingle(id, name, sprite, des, mp, ep, demandlv, cooltime, releaseObject, releaseType, singleDistance, applyAttrEffects);
                break;

            case SkillBaseInfo.ReleaseType.Trajectory:
                float shotSize  = temp["shotSize"].n;
                float shotSpeed = temp["shotSpeed"].n;
                float shotTime  = temp["shotTime"].n;
                bool  pierce    = temp["pierce"].IsBool;
                skill = new SkillTrajectory(id, name, sprite, des, mp, ep, demandlv, cooltime, releaseObject, releaseType, shotSize, shotSpeed, shotTime, pierce, applyAttrEffects);
                break;
            }
            mSkillInfoDict.Add(id, skill);
        }
    }
コード例 #14
0
    public void CaleSkillAttrObjectValue(GameObject SelfGameObject, GameObject ReleaseObject, SkillBaseInfo skillBaseInfo)
    {
        for (int i = 0; i < skillBaseInfo.ApplyAttrEffects.Count; i++)
        {
            float attradd = 0;
            if (skillBaseInfo.ApplyAttrEffects[i].AddAttrValues != null)
            {
                for (int j = 0; j < skillBaseInfo.ApplyAttrEffects[i].AddAttrValues.Count; j++)
                {
                    attradd += AttrManager.Instance.GetAttrByType(SelfGameObject, skillBaseInfo.ApplyAttrEffects[i].AddAttrValues[j].AttrType)
                               * skillBaseInfo.ApplyAttrEffects[i].AddAttrValues[j].AddPoint;
                }
            }
            float totaladdpoint = attradd + skillBaseInfo.ApplyAttrEffects[i].FixValue;

            StartCoroutine(ProduceEffect(ReleaseObject, skillBaseInfo.ApplyAttrEffects[i].AT,
                                         totaladdpoint, skillBaseInfo.ApplyAttrEffects[i].Count, skillBaseInfo.ApplyAttrEffects[i].Time));
        }
    }