Example #1
0
        /// <summary>
        /// Creates a new instance of a debri entity.
        /// </summary>
        /// <param name="spawn">Spawn location.</param>
        public Debri(Vector2 spawn) : base(ECS.GetNextId())
        {
            Random random = new Random();

            // Components
            Components = new IComponent[]
            {
                new PositionComponent()
                {
                    Position        = spawn,
                    Momentum        = Blackhole.GetInitialMomentum(spawn),
                    AngularMomentum = random.Next(-40, 40),
                    Direction       = random.Next(0, 360),
                    CollisionMask   = new CollisionMaskCircle(
                        spawn, 32
                        )
                },
                new AnimationComponent()
                {
                    Sprite = "Objects/Resources/Debri"
                },
                new AffectedByBlackholeComponent()
                {
                    Entity = this
                },
                new WorldComponent()
                {
                    Entity = this
                },
                new CombatComponent()
                {
                    Health    = 1,
                    MaxHealth = 1,
                    Armour    = 0,
                    MaxArmour = 0,
                    Entity    = this
                },
                new ResourceComponent()
                {
                    Value = 50
                }
            };

            // Link as required
            ((AffectedByBlackholeComponent)Components[2]).Position = Position;
            ((WorldComponent)Components[3]).PositionComponent      = Position;

            // Register components
            RegisterComponents();
        }
Example #2
0
        /// <summary>
        /// Creates a Mothership entity.
        /// </summary>
        public Mothership(int x, int y, Team team) : base(ECS.GetNextId())
        {
            // Register components.
            Components = new IComponent[]
            {
                new PositionComponent()
                {
                    Position = new Vector2(x, y),
                    Momentum = Blackhole.GetInitialMomentum(
                        new Vector2(x, y)
                        ),
                    Direction       = 0,
                    AngularMomentum = 0,
                    CollisionMask   = new CollisionMaskCircle(
                        new Vector2(x, y), 128
                        )
                },
                new WorldComponent(),
                new AnimationComponent()
                {
                    Sprite = "Objects/Ships/Mothership"
                },
                new AffectedByBlackholeComponent()
                {
                    Entity = this
                },
                new TeamComponent()
                {
                    Team = team
                },
                new ResourceComponent()
                {
                    Value = 0
                }
            };

            // Link components
            World.Entity            = this;
            World.PositionComponent = Position;
            ((AffectedByBlackholeComponent)Components[3]).Position = Position;
            Team.Team.Mothership = this;

            // Register components
            RegisterComponents();
        }
Example #3
0
        /// <summary>
        /// Creates a new player entity.
        /// </summary>
        public PlayerEntity(Team team) : base(ECS.GetNextId())
        {
            // Create components
            Components = new IComponent[]
            {
                new NetworkingClientComponent(this),
                new PositionComponent()
                {
                    Position        = new Vector2(),
                    Momentum        = new Vector2(),
                    AngularMomentum = 0,
                    Direction       = 0,
                    CollisionMask   = new CollisionMaskCircle(new Vector2(), 128),
                },
                new WorldComponent(),
                new AnimationComponent()
                {
                    Sprite = "Objects/Ships/GreenBeacon"
                },
                new EngineComponent()
                {
                    InputForce = new Vector2()
                },
                new ShipLimiterComponent()
                {
                    HandlingRank = 0,
                    SpeedRank    = 0
                },
                new TeamComponent()
                {
                    Team = team
                },
                new CombatComponent()
                {
                    Health    = 100,
                    MaxHealth = 100,
                    Armour    = 100,
                    MaxArmour = 100,
                    Entity    = this
                },
                new WeaponComponent()
                {
                    Cooldown        = 200,
                    CurrentCooldown = 0,
                    Direction       = 0f,
                    Trigger         = false,
                    Parent          = this
                },
                new ResourceComponent()
                {
                    Value = 0
                }
            };

            // Link components as required
            Client.Entity           = this;
            World.PositionComponent = Position;
            World.Entity            = this;
            Engine.Position         = Position;
            ShipLimiter.Position    = Position;
            ShipLimiter.Engine      = Engine;
            Weapon.Position         = Position;
            Weapon.Team             = Team;

            // Register to team
            Team.Team.RegisterPlayer(this);

            // Spawn according to team respawn
            Position.Position = Team.Team.Mothership.Position.Position
                                + new Vector2(100, 0);
            Position.Momentum =
                Blackhole.GetInitialMomentum(Position.Position);
            Position.Direction       = (new Random()).Next(0, 180);
            Position.AngularMomentum = (new Random()).Next(-20, 20);

            // Register components
            RegisterComponents();
        }