Пример #1
0
    protected virtual void Initialize()
    {
        rb                   = GetComponent <Rigidbody> ();
        courseIndex          = 0;
        target               = course [courseIndex];
        shouldBrake          = false;
        shouldBoost          = false;
        useBankingModifier   = false;
        remainingBoostTime   = 0.0f;
        remaingBoostCooldown = 0.0f;
        isPlayer             = false;
        myRenderer           = this.GetComponent <Renderer> ();
        originalMaterial     = myRenderer.material;
        gl                   = this.GetComponent <GoalHandler> ();
        isSpeedPowerUpActive = false;

        currentHealth = startingHealth;
        engineSound   = this.GetComponent <AudioSource> ();
        canBeDamaged  = true;
        respawnIndex  = 0;
        respawnPoint  = this.transform.position;
        rs            = RacerState.PreRace;

        if (gl)
        {
            foreach (GameObject g in course)
            {
                if (g.tag == "goal")
                {
                    gl.SetInitialTarget(g);
                    break;
                }
            }
        }
    }
 private void Start()
 {
     _count    = 0;
     _finished = false;
     _state    = RacerState.Select;
     ShowMessage();
 }
Пример #3
0
 public RaceEntry(BaseCar car, int number, string name, PlayerType typ)
 {
     this.vehicle       = car;
     this.vehicleNumber = number;
     this.racerName     = name;
     this.playerType    = typ;
     this.state         = RacerState.OUT;
 }
 private void Racer_Tapped(object sender, RoutedEventArgs e)
 {
     if (_state == RacerState.Select)
     {
         Grid  grid  = (Grid)sender;
         Racer racer = (Racer)grid.Tag;
         _selected = racer.Option;
         _state    = RacerState.Ready;
         ShowMessage();
     }
 }
Пример #5
0
 void Start()
 {
     rb = this.GetComponent <Rigidbody>();
     if (Handling == null)
     {
         Handling = this.GetComponent <IHandling>();
     }
     if (racerState == null)
     {
         racerState = this.GetComponent <RacerState>();
     }
 }
Пример #6
0
    public IEnumerator Death()
    {
        rs = RacerState.Dead;
        Instantiate(Explosion, transform.position, transform.rotation);
        myRenderer.enabled = false;
        rb.velocity        = Vector3.zero;
        canBeDamaged       = false;
        engineSound.Stop();
        yield return(new WaitForSeconds(RespawnTime));

        transform.position = respawnPoint;
        courseIndex        = respawnIndex;
        target             = course [courseIndex];
        currentHealth      = startingHealth;
        canBeDamaged       = true;
        myRenderer.enabled = true;
        engineSound.Play();
        rs = RacerState.Racing;
    }
        private void Race()
        {
            if (_state != RacerState.Ready)
            {
                ShowMessage();
                return;
            }
            List <TimeSpan> times = Choose(5, 15, total);
            int             i     = 0;

            foreach (Grid grid in _items)
            {
                Racer racer = (Racer)grid.Tag;
                racer.Time = times[i];
                Move(grid, width, 0, racer.Time);
                i++;
            }
            _state = RacerState.Started;
        }
 private async void Storyboard_Completed(object sender, object e)
 {
     if (_state == RacerState.Started)
     {
         Storyboard storyboard = (Storyboard)sender;
         TimeSpan   duration   = storyboard.GetCurrentTime();
         Racer      racer      = (Racer)_items.FirstOrDefault(w => ((Racer)w.Tag).Time == duration).Tag;
         _count++;
         if (_count == 1)
         {
             _winner = racer.Option;
             string name = Enum.GetName(typeof(RacerOption), _winner);
             await ShowDialogAsync($"{name} completed Race in {duration.ToString()}");
         }
         if (_count == total)
         {
             _state = RacerState.Finished;
             ShowMessage();
         }
         _finished = true;
     }
 }
Пример #9
0
 public void EndRace()
 {
     rs = RacerState.PostRace;
 }
Пример #10
0
 public void StartRace()
 {
     rs = RacerState.Racing;
 }
 public void Init(ref Grid display)
 {
     _count = 0;
     _state = RacerState.Select;
     Layout(ref display);
 }