Esempio n. 1
0
    private static void SetupPrefab(GameObject prefab, string directoryName, bool hasGibs = false)
    {
        // make all necessary adjustments to the prefab.
        Main.AddComponentRecursively(prefab.transform, "TileProperties");

        prefab.GetComponent <TileProperties>().category = directoryName;

        // Main.AddComponentRecursively( prefab.transform, "Rigidbody" );

        // remove excess components in the prefab.
//		RemoveExcessPrefabComponentsRecursively( prefab.transform );

        Main.SetMeshColliderConvexRecursively(prefab.transform, true);
        // Main.SetTriggerRecursively( prefab.transform, true );

        // set indestructibility based on the presence of a gibs folder.
        prefab.GetComponent <TileProperties>().isIndestructible = !hasGibs;

        // determine the size of the component, and add it to the tile properties.
        Bounds bounds = new Bounds();

        Main.GetBoundsRecursively(prefab.transform, ref bounds);

        Vector3 size = bounds.extents * 2;

        prefab.GetComponent <TileProperties>().size       = size;
        prefab.GetComponent <TileProperties>().tileBounds = bounds;
        prefab.GetComponent <TileProperties>().tileID     = directoryName + "/" + prefab.name;
    }
Esempio n. 2
0
    public static void ConfigureGibPrefab(GameObject prefab, string directoryName, string bundleName)
    {
        Main.AddComponentRecursively(prefab.transform, "GibProperties");
        prefab.GetComponent <GibProperties>().category = directoryName;
        prefab.GetComponent <GibProperties>().bundle   = bundleName;

        Main.SetMeshColliderConvexRecursively(prefab.transform, true);
        Main.AddComponentRecursively(prefab.transform, "Rigidbody");
    }
Esempio n. 3
0
    private static void SetupEffectPrefab(GameObject prefab, string directoryName)
    {
        Main.AddComponentRecursively(prefab.transform, "EffectProperties");

        prefab.GetComponent <TileProperties>().scalable = false;

        SetupPrefab(prefab, directoryName);

        // Effects are always indestructible.
        prefab.GetComponent <TileProperties>().isIndestructible = true;
    }
Esempio n. 4
0
    private static void SetupPointLightPrefab(GameObject prefab, string directoryName)
    {
        Main.AddComponentRecursively(prefab.transform, "LightProperties");

        prefab.GetComponent <TileProperties>().useYOffset = true;
        prefab.GetComponent <TileProperties>().yOffset    = 3.0f;
//		prefab.GetComponent<TileProperties>().placeableInBuildMode = false;
        prefab.GetComponent <TileProperties>().keepUpright = true;

        SetupPrefab(prefab, directoryName);

        // Lights are always indestructible.
        prefab.GetComponent <TileProperties>().isIndestructible = true;
    }
Esempio n. 5
0
    private static void SetupPickupPrefab(GameObject prefab, string directoryName, string prefabName)
    {
//		string[] pointString = prefabName.Split (new char[]{'_'});
//		int pointValue = 5;
//		int.TryParse (pointString[1], out pointValue);

        Main.AddComponentRecursively(prefab.transform, "PickupProperties");
//		prefab.GetComponent<PickupProperties>().yOffset = 0.5f;
//		Main.AddSphereColliderRecursively( prefab.transform, 2 );

        // if this is a pickup, we need to attach the proper gui texture file.
//		prefab.GetComponent<PickupProperties>().pickupTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(pickupTexturePath,typeof(Texture2D));
//		prefab.GetComponent<PickupProperties>().pointValue = pointValue;

        SetupPrefab(prefab, directoryName);

        // pickups are always indestructible.
        prefab.GetComponent <TileProperties>().isIndestructible = true;
    }
Esempio n. 6
0
    private static void SetupArtilleryPrefab(GameObject prefab, string directoryName, string prefabName)
    {
        Main.AddComponentRecursively(prefab.transform, "CannonProperties");

        // search for the projectile for this prefab.
        prefab.GetComponent <CannonProperties>().projectile = (Transform)AssetDatabase.LoadAssetAtPath("Assets/Source_Assets/Warehouse/Artillery/Resources/" + prefabName + "/Projectile.prefab", typeof(Transform));

        // TEMP
        if (prefabName == "Cannon")
        {
            prefab.GetComponent <CannonProperties>().fireAnimationOffsetPosition = new Vector3(0, 1.15f, 2.0f);
        }
        else if (prefabName == "Ballista")
        {
            prefab.GetComponent <CannonProperties>().fireAnimationOffsetPosition = new Vector3(0, 1.15f, 3.0f);
        }

        SetupPrefab(prefab, directoryName);
    }