コード例 #1
0
 // constructor
 // constructor -> no parameter -> set default
 public FurnitureInstance()
 {
     furniture   = null;
     position    = Vector3.zero;
     rotation    = Quaternion.identity;
     isAllocated = false;
 }
コード例 #2
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public Sprite GetFurnitureSprites(FurnitureData data)
    {
        Sprite returnSp = null;

        switch ((FurnitureType)data.type)
        {
        case FurnitureType.Bed:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.fur.bed)[data.id];
            break;

        case FurnitureType.Decoration:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.fur.decoration)[data.id];
            break;

        case FurnitureType.Windows:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.fur.furniture)[data.id];
            break;

        case FurnitureType.Toy:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.fur.other)[data.id];
            break;

        case FurnitureType.Floor:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.furPre.floor)[data.id];
            break;

        case FurnitureType.Wallpaper:
            returnSp = Atlas.Ins.GetSprites(Atlas.Ins.furPre.wallpaper)[data.id];
            break;
        }
        return(returnSp);
    }
コード例 #3
0
ファイル: SaveSystem.cs プロジェクト: safe27698/PetStory
    public static void A_SaveFurniture(FurnitureData data)
    {
        Player player = Loaded();

        try
        {
            Furniture furniture = (from p in player.inventory.furniture
                                   where p.type == data.type && p.furnitureIsUsing == true
                                   select p).First();
            if (data.id != furniture.id)
            {
                furniture.furnitureIsUsing = false;
            }
            Saved(player);
            API_Game.Ins.PutFurnitureRequest(furniture, null);
            return;
        }
        catch { }
        try
        {
            Furniture furniture = (from p in player.inventory.furniture
                                   where p.id == data.id && p.type == data.type && p.furnitureIsUsing == false
                                   select p).First();
            furniture.furnitureIsUsing = true;
            Saved(player);
            API_Game.Ins.PutFurnitureRequest(furniture, null);
            return;
        }
        catch { }
    }
コード例 #4
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void ChangeWallpaper(FurnitureData data)
    {
        try
        {
            FurnitureData[] furnitureData = GameObject.FindObjectsOfType <FurnitureData>();
            FurnitureData   m_Data        = (from d in furnitureData
                                             where wallpaperId == d.id && (int)FurnitureType.Wallpaper == d.type &&
                                             d.GetComponentInChildren <Text>() != null
                                             select d).First();
            Text t = m_Data.GetComponentInChildren <Text>();
            t.text = (int.Parse(t.text) + 1).ToString();
            m_Data.furnitureIsUsing = false;
            m_Data.position         = new Vector3(0, 0, 0);
            m_Data.rotation         = new Quaternion(0, 0, 0, 0);

            furDataList.Add(m_Data);
            //SaveSystem.A_DeleteFurniture(m_Data);
        }
        catch { }
        wallpaper.sprite      = Atlas.Ins.GetSprites(Atlas.Ins.fur.wallpaper)[data.id];
        wallpaperId           = data.id;
        data.furnitureIsUsing = true;
        furDataList.Add(data);
        //API_Game.Ins.PutFurnitureRequest(data.ReturnFurniture(), null);
        //SaveSystem.A_SaveFurniture(data);
    }
コード例 #5
0
ファイル: Shop_Type.cs プロジェクト: safe27698/PetStory
    public void CloneItemFurnitureType(List <Sprite> sp, int type)
    {
        for (int i = 0; i < sp.Count; i++)
        {
            //SaveSystem.A_AddFurniture(i, type);
            GameObject clone = Instantiate(item.gameObject, parent);
            clone.name = i.ToString();
            FurnitureData data = clone.AddComponent <FurnitureData>();
            data.id    = i;
            data.type  = type;
            data.price = priceListData[i];
            clone.SetActive(true);
            clone.transform.GetChild(0).GetComponent <Image>().sprite          = sp[i];
            clone.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = priceListData[i].ToString();

            List <Furniture> furnitures = SaveSystem.A_LoadFurniture();
            var furCount = from f in furnitures
                           where f.id == data.id && f.type == data.type
                           select f;

            clone.transform.GetChild(2).GetComponent <Text>().text = furCount.Count() <= 0 ? "" : furCount.Count().ToString();
            if (furCount.Count() >= 1 && (type == (int)FurnitureType.Wallpaper || type == (int)FurnitureType.Floor))
            {
                clone.GetComponentInChildren <Button>().interactable = false;
            }
        }
    }
コード例 #6
0
 void Awake()
 {
     _instance      = this;
     ReceiveData    = new FurnitureData();
     GameObjectPool = new List <GameObject>();
     Show           = Camera.main.GetComponent <SingleShow>();
 }
