Пример #1
0
 public void ParseMap(string fileName)
 {
     var node = GameBox.ParseNode(Path.Combine("Files", fileName));
 }
Пример #2
0
        public override void UpdateUI()
        {
            Controls.Clear();
            int maxRenderableColumns = (Width - 20) / 180;
            int maxRenderableRows    = Height / 160;
            int rowsCount            = 0;
            int columnsCount         = 0;

            if (_games == null || _games.Count <= 0)
            {
                return;
            }
            int currentLeft = 0;

            foreach (Game game in _games)
            {
                GameBox gameBox = new GameBox(_settings.BoxRendered);
                gameBox.BoxSelected     += new GameBox.BoxSelectedDelegate(Box_BoxSelected);
                gameBox.BoxDoubleClick  += new GameBox.BoxDoubleClickDelegate(Box_BoxDoubleClick);
                gameBox.ContextMenuStrip = CreateGameContextMenu(game.ID);
                gameBox.GameName         = game.Title;

                if (File.Exists(game.ImagePath))
                {
                    gameBox.GameImage = Image.FromFile(game.ImagePath);
                }
                else
                {
                    gameBox.GameImage = null;
                }

                gameBox.GameID = game.ID;
                gameBox.Top    = rowsCount * 160 + (rowsCount == 0 ? 0 : 5);
                gameBox.Left   = currentLeft;
                currentLeft   += gameBox.Width;
                this.Controls.Add(gameBox);
                ++columnsCount;
                if (columnsCount >= maxRenderableColumns)
                {
                    columnsCount = 0;
                    ++rowsCount;
                    currentLeft = 0;
                }
            }
            if (rowsCount + 1 > maxRenderableRows)
            {
                scroller             = new ScrollBarEx();
                scroller.Orientation = ScrollBarOrientation.Vertical;
                scroller.BorderColor = Color.FromArgb(64, 64, 64);
                scroller.Dock        = DockStyle.Right;
                scroller.Visible     = true;
                scroller.Maximum     = (rowsCount + 1) * 160;
                scroller.Scroll     += scroller_Scroll;
                this.MouseWheel     += CategoryGames_MouseWheel;
                this.Controls.Add(scroller);
            }
            else if (scroller != null)
            {
                scroller.Scroll -= scroller_Scroll;
                scroller.Dispose();
                scroller = null;
            }
            this.Focus();
        }
Пример #3
0
 /// <summary>
 /// Body with uncompressed data with compression parameters.
 /// </summary>
 /// <param name="gbx">Owner of the GBX body.</param>
 public GameBoxBody(GameBox <T> gbx) : base(gbx)
 {
 }
