private void AddButton_Click(object sender, EventArgs e)
        {
            string name        = NameBox.Text;
            string description = DescriptionBox.Text;
            string profession;
            int    lvl;

            int.TryParse(LevelBox.Text, out lvl);

            if (ClassCombo.SelectedItem == null)
            {
                profession = "Warrior";
            }
            else
            {
                profession = ClassCombo.SelectedItem.ToString();
            }

            Character New_Character = new Character(name, lvl, description, profession);

            CharactersList.Add(New_Character);
            ComboBind.ResetBindings(false);

            NameBox.Clear();
            LevelBox.Clear();
            DescriptionBox.Clear();
            ClassCombo.ResetText();
        }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            CharactersList.RemoveAt(CharactersCombo.SelectedIndex);
            ComboBind.ResetBindings(false);

            NameBox.Clear();
            LevelBox.Clear();
            DescriptionBox.Clear();
            ClassCombo.ResetText();
        }
예제 #3
0
    void SelectedLevel(LevelBox level_box, Vector3 hitpoint)
    {
        gameObject.SetActive(false);
        foreach (var ctrl in Baroque.GetControllers())
        {
            ctrl.SetControllerHints(/*nothing*/);
        }

        foreach (var mines1 in FindObjectsOfType <Mines>())
        {
            mines1.Unpopulate();
        }

        var mines = level_box.correspondingMines;

        for (int z = 0; z < mines.nz; z++)
        {
            for (int y = 0; y < mines.ny; y++)
            {
                for (int x = 0; x < mines.nx; x++)
                {
                    var sgt = Instantiate(sgtPrefab);
                    sgt.mines     = mines;
                    sgt.targetInt = new Vector3Int(x, y, z);

                    sgt.GetComponent <MeshRenderer>().sharedMaterial = level_box.correspondingMines.defaultMat;

                    sgt.transform.localScale    = level_box.particleSys.main.startSize.constant * Vector3.one;
                    sgt.transform.localPosition = hitpoint + Random.insideUnitSphere * 0.5f;
                }
            }
        }

        foreach (var laser in lasers)
        {
            if (laser != null && laser.tr != null)
            {
                Destroy(laser.tr.gameObject);
            }
        }
        lasers = null;
    }
예제 #4
0
        private void BindingInit()
        {
            Binding binduname = new Binding()
            {
                Source = Account.Instance,
                Path   = new PropertyPath("UName"),
                Mode   = BindingMode.OneWay
            };

            TBk_UserName.SetBinding(TextBlock.TextProperty, binduname);

            Binding bindface = new Binding()
            {
                Source = Account.Instance,
                Path   = new PropertyPath("Pic"),
                Mode   = BindingMode.OneWay
            };

            Img_Face.SetBinding(Image.SourceProperty, bindface);

            Binding binddesc = new Binding()
            {
                Source = Account.Instance,
                Path   = new PropertyPath("Desc"),
                Mode   = BindingMode.OneWay
            };

            TB_Desc.SetBinding(TextBox.TextProperty, binddesc);

            Binding bindlevel = new Binding()
            {
                Source             = Account.Instance,
                Path               = new PropertyPath("Level"),
                Mode               = BindingMode.OneWay,
                Converter          = new WidthNHeightValue_Times_Converter(),
                ConverterParameter = -36.5
            };

            Img_level.SetBinding(Canvas.TopProperty, bindlevel);

            Binding bindlevelprocess = new Binding()
            {
                Source             = Account.Instance,
                Path               = new PropertyPath("ExpProgress"),
                Mode               = BindingMode.OneWay,
                Converter          = new WidthNHeightValue_Times_Converter(),
                ConverterParameter = 398
            };

            Bar_level_top.SetBinding(WidthProperty, bindlevelprocess);

            Binding bindlevelprocessstr = new Binding()
            {
                Source = Account.Instance,
                Path   = new PropertyPath("str_ExpProgress"),
                Mode   = BindingMode.OneWay,
            };

            LevelBox.SetBinding(ToolTipProperty, bindlevelprocessstr);

            Binding bindlevelpercentage = new Binding()
            {
                Source    = Account.Instance,
                Path      = new PropertyPath("ExpProgress"),
                Mode      = BindingMode.OneWay,
                Converter = new Percentage_Converter()
            };

            Lbl_Level.SetBinding(TextBlock.TextProperty, bindlevelpercentage);
        }
예제 #5
0
    private void Gt_onControllersUpdate(Controller[] controllers)
    {
        foreach (var level_box in GetComponentsInChildren <LevelBox>())
        {
            level_box.SetHighlight(0);
        }

        foreach (var ctrl in Baroque.GetControllers())    /* includes inactive ones */
        {
            var laser = ctrl.GetAdditionalData(ref lasers);

            if (!ctrl.isActiveAndEnabled)
            {
                if (laser.tr != null)
                {
                    Destroy(laser.tr.gameObject);
                    laser.tr = null;
                }
            }
            else
            {
                if (laser.tr == null)
                {
                    laser.tr = Instantiate(laserPrefab);
                    laser.q  = ctrl.rotation;
                    successParticleSys.trigger.SetCollider(ctrl.index, laser.tr.GetComponentInChildren <Collider>());
                }
                laser.q = Quaternion.Lerp(ctrl.rotation, laser.q, Mathf.Exp(-Time.deltaTime * 50));

                laser.tr.position = ctrl.position;
                laser.tr.rotation = laser.q;

                RaycastHit hitinfo;
                LevelBox   level_box = null;
                float      distance  = 5f;
                if (Physics.SphereCast(laser.tr.position, 0.01f, laser.tr.forward, out hitinfo, 10f,
                                       1 << LevelBox.LAYER, QueryTriggerInteraction.Ignore))
                {
                    level_box = hitinfo.collider.GetComponentInParent <LevelBox>();
                    distance  = Vector3.Distance(ctrl.position, hitinfo.point);
                }
                var     tr0 = laser.tr.GetChild(0);
                Vector3 p   = tr0.localScale;
                p.y            = distance * 0.5f;
                tr0.localScale = p;
                p   = tr0.localPosition;
                p.z = distance * 0.5f + 0.07f;
                tr0.localPosition = p;

                Color c = level_box == null ? new Color(0.3f, 0.3f, 0.3f) :
                          ctrl.triggerPressed ? new Color(1f, 1f, 1f) : level_box.laserColor;
                laser.tr.GetComponentInChildren <Renderer>().material.color = c;

                if (level_box != null)
                {
                    level_box.SetHighlight((ctrl.triggerPressed | laser.trigger_pressed) ? 2 : 1);

                    if (laser.trigger_pressed && !ctrl.triggerPressed)
                    {
                        SelectedLevel(level_box, hitinfo.point);
                        ctrl.HapticPulse();
                        break;
                    }

                    float cur_time  = Time.time;
                    float prev_time = cur_time - Time.deltaTime;

                    int n1 = (int)(prev_time * particlesPerSecond);
                    int n2 = (int)(cur_time * particlesPerSecond);

                    if (n2 > n1)
                    {
                        ParticleSystem.EmitParams emit_params = new ParticleSystem.EmitParams
                        {
                            position             = hitinfo.point,
                            applyShapeToPosition = true,
                            startColor           = level_box.laserColor,
                        };
                        level_box.particleSys.Emit(emit_params, n2 - n1);
                    }
                    if (laser.level_box != level_box)
                    {
                        ctrl.HapticPulse();
                    }
                }
                laser.level_box       = level_box;
                laser.trigger_pressed = ctrl.triggerPressed;

                ctrl.SetControllerHints(trigger: "choose level");
            }
        }
    }