Exemplo n.º 1
0
    private void SpawnPlayer(string playerName, int cnnID)
    {
        GameObject go = Instantiate(playerPrefab, transform.position, Quaternion.identity);

        Player p = new Player();

        p.avatar       = go;
        p.playerName   = playerName;
        p.connectionID = cnnID;
        p.avatar.GetComponentInChildren <TextMesh>().text = playerName;

        var position = p.avatar.transform.position;

        p.oldPosition = position;
        p.newPosition = position;
        p.healthbar   = p.avatar.GetComponentInChildren <Slider>();

        if (cnnID == ourClientID)
        {
            // Remove canvas
            GameObject.Find("ConnectCanvas").SetActive(false);
            ChatCanvas.SetActive(true);
            go.AddComponent <PlayerController>();
            Rigidbody rb = go.AddComponent <Rigidbody>();
            rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionY;
            rb.mass        = 500;
            go.AddComponent <CapsuleCollider>();
            p.avatar.GetComponentInChildren <TextMesh>().text = ourPlayerName;
            healthBar = go.GetComponentInChildren <Slider>();
            ownPlayer = p;
            isStarted = true;
        }

        players.Add(p);
    }
Exemplo n.º 2
0
    public void InitSlider()
    {
        if (lifebarTrans != null)
        {
            return;
        }

        ResManager.LoadPrefab("LifeBar".ToLower() + LuaFramework.AppConst.ExtName, "LifeBar", (System.Action <UnityEngine.Object[]>)(objs =>
        {
            GameObject uiroot3d    = GameObject.Find("3DCanvas");
            GameObject lifebarPreb = objs[0] as GameObject;
            lifebar = (GameObject)Instantiate(lifebarPreb);
            if (UnityEngine.Object.Equals((UnityEngine.Object)lifebar, (UnityEngine.Object)null))
            {
                return;
            }
            lifebarTrans = lifebar.transform;
            lifebarTrans.SetParent(uiroot3d.transform);
            lifebarTrans.localScale = new Vector3(0.02f, 0.02f, 0.02f);
            lifebarSlider           = lifebarTrans.GetComponent <UnityEngine.UI.Slider>();
            energybarSlider         = lifebarTrans.Find("energy").GetComponent <UnityEngine.UI.Slider>();
            manabarSlider           = lifebarTrans.Find("mana").GetComponent <UnityEngine.UI.Slider>();
            UpdateLifebar();
        })
                              );
    }
Exemplo n.º 3
0
 void Start()
 {
     if (uiSlider == null)
     {
         uiSlider = transform.GetChild(0).GetComponent <UnityEngine.UI.Slider>();
     }
 }
Exemplo n.º 4
0
    public IEnumerator LoadInTime(string name)
    {
        // GameObject temp = (GameObject) Resources.Load(_transitionPath);

        GameObject TT = Instantiate(TransitionTemplate);

        Slider BAR = TT.GetComponentInChildren <Slider>();

        BAR.value = 0;

        yield return(new WaitForSeconds(2f));

        //yield return new WaitForSeconds(time);
        AsyncOperation loading = SceneManager.LoadSceneAsync(name);



        while (!loading.isDone)
        {
            BAR.value = Mathf.Clamp01(loading.progress / 0.9f);


            yield return(null);
        }


        AsyncOperation Unloading = Resources.UnloadUnusedAssets();

        while (!Unloading.isDone)
        {
            yield return(null);
        }
    }
Exemplo n.º 5
0
 public void setSliderValue(UnityEngine.UI.Slider slider, float value)
 {
     if (value <= slider.maxValue && value >= 0)
     {
         slider.value = value;
     }
 }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        p1       = GameObject.Find("Player1");
        p1Script = p1.GetComponent <FighterScript>();
        p2       = GameObject.Find("Player2");
        p2Script = p2.GetComponent <FighterScript2>();
        game     = true;
        time     = 60;
        foreach (UnityEngine.UI.Slider t in Object.FindObjectsOfType <UnityEngine.UI.Slider>())
        {
            if (t.name.Equals("Player1Health"))
            {
                health1 = (UnityEngine.UI.Slider)t;
            }
            if (t.name.Equals("Player2Health"))
            {
                health2 = (UnityEngine.UI.Slider)t;
            }
        }

        foreach (UnityEngine.UI.Text t in Object.FindObjectsOfType <UnityEngine.UI.Text>())
        {
            if (t.name.Equals("Timer"))
            {
                timer = t;
            }
            if (t.name.Equals("Shout"))
            {
                shout = t;
            }
        }

        shout.text = "Fight!";
        StartCoroutine(waitForTime(3, shout));
    }
