コード例 #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            switch (i)
            {
            case 0:
                TextHint.SetHint("太棒了!这里有篝火...");
                i++;
                if (imgMatchbox.enabled)
                {
                    Fire();
                }
                break;

            case 1:
                if (imgMatchbox.enabled)
                {
                    Fire();
                }
                else
                {
                    TextHint.SetHint("得想办法点燃它...", 2.0f);
                }
                break;
            }
        }
    }
コード例 #2
0
 void OnCollisionEnter(Collision other)
 {
     if (other.collider.gameObject.tag == "Player" && charge < 4)
     {
         if (Inventory.charge < 4)
         {
             if (charge < Inventory.charge)
             {
                 TextHint.SetHint("给设备装上了新电池...", 3.0f);
                 charge = Inventory.charge;
                 GetComponent <AudioSource>().PlayOneShot(soundGetPower);
                 transform.Find("chargeMeter").GetComponent <Renderer>().material.mainTexture = textureGenerator[Inventory.charge];
             }
             else
             {
                 TextHint.SetHint("这台设备的电量还不够多...", 3.5f);
             }
         }
         if (Inventory.charge >= 4)
         {
             TextHint.SetHint("装上这些电池应该足够了...", 3.0f);
             charge = 4;
             GetComponent <AudioSource>().PlayOneShot(soundGetPower);
             StartCoroutine("getFullPower"); //开启协程
             imageCell.enabled = false;      //去掉电池UI
         }
     }
 }
コード例 #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         TextHint.SetHint("这里有一盒火柴和一杆M16!", 1.9f);
         openTimer1 = true;
     }
 }
コード例 #4
0
    IEnumerator getFullPower()
    {
        transform.Find("chargeMeter").GetComponent <Renderer>().material.mainTexture = textureGenerator[4];
        StartCoroutine("TurnOnLight");

        yield return(new WaitForSeconds(spark * 0.59f));

        fullPower = true;
        TextHint.SetHint("门已经开了!", 2.0f);
        GameObject.Find("door").SendMessage("DoorCheck");
    }
コード例 #5
0
 // 检查门是否打开。若没有打开则打开
 void DoorCheck()
 {
     if (!doorIsOpen)
     {
         if (Generator.fullPower)
         {
             Door(soundOpen, true, "dooropen");
         }
         else
         {
             TextHint.SetHint("这扇门好像是电动的...", 3.0f);
         }
     }
 }
コード例 #6
0
 void Update()
 {
     if (openTimer1)
     {
         timer += Time.deltaTime;
         if (timer > 2.0f)
         {
             TextHint.SetHint("获得火柴 x1", 0.9f);
             imgMatchbox.enabled = true;
             openTimer2          = true;
             timer = 0.0f;
         }
         if (openTimer2 && timer > 1.0f)
         {
             openTimer1 = false;
             TextHint.SetHint("获得M16 x1", 0.9f);
             imgWeapon.enabled = true;
             GameObject.Destroy(weapon);
             GameObject.Destroy(matchBox);
         }
     }
 }
コード例 #7
0
 void Update()
 {
     if (i == 2)
     {
         // 点火
         timer += Time.deltaTime;
         if (timer > 1.0f)
         {
             fire.gameObject.SetActive(true);
             i++;   // i=3
         }
     }
     else if (i == 3)
     {
         // 进入菜单场景
         timer += Time.deltaTime;
         if (timer > 1.0f)
         {
             audioSource.PlayOneShot(soundWin);
             TextHint.SetHint("游戏暂时结束了,后续剧情敬请期待~");
         }
     }
 }
コード例 #8
0
 void Fire()
 {
     TextHint.SetHint("你使用了火柴...", 2.0f);
     i++;
 }