当前位置: 首页>>代码示例>>C#>>正文


C# GameStateManager.EnsureCoreScriptsAdded方法代码示例

本文整理汇总了C#中GameStateManager.EnsureCoreScriptsAdded方法的典型用法代码示例。如果您正苦于以下问题:C# GameStateManager.EnsureCoreScriptsAdded方法的具体用法?C# GameStateManager.EnsureCoreScriptsAdded怎么用?C# GameStateManager.EnsureCoreScriptsAdded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameStateManager的用法示例。


在下文中一共展示了GameStateManager.EnsureCoreScriptsAdded方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    // Set reference pointers to the correct objects.
    public void Start()
    {
        // Get the main object reference and ensure core scripts are added.
        GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];

        if(GameObject.FindGameObjectsWithTag("MainObject").Length > 1){
            GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject");
            for(int i = 0; i < mainObjectList.Length; ++i){
                if(mainObjectList[i].GetComponent<GameStateManager>().objectSaved){
                    mainObject = mainObjectList[i];
                }
            }
        }
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();

        // Get the global variables reference.
        GameObject gVar = GameObject.FindGameObjectsWithTag("globalVariables")[0];
        globalVariables = gVar.GetComponent<GVariables>();
    }
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:21,代码来源:Collectable.cs

示例2: Start

    void Start()
    {
        // the following is now needed due to the prefab of 'MainObject'
        GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        screenManagerRef = mainObject.GetComponent<ScreenManager>();
        soundManagerRef = mainObject.GetComponent<SoundManager>();
        characterControllerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>();
        mainCamera = GameObject.FindGameObjectWithTag("MainCamera");

        // get a reference to the tear manager
        tearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>();

        // get a reference to fold
        fold = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>();

        LvlGoalCoreRef = GameObject.FindGameObjectWithTag("GoalCore").GetComponent<LvlGoalCore>();

        // Get the global variables reference.
        GameObject gVar = GameObject.FindGameObjectsWithTag("globalVariables")[0];
        globalVariables = gVar.GetComponent<GVariables>();

        // if the goal is on the backside move necessary components by offset to be at correct location.
        if(goalOnBackSide){
            // change the box collider on the goal core
            Vector3 GoalCollider = this.gameObject.GetComponent<BoxCollider>().center;
            GoalCollider = new Vector3(GoalCollider.x, GoalCollider.y, GoalCollider.z + (offset*2f));
            this.gameObject.GetComponent<BoxCollider>().center = GoalCollider;

            // change the graphics child object position
            Vector3 GraphicTrans = transform.FindChild("Graphics").transform.position;
            GraphicTrans = new Vector3(GraphicTrans.x, GraphicTrans.y, GraphicTrans.z + offset);
            transform.FindChild("Graphics").transform.position = GraphicTrans;

            // change the goal core child object.
            Vector3 GoalCoreTrans = transform.FindChild("GoalCore").transform.position;
            GoalCoreTrans = new Vector3(GoalCoreTrans.x, GoalCoreTrans.y, GoalCoreTrans.z + offset);
            transform.FindChild("GoalCore").transform.position = GoalCoreTrans;
        }
        buttonCamera = GameObject.FindGameObjectWithTag("button");
    }
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:42,代码来源:LevelGoal.cs

示例3: Start

    // Use this for initialization.
    public void Start()
    {
        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = gameObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        gameStateManagerRef.EnsureScriptAdded("MainMenu");

        if(gameStateManagerRef.gameStartedFromUI){
            activeScreen = gameObject.GetComponent("MainMenu") as MainMenu;
            currentScreenArea = ScreenAreas.MainMenu;
        }
        else{
            // This will not be the active screen, but active screen needs to be initialized.
            activeScreen = gameObject.GetComponent("MainMenu") as MainMenu;
            activeScreen.enabled = false;
            currentScreenArea = ScreenAreas.InGame;
        }

        screenOrientation = ScreenOrientation.Landscape;
        deviceOrientation = DeviceOrientation.LandscapeLeft;

        if(Application.platform.Equals(RuntimePlatform.Android)){
            #if UNITY_ANDROID
            using(AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
                    metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")){
                using(AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
                        activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
                        windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
                        displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")){
                    displayInstance.Call("getMetrics", metricsInstance);
                    screenResolution.y = metricsInstance.Get<int>("heightPixels");
                    screenResolution.x = metricsInstance.Get<int>("widthPixels");
                    screenSize.x = Screen.width;
                    screenSize.y = Screen.height;
                    Screen.SetResolution((int)screenResolution.x, (int)screenResolution.y, true);
                    deviceOrientation = Input.deviceOrientation;
                }
            }
            #endif
        }
        else{
            // Overall screen resolution must be set initially to screen size for UI, then set to screen resolution while in game.
            screenSize = new Vector2(Screen.width, Screen.height);
            screenResolution = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);

            if(gameStateManagerRef.inUI){
                Screen.SetResolution((int)screenSize.x, (int)screenSize.y, gameStateManagerRef.fullScreen);
            }

            // Developer started in a level.
            else{
                Screen.SetResolution((int)screenResolution.x, (int)screenResolution.y, gameStateManagerRef.fullScreen);
            }
        }
    }
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:56,代码来源:ScreenManager.cs

