Esempio n. 1
0
        private static void GameLoop()
        {
            var Window = WindowHandler.Initialize();
            var GUI    = GUIHandler.Initialize();
            var Clock  = new Clock();

            new BasicScene();

            while (Window.IsOpen)
            {
                Window.DispatchEvents();
                Window.Clear();

                WorldCollision.CheckCollision();
                World.UpdateEntities();
                GlobalConsole.DrawConsole();
                DrawableHandler.Draw();
                InputHandler.UpdateInputs();

                GUI.Draw();
                Window.Display();

                var DeltaClock = Clock.Restart();
                deltaTime = DeltaClock.AsSeconds();
            }
        }
Esempio n. 2
0
        public Collider(float width, float height)
        {
            WorldCollision.AddCollider(this);

            Width  = width;
            Height = height;
        }
    public void Start()
    {
        //Grab mainObject prefab to access managers effectively
        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];
            }
        }

        // Notice, these are attached to the MainObject
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        animationManagerRef = gameStateManagerRef.GetAnimationManager();
        inputManagerRef = gameStateManagerRef.GetInputManager();
        worldCollisionRef = gameStateManagerRef.GetWorldCollision();

        // This script is attached to the player, so we use 'gameObject' here
        controllerRef = gameObject.GetComponent<TWCharacterController>();

        paperObject = GameObject.FindGameObjectWithTag("background");
    }
 // Update is called once per frame
 void Update()
 {
     if(inpManRef == null) inpManRef = gameStateManagerRef.GetInputManager();
     if(worldCollisionRef == null) worldCollisionRef = gameStateManagerRef.GetWorldCollision();
     if(inpManRef.foldMode) gameObject.renderer.material.color = new Color(0.0f, 0.0f, 0.0f);
     else gameObject.renderer.material.color = new Color(1.0f, 1.0f, 1.0f);
     // if the finger is within the bounds of this object
     #if UNITY_IPHONE
     if(worldCollisionRef.PointInsideObject(gameObject,
     gameStateManagerRef.GetTouchController().GetLastFingerPosition())
     #endif
     #if UNITY_ANDROID
     if(worldCollisionRef.PointInsideObject(gameObject,
     gameStateManagerRef.GetTouchController().GetLastFingerPosition())
     #endif
     #if UNITY_STANDALONE
     if(Input.GetMouseButtonDown(0) &&  (worldCollisionRef.PointInsideObject(gameObject, Input.mousePosition))
     #endif
     && !inpManRef.tearManagerRef.PlayerCurrentlyTearing &&
     !inpManRef.foldRef.currentlyFolding) /*&&
     // not performing a tear or a fold
     !gameStateManagerRef.GetInputManager().GetFingerGesture().Equals(InputManager.FingerGesture.TEAR) &&
     !gameStateManagerRef.GetInputManager().GetFingerGesture().Equals(InputManager.FingerGesture.FOLD)*/
     {
         inpManRef.moveMode = false;
         inpManRef.foldMode = true;
         inpManRef.tearMode = false;
         gameObject.renderer.material.color = new Color(0.0f, 0.0f, 0.0f);
     }
 }
    // Use this for initialization
    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];
            }
        }

        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureGameScriptsAdded();
        worldCollisionRef = gameStateManagerRef.GetWorldCollision();
    }
Esempio n. 6
0
        public virtual void Destroy()
        {
            for (var i = 0; i < Components.Count; i++)
            {
                var Component = Components[i];

                if (Component.GetType() == typeof(Collider))
                {
                    WorldCollision.RemoveCollider((Collider)Component);
                }

                if (Component.GetType() == typeof(Renderer))
                {
                    var Renderer = (Renderer)Component;

                    DrawableHandler.RemoveDrawable(Renderer.Drawable);
                }
            }

            World.RemoveEntity(this);
        }
    // Use this for initialization
    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];
            }
        }

        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureGameScriptsAdded();
        worldCollisionRef = gameStateManagerRef.GetWorldCollision();
        playerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>();

        //Init local reference - J.C.
        TearManagerLocalRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>();
    }
    // Use this for initialization
    void Start()
    {
        // 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
        GameStateManager gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureScriptAdded("WorldCollision");

        worldCollisionRef = mainObject.GetComponent<WorldCollision>();
        playerObject = GameObject.FindGameObjectWithTag("Player");
    }
    // Ensures game needed scripts are added to the overall 'MainObject'. Should only be called if you're referencing the MainObject!
    public void EnsureGameScriptsAdded()
    {
        if(!gameObject.GetComponent<AnimationManager>()){
            gameObject.AddComponent<AnimationManager>();
        }
        if(!gameObject.GetComponent<PlayerManager>()){
            gameObject.AddComponent<PlayerManager>();
        }
        if(!gameObject.GetComponent<TouchController>()){
            gameObject.AddComponent<TouchController>();
        }
        if(!gameObject.GetComponent<WorldCollision>()){
            gameObject.AddComponent<WorldCollision>();
        }
        if(!gameObject.GetComponent<InputManager>()){
            gameObject.AddComponent<InputManager>();
        }
        gameObject.GetComponent<AnimationManager>().enabled = true;
        gameObject.GetComponent<PlayerManager>().enabled = true;
        gameObject.GetComponent<TouchController>().enabled = true;
        gameObject.GetComponent<WorldCollision>().enabled = true;
        gameObject.GetComponent<InputManager>().enabled = true;

        if(!animManagerRef){
            animManagerRef = gameObject.GetComponent<AnimationManager>();
        }
        if(!touchControllerRef){
            touchControllerRef = gameObject.GetComponent<TouchController>();
        }
        if(!worldCollisionRef){
            worldCollisionRef = gameObject.GetComponent<WorldCollision>();
        //			UnityEngine.Debug.Log("TRUE");
        }
    }
 // Use this for initialization
 void Start()
 {
     gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>();
     inpManRef = gameStateManagerRef.GetInputManager();
     worldCollisionRef = gameStateManagerRef.GetWorldCollision();
 }
Esempio n. 11
0
    // 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;
        foldEdge = Edge.BuildManifoldEdges(backsideReference.GetComponent<MeshFilter>().mesh);
        guiEnable = false;
        blah = false;

        foldInput = false;
        prevFoldInput = false;
        #endregion
    }
Esempio n. 12
0
 public PlatformManager(WorldCollision worldCollide)
 {
     worldCollision = worldCollide;
 }
    // 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;
    }