コード例 #7
0
    FurnitureData ID(int _id)
    {
        // id reading in XML => Item Data All Load
        FurnitureData fd = DataManager.FindFurnitureDataByID(_id);

        return(fd);
    }
コード例 #8
0
 // constructor -> make furniture uid
 public FurnitureInstance(int id, int _slotNumber)
 {
     furniture   = DataManager.FindFurnitureDataByID(id);
     position    = Vector3.zero;
     rotation    = Quaternion.identity;
     isAllocated = false;
     slotNumber  = _slotNumber;
 }
コード例 #9
0
 // constructor -> make data ( allocated data )
 public FurnitureInstance(int _id, int _slotNumber, bool _allocated, Vector3 _position, Quaternion _rotation)
 {
     furniture   = DataManager.FindFurnitureDataByID(_id);
     slotNumber  = _slotNumber;
     isAllocated = _allocated;
     position    = _position;
     rotation    = _rotation;
 }
コード例 #10
0
 // constructor -> copy instance
 public FurnitureInstance(FurnitureInstance data)
 {
     furniture   = data.Furniture;
     position    = data.position;
     rotation    = data.rotation;
     isAllocated = data.isAllocated;
     slotNumber  = data.slotNumber;
 }
コード例 #11
0
 public void Setting(FurnitureData data, Vector3 positiondata, Vector3 rotationData, Vector3 scaleData)
 {
     info = data;
     gameObject.transform.Find("Text").GetComponent <Text>().text = info.FurnitureName;
     position = positiondata;
     rotation = rotationData;
     scale    = scaleData;
 }
コード例 #12
0
 // constructor -> make data (use data)
 public FurnitureInstance(FurnitureData data, int _slotNumber)
 {
     furniture   = data;
     position    = Vector3.zero;
     rotation    = Quaternion.identity;
     isAllocated = false;
     slotNumber  = _slotNumber;
 }
コード例 #13
0
    protected void Start()
    {
        fi = GetComponent<FurnitureData>();

        transform.position = DropLoc;
        //Face Camera
        transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y,
            Camera.mainCamera.transform.rotation.eulerAngles.y + 180);
        fi.Shadowplane.transform.parent = null;
        transform.Translate(0,3,0, Space.World);
        fi.Shadowplane.renderer.material.SetFloat("_AlphaMod", 1);
    }
コード例 #14
0
    public void AddFurniture(FurnitureData pData)
    {
        FurnitureData[] temp = _furniturePrefabs;
        _furniturePrefabs = new FurnitureData[temp.Length + 1];

        for (int i = 0; i < temp.Length; ++i)
        {
            _furniturePrefabs[i] = temp[i];
        }

        _furniturePrefabs[temp.Length] = pData;
    }
コード例 #15
0
 // select furniture
 public bool SelectFurniture(int index)
 {
     try
     {
         selectedFurniture = viewFurnitureGroup[index + (presentIndexFurniture * presentIndexFurniture)];
         return(true);
     }
     catch (ArgumentOutOfRangeException e)
     {
         return(false);
     }
 }
コード例 #16
0
    // update component element -> use furniture data
    public void UpdateComponentElement(FurnitureData data)
    {
        count.enabled = false;

        if ((data == null) || (data.ID == 0))
        {
            elementIcon.sprite = Resources.Load <Sprite>("Image/UI/FurnitureIcon/none");
        }
        else
        {
            elementIcon.sprite = Resources.Load <Sprite>("Image/UI/FurnitureIcon/" + data.File);
        }
    }
コード例 #17
0
    // public method
    // add furniture data -> use only data
    public bool AddFurnitureData(FurnitureData data)
    {
        for (int i = 0; i < haveFurnitureSet.Length; i++)
        {
            if (haveFurnitureSet[i] == null || haveFurnitureSet[i].Furniture == null || haveFurnitureSet[i].Furniture.ID == 0)
            {
                haveFurnitureSet[i] = new FurnitureInstance(data, i);
                return(true);
            }
        }

        Debug.Log("Furniture inventory is full");
        return(false);
    }
コード例 #18
0
ファイル: Shop_Manager.cs プロジェクト: safe27698/PetStory
    public void Preview(GameObject obj)
    {
        SoundManager.Ins.PlaySound(SoundManager.Ins._Select);
        furnitureData = obj.transform.parent.GetComponent <FurnitureData>();
        clothesData   = obj.transform.parent.GetComponent <ClothesData>();
        foodData      = obj.transform.parent.GetComponent <FoodData>();

        price = furnitureData != null ? furnitureData.price : price;
        price = clothesData != null ? clothesData.price : price;
        price = foodData != null ? foodData.price : price;
        coin  = SaveSystem.A_Coin();
        previewImage.sprite = obj.GetComponent <Image>().sprite;
        cost.text           = obj.transform.parent.GetChild(1).GetChild(0).GetComponent <Text>().text;
        previewObj.SetActive(true);
    }
