コード例 #1
0
    // Use this for initialization
    void Start()
    {
        m = GameObject.Find("GameLogic").GetComponent<Maximize>();
        ctrl  = this.GetComponent<Controller>();
        inner_crosshair = GameObject.Find("Crosshair"+ctrl.ctrlControlIndex).transform.Find("Inner").gameObject;
        outer_crosshair = GameObject.Find("Crosshair"+ctrl.ctrlControlIndex).transform.Find("Outer").gameObject;

        c = ctrl.ctrlAttachedCamera;
        cam_width = Screen.width / 2;
        cam_height = Screen.height / 2;

        // set the middle of the crosshair
        switch(ctrl.ctrlControlIndex){
            case 0: // player 1
                mx = cam_width/2;
                my = Screen.height - cam_height/2;
                break;
            case 1: // player 2
                mx = Screen.width - cam_width / 2;
                my = Screen.height - cam_height / 2;
                break;
            case 2: // player 3
                mx = cam_width / 2;
                my = cam_height / 2;
                break;
            case 3: // player 4
                mx = Screen.width - cam_width / 2;
                my = cam_height / 2;
                break;
        }
        // values for maximized
        fx = Screen.width / 2;
        fy = Screen.height / 2;
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        m = GameObject.Find("GameLogic").GetComponent<Maximize>();
        ctrl = this.GetComponent<Controller>();

        full = Resources.Load<Sprite>("Sprites/shot_icon");
        empty = Resources.Load<Sprite>("Sprites/shotempty_icon");
        // get the shots for each of the elements
        shotA = GameObject.Find("Shot" + ctrl.ctrlControlIndex).transform.Find("ShotA").gameObject;
        shotB = GameObject.Find("Shot" + ctrl.ctrlControlIndex).transform.Find("ShotB").gameObject;
        shotC = GameObject.Find("Shot" + ctrl.ctrlControlIndex).transform.Find("ShotC").gameObject;
        shotD = GameObject.Find("Shot" + ctrl.ctrlControlIndex).transform.Find("ShotD").gameObject;
        // set size
        shotA.GetComponent<RectTransform>().sizeDelta = new Vector2(17,33);
        shotB.GetComponent<RectTransform>().sizeDelta = new Vector2(17,33);
        shotC.GetComponent<RectTransform>().sizeDelta = new Vector2(17,33);
        shotD.GetComponent<RectTransform>().sizeDelta = new Vector2(17,33);
        // make the sprites visible
        shotA.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        shotB.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        shotC.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        shotD.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        // set inital sprites
        shotA.GetComponent<Image>().sprite = full;
        shotB.GetComponent<Image>().sprite = full;
        shotC.GetComponent<Image>().sprite = full;
        shotD.GetComponent<Image>().sprite = full;

        shots_left = 4;
        float cam_width = Screen.width / 2;
        float cam_height = Screen.height / 2;
        switch (ctrl.ctrlControlIndex) {
            case 0: // player 1
                split_anchor = new Vector2(cam_width-105, Screen.height - cam_height * 0.95f);
                fullscr_anchor = new Vector2(Screen.width-205, cam_height - cam_height * 0.92f);
                break;
            case 1: // player 2
                split_anchor = new Vector2(Screen.width - 105, Screen.height - cam_height * 0.95f);

                break;
            case 2: // player 3
                split_anchor = new Vector2(cam_width - 105, cam_height - cam_height * 0.95f);

                break;
            case 3: // player 4
                split_anchor = new Vector2(Screen.width - 105, cam_height - cam_height * 0.95f);

                break;
        }
    }
