Пример #1
0
    void Update()
    {
        move          = Input.GetAxis("Horizontal");
        buttonPressed = Input.GetKeyDown("space") || Input.GetKeyUp("return");

        // other = GameObject.Find(allConvos[nextDialog].Trigger).GetComponent<Character>();

        if (!isPaused)
        {
            playerRigidBody.velocity = new Vector2(move * playerSpeed, 0);

            if (move > 0)
            {
                player.GetComponent <SpriteRenderer>().flipX = true;
            }
            if (move < 0)
            {
                player.GetComponent <SpriteRenderer>().flipX = false;
            }

            // if (move != 0)
            // {

            //     audioSource.transform.position = player.transform.position;
            //     System.Random rnd = new System.Random();
            //     if (numberBetweenSteps == 0)
            //     {
            //         int clipNo = rnd.Next(0, 8);
            //         audioSource.clip = audioClips[clipNo];
            //         audioSource.Play();
            //         numberBetweenSteps = 480;
            //     }
            //     else
            //     {
            //         numberBetweenSteps--;
            //     }
            // }

            updateCameraPos();

            wanderAI();

            if (other.CollisionWith != null && other.EnteredTrigger && other.CollisionWith.name == player.name)
            {
                // GameObject otherCharacter = GameObject.Find(other.name);

                other.GetComponent <SpriteRenderer>().flipX = (other.transform.position.x - player.transform.position.x) < 0;

                displayScript.StartConvo(allConvos[convoIndex]);
                other.OnTriggerHandled();
            }
        }
        else
        {
            playerRigidBody.velocity        = new Vector2(0, 0);
            cameraObject.transform.position = new Vector3(player.transform.position.x, 0, -1);

            if (buttonPressed && buttonEnabled)
            {
                displayScript.StartNextEvent();
            }
        }
    }