Пример #4
0
        // Обработчик нажатия кнопки добавления Устройств
        protected void AddDeviceButtonClick(object sender, EventArgs e)
        {
            int count = 0;
            var res   =
                from t in devicesDictionary
                where t.Value.name == DeviceName.Text
                select t.Value;

            foreach (var source in res)
            {
                count++;
            }
            if (count == 0)
            {
                Device newDevice;
                switch (dropDownDevicesList.SelectedIndex)
                {
                default:
                    newDevice = new Fringe(DeviceName.Text, -20, 5);
                    Device lamp = new Device("FringeLamp");
                    ((Fringe)newDevice).Lamp = lamp;
                    break;

                case 1:
                    newDevice = new TVSet(DeviceName.Text, 0, 100);
                    break;

                case 2:
                    newDevice = new MicroWave(DeviceName.Text, 50, 250);
                    ((MicroWave)newDevice).highTemperature(100);
                    break;

                case 3:
                    newDevice = new Oven(DeviceName.Text, 50, 300);
                    ((Oven)newDevice).highTemperature(100);
                    break;

                case 4:
                    newDevice = new Satellite(DeviceName.Text);
                    foreach (Control parent in DevicePanel.Controls)
                    {
                        foreach (Control chield in parent.Controls)
                        {
                            if (chield is DropDownList && chield.ID == "source")
                            {
                                ((DropDownList)chield).Items.Add(DeviceName.Text);
                            }
                        }
                    }
                    break;

                case 5:
                    newDevice = new GameBox(DeviceName.Text);
                    foreach (Control parent in DevicePanel.Controls)
                    {
                        foreach (Control chield in parent.Controls)
                        {
                            if (chield is DropDownList && chield.ID == "source")
                            {
                                ((DropDownList)chield).Items.Add(DeviceName.Text);
                            }
                        }
                    }
                    break;
                }

                int id = (int)Session["NextId"];
                devicesDictionary.Add(id, newDevice);
                ErrText.Text = "";
                DevicePanel.Controls.Add(new DeviceControl(id, devicesDictionary));
                id++;
                Session["NextId"] = id;
            }
            else
            {
                ErrText.Text = "Устройство с такими именем уже сущесвует";
            }
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (isMainRole == false)
        {
            return;
        }
        isMoving = false;

        // Horizontal Motion

        if (GameManager.Instance.roleType == GameManager.RoleType.launch)
        {
            if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.LeftArrow))
            {
                if (Input.GetKey(KeyCode.RightArrow))
                {
                    angle -= 1f;
                }

                if (Input.GetKey(KeyCode.LeftArrow))
                {
                    angle += 1f;
                }

                if (angle > 180)
                {
                    angle = angle - 360;
                }

                if (angle < -180)
                {
                    angle = 360 + angle;
                }
                //Vector3 targetDir = launchDir ;
                //float angle = Vector3.Angle( targetDir, transform.forward );
                GameManager.Instance.arrow.transform.rotation = Quaternion.Euler(0f, 0f, angle);
            }
        }

        if (GameManager.Instance.roleType == GameManager.RoleType.move)
        {
            if (Input.GetKey(KeyCode.RightArrow))
            {
                isMoving = true;
                this.transform.Translate(Vector3.right * motionSpeed);
                this.GetComponent <SpriteRenderer>().flipX = true;
            }

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                isMoving = true;
                this.transform.Translate(Vector3.left * motionSpeed);
                this.GetComponent <SpriteRenderer>().flipX = false;
            }

            this.GetComponent <Animator>().SetBool("MarioIsMoving", isMoving);
            // Jump
            if (Input.GetKeyDown(KeyCode.Space))
            {
                this.GetComponent <Rigidbody2D>().AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
                this.GetComponent <Animator>().SetBool("MarioIsOnFloor", false);
            }
        }



        if (GameManager.Instance.roleType == GameManager.RoleType.launch)
        {
            // 抛掷
            if (Input.GetKeyUp(KeyCode.A))
            {
                if (isBoxMoving == false)
                {
                    curBox = Instantiate(box) as GameObject;
                    curBox.transform.localPosition =
                        new Vector3(transform.position.x, transform.position.y, transform.position.y);
                    curBox.GetComponent <Rigidbody2D>().AddForce(new Vector2((float)Math.Sin(angle), (float)Math.Cos(angle)) * 7, ForceMode2D.Impulse);
                    var boxPos = new GameBox();
                    boxPos.id = GameManager.Instance.boxs.Count;
                    boxPos.x  = curBox.transform.position.x;
                    boxPos.y  = curBox.transform.position.y;
                    GameManager.Instance.boxs.Add(boxPos);
                    GameManager.Instance.boxsDic.Add(boxPos.id, curBox);
                    isBoxMoving = true;
                }
                else if (isBoxMoving == true)
                {
                    curBox.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static;
                    isBoxMoving = false;
                }
            }

            if (GameManager.Instance.boxs != null)
            {
                for (int i = 0; i < GameManager.Instance.boxs.Count; i++)
                {
                    var        curBox = GameManager.Instance.boxs[i];
                    GameObject curBoxObj;
                    if (GameManager.Instance.boxsDic.TryGetValue(curBox.id, out curBoxObj))
                    {
                        curBox.x = curBoxObj.transform.position.x;
                        curBox.y = curBoxObj.transform.position.y;
                    }
                }
            }
        }



        //client.SetRotation (input.x, input.y);
        //移动指令
        if (client != null)
        {
            if (GameManager.Instance.roleType == GameManager.RoleType.move)
            {
                client.Move(transform.position.x, transform.position.y);
            }

            if (GameManager.Instance.roleType == GameManager.RoleType.launch)
            {
                if (GameManager.Instance.boxs != null && GameManager.Instance.boxs.Count > 0)
                {
                    client.OnBoxsPos(GameManager.Instance.boxs);
                }
                client.LaunchDir(angle);
            }
        }

        if (GameManager.Instance.roleType == GameManager.RoleType.move)
        {
            if (transform.childCount > 0)
            {
                var child = transform.GetChild(0);
                //child.transform.localPosition = new Vector3(0.05f, 0.1f, 0);
            }
        }



        //CubeController.Instance.UpdatePosition(transform.position.x,transform.position.y,transform.position.z) ;
    }
Пример #6
0
 public GameBoxIOCustom(GameBox <TNode> gbx)
 {
     GBX = gbx;
 }
Пример #7
0
 public GameBoxIOCustom(GameBox gbx)
 {
     InputGBX = gbx;
     GBX      = new GameBox <TNode>();
 }
Пример #8
0
 private string CCC(BaseEventArgs a)
 {
     Debug.Log("控制器处理!  " + (a as RouteDemoEventArgs).GO.name);
     return GameBox.GetBuiltInModule<IModelManager>().GetModel<MyModel>().Logic_UserNameWithCondition();
 }
Пример #9
0
 private void Awake()
 {
     GameBox.GetBuiltInModule<IRouteManager>();
     GameBox.GetBuiltInModule<IModelManager>();
 }
Пример #10
0
 public static string ToJson(this GameBox gbx, bool format = true)
 {
     return(JsonConvert.SerializeObject(gbx, format ? Formatting.Indented : Formatting.None, settings));
 }