コード例 #19
0
ファイル: SaveSystem.cs プロジェクト: safe27698/PetStory
    public static void A_DeleteFurniture(FurnitureData data)
    {
        Player player = Loaded();

        try
        {
            Furniture furniture = (from p in player.inventory.furniture
                                   where p.id == data.id && p.type == data.type && p.furnitureIsUsing &&
                                   p.position.Equals(data.position) && p.rotation.Equals(data.rotation)
                                   select p).First();
            furniture.furnitureIsUsing = false;
            furniture.position         = new Vector3(0, 0, 0);
            furniture.rotation         = new Quaternion(0, 0, 0, 0);
            Saved(player);
            API_Game.Ins.PutFurnitureRequest(furniture, null);
            return;
        }
        catch { }
    }
コード例 #20
0
ファイル: csvDB.cs プロジェクト: cpheinrich/VR
    /*
     * string[] getFilteredFurniture(Dictionary<string, List<FurnitureData>> d)
     * {
     *
     * }*/

    Dictionary <string, List <FurnitureData> > filterBySize(List <FurnitureData> fd, Vector3 box)
    {
        int l = fd.Count;
        Dictionary <string, List <FurnitureData> > X = new Dictionary <string, List <FurnitureData> >();

        for (int i = 0; i < l; i++)
        {
            Debug.Log(i);
            FurnitureData f = fd[i];
            Debug.Log(f.name);
            //List<FurnitureData> temp = new List<FurnitureData>();
            Vector3 scaledDims = f.dims;// * f.scale;
            Debug.Log(scaledDims);
            if (box.x > scaledDims.x && box.y > scaledDims.y && box.z > scaledDims.z)
            {
                Debug.Log("added");

                if (X.ContainsKey(f.tag))
                {
                    //Debug.Log("tag exits:");
                    //temp = X[f.tag];
                    //temp.Add(f);
                    //X[f.tag] = temp;
                    X[f.tag].Add(f);
                    //Debug.Log(X[f.tag].Count + 1);
                    //Debug.Log(f.tag);
                }
                else
                {
                    //Debug.Log("Creating new tag:");
                    //Debug.Log(X);
                    X.Add(f.tag, new List <FurnitureData>());
                    //X.Add(f.tag, fd);
                    X[f.tag].Add(f);
                    //Debug.Log(X.ContainsKey(f.tag));
                    // Debug.Log(X[f.tag].Count + 1);
                }
            }
        }
        return(X);
    }
コード例 #21
0
    public void Setup()
    {
        string objectID = gameObject.name.Replace("(Clone)", "");

        furnitureData = Database.Instance.Select <FurnitureData>("FurnitureDataTable").Select(objectID);

        sprites = new Sprite[furnitureData.spritePaths.Length];
        var atlas = Resources.Load <SpriteAtlas>("Atlas/FurnitureAtlas");

        for (int i = 0; i < sprites.Length; i++)
        {
            sprites[i] = atlas.GetSprite(furnitureData.spritePaths[i]);
        }

        buildingSprite = atlas.GetSprite("Construction");

        SpriteRenderer        = GetComponent <SpriteRenderer>();
        SpriteRenderer.sprite = sprites[0];

        Resources.UnloadAsset(atlas);
    }
コード例 #22
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void CustomFur(GameObject obj)
    {
        if (gameMode != GameMode.Normal && gameMode != GameMode.Furniture || setting.working)
        {
            return;
        }
        SoundManager.Ins.PlaySound(SoundManager.Ins._Inventory);


        if (gameMode == GameMode.Furniture)
        {
            gameMode = GameMode.Normal;
            for (int i = 0; i < obj.transform.childCount; i++)
            {
                obj.transform.GetChild(i).gameObject.SetActive(false);
            }
            for (int h = 1; h < roomParent.transform.childCount; h++)
            {
                FurnitureData furnitureData = roomParent.GetChild(h).GetComponent <FurnitureData>();
                //furIdlist.Add(SaveSystem.A_GetIDFur(furnitureData.ReturnFurniture(), furnitureData.transform.position , furnitureData.transform.rotation)) ;
                //Debug.LogError(SaveSystem.A_GetIDFur(furnitureData.ReturnFurniture(), furnitureData.transform.position, furnitureData.transform.rotation));

                furnitureData.furnitureIsUsing = true;
                furnitureData.position         = furnitureData.transform.position;
                furnitureData.rotation         = furnitureData.transform.rotation;
                furDataList.Add(furnitureData);
            }
            SaveSystem.A_SaveListFur(furDataList);

            //  Popup.Ins.PopupWaiting(true);
        }
        else
        {
            tutor4.SetActive(true);
            obj.transform.GetChild(0).gameObject.SetActive(true);
            gameMode = GameMode.Furniture;
            furDataList.Clear();
            idFurInstall.Clear();
        }
    }
