Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        DroppedItem droppedItem = other.GetComponent <DroppedItem>();

        if (droppedItem != null)
        {
            inventory.AddItem(droppedItem.GetItem());
            droppedItem.DestorySelf();
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Monster")
        {
            FindObjectOfType <SoundManager>().Play("default_hurt");
            FindObjectOfType <ParticleSupplier>().SetParticle(transform.position, "player_hit");

            GameObject obj = collision.gameObject;
            OnDamaged(obj.transform.position, obj.GetComponent <MonsterParent>().myMonsterInfo.monsterDamage); //해당 몬스터의 파워가 여기 들어가야함.
            OnDamaged(obj.transform.position, 0);                                                              //해당 몬스터의 파워가 여기 들어가야함.
        }
        if (collision.gameObject.tag == "DropGold")                                                            //Gold Or Crystal
        {
            FindObjectOfType <SoundManager>().Play("default_getCapital");

            DroppedGoldOrCrystal dropGOC = collision.gameObject.GetComponent <DroppedGoldOrCrystal>();
            if (!dropGOC.isGet)
            {
                //Capital(자본을 관리하는 은행)에 돈을 넣는다.
                dropGOC.GetMoneyOrCrystal();
                if (!dropGOC.isCrystal)
                {
                    GetComponent <Capital>().PlusMoney(dropGOC.GoldAmount);
                }
                else
                {
                    GetComponent <Capital>().PlusCrystal(dropGOC.GoldAmount / 10);   //100골드 = 10크리스탈..
                }
            }
        }
        if (collision.gameObject.tag == "Item")
        {
            FindObjectOfType <SoundManager>().Play("default_getItem");

            //아이템 획득 후 처리
            DroppedItem dropIS = collision.gameObject.GetComponent <DroppedItem>();
            dropIS.GetItem();
            changer.UnlockCode(dropIS.dropItemCode);
            //NoticeTextUI 에게 알려야함.
            //아이템 먹었다고 자랑해야함
            NoticeTextUI noticeUI = GameObject.Find("NoticeTextBackground").transform.GetChild(0).GetComponent <NoticeTextUI>();
            noticeUI.ItemEat("야매로 만듬.여기에 획득 아이템잉름 들어가야함");
        }
    }
Exemple #3
0
        private void UpdateTrackingObjects()
        {
            currentOwnerID = gameData.currentOwnerID;
            if (gameData.AK_ID == 0)
            {
                return;
            }

            DestroyAnyTracker();

            // Search the AK on actives players inventory
            foreach (BasePlayer player in BasePlayer.activePlayerList)
            {
                foreach (Item i in player.inventory.FindItemIDs(AK_ITEM_ID))
                {
                    if (i.uid == gameData.AK_ID)
                    {
                        Puts("Found player holding AK ");
                        holdingPlayer = player;
                        holdingPlayer.gameObject.AddComponent <Tracker>();
                        currentOwnerID = player.userID;
                        goldenAK       = i;
                        containerAK    = null;
                        droppedAK      = null;
                        return;
                    }
                }
            }

            // Search the AK on sleeping players inventory
            foreach (BasePlayer player in BasePlayer.sleepingPlayerList)
            {
                foreach (Item i in player.inventory.FindItemIDs(AK_ITEM_ID))
                {
                    if (i.uid == gameData.AK_ID)
                    {
                        Puts("Found sleeping player holding AK");
                        holdingPlayer = player;
                        holdingPlayer.gameObject.AddComponent <Tracker>();
                        currentOwnerID = player.userID;
                        goldenAK       = i;
                        containerAK    = null;
                        droppedAK      = null;
                        return;
                    }
                }
            }

            // Search the AK on dropped items
            droppedAK = FindOnDroppedItems(gameData.AK_ID);
            if (droppedAK != null)
            {
                Puts("Found AK on droppedItem");
                droppedAK.gameObject.AddComponent <Tracker>();
                goldenAK      = droppedAK.GetItem();
                holdingPlayer = null;
                containerAK   = null;
                return;
            }

            // Search the AK on containers
            foreach (StorageContainer container in UnityEngine.Object.FindObjectsOfType <StorageContainer>())
            {
                foreach (Item i in container.inventory.FindItemsByItemID(AK_ITEM_ID))
                {
                    if (i.uid == gameData.AK_ID)
                    {
                        Puts("Found AK on container");
                        containerAK = container;
                        containerAK.gameObject.AddComponent <Tracker>();
                        currentOwnerID = gameData.currentOwnerID;
                        holdingPlayer  = null;
                        goldenAK       = i;
                        return;
                    }
                }
            }
        }