예제 #1
0
 void Start()
 {
     cam     = Camera.main.transform;
     bag     = transform.GetChild(0).GetChild(0).GetComponent <BagScript>();
     kit     = transform.GetChild(0).transform;
     yFollow = new Vector3(0f, cam.eulerAngles.y, 0f);
     StoreRotation();
 }
예제 #2
0
 private void Start()
 {
     buttonAnimator = buttonObj.GetComponent <Animator>();
     button         = buttonObj.GetComponent <Button>();
     qt             = GetComponent <QuestTrigger>();
     qct            = GetComponent <QuestCollectTrigger>();
     bs             = GetComponent <BagScript>();
 }
        public void Initialize()
        {
            BagScript storageScript = _view.AddComponent <BagScript>();

            storageScript.Get_Storage += GetThings;

            _view.transform.position = Model.Position;
        }
예제 #4
0
    void CheckInCustomer(Collider2D customerCheck)
    {
        BagScript newBag = bag.GetComponent <BagScript>();

        newBag.customerId = customerCheck.gameObject.GetInstanceID();
        Instantiate(bag, bagSpawn.position, Quaternion.identity);
        for (int currentRoom = 0; currentRoom < rooms.Length; currentRoom++)
        {
            RoomScript roomScript = rooms[currentRoom].GetComponent <RoomScript>();
            if (!roomScript.isRoomOccupied && !roomScript.isRoomDirty)
            {
                roomScript.isRoomOccupied = true;
                roomScript.customerId     = customerCheck.gameObject.GetInstanceID();
                isCustomerWaiting         = false;
                bagSpawn.Translate(Vector3.right * 1);
                Destroy(customerCheck.gameObject);
                scoreManager.levelScore += 10;
                break;
            }
        }
    }
예제 #5
0
    void CheckForInteraction()
    {
        if (interact && Input.GetButton("Submit") && isRoomDirty)
        {
            //If interact button is pressed by player room cleaning action will be started and continue as long as button is pressed
            timeToClean           += Time.deltaTime;
            cleanProgressBar.value = timeToClean;

            if (timeToClean > 3) //Once counter reaches 3 room clean will be completed
            {
                isRoomDirty = false;
                SpriteRenderer roomSprite = GetComponent <SpriteRenderer>();
                roomSprite.sprite        = cleanRoom;
                timeToClean              = 0.0f;
                cleanProgressBar.value   = timeToClean;
                scoreManager.levelScore += 10;
            }
        }
        else if (interact && Input.GetButtonDown("Submit") && isRoomOccupied)
        {
            Debug.Log("checking for bag");
            Debug.DrawLine(lineStart.position, lineEnd.position, Color.blue);                    //Gizmo to help troubleshooting
            RaycastHit2D playerCheck = Physics2D.Linecast(lineStart.position, lineEnd.position); //Check to see if any object is in front of the room using raycast

            if (playerCheck.transform.childCount != 0)
            {
                GameObject bag     = playerCheck.transform.GetChild(0).gameObject;
                BagScript  thisBag = bag.GetComponent <BagScript>();

                if (thisBag.customerId == customerId)
                {
                    Destroy(bag);
                }
                else
                {
                    Debug.Log("this is the wrong bag");
                }
            }
        }
    }