Exemplo n.º 7
0
 //statics
 /// <summary>Tweens a Slider's <code>value</code> to the given value.
 public static Tweener DOSlider(this UnityEngine.UI.Slider target, float endValue, float duration)
 {
     return(DOTween.To(() => target.value, delegate(float x)
     {
         target.value = x;
     }, endValue, duration).SetTarget(target));
 }
Exemplo n.º 8
0
    public void DoKillSlider()
    {
        GameObject obj = this.gameObject;

        UnityEngine.UI.Slider sld = GetComponent <UnityEngine.UI.Slider>();
        sld.DOKill();
    }
Exemplo n.º 9
0
    private void LoadAndSetSliderFloat(string key, float value)
    {
        GameObject go = GameObject.Find(key + SliderPostfix); Debug.Assert(go != null);

        UnityEngine.UI.Slider slider = go.GetComponent <Slider>(); Debug.Assert(slider != null);
        slider.value = value;
    }
Exemplo n.º 10
0
 protected void Awake()
 {
     if (this.m_slider == null)
     {
         this.m_slider = this.gameObject.GetComponent <UnityEngine.UI.Slider>();
     }
 }
Exemplo n.º 11
0
 private void Start()
 {
     slider = GetComponent <UnityEngine.UI.Slider>();
     value  = transform.Find("Handle Slide Area/Handle/Value").GetComponent <TextMeshProUGUI>();
     slider.onValueChanged.AddListener(delegate { SetValue(); });
     SetValue();
 }
Exemplo n.º 12
0
 private void Awake()
 {
     if (_sliderInput == null)
     {
         _sliderInput = gameObject.GetComponent <UnityEngine.UI.Slider>();
     }
 }
Exemplo n.º 13
0
        /// <summary>Tweens a Slider's value to the given value.
        /// Also stores the Slider as the tween's target so it can be used for filtered operations</summary>
        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
        /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
        public static TweenerCore <float, float, FloatOptions> DOValue(this Slider target, float endValue, float duration, bool snapping = false)
        {
            TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.value, x => target.value = x, endValue, duration);

            t.SetOptions(snapping).SetTarget(target);
            return(t);
        }
Exemplo n.º 14
0
    void OnUpdateEnemy(object p1, object p2)
    {
        Enemy  e = (Enemy)p1;
        Slider s = _enemyNode.GetRef("HpSlider").GetComponent <Slider>();

        s.value = e.CreatureData.HpPercent;
    }
Exemplo n.º 15
0
    public void createHpUI(int roleSort)
    {
        hpPrefab = (GameObject)Resources.Load(csHpUI);

        uiPosition = transform.position;

        hpObj = Instantiate(hpPrefab, uiPosition, Quaternion.identity, mainCanvas.transform);

        hpUI = hpObj.GetComponent <RectTransform>();

        roleSlider = hpObj.GetComponent <Slider>();

        if (roleSort == 1)
        {
            setHpColor(roleSlider, true);
        }
        else
        {
            setHpColor(roleSlider, false);
        }

        updateHpValue(hp);

        hpObj.SetActive(false);
        isShowUI = false;
    }
Exemplo n.º 16
0
 public void ChangeSpeedText(Slider slider)
 {
     //expensive
     Speed          = Mathf.RoundToInt(slider.value);
     SpeedText.text = Speed.ToString();
     updateExpensiveStats();
 }
Exemplo n.º 17
0
        public override UGUINode DrawLayer(GroupNode layer, UGUINode parent)
        {
            UGUINode node = CreateRootNode(layer.displayName, layer.rect, parent); //GameObject.Instantiate(temp) as UnityEngine.UI.Slider;

            UnityEngine.UI.Slider slider = node.InitComponent <UnityEngine.UI.Slider>();
            SetSliderDirection(slider, layer);
            for (int i = 0; i < layer.images.Count; i++)
            {
                var imgNode = layer.images[i];
                if (MatchAddress(imgNode.Name, rule.backgroundAddress))
                {
                    DrawBackground(imgNode, node);
                }
                else if (MatchAddress(imgNode.Name, rule.fillAddress))
                {
                    DrawFill(imgNode, node);
                }
                else if (MatchAddress(imgNode.Name, rule.handleAddress))
                {
                    DrawHandle(imgNode, node, layer);
                }
                else
                {
                    ctrl.DrawImage(imgNode, node);
                }
            }
            return(node);
        }
