Ejemplo n.º 1
0
    private ItemManager.ItemCategory randomCapsuleRoom()
    {
        Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));

        ItemManager.ItemCategory randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
        while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Capsule || randombar == ItemManager.ItemCategory.CureAll)
        {
            randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
        }
        return(randombar);
    }
Ejemplo n.º 2
0
 /** 해당 카테고리에 해당하는 아이템이 있는지 확인한다.
  */
 public bool CheckItem(ItemManager.ItemCategory itemCategory)
 {
     for (int i = 0; i < size; i++)
     {
         if (itemCategory == ItemManager.LabelToCategory(labelList[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
    public void GiveCapsule()
    {
        ItemManager itemManager = GameObject.Find("ItemManager").GetComponent <ItemManager>();
        Array       values      = Enum.GetValues(typeof(ItemManager.ItemCategory));

        ItemManager.ItemCategory randomBar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));

        while (ItemManager.CategoryToType(randomBar) != ItemManager.ItemType.Capsule || randomBar == ItemManager.ItemCategory.CureAll)
        {
            randomBar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
        }

        itemManager.InstantiateItem(randomBar, boardmanager.NowPos());
    }
Ejemplo n.º 4
0
    public void setRank(ItemManager.ItemCategory category)
    {
        BoardManager boardManager = GameObject.Find("BoardManager").GetComponent <BoardManager>();
        ItemManager  itemManager  = GameObject.Find("ItemManager").GetComponent <ItemManager>();

        int floor = boardManager.WhichFloor;
        int cPer  = 77 - 7 * floor;
        int rPer  = 20 + 5 * floor;
        int lPer  = 3 + 2 * floor;

        UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);

        int  rand    = UnityEngine.Random.Range(0, 100);
        bool rankSet = false;

        while (!rankSet)
        {
            rand = UnityEngine.Random.Range(0, 100);
            if (rand < cPer)
            {
                if (itemManager.cEquip.Contains(category))
                {
                    rankSet = true;
                    rank    = ItemManager.Rank.Common;
                }
            }
            else if (rand < cPer + rPer)
            {
                if (itemManager.rEquip.Contains(category))
                {
                    rankSet = true;
                    rank    = ItemManager.Rank.Rare;
                }
            }
            else
            {
                if (itemManager.lEquip.Contains(category))
                {
                    rankSet = true;
                    rank    = ItemManager.Rank.Legendary;
                }
            }
        }
        Debug.Log(name + "의 등급은" + rank.ToString());
    }
Ejemplo n.º 5
0
    protected void OnDestroy()
    {
        int per;

        if (player.InventoryList.CheckItem(ItemManager.Label.AdrenalineDrug) || player.InventoryList.CheckItem(ItemManager.Label.MorfinDrug)) //약이 있는경우
        {
            per = dropDB[level];
        }
        else
        {
            if (player.isHallucinated)
            {
                per = 100;
            }
            else
            {
                per = nDropDB[level];
            }
        }

        if (per > UnityEngine.Random.Range(0, 100))
        {
            Debug.Log("주사기 줍니다");
            ItemManager itemManager            = GameObject.Find("ItemManager").GetComponent <ItemManager>();
            Array       values                 = Enum.GetValues(typeof(ItemManager.ItemCategory));
            ItemManager.ItemCategory randomBar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));

            while (ItemManager.CategoryToType(randomBar) != ItemManager.ItemType.Injector || randomBar == ItemManager.ItemCategory.RingerSolution)
            {
                randomBar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
            }
            Vector3 tnowPos = transform.position;
            Vector2 nowPos;
            nowPos.x = tnowPos.x;
            nowPos.y = tnowPos.y;

            itemManager.InstantiateItem(randomBar, nowPos);
        }
    }
