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

    public virtual void Refresh()
    {
        CheckReferences();

        CheckAxisRestraints();

        // Update obstacle-models
        var mdl   = ResourcesObstacles.GetModel(_type, _model);
        var model = Instantiate(mdl) as GameObject;

        Init(model);
    }
Esempio n. 2
0
    //=====================================================

    public override void Refresh()
    {
        CheckReferences();

        // Update obstacle-models
        var mdlArm  = ResourcesObstacles.GetModel(eObstacleType.SWINGING_ARM, _model);
        var mdlBody = ResourcesObstacles.GetModel(eObstacleType.SWINGING_BODY, _modelBody);

        var modelArm  = Instantiate(mdlArm) as GameObject;
        var modelBody = Instantiate(mdlBody) as GameObject;

        Init(modelArm, modelBody);
    }
Esempio n. 3
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. 4
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);
    }