Exemplo n.º 18
0
    private void Awake()
    {
        instance = this;
        Program  = codeUIElement.Program;
        codeButton.onClick.AddListener(() => SetState(UIState.Code));
        pauseButton.onClick.AddListener(() => SetState(UIState.Pause));
        resumeButton.onClick.AddListener(() => SetState(UIState.Game));
        closeCodeButton.onClick.AddListener(() => SetState(UIState.Game));
        restartButton.onClick.AddListener(() =>
        {
            Time.timeScale = 1;
            Restart();
        });
        exitButton.onClick.AddListener(() =>
        {
            Time.timeScale = 1;
            ToStageSelection();
        });

        player = FindObjectOfType <PlayerCtrl>();
        aimButton.onClick.AddListener(() => AimingButton.inst.CheckExprSlots());
        grimoireImage      = grimoire.GetComponent <Image>();
        transparencySlider = FindObjectOfType <Slider>();
        if (transparencySlider != null)
        {
            transparencySlider.onValueChanged.AddListener(ChangeCodeWindowTransparncy);
        }
    }
Exemplo n.º 19
0
        public void ChangeHealthText(Slider slider)
        {
            //expensive

            health          = Mathf.RoundToInt(slider.value);
            HealthText.text = health.ToString();
            updateExpensiveStats();
        }
Exemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        GameObject canvas = FindObjectOfType <Canvas>().gameObject;

        drawBar = Instantiate(drawBPrefab).GetComponent <Slider>();

        drawBar.transform.SetParent(canvas.transform);
    }
Exemplo n.º 21
0
 private void AssignColorsToSelection(GameObject gameObject, ColorSet colorSet)
 {
     recursiveLevel++;
     if (gameObject.GetComponent <UnityEngine.UI.Button>())
     {
         UnityEngine.UI.Button button = gameObject.GetComponent <UnityEngine.UI.Button>();
         SetColorBlock(button, colorSet);
         SetDetailColor(gameObject, colorSet);
     }
     else if (gameObject.GetComponent <UnityEngine.UI.InputField>())
     {
         UnityEngine.UI.InputField input = gameObject.GetComponent <UnityEngine.UI.InputField>();
         SetColorBlock(input, colorSet);
         input.selectionColor      = colorSet.highlighted;
         input.textComponent.color = colorSet.pressed;
         input.placeholder.color   = colorSet.highlighted;
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Scrollbar>())
     {
         UnityEngine.UI.Scrollbar sb = gameObject.GetComponent <UnityEngine.UI.Scrollbar>();
         SetColorBlock(sb, colorSet);
         gameObject.GetComponent <UnityEngine.UI.Image>().color = colorSet.disabled;
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Slider>())
     {
         UnityEngine.UI.Slider slider = gameObject.GetComponent <UnityEngine.UI.Slider>();
         SetColorBlock(slider, colorSet);
         slider.fillRect.gameObject.GetComponent <UnityEngine.UI.Image>().color = colorSet.normal;
         SetTextColorRecursive(gameObject, colorSet);
     }
     else if (gameObject.GetComponent <UnityEngine.UI.Toggle>())
     {
         UnityEngine.UI.Toggle toggle = gameObject.GetComponent <UnityEngine.UI.Toggle>();
         SetColorBlock(toggle, colorSet);
         toggle.graphic.color = colorSet.normal;
         SetTextColorRecursive(gameObject, colorSet);
     }
     else if (gameObject.transform.childCount > 0) // Recursive search for components
     {
         for (int i = 0; i < gameObject.transform.childCount; i++)
         {
             AssignColorsToSelection(gameObject.transform.GetChild(i).gameObject, colorSet);
         }
     }
     else if (recursiveLevel == 1)
     {
         if (gameObject.GetComponent <UnityEngine.UI.Image>())
         {
             UnityEngine.UI.Image image = gameObject.GetComponent <UnityEngine.UI.Image>();
             image.color = colorSet.normal;
         }
         else if (gameObject.GetComponent <UnityEngine.UI.Text>())
         {
             UnityEngine.UI.Text text = gameObject.GetComponent <UnityEngine.UI.Text>();
             text.color = colorSet.normal;
         }
     }
 }
