Beispiel #1
0
    public IEnumerator DamageTheEnnemy(float speed)
    {
        InputManagerOutRunPart playerInputManager = GetComponent <InputManagerOutRunPart>();

        canDamage = false;
        bool canDamageEnn = false;

        //playerInputManager.canSwap = false;
        while (!canDamageEnn)
        {
            if (playerInputManager.canSwap)
            {
                canDamageEnn = true;
            }
            yield return(null);
        }

        playerInputManager.canSwap = false;
        Vector3 playerBegin    = car.position;
        Vector3 PlayerToEnnemy = Vector3.zero;

        PlayerToEnnemy = updateEnnemyCar.transform.position - car.position;

        while (PlayerToEnnemy.magnitude > 0.1f)
        {
            car.position   = Vector3.MoveTowards(car.position, updateEnnemyCar.transform.position, Time.deltaTime * speed);
            PlayerToEnnemy = updateEnnemyCar.transform.position - car.position;
            yield return(car);
        }

        updateEnnemyCar.GoToHorizon(transform);
        GameObject tempExplosion = Instantiate(explosion, car.transform.position, Quaternion.identity);

        Destroy(tempExplosion, 3.0f);

        PlayerToEnnemy = playerBegin - car.position;

        while (PlayerToEnnemy.magnitude > 0.01f)
        {
            car.position   = Vector3.MoveTowards(car.position, playerBegin, Time.deltaTime * speed);
            PlayerToEnnemy = playerBegin - car.position;
            yield return(car);
        }

        car.position = playerBegin;

        playerInputManager.canSwap = true;
        updateEnnemyCar.canswap    = true;
        //updateEnnemyCar.GetComponent<BoxCollider>().enabled = false;

        StartCoroutine(EnableColliderIn(1.0f));
        yield break;
    }
Beispiel #2
0
 void Start()
 {
     canDamage       = true;
     isInBoost       = false;
     isInvinsible    = false;
     canBoost        = false;
     canColide       = true;
     useBoost        = true;
     playerRenderer  = GetComponentInChildren <Renderer>();
     playerRigidbody = GetComponent <Rigidbody>();
     inputManager    = playerStat.GetComponent <InputManagerOutRunPart>();
     StartCoroutine(UpdateMaxSpeedState());
 }
Beispiel #3
0
    public void EndOfOutRun()
    {
        PlayerTriggerManager   playerTriggerManager = GetComponent <PlayerTriggerManager>();
        InputManagerOutRunPart inputManager         = GetComponent <InputManagerOutRunPart>();

        ScoreNiv.targetNumber          = score;
        playerTriggerManager.canColide = false;
        playerTriggerManager.canDamage = false;
        playerTriggerManager.GetComponent <AudioSource>().enabled   = false;
        playerTriggerManager.GetComponent <Rigidbody>().isKinematic = true;
        playerTriggerManager.GetComponent <BoxCollider>().enabled   = false;
        inputManager.enabled = false;
        checkHealth          = false;
        GameObject.FindGameObjectWithTag("carManager").GetComponent <OtherCarsAndScoreAssetManager>().canInstantiate = false;
        GameObject.FindGameObjectWithTag("UI").SetActive(false);
    }