示例4: Start

    // Use this for initialization
    void Start()
    {
        #region initialization
        // NOTICE : DOM
        // the following is now needed
        // due to the prefab of 'MainObject'
        GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];

        if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1)
        {
            GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject");
            for (int i = 0; i < mainObjectList.Length; ++i)
            {
                if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved)
                    mainObject = mainObjectList[i];
            }
        }

        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        gameStateManagerRef.EnsureScriptAdded("TouchController");
        soundManagerRef = mainObject.GetComponent<SoundManager>();
        screenManagerRef = mainObject.GetComponent<ScreenManager>();

        #region initialize references

        backsidePivotReference = GameObject.Find("backsidepivot");
        coverupPivotReference = GameObject.Find ("coveruppivot");
        tornBacksidePieceReference = GameObject.Find ("tornBacksidePiece");
        //sets the reference of the touchcontroller to the touchcontroller script.
        touchController = mainObject.GetComponent<TouchController>();
        //sets the reference of the backsidesideReference to the backside or "fold"
        backsideReference = backsidePivotReference.transform.FindChild("backside").gameObject;

        backSideInitialColor = backsideReference.GetComponent<MeshRenderer>().material.color;

        //sets the reference of the backsideCollisionReference to the platforms on the back of the paper.
        backsideCollisionReference = GameObject.FindGameObjectsWithTag("FoldPlatform");
        //sets the camera reference to the main camera
        cameraReference = GameObject.Find("Main Camera");
        //sets the player reference to the player
        playerReference = GameObject.Find("Player_Prefab");
        //sets the backgroundTransform to the transform of the background paper.
        origBackground = GameObject.FindGameObjectWithTag("background");
        backgroundTransform = origBackground.transform;
        //sets backgroundBounds to the bounds of the background paper
        backgroundBounds = backgroundTransform.GetComponent<MeshFilter>().mesh.bounds;
        //sets changeMeshScript to the ChangeMeshScript which removes and restores triangles.
        changeMeshScript = this.GetComponent<ChangeMeshScript>();
        tearReference = GameObject.Find("Tear_Manager").GetComponent<TearManager>();
        coverupReference = coverupPivotReference.transform.FindChild("coverup").gameObject;
        tearPaperMesh = GameObject.Find("backside").GetComponent<MeshFilter>().mesh;
        unfoldCollisionReference = GameObject.Find("Player_Prefab").GetComponent<UnfoldCollision>();
        shadowReference = GameObject.Find("shadow");
        rayTraceBlockRef = GameObject.Find("rayTraceBlocker");
        paperBorderInsideRef = GameObject.Find("paper_border_inside");
        paperBorderOutsideRef = GameObject.Find("paper_border_outside");
        worldCollisionRef = mainObject.GetComponent<WorldCollision>();
        backsideTriangles = tearPaperMesh.triangles;
        #endregion

        //sets original position and rotation to its starting position and rotation
        foldOriginalRotation = backsidePivotReference.transform.rotation;
        foldOriginalPosition = backsidePivotReference.transform.position;

        //sets starting position coverup's starting position
        coverupStartingPosition = coverupPivotReference.transform.position;
        //sets coverup's original position to the vector required for the tranforms to work properly
        coverupOriginalPosition = new Vector3(0,0,-3);
        //sets coverup's original rotation to its starting rotation
        coverupOriginalRotation = coverupPivotReference.transform.rotation;

        coverupPrefab = coverupPivotReference.transform;
        foldPrefab = backsidePivotReference.transform;

        //initializes variables to defaults.
        fingerList = new List<Vector2>();
        backgroundObjMax = new Vector2();
        backgroundObjMin = new Vector2();
        posModifier = new Vector3();
        posModLastValid = new Vector3();
        unfoldPosModifier = new Vector3();
        foldTmpZLayer = GVariables.zFoldLayer - 1;
        coverupTmpZLayer = GVariables.zCoverLayer -1;
        prevMousestate = false;
        currMouseState = false;
        firstTouch = false;
        isFolded = false;
        overPlayer = false;
        needsToUnfold = false;
        isOffPaper = true;
        backsideIsInstantiated = false;
        currentlyFolding = false;
        missingTriangles = new List<Vector3>();
        //changeMeshScript.GrabUpdatedPlatforms("FoldPlatform");
        deletedTri = new int[0];
        startingQuadrant = Quadrant.NONE;
        currentQuadrant = Quadrant.NONE;
