Esempio n. 1
0
    //=====================================================

    private static void AddPushableObject()
    {
        const eObstacleType type = eObstacleType.PUSHABLE_BOX;
        var pfb = ResourcesObstacles.GetPrefab(type);
        var mdl = ResourcesObstacles.GetModel(type, 0);

        if (pfb == null)
        {
            return;
        }

        // Create containers for obstacles if they don't already exist
        var container = CreateObstacleContainers(type);

        var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject;

        if (prefab == null)
        {
            return;
        }

        switch (type)
        {
        case eObstacleType.PUSHABLE_BOX:
            prefab.name = "PushableBox";
            break;
        }

        // Add to traps gameObject in hierarchy
        prefab.transform.parent = container;

        var script = prefab.GetComponent <Obstacle>();

        if (script != null)
        {
            script.Type = type;

            if (mdl != null)
            {
                var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject;

                script.Init(model);
            }
        }

        PositionObjectAndSelect(prefab);
    }
Esempio n. 2
0
    //=====================================================

    private static void AddObstacleSwinging()
    {
        const eObstacleType type = eObstacleType.SWINGING;
        var pfb   = ResourcesObstacles.GetPrefab(type);
        var mdl01 = ResourcesObstacles.GetModel(eObstacleType.SWINGING_ARM, 0);
        var mdl02 = ResourcesObstacles.GetModel(eObstacleType.SWINGING_BODY, 0);

        if (pfb == null)
        {
            return;
        }

        // Create containers for obstacles if they don't already exist
        var container = CreateObstacleContainers(type);

        var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject;

        if (prefab == null)
        {
            return;
        }

        prefab.name = "SwingingObstacle";

        // Add to traps gameObject in hierarchy
        prefab.transform.parent = container;

        var script = prefab.GetComponent <SwingingObstacle>();

        if (script != null)
        {
            script.Type = type;

            if (mdl01 != null && mdl02 != null)
            {
                var model01 = PrefabUtility.InstantiatePrefab(mdl01) as GameObject;
                var model02 = PrefabUtility.InstantiatePrefab(mdl02) as GameObject;

                script.Init(model01, model02);
            }
        }

        PositionObjectAndSelect(prefab);
    }
Esempio n. 3
0
    //=====================================================

    private static void AddMagicalTrap(eObstacleType type)
    {
        var pfb = ResourcesObstacles.GetPrefab(type);

        if (pfb == null)
        {
            return;
        }

        // Create containers for obstacles if they don't already exist
        var container = CreateObstacleContainers(type);

        var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject;

        if (prefab == null)
        {
            return;
        }

        switch (type)
        {
        case eObstacleType.MAGICAL_TRAP_ICE:
            prefab.name = "MagicalTrapIce";
            break;

        case eObstacleType.MAGICAL_TRAP_WIND:
            prefab.name = "MagicalTrapWind";
            break;
        }

        // Add to traps gameObject in hierarchy
        prefab.transform.parent = container;

        var script = prefab.GetComponent <MagicalTrap>();

        if (script != null)
        {
            script.Type = type;
        }

        PositionObjectAndSelect(prefab);
    }