コード例 #23
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void ChangeFloor(FurnitureData data)
    {
        try
        {
            FurnitureData[] furnitureData = GameObject.FindObjectsOfType <FurnitureData>();
            FurnitureData   m_Data        = (from d in furnitureData
                                             where floorId == d.id && (int)FurnitureType.Floor == d.type &&
                                             d.GetComponentInChildren <Text>() != null
                                             select d).First();
            Text t = m_Data.GetComponentInChildren <Text>();
            t.text = (int.Parse(t.text) + 1).ToString();
            furDataList.Add(m_Data);
            //SaveSystem.A_DeleteFurniture(m_Data);
        }catch { }

        floor.sprite          = Atlas.Ins.GetSprites(Atlas.Ins.fur.floor) [data.id];
        floorId               = data.id;
        data.furnitureIsUsing = true;
        furDataList.Add(data);
        // API_Game.Ins.PutFurnitureRequest(data.ReturnFurniture(), null);
        //SaveSystem.A_SaveFurniture(data);
    }
コード例 #24
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void CloneItem(GameObject obj)
    {
        FurnitureData f = obj.GetComponent <FurnitureData>();

        Player        p     = SaveSystem.A_LoadSaveGame();
        GameObject    clone = Instantiate(furniturePrefab, roomParent);
        FurnitureData c     = clone.AddComponent <FurnitureData>();

        foreach (Furniture fur in p.inventory.furniture)
        {
            if (fur.id == f.id && fur.type == f.type && fur.furnitureIsUsing == false && !idFurInstall.Contains(fur.realId))
            {
                c.realId             = fur.realId;
                fur.furnitureIsUsing = true;
                idFurInstall.Add(fur.realId);
                break;
            }
        }
        SaveSystem.A_SaveGame(p);
        c.id               = f.id;
        c.type             = f.type;
        c.furnitureIsUsing = true;
        clone.SetActive(false);
        clone.GetComponent <SpriteRenderer>().sprite = GetFurnitureSprites(f);
        clone.name = ((FurnitureType)f.type).ToString();

        PolygonCollider2D polygonCollider2D = clone.AddComponent <PolygonCollider2D>();

        polygonCollider2D.isTrigger = true;

        clone.transform.position = new Vector3(clone.transform.position.x, clone.transform.position.y, 0);
        clone.GetComponent <Rigidbody2D>().gravityScale = 0;

        Text t = obj.GetComponentInChildren <Text>();

        t.text = (int.Parse(t.text) - 1).ToString();

        target = clone;
    }
コード例 #25
0
ファイル: Shop_Manager.cs プロジェクト: safe27698/PetStory
    public void CallbackPreview(bool bo)
    {
        if (bo)
        {
            if (coin >= price)//check coin
            {
                PopupWaiting();
                avatarPreview.SetActive(false);
                previewObj.SetActive(false);
                SaveSystem.A_MinusCoin(price);

                if (furnitureData != null)
                {
                    SaveSystem.A_AddFurniture(furnitureData.id, furnitureData.type);
                    //List<Furniture> furnitures = SaveSystem.A_LoadFurniture();
                    //var furCount = from f in furnitures
                    //               where f.id == furnitureData.id && f.type == furnitureData.type
                    //               select f;
                    string ttt = furnitureData.transform.GetChild(2).GetComponent <Text>().text;
                    if (ttt == "")
                    {
                        ttt = "0";
                    }
                    int count = int.Parse(ttt);
                    count += 1;
                    furnitureData.transform.GetChild(2).GetComponent <Text>().text = count.ToString();

                    if (furnitureData.type == (int)FurnitureType.Wallpaper || furnitureData.type == (int)FurnitureType.Floor)
                    {
                        furnitureData.gameObject.GetComponentInChildren <Button>().interactable = false;
                    }
                }
                else if (clothesData != null)
                {
                    SaveSystem.A_AddClothes(clothesData.id, clothesData.type);
                    clothesData.count++;
                    clothesData.transform.GetChild(2).GetComponent <Text>().text = clothesData.count.ToString();
                }
                else if (foodData != null)
                {
                    SaveSystem.A_AddFood(foodData.id);
                    foodData.count++;
                    foodData.transform.GetChild(2).GetComponent <Text>().text = foodData.count.ToString();
                }
                else
                {
                    Debug.Log("Can not add the item");
                }

                furnitureData = null;
                clothesData   = null;
            }
            else
            {
                Popup.Ins.PopupOne("Not enough money", "OK", null);
            }
        }
        else
        {
            avatarPreview.SetActive(false);
            previewObj.SetActive(false);
        }
    }
