Esempio n. 1
0
        //private Transform groundCheck;

        // Use this for initialization
        void Start()
        {
            jump        = false;
            horiz       = 0;
            canInteract = false;
            interactor  = null;
            animator    = this.GetComponent <Animator>();
            if (GameObject.Find("/Canvas/DialoguePanel"))
            {
                dialogueEngine = GameObject.Find("/Canvas/DialoguePanel").GetComponent <DialogueBehavior>();
            }
            talkIndicator = GameObject.Find("Fish/Exclamation");
            talkIndicator.GetComponent <Renderer>().enabled = false;

            if (SceneManager.GetActiveScene().name == "Beach_Penguin" && !GlobalState.instance.talkedToPenguin)
            {
                interactor = GameObject.Find("Penguin");
                dialogueEngine.Talk(interactor.GetComponent <Actor>());
            }

            List <string> levels = new List <string>()
            {
                "Beach_Penguin", "Beach_Seagull", "Garden", "Desert"
            };

            if (levels.Exists(x => x == SceneManager.GetActiveScene().name))
            {
                if (GlobalState.instance.enterSide == GlobalState.ScreenSide.LEFT)
                {
                    Vector3 pos = transform.position;
                    pos.x = -20;
                    transform.position = pos;
                }
                else if (GlobalState.instance.enterSide == GlobalState.ScreenSide.RIGHT)
                {
                    Vector3 pos = transform.position;
                    pos.x = 20;
                    transform.position = pos;
                }
            }

            // TODO: Spawn on the correct side based on GlobalState.instance.enterSide
        }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("X_button") && !done)
     {
         done = true;
         Player_Movement.frozen = false;
         title.GetComponent <CanvasGroup>().alpha = 0.0f;
         Actor npc = GameObject.Find("WhaleKing").GetComponent <Actor>();
         dialogueEngine.Talk(npc);
     }
 }
        // Update is called once per frame
        void Update()
        {
            //grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
            animator.SetInteger("Direction", 1);
            // Cannot receive inputs if we are talking to someone
            if (!dialogueEngine || !dialogueEngine.IsTalking())
            {
                if (leave_as_false && Input.GetAxis("Horizontal") < 0)
                {
                    horiz = 0;
                }
                else if (OstrichMG_controller.start)
                {
                    horiz = Input.GetAxis("Horizontal");
                }
                // Jumping

                /*if (Input.GetButtonDown ("Jump") && grounded) {
                 *              jump = true;
                 *              grounded = false;
                 * }*/

                // Crouching
                if (Input.GetButton("Hide") && grounded)
                {
                    animator.SetInteger("Fish_anim", 2);
                    animator.SetInteger("Direction", 1);
                    // Walking
                }
                else if (Input.GetAxis("Horizontal") != 0 && !leave_as_false)
                {
                    animator.SetInteger("Fish_anim", 1);
                    animator.SetInteger("Direction", 1);
                    Vector3 pos = transform.position;
                    pos.x += speed * horiz;
                    transform.position = pos;
                    // Idle
                }
                else if (Input.GetAxis("Horizontal") > 0 && OstrichMG_controller.start)
                {
                    animator.SetInteger("Fish_anim", 1);
                    animator.SetInteger("Direction", 1);
                    Vector3 pos = transform.position;
                    pos.x += speed * horiz;
                    transform.position = pos;
                    // Idle
                }
                else
                {
                    animator.SetInteger("Fish_anim", 0);
                    animator.SetInteger("Direction", 1);
                }



                // Interaction mechanics
                if (Input.GetButtonDown("Interact") && canInteract)
                {
                    // If the object is an Actor, talk to it
                    Actor npc = interactor.GetComponent <Actor>();
                    if (npc)
                    {
                        // Turn on the idle animation
                        animator.SetInteger("Fish_anim", 0);
                        dialogueEngine.Talk(npc);
                    }
                }
            }
            else
            {
                // If we are talking, progress the dialogue when the Input or Jump buttons are pressed
                if (Input.GetButtonDown("Interact") || Input.GetButtonDown("Jump"))
                {
                    dialogueEngine.OnButtonClick();
                }
            }

            if (jump)
            {
                // Add a vertical force to the player.
                GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, jumpForce));

                // Make sure the player can't jump again until the jump conditions from Update are satisfied.
                jump = false;
            }
        }