Пример #1
0
    void Start()
    {
        // bottom, left quadrant of screen
        leftJoystick          = UIJoystick.create("joystickUp.png", new Rect(0, Screen.height / 2, Screen.width / 2, 200), Screen.width / 4, -150 / 2);
        leftJoystick.deadZone = new Vector2(0.6f, 0.6f);
        leftJoystick.setJoystickHighlightedFilename("joystickDown.png");


        // bottom, right quadrant of screen
        rightJoystick          = UIJoystick.create("joystickUp.png", new Rect(Screen.width / 2, Screen.height / 2, Screen.width / 2, 200), Screen.width / 4, -150 / 2);
        rightJoystick.deadZone = new Vector2(0.5f, 0.5f);
        rightJoystick.setJoystickHighlightedFilename("joystickDown.png");
        rightJoystick.addBackgroundSprite("joystickTrack.png");
    }
Пример #2
0
 void Start()
 {
     joystick = UIJoystick.create("button_control.png", joystickTouchFrame, 120, -280);
     joystick.position = new Vector3(joystick.position.x, joystick.position.y, 10);
     joystick.maxJoystickMovement = 60;
  
     int x, y;
  
     x = Screen.width - 180;
     y = Screen.height - 180;
     missileButton = UIContinuousButton.create("button_missile.png", "button_missile.png", x, y);
     missileButton.normalTouchOffsets = new UIEdgeOffsets(20, 20, 5, 20);
     missileButton.highlightedTouchOffsets = new UIEdgeOffsets(20, 20, 5, 20);
     missileButton.onTouchIsDown += MissileButtonIsDown;
 }
Пример #3
0
    void Start()
    {
        text        = new UIText(textToolkit, "GhoulishFont", "GhoulishFont_0.png");
        startScript = FindObjectOfType(typeof(StartScript)) as StartScript;
        loader      = FindObjectOfType(typeof(loadingScript)) as loadingScript;
        character   = FindObjectOfType(typeof(CharacterMaster)) as CharacterMaster;
        //DontDestroyOnLoad(this.gameObject);



        AmmoText     = text.addTextInstance("Bullets: " + startScript.Ammunition.ToString(), 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount = text.addTextInstance("+20", 0, 0, textScaleFactor * 5, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        PickupAmount.hidden = true;

        LevelInstruc = text.addTextInstance("" + LvlInstructions, 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
        LevelInstruc.positionCenter();
        LevelInstruc.alphaTo(0.01f, 0, Easing.Quartic.easeIn);

        StartCoroutine(StartLvlInstruction());
        // buttons ------------------------------------


        PauseBtn = UIButton.create(buttonUI, "PauseBtn.png", "PauseBtn.png", 0, 0, 10);
        PauseBtn.positionFromTopLeft(0.035f, 0.045f);
        PauseBtn.onTouchUpInside += onTouchPauseBtn;
        PauseBtn.touchDownSound   = buttonSound;
        PauseBtn.hidden           = false;

        PlayBtn = UIButton.create(buttonUI, "PlayBtn.png", "PlayBtn.png", 0, 0, 10);
        PlayBtn.positionFromCenter(0.2f, -0.21f);
        PlayBtn.onTouchUpInside += onTouchPlayBtn;
        PlayBtn.touchDownSound   = buttonSound;
        PlayBtn.hidden           = true;

        RetryBtn = UIButton.create(buttonUI, "RetryBtn.png", "RetryBtn.png", 0, 0, 10);
        RetryBtn.positionFromCenter(0.2f, -0.07f);
        RetryBtn.onTouchUpInside += onTouchRetryBtn;
        RetryBtn.touchDownSound   = buttonSound;
        RetryBtn.hidden           = true;

        QuitBtn = UIButton.create(buttonUI, "QuitBtn.png", "QuitBtn.png", 0, 0, 10);
        QuitBtn.positionFromCenter(0.2f, 0.07f);
        QuitBtn.onTouchUpInside += onTouchQuitBtn;
        QuitBtn.touchDownSound   = buttonSound;
        QuitBtn.hidden           = true;

        //------TOGGLE BTNS-------------------------------


        AudioBtn = UIToggleButton.create(buttonUI, "AudioOffBtn.png", "AudioBtn.png", "AudioOffBtn.png", 0, 0, 10);
        AudioBtn.positionFromCenter(0.2f, 0.21f);
        AudioBtn.onToggle += onTouchAudioBtn;
        AudioBtn.hidden    = true;
        if (PlayerPrefs.GetInt("volume") == 1)
        {
            AudioBtn.selected = true;
        }

        //-------------------HEALTH METER--------------------------------------


        HealthBG = buttonUI.addSprite("HealthBG.png", 0, 0, 10);
        HealthBG.positionFromCenter(-0.41f, 0.0f);


        HealthBar = UIProgressBar.create(buttonUI, "HealthBar.png", 0, 0, false, 5, false);
        Vector2 tempVec;

        tempVec            = new Vector2(HealthBG.position.x + 95, HealthBG.position.y - 10);
        HealthBar.position = tempVec;

        HealthBar.value = 1;


        //----------------------PICKUPS-------------------------



        HealthPickup = buttonUI.addSprite("HeartPickup.png", 0, 0, 10);
        HealthPickup.positionFromCenter(-0.0f, 0.0f);
        HealthPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        HealthPickup.hidden = true;

        AmmoPickup = buttonUI.addSprite("AmmoPickup.png", 0, 0, 10);
        AmmoPickup.positionFromCenter(-0.0f, 0.0f);
        AmmoPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        AmmoPickup.hidden = true;


        //-----------------------------CONTROLS------------------------------------------


        LToggle          = UIJoystick.create(buttonUI, "LToggle.png", new Rect(Screen.width * 0.01f, Screen.height * 0.45f, Screen.width * 0.4f, Screen.height * 0.6f), Screen.width * 0.175f, Screen.height * -0.3f);
        LToggle.deadZone = new Vector2(0.8f, 0.8f);
        //LToggle.setJoystickHighlightedFilename( "LToggleT.png" );
        AttackBtn = UIContinuousButton.create("AttackBtn.png", "AttackBtn.png", 0, 0);
        AttackBtn.positionFromBottomRight(0.05f, 0.05f);
        AttackBtn.centerize();         // centerize the button so we can scale it from the center
        AttackBtn.highlightedTouchOffsets = new UIEdgeOffsets(30);
        AttackBtn.onTouchIsDown          += onTouchAttackBtn;
        AttackBtn.onTouchUpInside        += onTouchAttackBtnUp;



        if (loader != null)
        {
            if (loader.ControllerCount > 0)
            {
                LToggle.hidden   = true;
                AttackBtn.hidden = true;
            }
        }
    }