コード例 #26
0
ファイル: Main_Type.cs プロジェクト: safe27698/PetStory
    public void LoadItem()
    {
        itemList = new List <Sprite>();

        switch (pathLoad)
        {
        case "Ac":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.ac));
            break;

        case "Shirt":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.shirt));
            break;

        case "Pant":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.pant));
            break;

        case "Shoe":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.shoe));
            break;

        case "Bed":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.bed));
            break;

        case "Decoration":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.decoration));
            break;

        case "Floor":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.floor));
            break;

        case "Furniture":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.furniture));
            break;

        case "Other":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.other));
            break;

        case "Wallpaper":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.wallpaper));
            break;

        case "Food":
            itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.food.food));
            break;
        }

        for (int i = 0; i < itemList.Count; i++)
        {
            ClothesData   c      = new ClothesData();
            FurnitureData f      = new FurnitureData();
            FoodData      fo     = new FoodData();
            Player        player = SaveSystem.A_LoadSaveGame();

            item.GetComponent <Image>().sprite = itemList[i];
            GameObject clone = Instantiate(item, parent);
            clone.name = i.ToString();

            if (clothesType != ClothesType.None)
            {
                c    = clone.AddComponent <ClothesData>();
                c.id = i;
            }
            else if (furnitureType != FurnitureType.None)
            {
                f    = clone.AddComponent <FurnitureData>();
                f.id = i;
            }
            else if (foodType != FoodType.None)
            {
                fo    = clone.AddComponent <FoodData>();
                fo.id = i;
            }

            switch (furnitureType)
            {
            case FurnitureType.Decoration:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Decoration)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;

            case FurnitureType.Bed:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Bed)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;

            case FurnitureType.Windows:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Windows)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;

            case FurnitureType.Floor:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Floor)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;

            case FurnitureType.Wallpaper:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Wallpaper)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;

            case FurnitureType.Toy:
                for (int y = 0; y < player.inventory.furniture.Count; y++)
                {
                    if (player.inventory.furniture[y].type == (int)FurnitureType.Toy)
                    {
                        if (player.inventory.furniture[y].id == i)
                        {
                            clone.SetActive(true);
                            f.CloneData(player.inventory.furniture[y]);
                        }
                    }
                }
                break;
            }
            if (furnitureType != FurnitureType.None)
            {
                int t = (from tt in player.inventory.furniture
                         where f.id == tt.id && f.type == tt.type && !tt.furnitureIsUsing
                         select tt).Count();

                Text txt = clone.GetComponentInChildren <Text>();

                if (t > 0)
                {
                    txt.text = t.ToString();
                }
                else
                {
                    txt.text = "0";
                }
            }

            switch (clothesType)
            {
            case ClothesType.Accessories:
                for (int y = 0; y < player.inventory.clothes.Count; y++)
                {
                    if (player.inventory.clothes[y].type == (int)ClothesType.Accessories)
                    {
                        if (player.inventory.clothes[y].id == i)
                        {
                            clone.SetActive(true);
                            c.CloneData(player.inventory.clothes[y]);
                        }
                    }
                }
                break;

            case ClothesType.Shirts:
                for (int y = 0; y < player.inventory.clothes.Count; y++)
                {
                    if (player.inventory.clothes[y].type == (int)ClothesType.Shirts)
                    {
                        if (player.inventory.clothes[y].id == i)
                        {
                            clone.SetActive(true);
                            c.CloneData(player.inventory.clothes[y]);
                        }
                    }
                }
                break;

            case ClothesType.Pants:
                for (int y = 0; y < player.inventory.clothes.Count; y++)
                {
                    if (player.inventory.clothes[y].type == (int)ClothesType.Pants)
                    {
                        if (player.inventory.clothes[y].id == i)
                        {
                            clone.SetActive(true);
                            c.CloneData(player.inventory.clothes[y]);
                        }
                    }
                }
                break;

            case ClothesType.Shoes:
                for (int y = 0; y < player.inventory.clothes.Count; y++)
                {
                    if (player.inventory.clothes[y].type == (int)ClothesType.Shoes)
                    {
                        if (player.inventory.clothes[y].id == i)
                        {
                            clone.SetActive(true);
                            c.CloneData(player.inventory.clothes[y]);
                        }
                    }
                }
                break;
            }

            if (clothesType != ClothesType.None)
            {
                try
                {
                    Clothes t = (from tt in player.inventory.clothes
                                 where c.id == tt.id && c.type == tt.type
                                 select tt).First();

                    Text txt = clone.GetComponentInChildren <Text>();

                    if (t.count > 0)
                    {
                        txt.text = t.count.ToString();

                        foreach (Pet p in player.pets)
                        {
                            if (clothesType == ClothesType.Shirts && p.shirtWearing == c.id)
                            {
                                txt.text = (int.Parse(txt.text) - 1).ToString();
                            }
                            else if (clothesType == ClothesType.Pants && p.pantWearing == c.id)
                            {
                                txt.text = (int.Parse(txt.text) - 1).ToString();
                            }
                            else if (clothesType == ClothesType.Shoes && p.shoeWearing == c.id)
                            {
                                txt.text = (int.Parse(txt.text) - 1).ToString();
                            }
                            else if (clothesType == ClothesType.Accessories && p.accessoriesWearing == c.id)
                            {
                                txt.text = (int.Parse(txt.text) - 1).ToString();
                            }
                        }
                    }
                    else
                    {
                        txt.text = "0";
                    }
                }
                catch { }
            }
            switch (foodType)
            {
            case FoodType.Food:
                for (int y = 0; y < player.inventory.foods.Count; y++)
                {
                    if (player.inventory.foods[y].id == i && player.inventory.foods[y].count > 0)
                    {
                        clone.SetActive(true);
                        fo.CloneData(player.inventory.foods[y]);
                    }
                }
                break;
            }

            if (foodType != FoodType.None)
            {
                try
                {
                    Food t = (from tt in player.inventory.foods
                              where fo.id == tt.id
                              select tt).First();
                    Text txt = clone.GetComponentInChildren <Text>();

                    if (t.count > 0)
                    {
                        txt.text = t.count.ToString();
                    }
                    else
                    {
                        txt.text = "0";
                    }
                }
                catch { }
            }
        }
    }