//.........这里部分代码省略.........
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:101,代码来源:Fold.cs

示例5: Start

    // Use this for initialization
    public virtual void Start()
    {
        GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];

        if(GameObject.FindGameObjectsWithTag("MainObject").Length > 1){
            GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject");
            for(int i = 0; i < mainObjectList.Length; ++i){
                if(mainObjectList[i].GetComponent<GameStateManager>().objectSaved){
                    mainObject = mainObjectList[i];
                }
            }
        }

        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();

        // GUI elements depend on screen size, NOT RESOLUTION
        START_POS = gameStateManagerRef.GetScreenManager().GetScreenSize();
    }
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:20,代码来源:TearableScreen.cs

示例6: Start

    // Use this for initialization.
    public void Start()
    {
        // Keeping GameObject component grabbing consistent among classes. - J.T.
        GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];

        if(GameObject.FindGameObjectsWithTag("MainObject").Length > 1){
            GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject");
            for(int i = 0; i < mainObjectList.Length; ++i){
                if(mainObjectList[i].GetComponent<GameStateManager>().objectSaved){
                    mainObject = mainObjectList[i];
                }
            }
        }

        gameStateManagerRef = mainObject.GetComponent <GameStateManager>();
        gameStateManagerRef.EnsureGameScriptsAdded();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        screenManagerRef = mainObject.GetComponent<ScreenManager>();
        animManagerRef = mainObject.GetComponent<AnimationManager>();
        worldCollisionRef = mainObject.GetComponent<WorldCollision>();
        touchController = gameObject.GetComponent<TouchController>();
        soundManagerRef = gameStateManagerRef.GetSoundManager();
        paperObject = GameObject.FindGameObjectWithTag("background");
        tearBorder = GameObject.FindGameObjectWithTag("DeadSpace");
        foldBorder = GameObject.FindGameObjectWithTag("foldborder");
        unfoldBorder = GameObject.FindGameObjectWithTag("unfoldborder");
        unfoldBlocker = GameObject.FindGameObjectWithTag("RayTraceBlocker");
        moveBorder = GameObject.FindGameObjectWithTag("insideBorder");
        menuButton = GameObject.Find("MenuButton_Prefab");
        restartButton = GameObject.Find("RestartButton_Prefab");
        moveMode = true;
        tearMode = false;
        foldMode = false;
        //Keeping old code here in case something gets broken. - J.T.
        // Ensures all necessary scripts are added for the MainObject.
        /*
        gameStateManagerRef = gameObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        gameStateManagerRef.EnsureGameScriptsAdded();
        screenManagerRef = gameObject.GetComponent<ScreenManager>();
        animManagerRef = gameObject.GetComponent<AnimationManager>();
        worldCollisionRef = gameObject.GetComponent<WorldCollision>();
        touchController = gameObject.GetComponent<TouchController>();
        */
        idleTriggerLimit = Random.Range (1000, 3000);
        keyDownWatch = new Stopwatch();
        idleKeyWatch = new Stopwatch();
        releaseWatch = new Stopwatch();
        justPressedWatch = new Stopwatch();
        playerBottomCollisionWatch = new Stopwatch();
        idlePlayerWatch = new Stopwatch();

        watchList.Add(keyDownWatch);
        watchList.Add(idleKeyWatch);
        watchList.Add(releaseWatch);
        watchList.Add(justPressedWatch);
        watchList.Add(playerBottomCollisionWatch);
        watchList.Add(idlePlayerWatch);

        wasdRight = KeyCode.D;
        wasdLeft = KeyCode.A;
        arrowRight = KeyCode.RightArrow;
        arrowLeft = KeyCode.LeftArrow;
        keyJump = KeyCode.Space;

        hasHorizontalCollision = false;
        currentDirection = ScreenSide.NONE;
        tornPieceInitiated = false;
        movingTornPiece = false;
    }
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:71,代码来源:InputManager.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = gameObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        inputManagerRef = gameObject.GetComponent<InputManager>();

        playerObject = GameObject.FindGameObjectWithTag("Player");
        paperObject = GameObject.FindGameObjectWithTag("background");
        backsidePaperObject = GameObject.FindGameObjectWithTag("Fold");

        // by default, player should be facing right
        // since we typically start from the left and head right
        currentDirection = AnimationDirection.RIGHT;

        /*  FILLING IN ALL OF THE ANIMATIONS WITH TEXTURE2D FRAMES */
        List<Texture2D> walkList = new List<Texture2D>();
        PopulateWalkAnimations(walkList);
        walkAnimation = new Animation(walkList, Animation.AnimationState.WALK);

        List<Texture2D> idleList = new List<Texture2D>();
        PopulateIdleAnimations(idleList);
        idleAnimation = new Animation(idleList, Animation.AnimationState.IDLE);

        List<Texture2D> standList = new List<Texture2D>();
        PopulateStandAnimations(standList);
        standAnimation = new Animation(standList, Animation.AnimationState.STAND);

        List<Texture2D> jumpList = new List<Texture2D>();
        PopulateJumpAnimations(jumpList);
        jumpAnimation = new Animation(jumpList, Animation.AnimationState.JUMP);

        List<Texture2D> idleAnimAList = new List<Texture2D>();
        PopulateIdleAnimationA(idleAnimAList);
        idleAnimationA = new Animation(idleAnimAList, Animation.AnimationState.IDLEA);

        List<Texture2D> idleAnimBList = new List<Texture2D>();
        PopulateIdleAnimationB(idleAnimBList);
        idleAnimationB = new Animation(idleAnimBList, Animation.AnimationState.IDLEB);

        List<Texture2D> landWallList = new List<Texture2D>();
        PopulateLandWallAnimation(landWallList);
        landWallAnimation = new Animation(landWallList, Animation.AnimationState.WALKINTOWALL);

        List<Texture2D> slideUpList = new List<Texture2D>();
        PopulateSlideUpAnimation(slideUpList);
        slideUpAnimation = new Animation(slideUpList, Animation.AnimationState.WALKUP);

        List<Texture2D> slideDownList = new List<Texture2D>();
        PopulateSlideDownAnimation(slideDownList);
        slideDownAnimation = new Animation(slideDownList, Animation.AnimationState.WALKDOWN);

        List<Texture2D> deathList = new List<Texture2D>();
        PopulateDeathAnimation(deathList);
        deathAnimation = new Animation(deathList, Animation.AnimationState.DEATH);

        List<Texture2D> openList = new List<Texture2D>();
        PopulateOpenAnimation(openList);
        openAnimation = new Animation(openList, Animation.AnimationState.OPENDOOR);

        List<Texture2D> fallList = new List<Texture2D>();
        PopulateFallAnimation(fallList);
        fallAnimation = new Animation(fallList, Animation.AnimationState.FALL);

        level1FrameList.Add(level1Frame1);
        level1FrameList.Add(level1Frame2);
        level1FrameList.Add(level1Frame3);

        //Load backside textures -> J.C.
        BacksideLevel1FrameList.Add(BacksideLevel1Frame1);
        BacksideLevel1FrameList.Add(BacksideLevel1Frame2);
        BacksideLevel1FrameList.Add(BacksideLevel1Frame3);

        //Add to list storing level background animation -> J.C.
        level2FrameList.Add(level2Frame1);
        level2FrameList.Add(level2Frame2);
        level2FrameList.Add(level2Frame3);

        level3FrameList.Add(level3Frame1);
        level3FrameList.Add(level3Frame2);
        level3FrameList.Add(level3Frame3);

        Backsidelevel3FrameList.Add(Backsidelevel3Frame1);
        Backsidelevel3FrameList.Add(Backsidelevel3Frame2);
        Backsidelevel3FrameList.Add(Backsidelevel3Frame3);

        //Add to list storing level background animation -> J.C.
        level4FrameList.Add(level4Frame1);
        level4FrameList.Add(level4Frame2);
        level4FrameList.Add(level4Frame3);

        //Add to list storing level background animation -> J.C.
        level5FrameList.Add(level5Frame1);
        level5FrameList.Add(level5Frame2);
        level5FrameList.Add(level5Frame3);

        //Add to list storing level background animation -> J.C.
        Backsidelevel5FrameList.Add(Backsidelevel5Frame1);
        Backsidelevel5FrameList.Add(Backsidelevel5Frame2);
//.........这里部分代码省略.........
开发者ID:dindras234,项目名称:TearableWorld10-19-2015,代码行数:101,代码来源:AnimationManager.cs


注:本文中的GameStateManager.EnsureCoreScriptsAdded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。