Ejemplo n.º 6
0
    private ItemManager.ItemCategory randomItem(Dictionary <string, int> itemCount, int floor)
    {
        int percent = UnityEngine.Random.Range(0, 100);
        var totNum  = 0;

        foreach (var e in itemCount)
        {
            totNum += e.Value;
        }
        if (totNum < 1)
        {
            Debug.Log("준비한 아이템 모두 소모. Empty 리턴.");
            return(ItemManager.ItemCategory.Empty);
        }

        if (0 <= percent && percent < 60)
        {
            if (itemCount["Water"] != 0)
            {
                itemCount["Water"]--;
                return(ItemManager.ItemCategory.Water);
            }
            else if (itemCount["Can"] != 0)
            {
                itemCount["Can"]--;
                return(ItemManager.ItemCategory.Can);
            }
            else if (itemCount["Medicine"] != 0)
            {
                itemCount["Medicine"]--;
                return(ItemManager.ItemCategory.Medicine);
            }
            else if (itemCount["Bandage"] != 0)
            {
                itemCount["Bandage"]--;
                return(ItemManager.ItemCategory.Bandage);
            }
            else
            {
                return(randomItem(itemCount, floor));
            }
        }
        else if (60 <= percent && percent < 80)
        {
            if (itemCount["Capsule"] != 0)
            {
                itemCount["Capsule"]--;
                Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));
                ItemManager.ItemCategory randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Capsule || randombar == ItemManager.ItemCategory.CureAll)
                {
                    randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                }
                return(randombar);
            }
            else
            {
                return(randomItem(itemCount, floor));
            }
        }
        else if (80 <= percent && percent < 90)
        {
            if (itemCount["Injector"] != 0)
            {
                itemCount["Injector"]--;
                Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));
                ItemManager.ItemCategory randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Injector)
                {
                    randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                }
                return(randombar);
            }
            else
            {
                return(randomItem(itemCount, floor));
            }
        }
        else
        {
            if (itemCount["Equip"] != 0)
            {
                itemCount["Equip"]--;
                return(randomEquip(floor));

                Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));
                ItemManager.ItemCategory randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Armor &&
                       ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Weapon)
                {
                    randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                }
                return(randombar);
            }
            else
            {
                return(randomItem(itemCount, floor));
            }
        }
    }
