Esempio n. 1
0
        protected override IEnumerable <GameObject> CreateObjs()
        {
            var delay = TimeSpan.FromMilliseconds(800);
            var log   = new BufferedLog {
                BufferDuration = delay
            };
            var presenter  = new UIBattlePresenter(log, AddObj);
            var targetting = new BattleTargetSelection();

            yield return(Entity.Create("Battle UI Presenter")
                         .Add(presenter));

            yield return(Entity.Create("Battle Background", new Transform2 {
                Location = new Vector2(0, -100), Size = new Size2(1600, 1228), ZIndex = BackgroundLayer
            })
                         .Add((o, r) => new Texture(r.LoadTexture("Battle/tek-orange-room.jpg", o))));

            yield return(Entity.Create("Battle Log", new Transform2 {
                Location = new Vector2(150, 50), Size = new Size2(1300, 50), ZIndex = CombatLogLayer
            })
                         .Add((o, r) => new Texture(r.CreateRectangle(Color.DarkBlue, o)))
                         .Add((o, r) => new BorderTexture(r.CreateRectangle(Color.AntiqueWhite, o)))
                         .Add(log)
                         .Add(new TextDisplay {
                Text = () => log.Lines.Last()
            }));

            var char1Battle = BattleCharacter.Create(BattleSide.Gamer, Samples.CreateElectrician());
            var heroDisplay = CharacterDisplay.Create(char1Battle, "Heroes/gareth.png", new Vector2(1200, 350), targetting);

            yield return(heroDisplay);

            var enemy1Battle = BattleCharacter.Create(BattleSide.Enemy, Enemy.CreateLaserDrone());

            yield return(CharacterDisplay.Create(enemy1Battle, "Enemies/drone1.png", new Vector2(200, 350), targetting));

            BattlePresenter.Instance = presenter;
            BattleLog.Instance       = log;
            var battle = Battle.Create(new BattleCardSelectionPresenter(AddObj, targetting), new AIPlayer(), char1Battle, enemy1Battle);

            yield return(Entity.Create("Current Battle")
                         .Add(new CurrentBattle {
                Battle = battle
            }));
        }
Esempio n. 2
0
 public BattleCardSelectionPresenter(Action <GameObject> registerObj, BattleTargetSelection targetting)
 {
     _registerObj = x => { registerObj(x); _currentObjs.Add(x); };
     _targetting  = targetting;
 }
        public static GameObject Create(BattleCharacter character, string charImg, Vector2 location, BattleTargetSelection targets)
        {
            string CharText(string x) => $"Char {character.Name}: {x}";

            return(Entity.Create(CharText("Background"), new Transform2 {
                Location = location, Size = new Size2(300, 400)
            })
                   .Add((o, r) => new Texture(r.LoadTexture("Battle/char-portrait-back.png", o)))
                   .Add(Entity.Create(CharText("Image"), new Transform2 {
                Location = location + new Vector2(30, 80), Size = new Size2(240, 240), ZIndex = 1
            })
                        .Add((o, r) => new Texture(r.LoadTexture(charImg, o))))
                   .Add(Entity.Create(CharText("Hp Bar"), new Transform2 {
                Location = location + new Vector2(30, 30), Size = new Size2(240, 40), ZIndex = 1
            })
                        .Add((o, r) => new Texture(r.LoadTexture("Battle/hp-bar-back.png", o)))
                        .Add(new TextDisplay {
                Text = () => $"{character.CurrentHp}/{character.MaxHp}"
            }))
                   .Add(Entity.Create(CharText("Hp Bar"), new Transform2 {
                Location = location + new Vector2(30, 30), Size = new Size2(240, 40), ZIndex = 2
            })
                        .Add((o, r) => new Texture(r.LoadTexture("Battle/hp-bar-filled.png", o)))
                        .Add(new PercentBar {
                CurrentPercent = () => character.CurrentHp / (float)character.MaxHp, MaxWidth = 240
            }))
                   .Add(Entity.Create(CharText("Current Action Points"), new Transform2 {
                Location = location + new Vector2(40, 310), Size = new Size2(60, 60), ZIndex = 3
            })
                        .Add((o, r) => new Texture(r.LoadTexture("Battle/blue-icon.png", o)))
                        .Add(new TextDisplay {
                Text = () => $"{character.CurrentActionPoints}AP"
            }))
                   .Add(Entity.Create(CharText("Current Energy"), new Transform2 {
                Location = location + new Vector2(215, 310), Size = new Size2(60, 60), ZIndex = 3
            })
                        .Add((o, r) => new Texture(r.LoadTexture("Battle/blue-icon.png", o)))
                        .Add(new TextDisplay {
                Text = () => $"{character.CurrentEnergy}NG"
            }))
                   .Add(Entity.Create(CharText("Mouse Click Zone"), new Transform2 {
                Location = location, Size = new Size2(300, 400), ZIndex = 4
            })
                        .Add(new MouseClickTarget {
                OnHit = () => targets.OnCharacterIndicated(character)
            })));
        }