コード例 #3
0
ファイル: T4GUI.cs プロジェクト: doctordebug/GameDesign2015
 void Start()
 {
     g = GameObject.Find("GameLogic");
     if (g != null) {
         m = g.GetComponent<Maximize>();
     }
 }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        speed = 100;
        m = GameObject.Find("GameLogic").GetComponent<Maximize>();
        ctrl = this.GetComponent<Controller>();

        // load sprites
        sprites = Resources.LoadAll<Sprite>("Sprites/MiddleNumbers");

        // first number A config
        hbar_numA = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("NumA").gameObject;
        hbar_numA.GetComponent<RectTransform>().sizeDelta = new Vector2(25, 25);
        hbar_numA.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        hbar_numA.GetComponent<Image>().sprite = sprites[0];

        // second number B config
        hbar_numB = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("NumB").gameObject;
        hbar_numB.GetComponent<RectTransform>().sizeDelta = new Vector2(25, 25);
        hbar_numB.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        hbar_numB.GetComponent<Image>().sprite = sprites[1];

        // third number C config
        hbar_numC = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("NumC").gameObject;
        hbar_numC.GetComponent<RectTransform>().sizeDelta = new Vector2(25, 25);
        hbar_numC.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        hbar_numC.GetComponent<Image>().sprite = sprites[2];

        // bar bg
        empty = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("Empty").gameObject;
        empty.GetComponent<RectTransform>().sizeDelta = new Vector2(200, 25);
        empty.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        empty.GetComponent<Image>().sprite = Resources.Load<Sprite>("Sprites/bar_empty");

        // get the bar
        bar = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("Bar").gameObject;
        bar.GetComponent<RectTransform>().sizeDelta = new Vector2(200, 25);
        bar.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        spbar = new Sprite[76];
        bar_width_info = new int[76];
        spbar[75] = Resources.Load<Sprite>("Sprites/spbar_full");
        for (int i = 0; i < 75; i++) {
            spbar[i] = cropSprite(spbar[75], 0, 0, i * 5 + 5, 50);
            bar_width_info[i] = i * 5 + 5;
        }

        // speedbar icon
        icon = GameObject.Find("Speedbar" + ctrl.ctrlControlIndex).transform.Find("Icon").gameObject;
        icon.GetComponent<RectTransform>().sizeDelta = new Vector2(32, 32);
        icon.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
        icon.GetComponent<Image>().sprite = Resources.Load<Sprite>("Sprites/spbar_icon");

        float cam_width = Screen.width / 2;
        float cam_height = Screen.height / 2;
        // set the fullscrn_anchor & splitscreenanchor for each player
        switch (ctrl.ctrlControlIndex) {
            case 0: // player 1
                // 20% from left and 90% from top of camera
                // 210 since the texture is 200px width and 25 height
                split_anchor = new Vector2(cam_width-105, Screen.height - cam_height * 0.95f);
                fullscr_anchor = new Vector2(Screen.width-205, cam_height - cam_height * 0.92f);
                break;
            case 1: // player 2
                split_anchor = new Vector2(Screen.width - 105, Screen.height - cam_height * 0.95f);

                break;
            case 2: // player 3
                split_anchor = new Vector2(cam_width-105, cam_height - cam_height * 0.95f);

                break;
            case 3: // player 4
                split_anchor = new Vector2(Screen.width - 105, cam_height - cam_height * 0.95f);

                break;
        }
    }
コード例 #5
0
ファイル: T4Logic.cs プロジェクト: doctordebug/GameDesign2015
    // Use this for initialization
    void Start()
    {
        // add render settings
        RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
        RenderSettings.ambientLight = new Color(255, 255, 152, 255); // rgb 0-255 NOT 0-1
        RenderSettings.ambientIntensity = 0.0028f;
        // set level settings
        //Level.drag = 0.3f;
        Level.drag = 1;
        Level.angularDrag = 0.4f;
        Level.InitializationDone();

        // set gui at start pos
        GameObject.Find("Crosshair0").transform.Find("Inner").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair0").transform.Find("Outer").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair1").transform.Find("Inner").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair1").transform.Find("Outer").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair2").transform.Find("Inner").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair2").transform.Find("Outer").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair3").transform.Find("Inner").gameObject.transform.position = new Vector3(-200, -200, 0);
        GameObject.Find("Crosshair3").transform.Find("Outer").gameObject.transform.position = new Vector3(-200, -200, 0);

        // deactivate the countdown
        countdown = GameObject.Find("Countdown").gameObject;
        countdown.active = false;

        // deactivate the gui
        gui = GameObject.Find("GUI").gameObject;
        gui.active = false;
        m = GameObject.Find("GameLogic").GetComponent<Maximize>();
        lastMState = m.maximized;
    }