Exemplo n.º 22
0
 private void Awake()
 {
     selfcoll       = GetComponent <Collider>();
     CacaPorcentage = CrearMapa.slider;// Referencia al slider
     anim           = GetComponent <Animator>();
     navAgent       = GetComponent <NavMeshAgent>();
     rango          = GetComponent <SphereCollider>();
     rango.radius   = radioDeteccion;
 }
Exemplo n.º 23
0
 public void OnReplaySpeedChange()
 {
     if (_replaySpeedSlider == null)
     {
         _replaySpeedSlider = ReplaySpeedSlider.GetComponent <UnityEngine.UI.Slider>();
     }
     ReplaySpeed = (int)Mathf.Floor(_replaySpeedSlider.value * 100);
     Debug.Log(ReplaySpeed);
 }
Exemplo n.º 24
0
 public void SetMusicVolume(float volume)
 {
     audioMixer.SetFloat("musicVolume", volume);
     musicSlider = GameObject.Find("MusicVolumeSlider").GetComponent <Slider>();
     if (musicSlider.value == -30)
     {
         audioMixer.SetFloat("musicVolume", -80);
     }
 }
Exemplo n.º 25
0
 public void SetSoundEffectsVolume(float volume)
 {
     audioMixer.SetFloat("soundEffectsVolume", volume);
     soundEffectSlider = GameObject.Find("SoundEffectsVolumeSlider").GetComponent <Slider>();
     if (soundEffectSlider.value == -30)
     {
         audioMixer.SetFloat("soundEffectsVolume", -80);
     }
 }
Exemplo n.º 26
0
    //bool reload;


    void Start()
    {
        coll           = GetComponent <BoxCollider>();
        trig           = GetComponent <SphereCollider>();
        anim           = GetComponent <Animator>();
        CacaPorcentage = CrearMapa.slider;// Referencia al slider
        particles      = GameObject.FindWithTag("Gusano_CFX");
        particles.SetActive(false);
    }
Exemplo n.º 27
0
 public void rotationSliderValueChanged(UnityEngine.UI.Slider slider)
 {
     if (!(saveMenu.active || backgroundsCanvas.active || imagesCanvas.active))
     {
         if (currentPcture != null)
         {
             currentPcture.setRotation(slider.value);
         }
     }
 }
Exemplo n.º 28
0
    private void Start()
    {
        float music = PlayerPrefs.GetFloat("volume", -10);

        Slider musicSlider = GameObject.Find("MusiqueSlider").GetComponent <Slider>();

        musicSlider.SetValueWithoutNotify(music);

        AdjustMusicVolume(music);
    }
Exemplo n.º 29
0
 void OnDestroy()
 {
     m_produceEnergebar               = null;
     m_Text_ProduceEnergebar          = null;
     m_Image_minimapBG                = null;
     m_minimapUnitPrefab              = null;
     m_StringBuilder_ProduceEnergebar = null;
     m_minimapMgr.Dispose();
     m_minimapMgr = null;
 }
Exemplo n.º 30
0
        protected override void GameSetup()
        {
            DialogInstance = GetComponent <DialogInstance>();

            Assert.IsNotNull(DialogInstance.DialogGameObject, "Ensure that you have set the script execution order of dialog instance in settings (see help for details.");

            _musicVolume = GameObjectHelper.GetChildComponentOnNamedGameObject <UnityEngine.UI.Slider>(DialogInstance.DialogGameObject, "MusicSlider", true);
            _sfxVolume   = GameObjectHelper.GetChildComponentOnNamedGameObject <UnityEngine.UI.Slider>(DialogInstance.DialogGameObject, "SfxSlider", true);
            _language    = GameObjectHelper.GetChildComponentOnNamedGameObject <UnityEngine.UI.Dropdown>(DialogInstance.DialogGameObject, "LanguageDropdown", true);
        }
        public override void OnEnter()
        {
            GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (_go!=null)
            {
                _slider = _go.GetComponent<uUI.Slider>();
            }

            DoSetValue();

            if (!everyFrame)
                Finish();
        }
Exemplo n.º 32
0
 void OnDestroy()
 {
     m_produceEnergebar 					= null;
     m_Text_ProduceEnergebar 			= null;
     m_Image_minimapBG 					= null;
     m_minimapUnitPrefab 				= null;
     m_StringBuilder_ProduceEnergebar 	= null;
     m_minimapMgr.Dispose ();
     m_minimapMgr = null;
 }