Пример #1
0
 public void points()
 {
     if (CanUse != false)
     {
         StartCoroutine("Working");
         GetComponent <AudioSource>().Play();
         foreach (GameObject AllGrids in GameObject.FindGameObjectsWithTag("point"))
         {
             if (AllGrids.GetComponent <Pointbehavoir>().CanInteract == true)
             {
                 AllGrids.GetComponent <Pointbehavoir>().Image.enabled = false;
                 AllGrids.GetComponent <Pointbehavoir>().CanInteract   = false;
             }
         }
         Vector2 fwd = transform.TransformDirection(Vector2.up);
         Vector2 bwd = transform.TransformDirection(Vector2.down);
         SettingActive(fwd, pointOrginFront, true);
         SettingActive(bwd, pointOrginBack, false);
         foreach (GameObject Allboeats in GameObject.FindGameObjectsWithTag("boat"))
         {
             StartCoroutine(Allboeats.GetComponent <BoatBehavoir>().Working());
             Allboeats.GetComponent <Image>().enabled = false;
         }
         GetComponent <Image>().enabled = true;
         StartCoroutine(hit());
     }
 }
Пример #2
0
    IEnumerator BoatMoving(float TotalDistance)
    {
        foreach (GameObject AllBoats in GameObject.FindGameObjectsWithTag("boat"))
        {
            AllBoats.GetComponent <BoatBehavoir>().CanUse = false;
        }
        Vector2 pointtopoint = boat.transform.position;

        controller.Score++;
        _text.GetComponentInChildren <SpriteRenderer>().enabled = true;
        _text.text = ": " + controller.Score;
        while (Vector2.Distance(gameObject.transform.position, pointtopoint) >= TotalDistance && boat != null)
        {
            float speed = 30;
            if (Mathf.Abs(Vector2.Distance(gameObject.transform.position, pointtopoint) - TotalDistance) < 0.15f)
            {
                speed = 230;
            }
            if (frontOrBack == true)
            {
                boat.transform.position += boat.transform.TransformDirection(Vector2.up / speed);
            }
            else
            {
                boat.transform.position -= boat.transform.TransformDirection(Vector2.up / speed);
            }
            pointtopoint = boat.transform.position;
            yield return(new WaitForSeconds(0.0166666666666667f));
        }
        if (boat != null)
        {
            boat.GetComponent <BoatBehavoir>().CanUse = true;
        }
        foreach (GameObject Allboeats in GameObject.FindGameObjectsWithTag("boat"))
        {
            Allboeats.GetComponent <BoatBehavoir>().CanUse = true;
        }

        if (finishPoint == true)
        {
            Particles.Emit(100);
            _Button.transform.position = new Vector3(0, 0, 0);
            string HighScore = GlobalGameSettings.GetSetting("Reset_High_Score");
            if (PlayerPrefs.GetInt(controller.LevelName.ToString()) == 0)
            {
                PlayerPrefs.SetInt(controller.LevelName.ToString(), controller.Score);
            }
            if (controller.Score < PlayerPrefs.GetInt(controller.LevelName.ToString()))
            {
                PlayerPrefs.SetInt(controller.LevelName.ToString(), controller.Score);
            }
            if (HighScore == "Ja")
            {
                PlayerPrefs.DeleteKey(controller.LevelName.ToString());
                _Button.GetComponentInChildren <TextMesh>().text = "Beste score: " + controller.Score.ToString();
            }
            else
            {
                _Button.GetComponentInChildren <TextMesh>().text = "Beste score: " + PlayerPrefs.GetInt(controller.LevelName.ToString()).ToString();
            }
            _text.text = "";
            _text.GetComponentInChildren <SpriteRenderer>().enabled = false;
            controller.GetComponent <AudioSource>().Play();
            foreach (GameObject Allboeats in GameObject.FindGameObjectsWithTag("boat"))
            {
                Allboeats.GetComponent <BoatBehavoir>().CanUse = false;
            }
            for (int i = 0; i < 300; i++)
            {
                if (boat != null)
                {
                    boat.transform.position += boat.transform.TransformDirection(Vector2.up / 30);
                }
                else
                {
                    break;
                }
                yield return(new WaitForSeconds(0.0166666666666667f));
            }
            Invoke("ToScores", 2.5f);
        }
    }