コード例 #27
0
ファイル: Deleter.cs プロジェクト: Bloodsmith/PeekARScripts
 void Start()
 {
     fi = GetComponent<FurnitureData>();
     fi.Shadowplane.transform.parent = null;
     transform.collider.enabled = false;
 }
コード例 #28
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    public void CloneItem(FurnitureData furnitureData)
    {
        FurnitureData f = furnitureData;

        GameObject    clone = Instantiate(furniturePrefab, roomParent);
        FurnitureData c     = clone.AddComponent <FurnitureData>();

        c.id       = f.id;
        c.type     = f.type;
        c.realId   = f.realId;
        c.position = f.position;
        c.rotation = f.rotation;
        clone.SetActive(false);
        clone.GetComponent <SpriteRenderer>().sprite = GetFurnitureSprites(f);
        clone.name = ((FurnitureType)f.type).ToString();

        PolygonCollider2D polygonCollider2D = clone.AddComponent <PolygonCollider2D>();

        polygonCollider2D.isTrigger = true;

        clone.transform.position = new Vector3(clone.transform.position.x, clone.transform.position.y, 0);
        clone.GetComponent <Rigidbody2D>().gravityScale = 0;


        clone.transform.position = f.position;
        clone.transform.rotation = f.rotation;

        clone.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
        // clone.transform.rotation = new Quaternion(0, 0, 0, 0);
        clone.GetComponent <SpriteRenderer>().sortingOrder = 20;
        clone.GetComponent <Rigidbody2D>().gravityScale    = 0;
        clone.GetComponent <PolygonCollider2D>().isTrigger = false;

        switch (f.type)
        {
        case (int)FurnitureType.Bed:
            clone.GetComponent <Rigidbody2D>().gravityScale    = 0;
            clone.GetComponent <SpriteRenderer>().sortingOrder = 3;
            clone.layer = 15;
            break;

        case (int)FurnitureType.Windows:
            clone.GetComponent <Rigidbody2D>().gravityScale    = 0;
            clone.GetComponent <SpriteRenderer>().sortingOrder = 2;
            clone.layer = 16;
            break;

        case (int)FurnitureType.Decoration:
            clone.GetComponent <Rigidbody2D>().gravityScale    = 0;
            clone.GetComponent <SpriteRenderer>().sortingOrder = 2;
            clone.layer = 16;
            break;

        case (int)FurnitureType.Toy:
            clone.GetComponent <Rigidbody2D>().gravityScale    = 0;
            clone.GetComponent <SpriteRenderer>().sortingOrder = 4;
            clone.layer = 17;
            break;
        }

        clone.SetActive(true);

        //target = clone;
    }