Ejemplo n.º 7
0
    private List <MapTile> Generate(List <MapTile> map, int floor)
    {
        Dictionary <string, int> RoomCounts = new Dictionary <string, int>();

        RoomCounts.Add("L", 1);
        RoomCounts.Add("N1", 0);
        RoomCounts.Add("N2", 1);
        RoomCounts.Add("N3", 1);


        Dictionary <string, int> itemCounts    = new Dictionary <string, int>();
        Dictionary <string, int> capsuleCounts = new Dictionary <string, int>();

        itemCounts.Add("Equip", 2);
        itemCounts.Add("Capsule", 4);
        itemCounts.Add("Injector", 2);
        itemCounts.Add("Can", 1);
        itemCounts.Add("Water", 5);
        itemCounts.Add("Medicine", 3);
        itemCounts.Add("Bandage", 3);

        foreach (MapTile tile in map)
        {
            if (tile.roomType == BoardManager.RoomType.LockedRoom)
            {
                RoomCounts["N1"]++;
            }
        }

        int p         = 0;
        int nSpecific = 0;
        int lSpecific = 0;

        foreach (MapTile tile in map)
        {
            p++;

            // 임시 코드임. 원인 찾으면 해결바람.
            //for debug

            tile.enemyList.Clear();
            tile.NPCList.Clear();
            tile.itemList.Clear();

            switch (tile.roomType)
            {
            case BoardManager.RoomType.BossRoom:
                switch (floor)
                {
                case 1:
                    tile.AddEnemy(BoardManager.EnemyType.BoundedCrazy);
                    break;

                case 2:
                    tile.AddEnemy(BoardManager.EnemyType.Gunner);
                    break;

                case 3:
                    tile.AddEnemy(BoardManager.EnemyType.Nurse);
                    break;

                case 4:
                    tile.AddEnemy(BoardManager.EnemyType.AngryDog);
                    break;

                case 5:
                    tile.AddEnemy(BoardManager.EnemyType.GPOSClub);
                    tile.AddEnemy(BoardManager.EnemyType.GPOSClub);
                    tile.AddEnemy(BoardManager.EnemyType.GPOSClub);
                    tile.AddEnemy(BoardManager.EnemyType.GPOSClub);
                    tile.AddEnemy(BoardManager.EnemyType.GPOSClub);
                    break;

                case 6:
                    tile.AddEnemy(BoardManager.EnemyType.HospitalDirector);
                    break;
                }
                break;

            case BoardManager.RoomType.NormalRoom:

                switch (Ntype(RoomCounts["N1"], RoomCounts["N2"], RoomCounts["N3"], nSpecific))
                {
                case "1_NPC":
                    tile.AddNPC(randomNPC());
                    break;

                case "2_Enemy":
                    tile.AddEnemy(randomEnemy());
                    tile.AddEnemy(randomEnemy());
                    break;

                case "3_Enemy":
                    tile.AddEnemy(randomEnemy());
                    tile.AddEnemy(randomEnemy());
                    tile.AddEnemy(randomEnemy());
                    break;

                case "1_Item":
                    tile.AddItem(randomItem(itemCounts, floor));
                    break;

                case "2_Item":
                    tile.AddItem(randomItem(itemCounts, floor));
                    tile.AddItem(randomItem(itemCounts, floor));
                    break;

                case "1_Enemy":
                    tile.AddEnemy(randomEnemy());
                    break;

                case "1_WK+1_Item":
                    tile.AddItem(randomItem(itemCounts, floor));
                    tile.AddItem(ItemManager.ItemCategory.WhiteCard);
                    break;

                case "1_Can+3_Water":
                    tile.AddItem(ItemManager.ItemCategory.Can);
                    tile.AddItem(ItemManager.ItemCategory.Water);
                    tile.AddItem(ItemManager.ItemCategory.Water);
                    tile.AddItem(ItemManager.ItemCategory.Water);
                    break;

                case "1_Enemy+1_YK":
                    tile.AddEnemy(randomEnemy());
                    tile.AddItem(ItemManager.ItemCategory.YellowCard);
                    break;
                }
                nSpecific++;

                break;

            case BoardManager.RoomType.Hall:
                switch (Htype())
                {
                case "Nothing":
                    break;

                case "1_Enemy":
                    tile.AddEnemy(randomEnemy());
                    break;

                case "2_Enemy":
                    tile.AddEnemy(randomEnemy());
                    tile.AddEnemy(randomEnemy());
                    break;

                case "1_Item":
                    tile.AddItem(randomItem(itemCounts, floor));
                    break;
                }
                break;

            case BoardManager.RoomType.DrugRoom:
                tile.AddItem(ItemManager.ItemCategory.CureAll);
                tile.AddItem(randomCapsuleRoom());
                tile.AddItem(randomCapsuleRoom());
                tile.AddItem(randomCapsuleRoom());
                tile.AddItem(randomCapsuleRoom());
                break;

            case BoardManager.RoomType.RestRoom:
                if (floor == 5)
                {
                    tile.AddNPC(BoardManager.NPCType.CapsuleDespenser);
                    tile.AddNPC(BoardManager.NPCType.InjectorCollector);
                }
                else
                {
                    switch (Rtype())
                    {
                    case "CapNPC+1_NPC":
                        tile.AddNPC(BoardManager.NPCType.CapsuleDespenser);
                        tile.AddNPC(randomNPC());
                        break;

                    case "CapNPC+2_NPC":
                        tile.AddNPC(BoardManager.NPCType.CapsuleDespenser);
                        tile.AddNPC(randomNPC());
                        tile.AddNPC(randomNPC());
                        break;
                    }
                }
                break;

            case BoardManager.RoomType.LockedRoom:
                switch (Ltype(RoomCounts["L"], lSpecific))
                {
                case "1_NPC":
                    tile.AddNPC(randomNPC());
                    break;

                case "2_Item":
                    tile.AddItem(randomItem(itemCounts, floor));
                    tile.AddItem(randomItem(itemCounts, floor));
                    break;

                case "1_Human+1_Ringer":
                    tile.AddEnemy(BoardManager.EnemyType.Human);
                    tile.AddItem(ItemManager.ItemCategory.RingerSolution);
                    break;

                case "1_CureAll+1_Water":
                    tile.AddItem(ItemManager.ItemCategory.CureAll);
                    tile.AddItem(ItemManager.ItemCategory.Water);
                    break;
                }
                break;

            case BoardManager.RoomType.Equipment:
                if (floor == 1)
                {
                    ItemManager.ItemCategory randombar = randomEquip(floor);
                    while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Weapon)
                    {
                        randombar = randomEquip(floor);
                    }
                    tile.AddItem(randombar);
                }
                else
                {
                    Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));
                    ItemManager.ItemCategory randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                    while (ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Weapon &&
                           ItemManager.CategoryToType(randombar) != ItemManager.ItemType.Armor)
                    {
                        randombar = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                    }
                    tile.AddItem(randombar);
                }
                break;

            case BoardManager.RoomType.PlayerStart:
                break;

            default: break;
            }
            if (tile.enemyList.Count > 3)
            {
                Debug.Log("4층 이하에서 이거뜨면 버그룸임");
            }
        }

        return(map);
    }
