Beispiel #1
0
        public override float Prepare(PawnModel model)
        {
            if ((Containers.Length == 0) || !IsTargetted(model))
            {
                return(0f);
            }

            var list             = new List <float>();
            var totalFixedHeight = 0f;
            var totalVisible     = 0;

            foreach (var container in Containers)
            {
                var height = container.Prepare(model);
                list.Add(height);
                if (height != -1f)
                {
                    totalFixedHeight += height;
                }
                if (height != 0f)
                {
                    totalVisible++;
                }
            }

            _heights = list.ToArray();

            return(FillHeight ? -1f : totalFixedHeight + (HudLayout.Padding * (totalVisible - 1)));
        }
Beispiel #2
0
        private static PawnModel GeneratePawn(List <PawnModel> pawns, GridModel grid, Color color)
        {
            Random randomGen = new Random();
            var    pawn      = new PawnModel()
            {
                Color = color
            };

            var xLastIndex = grid.Grid.GetLength(0);
            var numberTest = 10;
            var stat_pawn  = false;

            for (var i = 0; i < numberTest && !stat_pawn; i++)
            {
                int x        = randomGen.Next(0, grid.XLastIndex);
                int y        = randomGen.Next(0, grid.YLastIndex);
                var tryAgain = false;
                for (var j = 0; j < pawns.Count && !tryAgain; j++)
                {
                    if (pawns[j].X == x && pawns[j].Y == y)
                    {
                        tryAgain = true;
                    }
                }
                stat_pawn = !tryAgain;
                if (stat_pawn)
                {
                    pawn.X = x;
                    pawn.Y = y;
                }
            }


            return(stat_pawn ? pawn : null);
        }
 public BattlefieldVision(PawnModel posessedPawn, Orientation directionOfAttack, UnitsContainer units, MapModel map, BattleCircumstances battleCircumstances)
 {
     _posessedPawn      = posessedPawn;
     _directionOfAttack = directionOfAttack;
     _units             = units;
     _map = map;
     _battleCircumstances = battleCircumstances;
 }
Beispiel #4
0
 private static void AddEngagementElement(PawnModel active, PawnModel passive, BattleEngagement engagement, IEffect defenderEffect)
 {
     engagement.AddEngagementElement(new EngagementElement()
     {
         ActivePawn  = active,
         PassivePawn = passive,
         EngagementVisibleConsequence = new EngagementVisibleConsequence(defenderEffect.UsageAnimationGenerator)
     });
 }
Beispiel #5
0
        public override float Prepare(PawnModel model)
        {
            if (Containers.Length == 0)
            {
                return(0f);
            }
            var maxHeight = Containers.Select(container => container.Prepare(model)).Max();

            return(FillHeight ? -1f : maxHeight);
        }
Beispiel #6
0
        public override float Prepare(PawnModel model)
        {
            if ((_rows.Length == 0) || !IsTargetted(model))
            {
                return(0f);
            }
            _heights = _rows.Select(row => row.Prepare(model)).ToArray();

            return(FillHeight ? -1f : _heights.Sum() + (HudLayout.Padding * (_rows.Length - 1)));
        }
Beispiel #7
0
        public static void DrawDocked(Rect bounds, PawnModel model)
        {
            var configRect = GetConfigButtonRect(bounds, false);

            IsMouseOverConfigButton = Mouse.IsOver(configRect);
            HudLayout.Docked.Draw(bounds, model ?? PawnModel.Selected);
            if (Mouse.IsOver(bounds))
            {
                DrawConfigButton(configRect);
            }
        }
Beispiel #8
0
 private PawnModelComponent GetPawnModelComponent(PawnModel model)
 {
     if (_unitModelToGameObjectMap.ContainsKey(model))
     {
         return(_unitModelToGameObjectMap[model]);
     }
     else if (_projectileModelToGameObjectMap.ContainsKey(model))
     {
         return(_projectileModelToGameObjectMap[model]);
     }
     Assert.IsFalse(true, "There is not pawnModel in dictionaries: " + model);
     return(null);
 }
Beispiel #9
0
        public void Draw(Rect rect, PawnModel model)
        {
            try
            {
                if ((model.Base != _lastPawn) || (_lastDraw == default) || ((DateTime.Now - _lastDraw).TotalMilliseconds > (Theme.RefreshRate.Value * 100)))
                {
                    Prepare(model);
                    _lastPawn = model.Base;
                    _lastDraw = DateTime.Now;
                }

                Draw(rect);
            }
            catch (Exception exception) { Mod.HandleError(exception); }
        }
