Example #1
0
        public void Respawn(PlayerMovementManager player)
        {
            Vector3    spawnPos      = new Vector3(0f, 5f, 0f);
            Quaternion spawnRotation = Quaternion.identity;

            if (FindObjectOfType <RepairPad>() != null)
            {
                // TODO: Player will have to hope that all repair pads don't die by the time they click.
                overheadCamera.enabled = true;
                normalCamera.enabled   = false;
                Cursor.visible         = true;
                Cursor.lockState       = CursorLockMode.None;
            }
            else
            {
                RepairPad.Spawn(this, player, Vector3.zero);
            }
        }
Example #2
0
    private void OnTriggerStay(Collider other)
    {
        // if colliding with boxes and not carrying anything
        if (other.tag == "Plank Box" && !isCarrying)
        {
            //display button sprite
            other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true;

            if (Input.GetButtonDown("joystick " + playerNumber + " A"))
            {
                PickUpPlank();
                other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false;
            }
        }



        if (other.tag == "Coal Box" && !isCarrying)
        {
            //display button sprite
            other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true;
            if (Input.GetButton("joystick " + playerNumber + " A"))
            {
                PickUpCoal();
                other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false;
            }
        }

        if (other.tag == "Gun Box" && !isCarrying)
        {
            //display button sprite
            other.transform.GetComponentInChildren <SpriteRenderer>().enabled = true;
            if (Input.GetButton("joystick " + playerNumber + " A"))
            {
                PickUpGun();
                ps.Reload();
                other.transform.GetComponentInChildren <SpriteRenderer>().enabled = false;
            }
        }

        // Repair pad
        //Repairing
        if (other.tag == "Repair Pad" && !isCarrying)
        {
            RepairPad pad = other.GetComponent <RepairPad>();


            if (Input.GetButton("joystick " + playerNumber + " X"))
            {
                pad.Repair();
            }
        }
        //Placing planks
        if (other.tag == "Repair Pad" && carryingPlank)
        {
            RepairPad pad = other.GetComponent <RepairPad>();


            if (Input.GetButtonDown("joystick " + playerNumber + " A"))
            {
                if (pad.CheckIfCanAdd())
                {
                    pad.AddPlank(1);
                    Drop();
                }
                else
                {
                    return;
                }
            }
        }

        //Furnace
        if (other.tag == "Furnace" && carryingCoal)
        {
            Furnace fur = other.GetComponent <Furnace>();


            if (Input.GetButtonDown("joystick " + playerNumber + " A"))
            {
                if (fur.CheckIfCanAdd())
                {
                    fur.AddCoal(1);
                    Drop();
                }
                else
                {
                    return;
                }
            }
        }

        if (other.tag == "Gatling Gun" && !isCarrying)
        {
            //display button sprite
            //other.transform.GetComponentInChildren<SpriteRenderer>().enabled = true;
            other.GetComponentInChildren <GatlingGun>().aButton.enabled = true;

            if (Input.GetButtonDown("joystick " + playerNumber + " A"))
            {
                other.GetComponentInChildren <GatlingGun>().aButton.enabled = false;
                UseGatlingGun(other.gameObject);
                //other.transform.GetComponentInChildren<SpriteRenderer>().enabled = false;
            }
        }
    }