Ejemplo n.º 8
0
 public void AddItem(ItemManager.ItemCategory item)
 {
     itemList.Add(item);
 }
Ejemplo n.º 9
0
    public override void talk(Player player)
    {
        if (usuability == 100)
        {
            if (boardmanager.WhichFloor == 5)
            {
                player.InventoryList.AddItem(ItemManager.Label.BlackKnife);//전설주사기로 바꿔.
                usuability = 0;

                player.InventoryList.InjecCommuni = false;

                CantTalkBox dBox = (gObject = Instantiate(dialogBox[1], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <CantTalkBox>();
                dBox.npc = this;
                dBox.GetComponentInChildren <UnityEngine.UI.Text>().text = "감사합니다. 여기 제가 가지고 있던 비상식량과 알약을 가져가세요.";
                player.GetInventoryList().isDialogBoxOn = false; //다이얼로그 끝난 정보 저장
            }
            else
            {
                Array values = Enum.GetValues(typeof(ItemManager.ItemCategory));
                ItemManager.ItemCategory randomBar1 = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                ItemManager.ItemCategory randomBar2 = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));

                while (ItemManager.CategoryToType(randomBar1) != ItemManager.ItemType.Capsule || randomBar1 == ItemManager.ItemCategory.CureAll ||
                       ItemManager.CategoryToType(randomBar2) != ItemManager.ItemType.Capsule || randomBar2 == ItemManager.ItemCategory.CureAll ||
                       randomBar1 == randomBar2
                       )
                {
                    randomBar1 = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                    randomBar2 = (ItemManager.ItemCategory)values.GetValue(UnityEngine.Random.Range(0, values.Length));
                }

                ItemManager.Label label1 = ItemManager.CategoryToLabel(randomBar1, boardmanager.WhichFloor);
                ItemManager.Label label2 = ItemManager.CategoryToLabel(randomBar2, boardmanager.WhichFloor);

                /*
                 * player.PlayerAction.PickItem( label1 );
                 * player.PlayerAction.PickItem( label2 );
                 * player.PlayerAction.PickItem( ItemManager.Label.Can );
                 * player.PlayerAction.PickItem( ItemManager.Label.Can );
                 * player.PlayerAction.PickItem( ItemManager.Label.Water );
                 * player.PlayerAction.PickItem( ItemManager.Label.Water );*/
                //아이템 포지션 설정.
                Vector2    nowPos = new Vector2(boardmanager.XPos * BoardManager.horizontalMovement, boardmanager.YPos * BoardManager.verticalMovement);
                Vector2 [] GenPos = new Vector2 [6];
                for (var i = 0; i < 6; i++)
                {
                    GenPos [i] = new Vector2(-5 + 2 * i, 0);
                }

                itemmanager.InstantiateItem(randomBar1, GenPos[0] + nowPos);
                itemmanager.InstantiateItem(randomBar2, GenPos[1] + nowPos);
                itemmanager.InstantiateItem(ItemManager.ItemCategory.Can, GenPos[2] + nowPos);
                itemmanager.InstantiateItem(ItemManager.ItemCategory.Can, GenPos[3] + nowPos);
                itemmanager.InstantiateItem(ItemManager.ItemCategory.Water, GenPos[4] + nowPos);
                itemmanager.InstantiateItem(ItemManager.ItemCategory.Water, GenPos[5] + nowPos);


                usuability = 0;

                player.InventoryList.InjecCommuni = false;

                CantTalkBox dBox = (gObject = Instantiate(dialogBox[1], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <CantTalkBox>();
                dBox.npc = this;
                dBox.GetComponentInChildren <UnityEngine.UI.Text>().text = "감사합니다. 여기 제가 가지고 있던 비상식량과 알약을 가져가세요.";
                player.GetInventoryList().isDialogBoxOn = false; //다이얼로그 끝난 정보 저장
            }
        }
        else
        {
            Debug.Log("InjectorCollector error: talk shld not work when usuablility = 0");
            usuability = 0;
        }
    }