示例#1
0
 private void OnDestroy()
 {
     OnResolutionChange.RemoveAllListeners();
     OnOrientationChange.RemoveAllListeners();
     if (instance == this)
     {
         instance = null;
     }
 }
示例#2
0
 private void OnDestroy()
 {
     if (instance == this)
     {
         // Clean up memory.
         OnResolutionChange.RemoveAllListeners();
         OnResolutionChange = null;
         OnOrientationChange.RemoveAllListeners();
         OnOrientationChange = null;
         instance            = null;
     }
 }
示例#3
0
    static ScreenOrientation orientation; // Current Screen Orientation

    static void init()
    {
        if (instance != null)
        {
            return;
        }

        resolution  = new Vector2(Screen.width, Screen.height);
        orientation = Screen.orientation;

        GameObject canvas = new GameObject("ScreenWatcher");

        canvas.AddComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
        instance = canvas.AddComponent <ScreenWatcher>();
        DontDestroyOnLoad(canvas);
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        score          = 0;
        failCounter    = 0;
        chainAmt       = 0;
        chainThreshold = 5;
        levelThreshold = 1;
        level          = 0;
        currentLevel   = levels[0];
        numberOfShapes = 1;
        polyRangeLow   = 0;
        polyRangeHigh  = 1;
        currHealth     = 1f;
        newHealth      = 1f;
        t            = 0f;
        wallSpeed    = .05f;
        audiosource  = GameObject.Find("BGM").GetComponent <AudioSource> ();
        wallPlane    = GameObject.Find("Wall").transform.Find("Plane");
        animDone     = false;
        smallBeat    = false;
        skyboxOffset = 0f;
        //screen orientation stuff
        ScreenWatcher.AddOrientationChangeListener(OnOrientationChanged);
        //Screen.orientation = ScreenOrientation.LandscapeLeft;
        wall = GameObject.FindObjectOfType <Wall>();
        bs   = bonusSelector.GetComponent <BonusSelect>();

        cylinderOffsetProperty = "_DownTex";
        cylinderOffsetProp2    = "_DownTex2";
        twoOffsetProps         = false;
        //PositionForLandscape ();

        //set up text colors
        scoreText.color = world1Text;
        scoreText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline;
        chainText.color = world1Text;
        chainText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline;
        infoText.color = world1Text;
        infoText.GetComponent <UnityEngine.UI.Outline>().effectColor = world1Outline;


        if (Screen.orientation == ScreenOrientation.Landscape)
        {
            PositionForLandscape();
        }
        else if (Screen.orientation == ScreenOrientation.Portrait)
        {
            PositionForPortrait();
        }
        //GameObject.Find ("MainCanvas").GetComponent<CanvasScaler> ().referenceResolution = new Vector2 (Screen.width, Screen.height);

        polygons = new List <List <Vector3> >();
        Vector3[] shape1 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 1f, 0f),
            new Vector3(1f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape1));
        Vector3[] shape2 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(1f, 2f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(0f, -1f, 0f)
        };
        polygons.Add(new List <Vector3>(shape2));
        Vector3[] shape3 = new Vector3[] {
            new Vector3(-1f, -1f, 0f),
            new Vector3(0f, 0f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(0f, -1f, 0f)
        };
        polygons.Add(new List <Vector3>(shape3));
        Vector3[] shape4 = new Vector3[] {
            new Vector3(-1f, 0f, 0f),
            new Vector3(-.5f, 1f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(1f, 0f, 0f)
        };

        //5 sided
        polygons.Add(new List <Vector3>(shape4));
        Vector3[] shape5 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape5));
        Vector3[] shape6 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape6));
        Vector3[] shape7 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape7));
        Vector3[] shape8 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, .5f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(0f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape8));

        //6 sided
        Vector3[] shape9 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, .5f, 0f),
            new Vector3(1f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape9));
        Vector3[] shape10 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape10));
        Vector3[] shape11 = new Vector3[] {
            new Vector3(-.5f, -0f, 0f),
            new Vector3(0f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(.5f, 0f, 0f),
            new Vector3(1f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape11));
        Vector3[] shape12 = new Vector3[] {
            new Vector3(-.5f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 1f, 0f),
            new Vector3(1f, -.5f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape12));

        //create custom polygons list if custom game
        if (gameType == GameType.CasualCustom)
        {
            CreateCustomParamsLevel(GameObject.FindObjectOfType <CustomGameParams>());
        }

        //currentPoly.Setup ();
        currentPolys = new List <TestPolygon>();
        CreateNewPlayerPolygons();
        numToRemove = 0;
        foreach (TestPolygon p in currentPolys)
        {
            numToRemove += p.numToRemove;
        }
        currentHoles = new List <TestPolygon>();
        CreateHoles();
    }
