コード例 #1
0
    IEnumerator ExecuteAfterTime(float time)
    {
        yield return(new WaitForSeconds(time));

        player          = GameObject.FindGameObjectWithTag("Player"); // null because player isn't exist yet;
        playerInventory = player.GetComponent <ShootBehaviour>();
        gameController  = GameObject.FindGameObjectWithTag("GameController");
        // Assert that exists a on-screen HUD.
        if (GameObject.Find("ScreenHUD") == null)
        {
            Debug.LogError("No ScreenHUD canvas found. Create ScreenHUD inside the GameController");
        }
        weaponHud = GameObject.Find("ScreenHUD").GetComponent <WeaponUIManager>();
        pickupHUD = gameController.transform.Find("PickupHUD");
        // Create physics components and radius of interaction.
        col = this.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();
        CreateInteractiveRadius(col.center);
        this.rbody = this.gameObject.AddComponent <Rigidbody>();
        // Assert that an weapon slot is set up.
        if (this.type == WeaponType.NONE)
        {
            Debug.LogWarning("Set correct weapon slot ( 1 - small/ 2- big)");
            type = WeaponType.SHORT;
        }
        // Assert that the gun muzzle is exists.
        if (!this.transform.Find("muzzle"))
        {
            Debug.LogError(this.name + " muzzle is not present. Create a game object named 'muzzle' as a child of this game object");
        }
        // Set default values.
        fullMag    = mag;
        maxBullets = totalBullets;
        pickupHUD.gameObject.SetActive(false);
    }
    private Transform pickupHUD;                              // Reference to the weapon pickup in-game label.


    void Awake()
    {
        // Set up the references.
        this.gameObject.name  = this.label;
        this.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
        foreach (Transform t in this.transform)
        {
            t.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
        }

        player = GameObject.FindGameObjectWithTag("Player");

        //playerInventory = player.GetComponent<ShootBehaviour>();

        gameController = GameObject.FindGameObjectWithTag("GameController");

        // Assert that exists a on-screen HUD.
        if (GameObject.Find("ScreenHUD") == null)
        {
            Debug.LogError("No ScreenHUD canvas found. Create ScreenHUD inside the GameController");
        }
        weaponHud = GameObject.Find("ScreenHUD").GetComponent <WeaponUIManager>();
        pickupHUD = gameController.transform.GetChild(0);//Find("PickupHUD");


        // Create physics components and radius of interaction.
        col = this.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();
        CreateInteractiveRadius(col.center);
        this.rbody = this.gameObject.AddComponent <Rigidbody>();

        // Assert that an weapon slot is set up.
        if (this.type == WeaponType.NONE)
        {
            Debug.LogWarning("Set correct weapon slot ( 1 - small/ 2- big)");
            type = WeaponType.SHORT;
        }

        // Assert that the gun muzzle is exists.
        if (!this.transform.Find("muzzle"))
        {
            Debug.LogError(this.name + " muzzle is not present. Create a game object named 'muzzle' as a child of this game object");
        }

        // Set default values.
        fullMag    = mag;
        maxBullets = totalBullets;
        pickupHUD.gameObject.SetActive(false);
    }
コード例 #3
0
    private void Awake()
    {
        myTransform     = transform;
        gameObject.name = this.label_weaponName;

        // 레이캐스트 무시 레이어 설정(하위 자식 모두)
        gameObject.layer = LayerMask.NameToLayer(FC.TagAndLayer.LayerName.IgnoreRayCast);
        foreach (Transform tr in this.myTransform)
        {
            tr.gameObject.layer = LayerMask.NameToLayer(FC.TagAndLayer.LayerName.IgnoreRayCast);
        }

        player          = GameObject.FindGameObjectWithTag(FC.TagAndLayer.TagName.Player);
        playerInventory = player.GetComponent <ShootBehaviour>();
        gameController  = GameObject.FindGameObjectWithTag(FC.TagAndLayer.TagName.GameController);

        if (weaponHUD == null)
        {
            if (screenHUD == null)
            {
                screenHUD = GameObject.Find("ScreenHUD");
            }
            weaponHUD = screenHUD.GetComponent <WeaponUIManager>();
        }

        if (pickHUD == null)
        {
            pickHUD = gameController.transform.Find("PickupHUD");
        }

        //Interactive 하기 위한 충돌체 설정
        weaponCollider = myTransform.GetChild(0).gameObject.AddComponent <BoxCollider>();
        CreateInteractiveRadius(weaponCollider.center);
        weaponRigidbody = gameObject.AddComponent <Rigidbody>();

        if (this.weaponType == WeaponType.NONE)
        {
            this.weaponType = WeaponType.SHORT;
        }
        fullMag    = currentMagCapacity;
        maxBullets = totalBullets;
        pickHUD.gameObject.SetActive(false);
        if (muzzleTransform == null)
        {
            muzzleTransform = transform.Find("muzzle");
        }
    }
コード例 #4
0
    private void Awake()
    {
        thisTrans      = transform;
        thisGameObject = gameObject;

        thisGameObject.name  = label_WeaponName;
        thisGameObject.layer = LayerMask.NameToLayer(TagAndLayer.LayerName.IgnoreRayCast);
        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject child = transform.GetChild(i).gameObject;
            child.layer = LayerMask.NameToLayer(TagAndLayer.LayerName.IgnoreRayCast);
        }
        player          = GameObject.FindGameObjectWithTag(TagAndLayer.TagName.Player);
        playerInventory = player.GetComponent <ShootBehaviour>();
        gameController  = GameObject.FindGameObjectWithTag(TagAndLayer.TagName.GameController);

        if (weaponHUD == null)
        {
            if (screenHUD == null)
            {
                screenHUD = GameObject.Find("ScreenHUD");
            }
            weaponHUD = screenHUD.GetComponent <WeaponUIManager>();
        }
        if (pickHUD == null)
        {
            pickHUD = gameController.transform.Find("PickupHUD");
        }

        weaponCollider = thisTrans.GetChild(0).gameObject.AddComponent <BoxCollider>();
        CreateInteractiveRadius(weaponCollider.center);

        weaponRigidbody = thisGameObject.AddComponent <Rigidbody>();

        if (weaponType == WeaponType.NONE)
        {
            weaponType = WeaponType.SHORT;
        }

        fullMag    = currentMagCapacity;
        maxBullets = totalBullets;
        pickHUD.gameObject.SetActive(false);
        if (muzzleTrans == null)
        {
            muzzleTrans = thisTrans.Find("muzzle");
        }
    }