Пример #1
0
    public override void OnInspectorGUI()
    {
        BuildWorld buildWorld = (BuildWorld)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Load Configuration"))
        {
            buildWorld.LoadConfigurationFile();
        }

        if (GUILayout.Button("Save Configuration"))
        {
            buildWorld.SaveConfigurationFile();
        }
    }
Пример #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <BuildWorld>() != null)
        {
            Vector3 tempPlayerPosition;

            BuildWorld world = other.GetComponent <BuildWorld>();

            do
            {
                tempPlayerPosition = new Vector3(Random.Range(0, world.worldX - world.gridSize), .6f, Random.Range(0, world.worldX - world.gridSize));
            } while (Physics.OverlapBox(tempPlayerPosition, this.transform.position / 2).Length != 0);

            this.transform.position = tempPlayerPosition;
        }
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <PedestrianController>() != null && this.Pilot != null)
        {
            if (other.gameObject.GetComponent <Rigidbody>() == null)
            {
                Rigidbody body = other.gameObject.AddComponent <Rigidbody>() as Rigidbody;
                Destroy(body, 10000);
            }

            BoxCollider[] colliders = other.gameObject.GetComponents <BoxCollider>();

            for (int i = 0; i < colliders.Length; ++i)
            {
                colliders[i].isTrigger = true;
            }

            other.gameObject.transform.LookAt(this.transform.position);
            Vector3 explosionPosition = this.transform.position;
            explosionPosition.y -= 3;
            other.gameObject.GetComponent <Rigidbody>().AddExplosionForce(2000f, explosionPosition, 20);
        }

        if (other.GetComponent <BuildWorld>() != null)
        {
            Vector3 tempCarPosition;

            BuildWorld world = other.GetComponent <BuildWorld>();

            do
            {
                tempCarPosition = new Vector3(Random.Range(0, world.worldX - world.gridSize), 20f, Random.Range(0, world.worldX - world.gridSize));
            } while (Physics.OverlapBox(tempCarPosition, this.transform.position / 2).Length != 0);

            this.transform.position = tempCarPosition;
        }
    }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     worldObj = GameObject.Find("World");
     world    = worldObj.GetComponent <BuildWorld>();
 }