Beispiel #10
0
        public override float Prepare(PawnModel model)
        {
            _visible = false;
            if ((_elements.Length == 0) || !IsTargetted(model))
            {
                return(0f);
            }

            var maxHeight = 0f;

            foreach (var element in _elements)
            {
                element.Build(model);
                maxHeight = Mathf.Max(maxHeight, element.Widget.Height);
            }

            _visible = maxHeight > 0f;
            return(maxHeight);
        }
        public bool CanMoveTo(PawnModel unitMoved, MyHexPosition target, MyHexPosition magicSelector, MyPlayer player)
        {
            if (!unitMoved.PossibleMoveTargets.Contains(target))
            {
                return(false);
            }
            else if (IsTileMovable(target))  //empty!
            {
                if (magicSelector == null)
                {
                    return(true);
                }
                if (GetPlayerMagicType(player) != MagicType.Wind)
                {
                    return(!magicSelector.Equals(target));
                }

                return(true);
            }
            else
            {
                if (Units.IsPawnAt(target))
                {
                    var tempUnitsContainer       = Units.Clone();
                    var tempProjectilesContainer = Projectiles.Clone();
                    var tempMapModel             = MapModel.Clone();

                    var newOrientation = unitMoved.Position.NeighboursWithDirections.Where(c => c.NeighbourPosition.Equals(target))
                                         .Select(c => c.NeighbourDirection).First();

                    var tempUnitModel = tempUnitsContainer.GetPawnAt(unitMoved.Position);
                    tempUnitsContainer.OrientPawn(tempUnitModel.Position, newOrientation);

                    var arbiter       = new BattleArbiter(tempUnitsContainer, tempProjectilesContainer, tempMapModel);
                    var battleResults = arbiter.PerformBattleAtPlace(unitMoved.Position, BattleCircumstances.Director);
                    return(battleResults.PositionWasFreed(target));
                }
            }
            return(false);
        }
Beispiel #12
0
        public static void DrawContent(Rect rect, PawnModel model, Pawn pawn)
        {
            if (pawn == null)
            {
                if (model == null)
                {
                    throw new Mod.Exception("Both model and pawn are null");
                }

                pawn = model.Base;
            }

            Text.Font = GameFont.Small;

            if (Theme.HudDocked.Value)
            {
                Hud.DrawDocked(rect, model);
            }
            else if (Theme.InspectPaneTabAddLog.Value)
            {
                DrawLog(pawn, rect);
            }
        }
Beispiel #13
0
        public void Draw(Rect rect, PawnModel model)
        {
            HudTimings.Update(this)?.Start();

            try
            {
                if (model == null)
                {
                    return;
                }

                if (model.Base != _lastPawn || _lastRefresh == default || (DateTime.Now - _lastRefresh).TotalMilliseconds > Theme.RefreshRate.Value * 100)
                {
                    Prepare(model);
                    _lastPawn    = model.Base;
                    _lastRefresh = DateTime.Now;
                }

                Draw(rect);
            }
            catch (Exception exception) { Mod.HandleError(exception); }

            HudTimings.Update(this)?.Finish(rect, true);
        }
Beispiel #14
0
 public void Start()
 {
     _owningUnit = GetComponentInParent <UnitModelComponent>().Model;
 }
Beispiel #15
0
 public void Draw(Rect rect, PawnModel model)
 {
     Prepare(model);
     Draw(rect);
 }
Beispiel #16
0
 public static void DrawDocked(Rect bounds, PawnModel model)
 {
     HudLayout.Docked.Draw(bounds, model ?? PawnModel.Selected);
     DrawConfigButton(bounds, false);
 }
Beispiel #17
0
 protected bool IsTargetted(PawnModel model) => Targets.HasTarget(model.Target);
Beispiel #18
0
 //base
 public void setPawnModel(PawnModel newModelType, Sprite newModel)
 {
     setPawnModel(newModelType, newModel, null);
 }
Beispiel #19
0
 //full
 public void setPawnModel(PawnModel newModelType, Sprite newModel, Sprite newBeard)
 {
     modelType       = newModelType;
     pawnBody.sprite = newModel;
     beard.sprite    = newBeard;
 }
Beispiel #20
0
 private void findChildrenGameObjects()
 {
     spritePlane = GetComponentInChildren <SpritePlane>();
     pawnModel   = GetComponentInChildren <PawnModel>();
 }
Beispiel #21
0
 public abstract float Prepare(PawnModel model);
Beispiel #22
0
 public override float Prepare(PawnModel model) => Widget?.Height ?? 0f;
 public void FinalizeKillUnit(PawnModel unit) // ugly code
 {
     Units.RemovePawn(unit.Position);
 }
 public void MoveUnit(PawnModel unit, MyHexPosition newPosition)
 {
     Units.MovePawn(unit.Position, newPosition);
 }
Beispiel #25
0
        public void Build(PawnModel model)
        {
            var widget = HudModel.GetWidget(model, _type, _defName);

            Widget = IsTargetted(model) ? widget : HudBlank.Get(widget.Height);
        }
Beispiel #26
0
 public GeneRicochet(GeneRicochet g)
 {
     Direction = g.Direction;
     Pawn      = (PawnModel)g.Pawn;
 }
Beispiel #27
0
 private void InitRandomGene()
 {
     Direction = (BoardModel.Direction)Parameters.randomGenerator.Next(4);
     Pawn      = (PawnModel)RicochetProblem.Board.Pawns[Parameters.randomGenerator.Next(RicochetProblem.Board.Pawns.Count)];
 }
 public void OrientUnit(PawnModel unit, Orientation orientation)
 {
     Units.OrientPawn(unit.Position, orientation);
 }