예제 #1
0
    /// <summary>
    /// Used to detect tripwire material pick ups as this is attached to the player
    /// </summary>
    /// <param name="collision"></param>
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Trip Wire Materials")
        {
            //this should probably be an event instead
            if (gameObject.GetComponent <ToolBelt>().allToolsDisabled == true)
            {
                // AudioManager.Instance.Play(AudioClipName.tripwire_TTS);
                gameObject.GetComponent <ToolBelt>().enabledTool      = Constants.Tools.TripWire;
                gameObject.GetComponent <ToolBelt>().allToolsDisabled = false;

                //invoke the event to change the UI to make the tripwire the enabled tool
                changeSelectionEvent.Invoke(Constants.Tools.TripWire);
            }



            tripWireCount++;
            //TEMPORARY CODE FOR TUTORIAL TO TESTERS
            if (tripWireCount > 5)
            {
                tripWireCount = 5;
            }
            updateCountEvent.Invoke(Constants.Tools.TripWire, tripWireCount);
            Destroy(collision.gameObject);
            AudioManager.Instance.Play(AudioClipName.item_Pickup);
        }
    }
예제 #2
0
    /// <summary>
    /// Player interacts with grenade materials and increments count
    /// </summary>
    /// <param name="collision"></param>
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Grenade Material")
        {
            //This should probably be an event instead
            if (gameObject.GetComponent <ToolBelt>().allToolsDisabled == true)
            {
                //AudioManager.Instance.Play(AudioClipName.stasis_Grenade_TTS);
                gameObject.GetComponent <ToolBelt>().enabledTool      = Constants.Tools.StasisGrenade;
                gameObject.GetComponent <ToolBelt>().allToolsDisabled = false;

                //invoke event to change highlight to grenade
                selectionChangeEvent.Invoke(Constants.Tools.StasisGrenade);
            }
            Destroy(collision.gameObject);
            grenadeCount++;
            //TEMPORARY CODE FOR TUTORIAL TO TESTERS
            if (grenadeCount > 5)
            {
                grenadeCount = 5;
            }
            //update the count in the UI for the stasis grenade
            updateCountEvent.Invoke(Constants.Tools.StasisGrenade, grenadeCount);
            AudioManager.Instance.Play(AudioClipName.item_Pickup);
        }
    }
