Exemple #1
0
 public wupingObject(int[] Zuobiao, wupingType WupingType)
 {
     zuobiao  = Zuobiao;
     thisType = WupingType;
 }
Exemple #2
0
    public void showWuping()
    {
        for (int i = 0; i <= wupinglist.Count - 1; i++)
        {
            //获取物品种类、位置
            wupingType type    = wupinglist[i].thisType;
            int[]      ZuoBiao = wupinglist[i].zuobiao;

            int    newhp = 0, newatk = 0, newdef = 0, newyellow = 0, newblue = 0, newred = 0, newem = 0, newcoin = 0;
            string prefabUrl = "";//prefab路径
            string info      = "";

            //实例化物品
            switch (type)
            {
            case wupingType.Atkup:
                prefabUrl = "wuping/item_0";
                newatk    = 5;
                info      = "发现红宝石!攻击力上升5!";
                break;

            case wupingType.Defup:
                prefabUrl = "wuping/item_1";
                newdef    = 5;
                info      = "发现蓝宝石!防御力上升5!";
                break;

            case wupingType.smallHp:
                prefabUrl = "wuping/item_4";
                newhp     = 300;
                info      = "喝下小生命药水!生命恢复300!";
                break;

            case wupingType.normalHp:
                prefabUrl = "wuping/item_5";
                newhp     = 500;
                info      = "喝下生命药水!生命恢复500!";
                break;

            case wupingType.bigHp:
                prefabUrl = "wuping/item_6";
                newhp     = 1000;
                info      = "喝下大生命药水!生命恢复1000!";
                break;

            case wupingType.maxHP:
                prefabUrl = "wuping/item_7";
                newhp     = 1500;
                info      = "喝下圣水,生命恢复1500!";
                break;

            case wupingType.yellowKey:
                prefabUrl = "wuping/item_14";
                newyellow = 1;
                info      = "找到一把黄色钥匙!";
                break;

            case wupingType.blueKey:
                prefabUrl = "wuping/item_15";
                newblue   = 1;
                info      = "找到一把蓝色钥匙!";
                break;

            case wupingType.redKey:
                prefabUrl = "wuping/item_16";
                newred    = 1;
                info      = "找到一把红色钥匙!";
                break;

            case wupingType.Shieldlevel_1:
                prefabUrl = "wuping/item_50";
                newdef    = 50;
                info      = "装备盾牌!防御力上升50!";
                break;

            case wupingType.Shieldlevel_2:
                prefabUrl = "wuping/item_53";
                newdef    = 80;
                info      = "装备精良盾牌!防御力上升80!";
                break;

            case wupingType.Shieldlevel_3:
                prefabUrl = "wuping/item_54";
                newdef    = 120;
                info      = "装备先锋盾!防御力上升120!";
                break;

            case wupingType.Swordlevel_1:
                prefabUrl = "wuping/item_45";
                newatk    = 50;
                info      = "装备铁剑!攻击力上升50!";
                break;

            case wupingType.Swordlevel_2:
                prefabUrl = "wuping/item_47";
                newatk    = 80;
                info      = "装备战士剑!攻击力上升80!";
                break;

            case wupingType.Swordlevel_3:
                prefabUrl = "wuping/item_49";
                newatk    = 120;
                info      = "装备退魔剑!攻击力上升120!";
                break;
            }
            //加载位置
            GameObject wuping = (GameObject)Instantiate(Resources.Load(prefabUrl));
            wuping.transform.position = new Vector3(ZuoBiao[0] * 0.32f + 0.16f, -ZuoBiao[1] * 0.32f - 0.16f, 0f);
            wuping.GetComponent <SpriteRenderer>().sortingOrder = 10;
            //挂载物品属性脚本
            wupingMain wm = wuping.AddComponent <wupingMain>();
            wm.hpVar        = newhp;
            wm.atkVar       = newatk;
            wm.defVar       = newdef;
            wm.yellowKeyVar = newyellow;
            wm.blueKeyVar   = newblue;
            wm.redKeyVar    = newred;
            wm.emVar        = newem;
            wm.coinVar      = newcoin;
            wm.Infostring   = info;

            gameObject.GetComponent <myTweenAlpha>()._thisSprite.Add(wuping);
        }
    }