Exemple #1
0
 public Line(Model.Vec2Float p1, Model.Vec2Float p2, float width, Model.ColorFloat color)
 {
     this.P1    = p1;
     this.P2    = p2;
     this.Width = width;
     this.Color = color;
 }
Exemple #2
0
 public PlacedText(string text, Model.Vec2Float pos, Model.TextAlignment alignment, float size, Model.ColorFloat color)
 {
     this.Text      = text;
     this.Pos       = pos;
     this.Alignment = alignment;
     this.Size      = size;
     this.Color     = color;
 }
Exemple #3
0
        private WeaponOperation OperateWeapon(Unit enemy)
        {
            if (enemy == null || _Weapon == null)
            {
                return(new WeaponOperation(Vector2.UnitX, WeaponOperation.ActionType.None));
            }

            var aim = CalculateAim(enemy);

            var hasLineOfSight = HasLineOfSight(WeaponPoint, aim, Vector2.Distance(WeaponPoint, TakeCenter(enemy)), 2 * _Weapon.BulletSize);

            var action = hasLineOfSight && CheckWeaponFireSafety(enemy, aim) ? WeaponOperation.ActionType.Shoot : WeaponOperation.ActionType.None;

#if DEBUG
            {
                Model.ColorFloat lineColor;
                switch (action)
                {
                case WeaponOperation.ActionType.None:
                    lineColor = new Model.ColorFloat(1, 0, 0, 0.3f);
                    break;

                case WeaponOperation.ActionType.Shoot:
                    lineColor = new Model.ColorFloat(0, 1, 0, 0.3f);
                    break;

                case WeaponOperation.ActionType.Reload:
                    lineColor = new Model.ColorFloat(1, 1, 0, 0.3f);
                    break;

                default: throw new System.ArgumentOutOfRangeException(nameof(action));
                }

                Debug.Instance?.Draw(
                    new Model.Debugging.Line(WeaponPoint.Convert(),
                                             (WeaponPoint + 30 * aim).Convert(),
                                             0.1f,
                                             lineColor));
            }
#endif

            return(new WeaponOperation(aim, action));
        }
Exemple #4
0
 public ColoredVertex(Model.Vec2Float position, Model.ColorFloat color)
 {
     this.Position = position;
     this.Color    = color;
 }
Exemple #5
0
 public Rect(Model.Vec2Float pos, Model.Vec2Float size, Model.ColorFloat color)
 {
     this.Pos   = pos;
     this.Size  = size;
     this.Color = color;
 }