コード例 #1
0
    void Track()
    {
        ObjectPast past = new ObjectPast(transform.position, transform.rotation);

        pastList.Add(past);
    }
コード例 #2
0
    void Reverse()
    {
        if (shardFlag)
        {
            rbody.isKinematic      = true;
            rbody.useGravity       = false;
            rbody.detectCollisions = true;
            rbody.mass             = 1;
        }
        if (enemyFlag)
        {
            enemy.agent.enabled      = true;
            enemy.enabled            = true;
            enemy.agent.speed        = agentSpeed;
            enemy.agent.angularSpeed = agentTurn;
        }

        if (!started)
        {
            rbody.mass            = mass;
            rbody.velocity        = Vector3.zero;
            rbody.angularVelocity = Vector3.zero;
            rbody.isKinematic     = true;

            if (shardFlag)
            {
                rbody.useGravity = false;
            }

            if (enemyFlag)
            {
                enemy.agent.enabled = false;
                enemy.enabled       = false;
            }
        }

        if (pastList.Count != 0)
        {
            ObjectPast past = pastList[pastList.Count - 1];
            pastList.RemoveAt(pastList.Count - 1);

            transform.position = past.position;
            transform.rotation = past.rotation;
            if (!enemyFlag)
            {
                rbody.detectCollisions = false;
            }

            if (pastList.Count == 0)
            {
                if (shardFlag)
                {
                    Debug.Log("ggg");
                    rbody.detectCollisions = true;
                    Destroy(this);
                    return;
                }
            }
        }
        else
        {
            if (destroyAtEnd & !shardFlag)
            {
                Destroy(gameObject);
            }

            reversing = false;
            started   = false;
            if (!wallFlag & !shardFlag)
            {
                rbody.isKinematic = false;
            }

            if (shardFlag)
            {
                rbody.velocity        = Vector3.zero;
                rbody.angularVelocity = Vector3.zero;
                rbody.isKinematic     = true;
            }
            rbody.velocity         = vel;
            rbody.angularVelocity  = angVel;
            rbody.mass             = mass;
            rbody.detectCollisions = true;
            if (enemyFlag)
            {
                enemy.agent.enabled      = true;
                enemy.enabled            = true;
                enemy.agent.speed        = agentSpeed;
                enemy.agent.angularSpeed = agentTurn;
            }
        }
    }