コード例 #29
0
ファイル: Main_Manager.cs プロジェクト: safe27698/PetStory
    private void LoadPet()
    {
        for (int i = 0; i < player.pets.Count; i++)
        {
            if (player.pets[i].color < 0 || !player.pets[i].selected || player.pets[i].status < 0)
            {
                continue;
            }

            PetAI clone = Instantiate(petPrefab.gameObject).GetComponent <PetAI>();
            clone.id        = player.pets[i].id;
            clone.namePet   = player.pets[i].namePet;
            clone.Hunger    = player.pets[i].hunger;
            clone.Happiness = player.pets[i].happiness;
            int color = player.pets[i].color;
            clone.head.sprite    = Atlas.Ins.GetSprites(Atlas.Ins.cha.head.color[color])[player.pets[i].head];
            clone.ear.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.ear.color[color])[player.pets[i].ear];
            clone.pattern.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.pattern.color[color])[player.pets[i].pattern];
            clone.eye.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.eye)[player.pets[i].eye];
            clone.eyebrow.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.eyebrow)[player.pets[i].eyebrow];
            clone.nose.sprite    = Atlas.Ins.GetSprites(Atlas.Ins.cha.nose)[player.pets[i].nose];
            clone.mouth.sprite   = Atlas.Ins.GetSprites(Atlas.Ins.cha.mouth)[player.pets[i].mouth];

            clone.body.sprite     = Atlas.Ins.GetSprites(Atlas.Ins.cha.body)[color];
            clone.armLeft.sprite  = Atlas.Ins.GetSprites(Atlas.Ins.cha.armLeft)[color];
            clone.armRight.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.armRight)[color];
            clone.legLeft.sprite  = Atlas.Ins.GetSprites(Atlas.Ins.cha.legLeft)[color];
            clone.legRight.sprite = Atlas.Ins.GetSprites(Atlas.Ins.cha.legRight)[color];
            List <Sprite> sprite = new List <Sprite>();
            if (player.pets[i].shirtWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shirt.number[player.pets[i].shirtWearing]));
            }
            if (sprite.Count > 1)
            {
                foreach (Sprite s in sprite)
                {
                    if (s.name.ToLower().Contains("body"))
                    {
                        clone.shirtBody.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("left"))
                    {
                        clone.shirtLeft.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("right"))
                    {
                        clone.shirtRight.sprite = s;
                    }
                }
            }
            else if (sprite.Count > 0)
            {
                clone.shirtBody.sprite = sprite[0];
            }
            sprite.Clear();
            if (player.pets[i].pantWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.pant.number[player.pets[i].pantWearing]));
            }
            if (sprite.Count > 1)
            {
                foreach (Sprite s in sprite)
                {
                    if (s.name.ToLower().Contains("body"))
                    {
                        clone.pantBody.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("left"))
                    {
                        clone.pantLeft.sprite = s;
                    }
                    else if (s.name.ToLower().Contains("right"))
                    {
                        clone.pantRight.sprite = s;
                    }
                }
            }
            else if (sprite.Count > 0)
            {
                clone.pantBody.sprite = sprite[0];
            }

            sprite.Clear(); if (player.pets[i].shoeWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shoe.number[player.pets[i].shoeWearing]));
            }
            foreach (Sprite s in sprite)
            {
                if (s.name.ToLower().Contains("left"))
                {
                    clone.shoeLeft.sprite = s;
                }
                else if (s.name.ToLower().Contains("right"))
                {
                    clone.shoeRight.sprite = s;
                }
            }

            sprite.Clear(); if (player.pets[i].accessoriesWearing >= 0)
            {
                sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.ac));
            }
            if (sprite.Count > 0)
            {
                clone.ac.sprite = sprite[player.pets[i].accessoriesWearing];
            }

            petList.Add(clone);
        }

        foreach (Furniture f in player.inventory.furniture)
        {
            if (!f.furnitureIsUsing)
            {
                continue;
            }

            if (f.type == 3)
            {
                FurnitureData data = new FurnitureData();
                data.CloneData(f);
                ChangeFloor(data);
                continue;
            }
            if (f.type == 4)
            {
                FurnitureData data = new FurnitureData();
                data.CloneData(f);
                ChangeWallpaper(data);
                continue;
            }

            FurnitureData ff = new FurnitureData();
            ff.CloneData(f);
            CloneItem(ff);
        }
    }
