Beispiel #1
0
        private GameObject InstantiateObject(ObjectInfo.ObjectType type, Transform transform)
        {
            var go = Instantiate(_objectsInfo.Find(x => x._type == type)._prefab, transform);

            go.SetActive(false);
            return(go);
        }
        public GameObject GetObject(ObjectInfo.ObjectType type)
        {
            var obj = (pools[type].objects.Count > 0) ?
                      pools[type].objects.Dequeue() : InstantiateObject(type, pools[type].container);

            obj.SetActive(true);
            return(obj);
        }
Beispiel #3
0
    /// <summary>
    /// 从文本文件中读取信息到字典中
    /// </summary>
    void ReadInfo()
    {
        string text = objectsInfoTxt.text;

        string[] lineArray = text.Split('\n');
        foreach (string line in lineArray)
        {
            string[]              perlineArray  = line.Split(',');
            ObjectInfo            objInfo       = new ObjectInfo();
            int                   tempid        = int.Parse(perlineArray[0]);
            string                tempname      = perlineArray[1];
            string                tempicon_name = perlineArray[2];
            ObjectInfo.ObjectType temptypeobj   = ObjectInfo.ObjectType.Drug;
            switch (perlineArray[3])
            {
            case "Drug":  temptypeobj = ObjectInfo.ObjectType.Drug;  break;

            case "Equip": temptypeobj = ObjectInfo.ObjectType.Equip; break;
            }
            objInfo.id        = tempid;
            objInfo.name      = tempname;
            objInfo.icon_name = tempicon_name;
            objInfo.type      = temptypeobj;
            if (temptypeobj == ObjectInfo.ObjectType.Drug)
            {
                int temphp         = int.Parse(perlineArray[4]);
                int tempmp         = int.Parse(perlineArray[5]);
                int tempprice_sell = int.Parse(perlineArray[6]);
                int tempprice_buy  = int.Parse(perlineArray[7]);
                objInfo.hp         = temphp;
                objInfo.mp         = tempmp;
                objInfo.price_buy  = tempprice_buy;
                objInfo.price_sell = tempprice_sell;
            }
            if (temptypeobj == ObjectInfo.ObjectType.Equip)
            {
                int tempattack = int.Parse(perlineArray[4]);
                int tempdef    = int.Parse(perlineArray[5]);
                int tempspeed  = int.Parse(perlineArray[6]);
                ObjectInfo.WearType temptypewear = ObjectInfo.WearType.Headgear;
                switch (perlineArray[7])
                {
                case "Headgear":  temptypewear = ObjectInfo.WearType.Headgear;  break;

                case "Armor":     temptypewear = ObjectInfo.WearType.Armor;     break;

                case "Hand":      temptypewear = ObjectInfo.WearType.Hand;      break;

                case "Accessory": temptypewear = ObjectInfo.WearType.Accessory; break;

                case "Shoe":      temptypewear = ObjectInfo.WearType.Shoe;      break;
                }
                PlayerStatusInfo.Playertype temptypesuit = PlayerStatusInfo.Playertype.Swordman;
                switch (perlineArray[8])
                {
                case "Swordman": temptypesuit = PlayerStatusInfo.Playertype.Swordman; break;

                case "Magician": temptypesuit = PlayerStatusInfo.Playertype.Magician; break;
                }
                int tempprice_sell = int.Parse(perlineArray[9]);
                int tempprice_buy  = int.Parse(perlineArray[10]);
                objInfo.attack     = tempattack;
                objInfo.def        = tempdef;
                objInfo.speed      = tempspeed;
                objInfo.weartype   = temptypewear;
                objInfo.suittype   = temptypesuit;
                objInfo.price_buy  = tempprice_buy;
                objInfo.price_sell = tempprice_sell;
            }
            objectInfoDict.Add(tempid, objInfo);
        }
    }
 private GameObject InstantiateObject(ObjectInfo.ObjectType type, Transform parent)
 {
     tempInstantiateGameObject = Instantiate(objectsInfo.Find(elem => elem.Type == type).Prefab, parent);
     tempInstantiateGameObject.SetActive(false);
     return(tempInstantiateGameObject);
 }