Ejemplo n.º 1
0
    //public static adsEnabled;

    // Start is called before the first frame update
    void Start()
    {
        rewardImage.enabled = false;
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(initStatus => { });
        Advertisement.Initialize(gameId, testMode);
        //myButton = GetComponent<Button>();

        myComputerControl = GameObject.Find("Paddle2").GetComponent <ComputerControl>();

        whichBanner = Random.Range(1, 3);

        whichBannerToShow();
    }
Ejemplo n.º 2
0
    private void Start()
    {
        //doorAnimator = GetComponent<Animator>();
        originalPosition = transform.localPosition;

        openPosition = originalPosition + (directionToMove * distanceToMove);

        if (automaticTrigger)
        {
            computer          = gameObject.AddComponent <ComputerControl>();
            computer.activate = true;
        }

        // switches the default activate status to align with opposite directions
        switch (invertDirection)
        {
        case true:
            computer.activate = true;
            break;
        }
    }
Ejemplo n.º 3
0
    ComputerControl FindNearestComputer()
    {
        ComputerControl nearest = null;

        Vector3 playerLocation = transform.position;
        float   minDistance    = computerReachDistance;



        foreach (ComputerControl computer in nearbyComputers)
        {
            // allows to interact if computer is within an angle of the direction
            if (Vector3.Distance(computer.transform.position, playerLocation) < minDistance && Vector3.Angle(transform.forward, computer.transform.position - transform.position) < computerAngle)
            {
                nearest = computer;
            }
        }
        if (nearest != null)
        {
            switch (nearest.isClone)
            {
            case true:
                PGM.Instance.computerBeingUsed = nearest.mainComputer;
                break;

            case false:
                PGM.Instance.computerBeingUsed = nearest;
                break;
            }
        }
        else
        {
            PGM.Instance.computerBeingUsed = nearest;
        }



        return(nearest);
    }
Ejemplo n.º 4
0
    void Update()
    {
        // Pauses the game
        if (Input.GetKeyDown(KeyCode.Escape) && PGM.Instance.settingsOpen == false)
        {
            PGM.Instance.settingsOpen = true;
            SceneManager.LoadSceneAsync(PGM.Instance.pauseScene, LoadSceneMode.Additive);
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            Time.timeScale   = 0;
        }


        // Triggers the walking animation if the velocity is nonzero
        if (rb.velocity.magnitude > 0)
        {
            animator.SetBool("isMoving", true);
        }
        // All of the controls are based on custom keybinds
        if (!Input.GetKey(PGM.Instance.keyBinds["Forward"]) && !Input.GetKey(PGM.Instance.keyBinds["Backward"]))
        {
            animator.SetBool("isMoving", false);
            animator.SetBool("movingForward", false);
            animator.SetBool("movingBackward", false);
        }

        if (Input.GetKey(PGM.Instance.keyBinds["Left"]) && canMove == true)
        {
            transform.Rotate(0f, -rotateSpeed * Time.deltaTime, 0f);
        }

        if (Input.GetKey(PGM.Instance.keyBinds["Right"]) && canMove == true)
        {
            transform.Rotate(0f, rotateSpeed * Time.deltaTime, 0f);
        }


        if (Input.GetKeyDown(PGM.Instance.keyBinds["Interact"]) && holdingObject == false && PGM.Instance.settingsOpen == false)
        {
            /*
             * if (objectBeingHeld == null || holdingObject == false)
             * {
             *  pickUpObject = false;
             * }
             */

            // Defined here so they only run once per input
            nearestNPC      = FindNearestNPC();
            nearestObject   = FindNearestObject();
            nearestComputer = FindNearestComputer();

            // only interacts if there's no object that's closer (or being held)
            if (nearestNPC != null && holdingObject == false && nearestObject == null)
            {
                nearestNPC.ContinueDialogue();
            }


            if (nearestObject != null)
            {
                // Picks up an object if there's no nearby npc
                if (nearestNPC == null && nearestComputer == null)
                {
                    pickUpObject = true;
                }


                // If there is a nearby npc or computer, only picks up object if the object is closer
                if ((nearestNPC != null && Vector3.Distance(nearestNPC.transform.position, transform.position) > Vector3.Distance(nearestObject.transform.position, transform.position)) ||
                    (nearestComputer != null && Vector3.Distance(nearestComputer.transform.position, transform.position) > Vector3.Distance(nearestObject.transform.position, transform.position)))
                {
                    pickUpObject = true;
                }
            }


            // If there is a nearby computer and the player is not holding anything
            if (nearestComputer != null && PGM.Instance.usingComputer == false && holdingObject == false)
            {
                compTime         = Time.time;
                interactComputer = true;
                // triggers the correct action for the computer
                switch (PGM.Instance.computerBeingUsed.activate)
                {
                case true:
                    PGM.Instance.computerBeingUsed.activate = false;
                    // Prints an event for the player to see
                    switch (PGM.Instance.computerBeingUsed.assignedObject.objectType)
                    {
                    case MoveObject.ObjectType.Door:
                        PGM.Instance.AddEvents("doorClose");
                        break;

                    case MoveObject.ObjectType.Lift:
                        PGM.Instance.AddEvents("liftRaise");
                        break;
                    }

                    break;

                case false:
                    PGM.Instance.computerBeingUsed.activate = true;
                    // Prints an event for the player to see
                    switch (PGM.Instance.computerBeingUsed.assignedObject.objectType)
                    {
                    case MoveObject.ObjectType.Door:
                        PGM.Instance.AddEvents("doorOpen");
                        break;

                    case MoveObject.ObjectType.Lift:
                        PGM.Instance.AddEvents("liftLower");
                        break;
                    }
                    break;
                }
            }
        }


        if (Input.GetKeyDown(PGM.Instance.keyBinds["Interact"]) && holdingObject == true)
        {
            dropObject = true;
        }

        if (Input.GetKeyDown(PGM.Instance.keyBinds["Interact"]) && usingComputer == true || (usingComputer && FindNearestComputer() == null) || (usingComputer && Time.time > compTime + compSeconds))
        {
            exitComputer = true;
        }

        if (objectBeingHeld != null)
        {
            // places object between left and right hand (fits with animation better/looks nicer)
            objectBeingHeld.transform.position = (handRight.transform.position + handLeft.transform.position) / 2;
            animator.SetBool("holdingObject", true);
            // enables animation override while holding object so that the player can have the walk animation but keep the arms holding the object
            animator.SetLayerWeight(1, 1f);
        }



        if (usingComputer)
        {
            canMove = false;
        }
    }
Ejemplo n.º 5
0
 public void Set(ComputerControl comp)
 {
     _computerControl = comp;
     _active          = true;
     InputManager.SwitchGameInput(InputManager.GameplayType.Computer);
 }