コード例 #30
0
    private void GetDataParse()
    {
        foreach (TileData _data in mapDataArr)
        {
            if (_data != null)
            {
                TileInfo _info = new TileInfo();

                string[] xyPos = _data.pos.Split('/');
                int      x     = int.Parse(xyPos[0]);
                int      y     = int.Parse(xyPos[1]);

                _info.position  = new Vector2(x, y);
                _info.roomIndex = _data.roomIndex;
                _info.roomType  = _data.roomType;
                _info.doorArr   = _data.doorArr;

                foreach (KeyValuePair <string, int> _dicionary in _data.monSpawnInfoDic)
                {
                    string[] _xyPos = _dicionary.Key.Split('/');

                    float _x = float.Parse(_xyPos[0]);
                    float _y = float.Parse(_xyPos[1]);

                    int _type = _dicionary.Value;

                    _info.monSpawnInfoDic.Add(new Vector2(_x, _y), _type);
                }

                foreach (KeyValuePair <string, FurnitureData> _dicionary in _data.FurnitureInfoDic)
                {
                    FurnitureInfo _finfo = new FurnitureInfo();

                    string[] _xyPos = _dicionary.Key.Split('/');

                    float _x = float.Parse(_xyPos[0]);
                    float _y = float.Parse(_xyPos[1]);

                    FurnitureData _fdata = _dicionary.Value;

                    _finfo.name = _fdata.name;
                    _finfo.pos  = new Vector2(_x, _y);
                    _finfo.dir  = _fdata.dir;

                    _info.FurnitureInfoDic.Add(_finfo.pos, _finfo);
                }

                if (roomIndexListArr[_info.roomIndex] == null)
                {
                    List <TileInfo> roomIndexList = new List <TileInfo>();

                    roomIndexListArr[_info.roomIndex] = roomIndexList;
                }

                roomIndexListArr[_info.roomIndex].Add(_info);

                boardRoomIndexArr[BoardPosParse(x), BoardPosParse(y)] = _info.roomIndex;

                CreateMiniMap(_info);
            }
        }

        mapDataArr = null;
    }
コード例 #31
0
 public void SendMessage(FurnitureData Data)
 {
     //MsgCenter._instance.ChangeTarget(ChooseTarget);
     //MsgCenter._instance.ReceiveMessage(Data);
 }
コード例 #32
0
ファイル: Form1.cs プロジェクト: JacekCzupyt/RoomPlanner
        private void openBlueprintToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openBlueprintDialog = new OpenFileDialog();

            openBlueprintDialog.Filter = "Blueprint files|*.bp";
            openBlueprintDialog.Title  = "Open a Blueprint";

            if (openBlueprintDialog.ShowDialog() == DialogResult.OK)
            {
                var    fs = openBlueprintDialog.OpenFile();
                string content;
                using (StreamReader sr = new StreamReader(fs))
                {
                    content = sr.ReadToEnd();
                }
                fs.Close();
                var furnitureStringList = content.Split("\n".ToCharArray());
                newBlueprintToolStripMenuItem_Click(this, null);
                foreach (string furnitureString in furnitureStringList)
                {
                    if (furnitureString != "")
                    {
                        var s = furnitureString.Split(",".ToCharArray());
                        if (Int32.Parse(s[0]) == 4)
                        {
                            WallData furniture = new WallData(Int32.Parse(s[0]), "", Int32.Parse(s[2]), Int32.Parse(s[3]));
                            furniture.angle = Int32.Parse(s[1]);
                            furniture.image = WallButton.BackgroundImage;
                            for (int i = 6; i < s.Length; i += 2)
                            {
                                furniture.anchors.Add(new Point(Int32.Parse(s[i]), Int32.Parse(s[i + 1])));
                            }
                            FurnitureList.Add(furniture);
                        }
                        else
                        {
                            FurnitureData furniture = new FurnitureData(Int32.Parse(s[0]), "", Int32.Parse(s[2]), Int32.Parse(s[3]));
                            furniture.angle = Int32.Parse(s[1]);
                            switch (Int32.Parse(s[0]))
                            {
                            case 0:
                                furniture.image = CoffeeTableButton.BackgroundImage;
                                break;

                            case 1:
                                furniture.image = TableButton.BackgroundImage;
                                break;

                            case 2:
                                furniture.image = SofaButton.BackgroundImage;
                                break;

                            case 3:
                                furniture.image = BedButton.BackgroundImage;
                                break;

                            default:
                                throw new ArgumentException();
                            }
                            FurnitureList.Add(furniture);
                        }
                    }
                }
                FurnitureList.ResetBindings();
                DrawDesign();
                MessageBox.Show(GlobalStrings.OpenSuccess);
            }
        }