Пример #1
0
 public UnitRenderer(BoardRenderer boardRenderer, Camera2 camera, Client client)
 {
     this.client        = client;
     this.camera        = camera;
     playerID           = client.Player.InstanceID;
     this.boardRenderer = boardRenderer;
     pathColor          = Color.White;
     moveTargets        = new List <Tile>();
     // register events and load resources
     client.SelectedCommandChanged += Client_SelectedCommandChanged;
     LoadResources();
 }
Пример #2
0
            public TileIcon(Tile tile, BoardRenderer boardRenderer)
            {
                Income = tile.GetIncome();
                RichText resourceIcons = new RichText();

                Icons = new List <RichText>();
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Culture]; inc++)
                {
                    Icons.Add("$(culture)".ToRichText());
                }
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Food]; inc++)
                {
                    Icons.Add("$(food)".ToRichText());
                }
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Gold]; inc++)
                {
                    Icons.Add("$(gold)".ToRichText());
                }
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Happiness]; inc++)
                {
                    Icons.Add("$(happiness)".ToRichText());
                }
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Production]; inc++)
                {
                    Icons.Add("$(production)".ToRichText());
                }
                for (int inc = 0; inc < Income[(int)TileIncomeFormat.Science]; inc++)
                {
                    Icons.Add("$(science)".ToRichText());
                }

                tileCentre = boardRenderer.GetTileCentre(tile);
                iconPos    = new List <Vector2>(Icons.Count);
                int i = 0;

                switch (Icons.Count)
                {
                case 1:
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2);
                    break;

                case 2:
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(Icons[i].Measure().X, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(Icons[i].Measure().X, 0));
                    break;

                case 3:
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(Icons[i].Measure().X, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(Icons[i].Measure().X, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(0, Icons[i].Measure().Y));
                    break;

                case 4:
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(Icons[i].Measure().X, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(Icons[i].Measure().X, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(0, Icons[i].Measure().Y));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(0, Icons[i].Measure().Y));
                    break;

                case 5:
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(Icons[i].Measure().X * 1.5f, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(Icons[i].Measure().X * 1.5f, 0));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 - new Vector2(0, Icons[i].Measure().Y * 1.5f));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2 + new Vector2(0, Icons[i].Measure().Y * 1.5f));
                    i++;
                    iconPos.Add(tileCentre - Icons[i].Measure() / 2);
                    break;
                }
            }