void OnTriggerEnter2D(Collider2D other)
 {
     Debug.Log(other.name);
     if (other.name == "CEO")
     {
         TurnOnMessage(other);
     }
     else if (other.name.Contains("ChairTriggerFront"))
     {
         this.gameObject.transform.position = other.transform.position;
         characterSprites.SetDownSprite();
         this.gameObject.GetComponent <EdgeCollider2D>().enabled = false;
         this.spriteRenderer.sortingLayerName = "OnChair";
         Status          = walking.passive;
         passiveWalkTime = 5f;
     }
     else if (other.name.Contains("ChairTriggerBack"))
     {
         this.gameObject.transform.position = new Vector3(other.transform.position.x,
                                                          other.gameObject.transform.position.y + 0.070f, other.transform.position.x);
         characterSprites.SetUpSprite();
         this.gameObject.GetComponent <EdgeCollider2D>().enabled = false;
         this.spriteRenderer.sortingLayerName = "OnChair";
         Status          = walking.passive;
         passiveWalkTime = 5f;
     }
 }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            // dog.isMyDog();
            //walking wForm = new walking();
            //wForm.Show();
            //this.Hide();
            walking b_Form = new walking();

            b_Form.Show();
            this.Hide();
        }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        player = FindObjectOfType <walking>();

        if (textFile != null)                        // if there is a text file to look at
        {
            textLines = (textFile.text.Split('\n')); // seperate them by \n, which means by space enter
        }

        if (endAtLine == 0)                   // if you just started talking to the npc
        {
            endAtLine = textLines.Length - 1; // start at line one (remember unity starts at 0)
        }

        if (isActive) // if the textbox is active
        {
            EnableTextBox();
        }
        else
        {
            DisableTextBox();
        }
    }
    void Update()
    {
        if (isWalking && Status == walking.active)
        {
            walkCounter -= Time.deltaTime;
            if (walkCounter <= 0)
            {
                isWalking   = false;
                waitCounter = waitTime;
            }

            switch (walkDirection)
            {
            // Up
            case 0:
                myRigidBody.velocity = new Vector2(0, moveSpeed);
                characterSprites.SetUpSprite();
                break;

            // Right
            case 1:
                myRigidBody.velocity = new Vector2(moveSpeed, 0);
                characterSprites.SetRightSprite();
                break;

            // Down
            case 2:
                myRigidBody.velocity = new Vector2(0, -moveSpeed);
                characterSprites.SetDownSprite();
                break;

            // Left
            case 3:
                myRigidBody.velocity = new Vector2(-moveSpeed, 0);
                characterSprites.SetLeftSprite();
                break;
            }

            moveSpeed = 1f * Random.Range(0.5f, 0.8f);
            walkTime  = 1f * Random.Range(0.5f, 0.8f);
        }
        else
        {
            waitCounter         -= Time.deltaTime;
            myRigidBody.velocity = Vector2.zero;

            if (waitCounter < 0)
            {
                chooseDirection();
            }
        }

        if (Status == walking.passive)
        {
            passiveWalkTime -= Time.deltaTime;
            if (passiveWalkTime < 0)
            {
                this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x + 0.5f,
                                                                 this.gameObject.transform.position.y + 0.5f, this.gameObject.transform.position.x);
                Status = walking.active;
                this.gameObject.GetComponent <EdgeCollider2D>().enabled = true;
            }
        }
    }