Esempio n. 1
0
 public Unit(int id, int playerId, Vector2 pos, Weapon weapon, Vector2 size, float runSpeed, float jumpSpeed, float jumpTimeLeft, float maxJumpTime, VerticalDynamic verticalDynamic, float health, float maxHealth, HorizontalMovement currentHorizontalMovement, IEnvironment environment, IScoretable scoretable) :
     base(pos, size)
 {
     _Id                        = id;
     PlayerId                   = playerId;
     _Weapon                    = weapon;
     _Size                      = size;
     _RunSpeed                  = runSpeed;
     _JumpSpeed                 = jumpSpeed;
     _JumpTimeLeft              = jumpTimeLeft;
     _MaxJumpTime               = maxJumpTime;
     VerticalDynamic            = verticalDynamic;
     Health                     = health;
     MaxHealth                  = maxHealth;
     _CurrentHorizontalMovement = currentHorizontalMovement;
     _Environment               = environment;
     _Scoretable                = scoretable;
 }
Esempio n. 2
0
        public static Strategy.Unit Convert(this Unit value, Game game, bool tempWorkaround)
        {
            Strategy.VerticalDynamic.Type verticalDynamicType;
            if (value.JumpState.MaxTime == 0 || tempWorkaround)
            {
                verticalDynamicType = Strategy.VerticalDynamic.Type.Falling;
            }
            else if (!value.JumpState.CanCancel)
            {
                verticalDynamicType = Strategy.VerticalDynamic.Type.ThrownUp;
            }
            else
            {
                verticalDynamicType = Strategy.VerticalDynamic.Type.None;
            }

            var verticalDynamic = new Strategy.VerticalDynamic(
                verticalDynamicType,
                (float)game.Properties.UnitFallSpeed,
                (float)game.Properties.JumpPadJumpSpeed,
                (float)value.JumpState.MaxTime);

            return(new Strategy.Unit(
                       value.Id,
                       value.PlayerId,
                       value.Position.CastToVector2(),
                       value.Weapon?.Convert(),
                       value.Size.CastToVector2(),
                       (float)game.Properties.UnitMaxHorizontalSpeed,
                       (float)game.Properties.UnitJumpSpeed,
                       (float)value.JumpState.MaxTime,
                       (float)game.Properties.UnitJumpTime,
                       verticalDynamic,
                       value.Health,
                       game.Properties.UnitMaxHealth,
                       value.Stand ? Strategy.HorizontalMovement.None : (value.WalkedRight ? Strategy.HorizontalMovement.Right : Strategy.HorizontalMovement.Left),
                       new Environment(game),
                       new Scoretable(game)));
        }