Ejemplo n.º 1
0
    void UpdateCarStat()
    {
        WheelVehicle v  = vehicles[curVehicle];
        Player       p  = vehicles[curVehicle].GetComponent <Player>();
        Rigidbody    rb = vehicles[curVehicle].GetComponent <Rigidbody>();

        carPreview.sprite = v.preview;

        lifeBar.fillAmount   = p.MaxLife / 200f;
        speedBar.fillAmount  = 0.5f;
        boostBar.fillAmount  = v.MaxBoost / 20f;
        weightBar.fillAmount = rb.mass / 3000f;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        Instance     = this;
        _missionList = FindObjectsOfType <CheckPoint>();
        PlayerCar    = FindObjectOfType <WheelVehicle>();

        foreach (var checkPoint in _missionList)
        {
            checkPoint.gameObject.SetActive(false);
        }

        Random.InitState(DateTime.Now.Millisecond);
    }
Ejemplo n.º 3
0
    public void StartRace(WheelVehicle player)
    {
        if (player != null)
        {
            Debug.Log("Race start");
            _startTime = Time.realtimeSinceStartup;

            _recorders[player] = new GhostRecorder(expectedTime, 10, ref player);

            StartCoroutine(_recorders[player].RecordCoroutine());
            _ghost.run = true;
            _ghost.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 4
0
    public override void OnStartClient()
    {
        messagers.Add(this);

        lastSync = Time.realtimeSinceStartup;

        player    = GetComponent <Player>();
        vehicle   = GetComponent <WheelVehicle>();
        rigidbody = GetComponent <Rigidbody>();

        foreach (NetworkClient client in NetworkClient.allClients)
        {
            client.RegisterHandler(NetworkMessages.PlayerUpdatePos, OnClientVehiclePosMsg);
        }
    }
Ejemplo n.º 5
0
    public void FinishRace(WheelVehicle player)
    {
        bool finished = true;

        foreach (CheckPoint cp in _checkPoints)
        {
            if (!cp.IsChecked(player))
            {
                finished = false;
            }
        }

        if (finished)
        {
            if (player != null)
            {
                PlayerHolder ph = player.GetComponentInParent <PlayerHolder>();

                _endTime = Time.realtimeSinceStartup - _startTime;
                Debug.Log("Finish time: " + _endTime);

                ph.Ui.AddScore(Mathf.FloorToInt(expectedTime - _endTime) * 1000);

                Transform  spawnPos = player.gameObject.transform;
                ScorePopup sp       = GameObject.Instantiate(scorePopupPrefab.gameObject, spawnPos.position, spawnPos.rotation).GetComponent <ScorePopup>();
                sp.SetScore(Mathf.FloorToInt(expectedTime - _endTime) * 1000);

                int score = ph.Ui.GetScore();

                _recorders[player].Stop();
                if (!_ghost.exist || score > _ghost.score)
                {
                    _ghost.score = score;
                    _recorders[player].Save(_scene + "-BestTime");

                    ph.Ui.Finish(_endTime, score, true);
                }
                else
                {
                    ph.Ui.Finish(_endTime, score, false);
                }
            }
        }
        else
        {
            Debug.Log("You missed a checkpoint!");
        }
    }
Ejemplo n.º 6
0
    void OnTriggerEnter(Collider c)
    {
        WheelVehicle cart = c.gameObject.GetComponent <WheelVehicle>();

        Debug.Log(c.gameObject);
        if (!cart)
        {
            return;
        }
        PowerUpSlot slot = cart.GetComponent <PowerUpSlot>();

        if (slot.load(item))
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 7
0
    public void ignite(WheelVehicle user, Vector3 rotation)
    {
        Debug.Log("HM ignited~~~~");
        _rb          = gameObject.GetComponent <Rigidbody>();
        owner        = user;
        _rb.velocity = constspeed =  //TODO: change this to "x" where z is normal
                                    (user._rb.transform.up * 4f - user._rb.transform.right) * 2f + user._rb.velocity * 0.5f + user._rb.velocity;
        findTarget(rotation);
        HMLocked clone = Instantiate(hmlPrefeb);

        clone.Initialize(hit_delay, target);
        target.stat.LoadEffect(clone);
        ignited  = true;
        flytimer = 0;
        Debug.Log("ign");
        Debug.Log(ignited);
    }
Ejemplo n.º 8
0
    public void SetPlayer(Player p)
    {
        player = p;
        if (p != null)
        {
            vehicle = p.GetComponent <WheelVehicle>();
        }

        if (player != null && vehicle != null)
        {
            playerUI.gameObject.SetActive(true);
        }
        else
        {
            playerUI.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 9
0
    void findTarget(Vector3 r)
    {
        WheelVehicle[] carts = FindObjectsOfType <WheelVehicle>();
        WheelVehicle   tgt = null;
        float          tmp, bd = 10000000f;

        foreach (WheelVehicle c in carts)
        {
            if (c == owner)
            {
                continue;
            }
            tmp = owner.transform.position.y - c.transform.position.y;
            if (90f < r.y && r.y <= 270f && tmp > 0)
            {
                continue;
            }
            if (!(90f < r.y && r.y <= 270f) && tmp < 0)
            {
                continue;
            }
            tmp = Mathf.Abs(tmp);
            if (tmp < bd)
            {
                bd  = tmp;
                tgt = c;
            }
        }
        if (tgt != null)
        {
            target = tgt;
        }
        else
        {
            r.y = 180 - r.y;
            findTarget(r);
        }
    }
Ejemplo n.º 10
0
    void OnTriggerEnter(Collider other)
    {
        WheelVehicle v = other.GetComponentInParent <WheelVehicle>();

        if (v != null && other.gameObject.CompareTag("Player") && !_checked.ContainsKey(v))
        {
            _sprite.color = _passedColor;

            _checked[v] = true;

            _checkedEvent.Invoke(v);

            if (_isStart)
            {
                GameManager.instance.StartRace(v);
            }

            if (_isFinish)
            {
                GameManager.instance.FinishRace(v);
            }
        }
    }
Ejemplo n.º 11
0
    void Start()
    {
        rigidbody = GetComponent <Rigidbody>();

        life = maxLife;

        ui = FindObjectOfType <PlayerUI>();
        if (ui != null && isLocalPlayer)
        {
            ui.SetPlayer(this);
        }

        if (onPlayerSpawn != null)
        {
            onPlayerSpawn.Invoke(this);
        }

        gameManager = GameManager.Instance;

        wheels = GetComponentsInChildren <WheelCollider>();

        vehicle = GetComponent <WheelVehicle>();
    }
Ejemplo n.º 12
0
    void OnTriggerEnter(Collider c)
    {
        Debug.Log("Trig");
        Debug.Log(ignited);
        if (!ignited)
        {
            return;
        }
        WheelVehicle hit = c.gameObject.GetComponent <WheelVehicle>();

        if (hit)
        {
            if (hit == owner)
            {
                return;
            }
            else
            {
                attach(hit);
            }
        }
        Destroy(gameObject);
    }
Ejemplo n.º 13
0
    void StartRace(WheelVehicle vehicle)
    {
        startTime = Time.realtimeSinceStartup;

        lastCp = 1;

        Debug.Log("Race start!");

        if (vehicle != null)
        {
            recorder = new GhostRecorder(60.0f, 10, ref vehicle);
            StartCoroutine(recorder.RecordCoroutine());
        }
        else
        {
            recorder = null;
        }

        if (ghost != null)
        {
            ghost.LoadData(vehicle.name);
            ghost.RestartGhost();
        }
    }
Ejemplo n.º 14
0
        // Select target from targets list using it's index
        public void SetTargetIndex(int i)
        {
            WheelVehicle v;

            foreach (UnityEngine.Transform t in targets)
            {
                v = t != null?t.GetComponent <WheelVehicle>() : null;

                if (v != null)
                {
                    v.IsPlayer  = false;
                    v.Handbrake = true;
                }
            }

            target = targets[i % targets.Length];

            vehicle = target != null?target.GetComponent <WheelVehicle>() : null;

            if (vehicle != null)
            {
                vehicle.IsPlayer = true;
            }
        }
Ejemplo n.º 15
0
 public bool IsChecked(WheelVehicle v)
 {
     return(_checked[v]);
 }
Ejemplo n.º 16
0
 void Start()
 {
     _source  = GetComponent <AudioSource>();
     _vehicle = GetComponent <WheelVehicle>();
 }
 // Start is called before the first frame update
 void Start()
 {
     wheelVehicle = GetComponent <WheelVehicle> ();
 }
Ejemplo n.º 18
0
 public void Initialize(float dur, WheelVehicle pl)
 {
     duration = dur;
     player   = pl;
     lifespan = 1;
 }
Ejemplo n.º 19
0
 void Start()
 {
     carComponent = car.GetComponent <WheelVehicle>();
 }
Ejemplo n.º 20
0
 public abstract void activate(WheelVehicle user);
Ejemplo n.º 21
0
    override public void activate(WheelVehicle user)
    {
        BasicRocket clone = Instantiate(prefab, user.gameObject.transform.position + Vector3.up, user.gameObject.transform.rotation);

        clone.ignite(user, aim.rot);
    }