示例#5
0
    // Use this for initialization
    void Start()
    {
        score          = 0;
        failCounter    = 0;
        chainAmt       = 0;
        chainThreshold = 5;
        levelThreshold = 1;
        level          = 0;
        currentLevel   = levels[0];
        polyRangeLow   = 0;
        polyRangeHigh  = 1;
        currHealth     = 1f;
        newHealth      = 1f;
        t            = 0f;
        wallSpeed    = .05f;
        audiosource  = GameObject.Find("BGM").GetComponent <AudioSource> ();
        wallPlane    = GameObject.Find("Wall").transform.Find("Plane");
        animDone     = false;
        smallBeat    = false;
        skyboxOffset = 0f;
        //screen orientation stuff
        ScreenWatcher.AddOrientationChangeListener(OnOrientationChanged);
        //Screen.orientation = ScreenOrientation.LandscapeLeft;
        wall = GameObject.FindObjectOfType <Wall>();

        currentPoly = GameObject.Find("PlayerPolygon").GetComponent <TestPolygon> ();

        cylinderOffsetProperty = "_DownTex";
        cylinderOffsetProp2    = "_DownTex2";
        twoOffsetProps         = false;
        //PositionForLandscape ();

        if (Screen.orientation == ScreenOrientation.Landscape)
        {
            PositionForLandscape();
        }
        else if (Screen.orientation == ScreenOrientation.Portrait)
        {
            PositionForPortrait();
        }
        GameObject.Find("MainCanvas").GetComponent <CanvasScaler> ().referenceResolution = new Vector2(Screen.width, Screen.height);

        polygons = new List <List <Vector3> >();
        Vector3[] shape1 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 1f, 0f),
            new Vector3(1f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape1));
        Vector3[] shape2 = new Vector3[] {
            new Vector3(0f, -1f, 0f),
            new Vector3(0f, 0f, 0f),
            new Vector3(2f, 1f, 0f),
            new Vector3(1f, -1f, 0f)
        };
        polygons.Add(new List <Vector3>(shape2));
        Vector3[] shape3 = new Vector3[] {
            new Vector3(-1f, -1f, 0f),
            new Vector3(0f, 0f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(0f, -1f, 0f)
        };
        polygons.Add(new List <Vector3>(shape3));
        Vector3[] shape4 = new Vector3[] {
            new Vector3(-1f, -1f, 0f),
            new Vector3(0f, 0f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(2f, -1f, 0f)
        };

        //5 sided
        polygons.Add(new List <Vector3>(shape4));
        Vector3[] shape5 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape5));
        Vector3[] shape6 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape6));
        Vector3[] shape7 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape7));
        Vector3[] shape8 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, .5f, 0f),
            new Vector3(1f, 0f, 0f),
            new Vector3(0f, 0f, 0f)
        };
        polygons.Add(new List <Vector3>(shape8));

        //6 sided
        Vector3[] shape9 = new Vector3[] {
            new Vector3(0f, 0f, 0f),
            new Vector3(-.5f, 0f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, .5f, 0f),
            new Vector3(1f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape9));
        Vector3[] shape10 = new Vector3[] {
            new Vector3(0f, -.5f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(1f, .5f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape10));
        Vector3[] shape11 = new Vector3[] {
            new Vector3(-.5f, -0f, 0f),
            new Vector3(0f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(.5f, 1f, 0f),
            new Vector3(.5f, 0f, 0f),
            new Vector3(1f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape11));
        Vector3[] shape12 = new Vector3[] {
            new Vector3(-.5f, 0f, 0f),
            new Vector3(-.5f, .5f, 0f),
            new Vector3(0f, 1f, 0f),
            new Vector3(1f, 1f, 0f),
            new Vector3(1f, -.5f, 0f),
            new Vector3(.5f, -.5f, 0f)
        };
        polygons.Add(new List <Vector3>(shape12));
        currentPoly.Setup();
        CreateNewPlayerPolygon();
        CreateHole();
    }