Exemplo n.º 1
0
    void Awake()
    {
        _canvas             = GetComponentInChildren <Canvas>();
        _energyInitialWidth = EnergyBar.rectTransform.rect.width / _canvas.scaleFactor;

        _undoImage = UndoButton.GetComponentInChildren <UIButtonController>();
    }
Exemplo n.º 2
0
    public void ShowDialogueBox(string[] contents, string title = "")
    {
        if (title != "")
        {
            title = title.ToUpper();
        }

        Player.instance.IsCurrentlyBusy = true;
        gameObject.SetActive(true);

        if (UIBC == null)
        {
            UIBC = NextButton.GetComponent <UIButtonController> ();
        }

        dialogue.Clear();
        foreach (string log in contents)
        {
            if (log.Length > 1024)
            {
                Debug.LogWarning("UIDialogueController::ShowDialogueBox -- One of " + title + "'s contents is more than 1,024 characters");
            }

            dialogue.Enqueue(log);
        }

        // TODO: These need to probably get their data from Localisation, you'd probably give in LocalisationIDs.
        listOfTextElements [0].text = title;

        DisplayNextSentence();
    }
Exemplo n.º 3
0
 public static void AddButton(UIButtonController _button)  //кнопка
 {
     if (_button.type == TypeButton.None)
     {
         return;
     }
     lButton.Add(_button);
 }
Exemplo n.º 4
0
 public bool RemoveButtonController(UIButtonController buttonController)
 {
     if (buttonControllers.Contains(buttonController))
     {
         buttonControllers.Remove(buttonController);
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
    public bool AddButtonController(UIButtonController buttonController)
    {
        if (buttonControllers.Contains(buttonController))
        {
            return(false);
        }

        buttonControllers.Add(buttonController);
        return(true);
    }
Exemplo n.º 6
0
    /* sets the MVC relationships */
    public void createMVC(UIButtonModel m, UIButtonView v, UIButtonController c)
    {
        Model      = m;
        View       = v;
        Controller = c;

        Model.setElement(this);
        View.setElement(this);
        Controller.setElement(this);
    }
Exemplo n.º 7
0
    void Update()
    {
        RaycastHit         hit;
        UIButtonController buttonController = null;

#if UNITY_EDITOR
        for (int i = 0; i < 3; ++i)
        {
            if (Input.GetMouseButtonDown(i))
            {
                if (UICamera.Raycast(Input.mousePosition, out hit))
                {
                    buttonController = hit.collider.GetComponent <UIButtonController>();
                    if (buttonController != null)
                    {
                        buttonController.Press();
                    }
                }
            }
            else if (Input.GetMouseButton(i))
            {
                if (UICamera.Raycast(Input.mousePosition, out hit))
                {
                    buttonController = hit.collider.GetComponent <UIButtonController>();
                    if (buttonController != null)
                    {
                        buttonController.Holding();
                    }
                }
            }
        }
#else
        foreach (Touch touch in Input.touches)
        {
            if (UICamera.Raycast(touch.position, out hit))
            {
                buttonController = hit.collider.GetComponent <UIButtonController>();
                if (buttonController != null)
                {
                    switch (touch.phase)
                    {
                    case TouchPhase.Began:
                        buttonController.Press();
                        break;

                    case TouchPhase.Moved:
                    case TouchPhase.Stationary:
                        buttonController.Holding();
                        break;
                    }
                }
            }
        }
#endif
    }
Exemplo n.º 8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != null)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 9
0
 void Start()
 {
     if (prefabUIObject != null)
     {
         uiObject = Instantiate(prefabUIObject) as UIObject;
         uiObject.transform.parent        = UIRoot2D.Get().game.transform;
         uiObject.transform.localPosition = transform.position;
         uiObject.transform.localRotation = transform.rotation;
         uiObject.transform.localScale    = Vector3.one;
         buttonController = uiObject.GetComponent <UIButtonController>();
     }
     Start_();
 }
Exemplo n.º 10
0
 void OnSubBtnClick(UIButtonController controller)
 {
     if (controller != null)
     {
         var animName = controller.btnName;
         Debug.LogError("按钮点击:" + animName + " " + animationController[animName]);
         if (animationController != null)
         {
             if (!animSet.Contains(animName))
             {
                 animationController[animName] = AssetsHelper.LoadAssetAtPath(string.Format(@"Assets\GameAssets\Models\aisi\Anim\aisi@aisi@{0}.anim", animName), typeof(AnimationClip)) as AnimationClip;
                 Debug.LogError(string.Format("动作为空 {0}", animName));
                 animSet.Add(animName);
             }
             playerAnimator.Play(animName, 0);
         }
     }
 }
Exemplo n.º 11
0
    public override void instantiateElement(Vector3 startPos, Vector3 endPos)
    {
        UIButtonModel newModel = new UIButtonModel();

        // instantiate GameObject
        GameObject newObject = Singletons.Instantiator.instantiateObject(Type);

        // get the View from GameObject
        UIButtonView newView = newObject.transform.GetComponent <UIButtonView>();

        // assign MVC so everyone knows each other
        UIButtonController newController = new UIButtonController();

        this.createMVC(newModel, newView, newController);

        // update Model values - must be done after MVC is created
        newModel.Position = endPos;
        newModel.initModel();
    }
Exemplo n.º 12
0
 void Start()
 {
     this.controller     = this.gameObject.GetComponent <CharacterController>();
     this.spriteRenderer = this.gameObject.GetComponent <SpriteRenderer>();
     this.animator       = this.gameObject.GetComponent <Animator>();
     // Alcune caratteristiche peculiari del secondo giocatore
     if (this.playerNo == 2)
     {
         this.zPos      = -zPos;
         this.direction = Direction.Left;
     }
     this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.zPos);
     // Le dimensioni del personaggio
     this.xSize = this.controller.bounds.extents.x * 2;
     this.ySize = this.controller.bounds.extents.y * 2;
     // Trova le componenti della UI associate ai tasti
     leftMovementBtn  = GameObject.Find("P" + this.playerNo + "LeftBtn").GetComponent <UIButtonController>();
     rightMovementBtn = GameObject.Find("P" + this.playerNo + "RightBtn").GetComponent <UIButtonController>();
     jumpBtn          = GameObject.Find("P" + this.playerNo + "JumpBtn").GetComponent <UIButtonController>();
     // Setta le impostazioni audio
     audioSource = GetComponent <AudioSource>();
 }