예제 #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ping Materials")
        {
            if (gameObject.GetComponent <ToolBelt>().allToolsDisabled == true)
            {
                // AudioManager.Instance.Play(AudioClipName.tripwire_TTS);
                gameObject.GetComponent <ToolBelt>().enabledTool      = Constants.Tools.PingDevice;
                gameObject.GetComponent <ToolBelt>().allToolsDisabled = false;

                //invoke the event to change the UI to make the tripwire the enabled tool
                changeSelectionEvent.Invoke(Constants.Tools.PingDevice);
            }
            AudioManager.Instance.Play(AudioClipName.item_Pickup);
            pingDeviceCount += 2;
            //TEMPORARY CODE FOR TUTORIAL TO TESTERS
            if (pingDeviceCount > 5)
            {
                pingDeviceCount = 5;
            }
            updateCountEvent.Invoke(Constants.Tools.PingDevice, pingDeviceCount);
            Destroy(collision.gameObject);
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Tools are disabled? " + allToolsDisabled);

        //if all the tools arent disabled
        if (!allToolsDisabled)
        {
            //if player presses one then try to switch to tripwire tool
            if (Input.GetKeyDown("1"))
            {
                //if count of tripwire is greater than 0, then switch to it
                if (gameObject.GetComponent <TripWire>().tripWireCount > 0)
                {
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                    //enabled tool is now TripWire
                    enabledTool = Constants.Tools.TripWire;
                    //invoke event to change the selection on the UI to the now enabled tool TripWire
                    changeSelectionEvent.Invoke(enabledTool);
                    //Debug.Log("Switched through num 1");
                }
                //if count is less than 1 then play sound for not enough materials
                else
                {
                    //Debug.Log("Not enough to switch for num 1 use");
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
                }
            }
            //if player presses two then try to switch to grenade tool
            else if (Input.GetKeyDown("2"))
            {
                //if grenade count if greater than 0 then switch to this tool
                if (gameObject.GetComponent <StasisGrenade>().grenadeCount > 0)
                {
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                    //set enabled tool as Stasis Grenade
                    enabledTool = Constants.Tools.StasisGrenade;
                    //invoke the event for changing the highlight in the toolbelt UI to the enabled tool, Stasis Grenade
                    changeSelectionEvent.Invoke(enabledTool);
                    //Debug.Log("Switched through num 2");
                }
                //if count is less than one then play sound for not enough materials
                else
                {
                    //Debug.Log("Not enough to switch for num 2 use ");
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
                }
            }
            else if (Input.GetKeyDown("3"))
            {
                //if grenade count if greater than 0 then switch to this tool
                if (gameObject.GetComponent <PingDevice>().pingDeviceCount > 0)
                {
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                    //set enabled tool as Stasis Grenade
                    enabledTool = Constants.Tools.PingDevice;
                    //invoke the event for changing the highlight in the toolbelt UI to the enabled tool, Stasis Grenade
                    changeSelectionEvent.Invoke(enabledTool);
                    //Debug.Log("Switched through num 2");
                }
                //if count is less than one then play sound for not enough materials
                else
                {
                    //Debug.Log("Not enough to switch for num 2 use ");
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
                }
            }
            //Debug.Log("Tool enabled on " + enabledTool);
            //if player scrolls up then switch to the tool to the left of the current tool enabled
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                //used to set enabledTool to end of enums list
                //need to replace this with ping device once it's created
                if (enabledTool == Constants.Tools.TripWire)
                {
                    if (gameObject.GetComponent <PingDevice>().pingDeviceCount <= 0)
                    {
                        enableTool(Constants.Tools.StasisGrenade);
                    }
                    else
                    {
                        enableTool(Constants.Tools.PingDevice);
                    }
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                }
                //if enabled tool isnt the beginning of the list then go back one
                //in the enums and try to enable that tool
                else if (enabledTool == Constants.Tools.StasisGrenade)
                {
                    if (gameObject.GetComponent <TripWire>().tripWireCount <= 0)
                    {
                        enableTool(Constants.Tools.PingDevice);
                    }
                    else
                    {
                        enableTool(Constants.Tools.TripWire);
                    }

                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                }
                else if (enabledTool == Constants.Tools.PingDevice)
                {
                    if (gameObject.GetComponent <StasisGrenade>().grenadeCount <= 0)
                    {
                        enableTool(Constants.Tools.TripWire);
                    }
                    else
                    {
                        enableTool(Constants.Tools.StasisGrenade);
                    }
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                }

                //Debug.Log("Scrolled up and tool is " + enabledTool);
            }
            //if player scrolls down to switch tools
            else if (Input.GetAxis("Mouse ScrollWheel") < 0)
            {
                if (enabledTool == Constants.Tools.TripWire)
                {
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                    enableTool(Constants.Tools.StasisGrenade);
                }
                else if (enabledTool == Constants.Tools.StasisGrenade)
                {
                    enableTool(Constants.Tools.PingDevice);
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                }
                //used to reset the enabledTool to the beginning of enums
                //if we are at the end of enum list
                else if (enabledTool == Constants.Tools.PingDevice)
                {
                    AudioManager.Instance.Play(AudioClipName.toolBelt_Search);
                    enableTool(Constants.Tools.TripWire);
                }

                //Debug.Log("Scrolled down and enabled tool is " + enabledTool);
            }
        }
        //when tools are all disabled and trying to change tools through num keys
        //play sound to show theres no materials
        else if (allToolsDisabled)
        {
            //for tripwire
            if (Input.GetKeyDown("1"))
            {
                //Debug.Log("cant move, all tools disabled");
                AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
            }
            //for stasis grenade
            else if (Input.GetKeyDown("2"))
            {
                //Debug.Log("Cant move all tools disabled");
                AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
            }
            else if (Input.GetKeyDown("3"))
            {
                AudioManager.Instance.Play(AudioClipName.toolBelt_Denied);
            }
        }
    }