コード例 #1
0
    void Awake()
    {
        highlightBox = transform.Find("chkHighlight").gameObject;
        playerRigid  = GetComponent <Rigidbody>();
        nowRot       = transform.localRotation;
        playerCamera = GameObject.Find("Camera").GetComponent <Camera>();
        cameraAni    = playerCamera.GetComponent <Animator>();
        playerAniCon = GetComponent <AnimationController>();

        sceneName = SceneManager.GetActiveScene().name;

        if (sceneName == "ItemCollectScene")
        {
            playerSpeed = 3;
            s_itemBtn   = GameObject.Find("itemBtnCanvas/btn_GetItem").GetComponent <ItemBtn>();
            canvas      = GameObject.Find("Canvas");
            Block       = null;
        }

        else if (sceneName == "GameScene")
        {
            DontDestroyOnLoad(transform.parent);
            GM          = GameObject.Find("GameMgr2/itemFieldCntrl").GetComponent <ItemFieldCntrl>();
            sockServObj = GameObject.Find("GameMgr2/MatchingCntrl");
            playerInfo  = sockServObj.GetComponent <GameEnterScript>();
            weaponNum   = playerInfo.savCharInfo.weapon;
            spawnInfo   = sockServObj.GetComponent <SpawnScript>();

            shotMgr = GetComponentInChildren <ShotManager>();
            shotMgr.ShotPosChange(weaponNum);
            shotMgr.point = GameObject.Find("PointPrefab");
            shotMgr.point.SetActive(false);

            StartCoroutine(MoveDelay()); //플레이어의 정보 전송하는 코루틴
            hpText      = GameObject.Find("Canvas").transform.GetChild(0).GetComponent <Text>();
            playerHPBar = GameObject.Find("Canvas").transform.GetChild(3).GetComponent <HpBar>();
            Block       = GameObject.Find("Canvas").transform.GetChild(4).gameObject;


            s_itemSpawn = GameObject.Find("itemSpawnArr").GetComponent <ItemSpawn>();
            s_hitEffect = GameObject.Find("HitEffect").GetComponent <hitEffect>();
            ChinkEffect = GameObject.Find("ChinkEffect");

            ItemImg = new GameObject[4];
            ItemImg[(int)eITEM.em_HP_POTION]         = GameObject.Find("HpPotionImg").gameObject;
            ItemImg[(int)eITEM.em_SPEED_POTION]      = GameObject.Find("SpdPotionImg").gameObject;
            ItemImg[(int)eITEM.em_DAMAGE_UP_POTIOM]  = GameObject.Find("AtkPotionImg").gameObject;
            ItemImg[(int)eITEM.em_DEFENCE_UP_POTION] = GameObject.Find("DefPotionImg").gameObject;
            for (int i = 0; i < 4; i++)
            {
                ItemImg[i].SetActive(false);
            }

            sound    = GameObject.Find("GameMgr").GetComponent <BgmController>();
            effSound = gameObject.GetComponentInChildren <EffSoundController>();
        }
    }
コード例 #2
0
    void Awake()
    {
        highlightBox = transform.Find("chkHighlight").gameObject;
        playerRigid  = GetComponent <Rigidbody>();
        nowRot       = transform.localRotation;
        playerCamera = GameObject.Find("Camera").GetComponent <Camera>();
        cameraAni    = playerCamera.GetComponent <Animator>();
        playerAniCon = GetComponent <AnimationController>();

        sceneName = SceneManager.GetActiveScene().name;

        if (sceneName == "ItemCollectScene")
        {
            playerSpeed = 3;
            s_itemBtn   = GameObject.Find("itemBtnCanvas/btn_GetItem").GetComponent <ItemBtn>();
            canvas      = GameObject.Find("Canvas");
            block       = null;
        }

        else if (sceneName == "GameScene")
        {
            DontDestroyOnLoad(transform.parent);
            GM          = GameObject.Find("GameMgr2/itemFieldCntrl").GetComponent <ItemFieldCntrl>();
            sockServObj = GameObject.Find("GameMgr2/MatchingCntrl");
            playerInfo  = sockServObj.GetComponent <GameEnterScript>();
            weaponNum   = playerInfo.savCharInfo.weapon;
            spawnInfo   = sockServObj.GetComponent <SpawnScript>();
            usedItemEff = GameObject.Find("usedItemEff").GetComponent <Image>();
            usedItemEff.gameObject.SetActive(false);
            Info = GameObject.Find("Info");
            Info.transform.GetChild(weaponNum + 1).gameObject.SetActive(true);

            shotMgr = GetComponentInChildren <ShotManager>();
            shotMgr.ShotPosChange(weaponNum);
            shotMgr.point = GameObject.Find("PointPrefab");
            shotMgr.point.SetActive(false);

            StartCoroutine(MoveDelay()); //플레이어의 정보 전송하는 코루틴
            playerHPBar = GameObject.Find("Canvas/playerHP").GetComponent <HpBar>();
            block       = GameObject.Find("Canvas/Block").gameObject;
            block.SetActive(false);

            s_itemSpawn            = GameObject.Find("itemSpawnArr").GetComponent <ItemSpawn>();
            s_hitEffect            = GameObject.Find("HitEffect").GetComponent <hitEffect>();
            ChinkEffect            = GameObject.Find("ChinkEffect");
            usedItemParticle       = transform.Find("ItemEffect").GetComponentInChildren <ParticleSystem>();
            usedItemParticleRender = transform.Find("ItemEffect").GetComponentInChildren <ParticleSystemRenderer>();
            sound    = GameObject.Find("GameMgr").GetComponent <BgmController>();
            effSound = gameObject.GetComponentInChildren <EffSoundController>();
        }
    }
コード例 #3
0
    void Update()
    {
        if (GM.gameObject == null)
        {
            GM          = GameObject.Find("GameMgr2/itemFieldCntrl").GetComponent <ItemFieldCntrl>();
            layerChange = GameObject.Find("GameMgr2/itemFieldCntrl").GetComponent <LayerChange>();
        }

        if (!IsLayerChange) //무기아이템 GameScene으로 넘어갈 때 weapon layer로 변경
        {
            IsLayerChange = true;
            layerChange   = GM.gameObject.GetComponent <LayerChange>();
            ItemSpawn1 s_itemSpawn   = GameObject.Find("itemSpawn").GetComponent <ItemSpawn1>();
            int        itemSpawnLens = s_itemSpawn.itemSpawn.Length;

            GameObject[] Items = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
            int          len   = Items.Length;
            touchableItems = new GameObject[itemSpawnLens];
            int idx = 0;
            for (int i = 0; i < len; i++)
            {
                if (Items[i].layer == (int)eLAYER.TOUCHABLE)
                {
                    touchableItems[idx] = Items[i];
                    if (touchableItems[idx].tag == "weapon")
                    {
                        layerChange.InputWeaponArr(touchableItems[idx]);
                    }
                    idx++;
                }
            }
        }
        if (Input.GetMouseButtonDown(0) && highlightBox.activeSelf == true)
        {
            TouchItem();
        }
    }