コード例 #1
0
    private void Start()
    {
        messageToRepair += " metal: 2, rubber: 2, glass: 3.";

        player = FindObjectOfType <PlayerController>();

        dialogueToRepair        = new dialogueArray();
        dialogueToRepair.line   = new string[] { messageToRepair };
        dialogueToRepair.sprite = new Sprite[] { portrait };

        dialogueWhenRepaired        = new dialogueArray();
        dialogueWhenRepaired.line   = new string[] { messageWhenRepaired };
        dialogueWhenRepaired.sprite = new Sprite[] { portrait };
    }
コード例 #2
0
 public void displayText(GameObject selfReference, dialogueArray textString)
 {
     textSpeed     = 0.1f;
     originator    = selfReference;
     diagArray     = textString;
     textToDisplay = textString.line;
     textBox.SetActive(true);
     text.text   = "";
     currentLine = textString.line[currentText].ToCharArray();
     currentChar = 0;
     if (textString.sprite[currentText] != null)
     {
         portrait.sprite = textString.sprite[currentText];
     }
     StartCoroutine(printLine());
 }
コード例 #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //Player has to have the right material to fix the door
     //The material will then be used and the door will always be fixed
     if (collision.gameObject.tag == "interact" && broken)
     {
         if (lifeSupport.isRepaired && engine.isRepaired && generator.isRepaired)
         {
             repairSound.Play();
             broken = false;
             animator.SetBool("fixed", true);
         }
         else
         {
             dialogueArray dialogueNotEnough = new dialogueArray();
             dialogueNotEnough.line   = new string[] { "You need to repair the 3 core systems to disengage the lockdown." };
             dialogueNotEnough.sprite = new Sprite[] { portrait };
             PlayerController player = FindObjectOfType <PlayerController>();
             player.hasControl = false;
             player.gameObject.GetComponent <Rigidbody2D>().velocity        = Vector2.zero;
             player.gameObject.GetComponent <Rigidbody2D>().angularVelocity = 0;
             FindObjectOfType <BasicDisplayText>().hasControl = true;
             FindObjectOfType <BasicDisplayText>().displayText(gameObject, dialogueNotEnough);
         }
     }
     //This block controls the doors movement
     else if (collision.gameObject.tag == "interact" && !animator.GetBool("open") && !broken)
     {
         openSound.Play();
         animator.SetBool("open", true);
     }
     else if (collision.gameObject.tag == "interact" && animator.GetBool("open") && !broken)
     {
         openSound.Play();
         animator.SetBool("open", false);
     }
 }
コード例 #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //Player has to have the right material to fix the door
     //The material will then be used and the door will always be fixed
     if (collision.gameObject.tag == "interact" && broken)
     {
         if (FindObjectOfType <PlayerController>().materials[0] >= metal)
         {
             if (FindObjectOfType <PlayerController>().materials[2] >= rubber)
             {
                 //Debug.Log("Fixed");
                 repairSound.Play();
                 broken = false;
                 animator.SetBool("fixed", true);
                 //Debug.Log(FindObjectOfType<DoorOpen>().animator.GetBool("fixed"));
                 FindObjectOfType <PlayerController>().materials[0]--;
                 FindObjectOfType <PlayerController>().materials[2]--;
             }
             else
             {
                 if (Time.time > gameObject.GetComponent <doorNPC>().interactEndTime + gameObject.GetComponent <doorNPC>().interactWaitTime)
                 {
                     dialogueArray dialogueNotEnough = new dialogueArray();
                     dialogueNotEnough.line   = new string[] { "You need metal: " + metal + ", and rubber: " + rubber + " to repair a door." };
                     dialogueNotEnough.sprite = new Sprite[] { portrait };
                     PlayerController player = FindObjectOfType <PlayerController>();
                     player.hasControl = false;
                     player.gameObject.GetComponent <Rigidbody2D>().velocity        = Vector2.zero;
                     player.gameObject.GetComponent <Rigidbody2D>().angularVelocity = 0;
                     FindObjectOfType <BasicDisplayText>().hasControl = true;
                     FindObjectOfType <BasicDisplayText>().displayText(gameObject, dialogueNotEnough);
                 }
             }
         }
         else
         {
             if (Time.time > gameObject.GetComponent <doorNPC>().interactEndTime + gameObject.GetComponent <doorNPC>().interactWaitTime)
             {
                 dialogueArray dialogueNotEnough = new dialogueArray();
                 dialogueNotEnough.line   = new string[] { "You need metal: " + metal + ", and rubber: " + rubber + " to repair a door." };
                 dialogueNotEnough.sprite = new Sprite[] { portrait };
                 PlayerController player = FindObjectOfType <PlayerController>();
                 player.hasControl = false;
                 player.gameObject.GetComponent <Rigidbody2D>().velocity        = Vector2.zero;
                 player.gameObject.GetComponent <Rigidbody2D>().angularVelocity = 0;
                 FindObjectOfType <BasicDisplayText>().hasControl = true;
                 FindObjectOfType <BasicDisplayText>().displayText(gameObject, dialogueNotEnough);
             }
         }
     }
     //This block controls the doors movement
     else if (collision.gameObject.tag == "interact" && !animator.GetBool("open") && !broken)
     {
         openSound.Play();
         animator.SetBool("open", true);
     }
     else if (collision.gameObject.tag == "interact" && animator.GetBool("open") && !broken)
     {
         openSound.Play();
         animator.SetBool("open", false);
     }
 }