Ejemplo n.º 1
0
 private void Start()
 {
     score    = new int[2];
     score[0] = score[1] = 0;
     control  = FindObjectOfType <GameFlowControl>();
     switcher = FindObjectOfType <GameSwitcher>();
 }
Ejemplo n.º 2
0
 void Update()
 {
     if (inMovement)
     {
         float step = speed * Time.deltaTime;
         transform.position = Vector3.MoveTowards(transform.position, Planet.transform.position, step);
         var dir   = Planet.transform.position - transform.position;
         var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
         transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
         float        totalDistance = Vector3.Distance(Planet.transform.position, startPlanet.transform.position);
         float        shipDistance  = Vector3.Distance(Planet.transform.position, transform.position);
         GameSwitcher gs            = gameSwitcher.GetComponent <GameSwitcher>();
         elapsed += Time.deltaTime;
         if (elapsed >= 1f)
         {
             elapsed = elapsed % 1f;
             if (Random.Range(0.0f, 1.0f) < P_switch)
             {
                 gs.TestGameSwitch();
             }
         }
         slider.value = 1 - shipDistance / totalDistance;
         if (Vector3.Distance(Planet.transform.position, this.transform.position) < 0.5)
         {
             inMovement = false;
         }
     }
     else
     {
         slider.value       = 0;
         transform.position = Planet.transform.position;
     }
 }
Ejemplo n.º 3
0
 void Start()
 {
     switcher = GetComponent <GameSwitcher>();
 }