Пример #1
0
    /**
     * 아이템과 관련된 메세지를 출력하는 함수
     * 상황에 따라 3가지 오버로딩
     */
    public void MakeCannotMessage(ItemManager.Label label)
    {
        string s = "";

        ItemManager.ItemType type = ItemManager.LabelToType(label);
        if (type == ItemManager.ItemType.Injector)
        {
            s = "지금은 이 주사기를 사용할 수 없습니다.";
        }
        else if (type == ItemManager.ItemType.Card)
        {
            s = "이 문은 잠겨있습니다. 문 옆에 카드 리더기가 있습니다.";
        }
        else
        {
            s = "Undefined CannotMessage Called";
            Debug.Log("지정되지 않은 예외 상황에서 MakeCannotMessage를 사용했습니다.");
        }
        logger.AddLog(s);
    }
Пример #2
0
    /**
     * 인벤토리 아이템을 플레이어가 클릭했을 때 각 아이템의 라벨에 해당하는 선택 상자를 띄워준다.
     */
    public void OnClicked()
    {
        /* if( false == player.GetInventoryList().isDialogBoxOn && ItemManager.Label.Water== player.InventoryList.GetLabel( index ) )
         *   {
         *   DialogBox dBox;
         *   dBox = ( gObject = Instantiate( dialogBox[ 5 ], new Vector2( 0 + GameObject.Find( "PlayerUI" ).transform.position.x, 2 + GameObject.Find( "PlayerUI" ).transform.position.y ), Quaternion.identity, GameObject.Find( "PlayerUI" ).transform ) ).GetComponent<ExpendableDialogBox>();
         *   dBox.inventoryItem = this;
         *   player.GetInventoryList().isDialogBoxOn = true;
         *
         * } else */if (player.InventoryList.InjecCommuni)
        {
            /*GivemeBox dBox;
             * ItemManager.ItemType nowType = ItemManager.LabelToType(player.InventoryList.GetLabel(index));
             * 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<GivemeBox>();
             * dBox.inventoryItem = this;
             * dBox.npc = this.npc as InjectorCollector;
             * player.GetInventoryList().isDialogBoxOn = true;*/
            //1. dialogbox 요소 가져오기
            Debug.Log("Hi I am GivemeBox");
            GivemeBox gBox = GameObject.Find("Giveme(Clone)").GetComponent <GivemeBox>();
            //2. dialogbox 요소에 정보와 사진 때려박기
            if (ItemManager.ItemType.Injector == ItemManager.LabelToType(player.InventoryList.GetLabel(index)))
            {
                gBox.injector = player.InventoryList.GetLabel(index);
                ItemManager itemManager = GameObject.Find("ItemManager").GetComponent <ItemManager>();
                GameObject.FindWithTag("GivemeBoxImage").GetComponent <UnityEngine.UI.Image>().sprite = itemManager.LabelToSprite(gBox.injector);
            }
            else
            {
                Debug.Log("주사기 아님");
            }
        }

        else if (player.InventoryList.MedicineCommuni)
        {
            //1. dialogbox 요소 가져오기
            Debug.Log("Hi I am GivemeBox");
            SelectBox gBox = GameObject.Find("Select(Clone)").GetComponent <SelectBox>();
            //2. dialogbox 요소에 정보와 사진 때려박기
            if (ItemManager.ItemType.Capsule == ItemManager.LabelToType(player.InventoryList.GetLabel(index)))
            {
                gBox.pill = player.InventoryList.GetLabel(index);
                ItemManager itemManager = GameObject.Find("ItemManager").GetComponent <ItemManager>();
                GameObject.FindWithTag("SelectBoxImage").GetComponent <UnityEngine.UI.Image>().sprite = itemManager.LabelToSprite(gBox.pill);
            }
            else
            {
                Debug.Log("알약 아님");
            }
        }

        else if (false == player.GetInventoryList().isDialogBoxOn)
        {
            DialogBox            dBox;
            ItemManager.ItemType nowType = ItemManager.LabelToType(player.InventoryList.GetLabel(index));
            switch (nowType)
            {
            case ItemManager.ItemType.Weapon:
            case ItemManager.ItemType.Armor: {
                dBox = (gObject = Instantiate(dialogBox[0], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <WeaponArmorDialogBox>();
                dBox.inventoryItem = this;
                WeaponArmorDialogBox W = dBox as WeaponArmorDialogBox;
                ChangeButtonText(W);

                foreach (UnityEngine.UI.Text text in dBox.GetComponentsInChildren <UnityEngine.UI.Text>())
                {
                    if (text.gameObject.name == "Description")
                    {
                        text.text = ItemManager.DescriptionOfItem(ItemManager.LabelToCategory(player.InventoryList.GetLabel(index)));
                    }
                }
                player.GetInventoryList().isDialogBoxOn = true;
                break;
            }

            case ItemManager.ItemType.Expenables: {
                if (player.InventoryList.GetLabel(index) != ItemManager.Label.Water)
                {
                    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 <ExpendableDialogBox>();
                    dBox.inventoryItem = this;
                    foreach (UnityEngine.UI.Text text in dBox.GetComponentsInChildren <UnityEngine.UI.Text>())
                    {
                        if (text.gameObject.name == "Description")
                        {
                            text.text = ItemManager.DescriptionOfItem(ItemManager.LabelToCategory(player.InventoryList.GetLabel(index)));
                        }
                    }
                    player.GetInventoryList().isDialogBoxOn = true;
                }
                else
                {
                    dBox = (gObject = Instantiate(dialogBox[5], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <WaterDialogBox>();
                    dBox.inventoryItem = this;
                    foreach (UnityEngine.UI.Text text in dBox.GetComponentsInChildren <UnityEngine.UI.Text>())
                    {
                        if (text.gameObject.name == "Description")
                        {
                            text.text = ItemManager.DescriptionOfItem(ItemManager.LabelToCategory(player.InventoryList.GetLabel(index)));
                        }
                    }
                    player.GetInventoryList().isDialogBoxOn = true;
                }
                break;
            }

            case ItemManager.ItemType.Capsule: {
                dBox = (gObject = Instantiate(dialogBox[2], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <CapsuleDialogBox>();
                dBox.inventoryItem = this;
                foreach (UnityEngine.UI.Text text in dBox.GetComponentsInChildren <UnityEngine.UI.Text>())
                {
                    if (text.gameObject.name == "Description")
                    {
                        if (GameObject.Find("ItemManager").GetComponent <ItemManager>().GetItemIdentificationInfo(player.InventoryList.GetLabel(index)))
                        {
                            text.text = ItemManager.DescriptionOfItem(ItemManager.LabelToCategory(player.InventoryList.GetLabel(index)));
                        }
                        else
                        {
                            text.text = "뭘까요.";
                        }
                    }
                }
                player.GetInventoryList().isDialogBoxOn = true;
                break;
            }

            case ItemManager.ItemType.Injector: {
                dBox = (gObject = Instantiate(dialogBox[3], new Vector2(0 + GameObject.Find("PlayerUI").transform.position.x, 2 + GameObject.Find("PlayerUI").transform.position.y), Quaternion.identity, GameObject.Find("PlayerUI").transform)).GetComponent <InjectorDialogBox>();
                dBox.inventoryItem = this;
                foreach (UnityEngine.UI.Text text in dBox.GetComponentsInChildren <UnityEngine.UI.Text>())
                {
                    if (text.gameObject.name == "Description")
                    {
                        text.text = ItemManager.DescriptionOfItem(ItemManager.LabelToCategory(player.InventoryList.GetLabel(index)));
                    }
                }
                player.GetInventoryList().isDialogBoxOn = true;
                break;
            }

            case ItemManager.ItemType.Card: {
                /*      foreach( UnityEngine.UI.Text text in dBox.GetComponentsInChildren<UnityEngine.UI.Text>() ) {
                 *        if( text.gameObject.name == "Description" )
                 *            text.text = ItemManager.DescriptionOfItem( ItemManager.LabelToCategory( player.InventoryList.GetLabel( index ) ) );
                 *    }
                 *    dBox = ( gObject = Instantiate( dialogBox[ 4 ], new Vector2( 0 + GameObject.Find( "PlayerUI" ).transform.position.x, 2 + GameObject.Find( "PlayerUI" ).transform.position.y ), Quaternion.identity, GameObject.Find( "PlayerUI" ).transform ) ).GetComponent<CapsuleDialogBox>();
                 *    dBox.inventoryItem = this;
                 *    player.GetInventoryList().isDialogBoxOn = true;*/
                break;
            }

            default:
                return;
            }
        }
        else
        {
            return;
        }
    }
Пример #3
0
    // generate new lilypads from startRow to endRow. The startRow - 1
    // must have a valid lilypad.
    public void GenerateRows(int startRow, int endRow)
    {
        int[] lastRowLanes = GetRowLilypadLanes(startRow - 1);

        if (lastRowLanes.Length == 0)
        {
            Debug.LogError("Row before startRow " + startRow
                           + "is deleted, but the frog may not even have reached that row!");
            return;
        }

        for (int row = startRow; row <= endRow; row++)
        {
            // lilypad generation

            // merging phase
            if (row >= startMergePathRow)
            {
                // "gravitate" the lilypads towards the centre point
                // of the group of lilypads
                int midPoint = 0;
                foreach (int lane in lastRowLanes)
                {
                    midPoint += lane;
                }
                midPoint /= lastRowLanes.Length;

                // only add the lilypad if they do not
                // move beyond the centre point
                foreach (int lane in lastRowLanes)
                {
                    bool goRight = (midPoint - lane) > 0;

                    if (goRight)
                    {
                        if (lane + 1 <= midPoint)
                        {
                            AddLilypad(row, lane + 1);
                        }
                    }
                    else
                    {
                        if (lane - 1 >= midPoint)
                        {
                            AddLilypad(row, lane - 1);
                        }
                    }
                }

                // check if merging ended, if so, start preparing
                // for the next split path
                if (GetRowLilypadLanes(row).Length == 1)
                {
                    SetUpNextSplitPath(row);
                }

                // normal / splitting phase
            }
            else
            {
                // generate next lilypad for each path
                foreach (int lane in lastRowLanes)
                {
                    GenerateRandomLilypad(row, lane);
                }

                // do we need to split?
                if (row == splitPathRow)
                {
                    // generate a new lilypad for the new path
                    // by branching off the 0th path into two
                    GenerateRandomLilypad(row, lastRowLanes[0]);
                }

                if (row == itemRow)
                {
                    int[] lilypadLanes        = GetRowLilypadLanes(row);
                    int   chosenLaneIndex     = Random.Range(0, lilypadLanes.Length);
                    ItemManager.ItemType type = ItemManager.ItemType.SpeedUpItem;
                    if (environmentSingleton.GetBiomeAt(row) == Environment.BiomeType.Space)
                    {
                        type = ItemManager.ItemType.SpeedUpItemSpace;
                    }
                    // 33% chance of spawning dragonfly.
                    if (Random.Range(0, 3) == 0)
                    {
                        type = ItemManager.ItemType.DragonflyItem;
                        if (environmentSingleton.GetBiomeAt(row) == Environment.BiomeType.Space)
                        {
                            type = ItemManager.ItemType.DragonflyItemSpace;
                        }
                    }
                    ItemManager.GetSingleton().CreateItem(
                        type,
                        row,
                        lilypadLanes[chosenLaneIndex]);
                }
            }

            lastRowLanes = GetRowLilypadLanes(row);

            // background generation
            int currentRowBgRow = background.GetBgRowFromFrogRow(row);
            if (currentRowBgRow != lastGeneratedBgRow)
            {
                background.SpawnBg(currentRowBgRow);
                lastGeneratedBgRow = currentRowBgRow;
            }
        }
    }