Exemple #1
0
 //player bullet constructor
 Bullet(Vector2 position, float speed, float angle, BulletDefinition definition, Function function, int dummy) : base(function, Layer.PlayerBullets, position)
 {
     PlayerTeam = true;
     Speed      = speed;
     Angle      = angle;
     Definition = definition;
 }
Exemple #2
0
 //enemy bullet constructor
 public Bullet(Vector2 position, float speed, float angle, BulletDefinition definition, Function function) : base(null, Layer.Bullets, position)
 {
     Speed      = speed;
     Angle      = angle;
     Definition = definition;
     Script.InvokeEntityEventTask(this, "onBulletCreate");
     if (function != null)
     {
         Script.CreateTask(this, function);
     }
 }
Exemple #3
0
            public static Value CreateBulletDefinitions(Interpreter interpreter, SourceRef location, Value[] args, int argCount)
            {
                var defs = new Table();

                args[0].VerifyType(Value.ValueType.Table, location);
                var   table      = args[0].Table;
                var   tex        = table["texture"].String;
                var   speed      = table["speed"].Number;
                var   hitbox     = (float)table["hitbox"].Number;
                var   x          = (int)table["x"].Number;
                var   y          = (int)table["y"].Number;
                var   width      = (int)table["width"].Number;
                var   height     = (int)table["height"].Number;
                var   frames     = (int)table["frames"].Number;
                var   variations = table["types"].VerifyType(Value.ValueType.Array, location).Array;
                float damage     = 1f;
                Value temp;

                if (table.TryGetValue("damage", out temp))
                {
                    damage = (float)temp.Number;
                }
                bool fixedAngle = false;

                if (table.TryGetValue("fixedAngle", out temp))
                {
                    fixedAngle = temp.Number != 0.0;
                }
                BlendState blend = BlendState.AlphaBlend;

                if (table.TryGetValue("blend", out temp))
                {
                    blend = (BlendState)temp.VerifyType <BlendState>(location).Object;
                }
                foreach (var variation in variations)
                {
                    var animation = new Animation(tex, speed, x, y, width, height, frames);
                    var def       = new BulletDefinition(animation, hitbox, blend, variation.String, damage, fixedAngle);
                    defs[variation] = Value.Create(def);
                    x += width * frames;
                }
                return(defs);
            }
Exemple #4
0
 public static Bullet PlayerBullet(Vector2 position, float speed, float angle, BulletDefinition definition, Function function)
 {
     return(new Bullet(position, speed, angle, definition, function, 0));
 }