예제 #1
0
파일: GameManager.cs 프로젝트: kula1027/AD
    /*	public void makeDrink (Item sc_drink, Vector3 drinkPos){
        //todo 미리 뿌려져있는 술과 겹쳐지게 해야함.
        TileInfo ti = boardManager._Stage [currStage].get_tileInfo ()[((int)drinkPos.y), ((int)drinkPos.x)];
        GameObject go_drink = Instantiate (Resources.Load ("Image_Drink/" + Config.spriteName_Item[sc_drink.GetItemCode()], typeof(GameObject))) as GameObject;
        go_drink.transform.position = drinkPos;
        ti.i.Add (sc_drink);					//Tile Info에 등록
    }*/
    public void makeItemGO(int itemType, Vector3 itemPos, string resourceName)
    {
        TileInfo ti = boardManager._Stage [currStage].get_tileInfo ()[((int)itemPos.y), ((int)itemPos.x)];

        if (itemType < 0) {																			//골드일 경우
            GameObject go_gold = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
            go_gold.GetComponent<ObjectID> ().secondCode = -itemType;
            go_gold.transform.position = itemPos;
            go_gold.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;			//소팅 레이어 등록
            Gold sc_gold = new Gold ();
            sc_gold.SetGameObject (go_gold);
            sc_gold.init (-1, -itemType, 0);
        //			Debug.Log("make Item in " + itemPos.x + "," + itemPos.y);
            ti.i.Add (sc_gold);		//Tile Info에 드랍 골드 등록
        } else {
            switch(itemType){
            case 0:			//drink
                Debug.Log("Can't make drink here");
                break;
            case 1:			//weapon
                GameObject go_weapon = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_weapon.transform.position = itemPos;
                go_weapon.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Weapon sc_weapon = new Weapon();
                sc_weapon.SetGameObject (go_weapon);
                ObjectID weaponId = go_weapon.GetComponent<ObjectID>();
                sc_weapon.init (weaponId.firstCode, weaponId.secondCode, weaponId.thirdCode);
                ti.i.Add (sc_weapon);		//Tile Info에 등록
                break;
            case 2:			//accessory
                GameObject go_acce = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_acce.transform.position = itemPos;
                go_acce.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Accessory sc_acce = new Accessory();
                sc_acce.SetGameObject (go_acce);
                ObjectID acceId = go_acce.GetComponent<ObjectID>();
                sc_acce.init (acceId.firstCode, acceId.secondCode, acceId.thirdCode);
                ti.i.Add (sc_acce);		//Tile Info에 등록
                break;
            case 3:			//snack
                GameObject go_snack = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_snack.transform.position = itemPos;
                go_snack.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                Snack sc_snack = new Snack();
                sc_snack.SetGameObject (go_snack);
                ObjectID snackId = go_snack.GetComponent<ObjectID>();
                sc_snack.init (snackId.firstCode, snackId.secondCode, snackId.thirdCode);
                ti.i.Add (sc_snack);		//Tile Info에 등록
                break;
            case 4:			//alcoholBag
                GameObject go_abg = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_abg.transform.position = itemPos;
                go_abg.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                AlcoholBag sc_abg = new AlcoholBag();
                sc_abg.SetGameObject (go_abg);
                ObjectID abgId = go_abg.GetComponent<ObjectID>();
                sc_abg.init (abgId.firstCode, abgId.secondCode, abgId.thirdCode);
                ti.i.Add (sc_abg);			//Tile Info에 등록
                break;
            case 5:			//alcoholBottle
                GameObject go_abt = Instantiate (Resources.Load (resourceName, typeof(GameObject))) as GameObject;
                go_abt.transform.position = itemPos;
                go_abt.GetComponent<SpriteRenderer> ().sortingOrder = ti.i.Count+ti.d.Count;		//소팅 레이어 등록
                AlcoholBottle sc_abt = new AlcoholBottle();
                sc_abt.SetGameObject (go_abt);
                ObjectID abtId = go_abt.GetComponent<ObjectID>();
                sc_abt.init (abtId.firstCode, abtId.secondCode, abtId.thirdCode);
                ti.i.Add (sc_abt);			//Tile Info에 등록
                break;
            }
        }
    }