Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (dead)
        {
            deathTimer -= Time.deltaTime;
            if (deathTimer < 0)
            {
                GameObject.Destroy(transform.parent.gameObject);
            }

            return;
        }
        Vector3 nPos = cMath.CalcPositionByDistance(curveDistance);
        Vector3 nTan = cMath.CalcTangentByDistance(curveDistance);

        transform.position = nPos;
        transform.forward  = nTan;

        curveDistance += speed * Time.deltaTime;
        if (curveDistance > curveTotal)
        {
            if (looping)
            {
                curveDistance = curveDistance % curveTotal;
            }
            else
            {
                curveDistance = curveTotal;
            }
            if (removeAtEnd)
            {
                GameObject.Destroy(transform.parent.gameObject);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 nPos = cMath.CalcPositionByDistance(curveDistance);
        Vector3 nTan = cMath.CalcTangentByDistance(curveDistance);

        transform.position = nPos;
        transform.forward  = nTan;

        curveDistance += speed * Time.deltaTime;
        if (curveDistance > curveTotal)
        {
            if (looping)
            {
                curveDistance = curveDistance % curveTotal;
            }
            else
            {
                curveDistance = curveTotal;
            }
            if (removeAtEnd)
            {
                GameObject.Destroy(this.gameObject);
            }
            if (loadSceneAtEnd)
            {
                SceneManager.LoadScene(sceneName);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 nPos = cMath.CalcPositionByDistance(curveDistance);
        Vector3 nTan = cMath.CalcTangentByDistance(curveDistance);

        transform.position = nPos;
        transform.forward  = nTan;

        if (state == SpiderState.Running)
        {
            curveDistance += speed * Time.deltaTime;
            if (curveDistance > curveTotal)
            {
                if (looping)
                {
                    curveDistance = curveDistance % curveTotal;
                }
                else
                {
                    curveDistance = curveTotal;
                }
                if (removeAtEnd)
                {
                    GameObject.Destroy(this.gameObject);
                }
            }
        }
        else if (state == SpiderState.Charging)
        {
            LaserSlerp(2f);
            remainingChargeTime -= Time.deltaTime;
            if (remainingChargeTime <= 0f)
            {
                state = SpiderState.Attacking;
            }
        }
        else if (state == SpiderState.Attacking)
        {
            LaserSlerp(1f);
            laser.SetActive(true);
            remainingAttackTime -= Time.deltaTime;
            if (remainingAttackTime <= 0f)
            {
                state = SpiderState.Uncharging;
                laser.SetActive(false);
            }
        }

        if (dead)
        {
            invisiTimer -= Time.deltaTime;
            if (invisiTimer <= 0f)
            {
                foreach (Renderer r in rbRends)
                {
                    Color c = r.material.color;
                    c.a -= Time.deltaTime * 1f;
                    r.material.color = c;
                }
            }
        }
    }