예제 #1
0
        private Entity CreateProjectile(LocationComponent location, Vector2 target, WeaponComponent weaponComponent)
        {
            var projectile = new Entity
            {
                Id         = 72, // todo: EntityFactory
                Components = new List <IComponent>
                {
                    location.Clone(),
                    new CollisionComponent(new BoundingCircle {
                        Radius = weaponComponent.CollisionRadius
                    }),                                                                                        // should this be definable?
                    new ImageComponent {
                        TextureId = weaponComponent.TextureId
                    },
                    new MovementComponent
                    {
                        Velocity     = target,
                        Steering     = Vector2.Zero,
                        MaxVelocity  = weaponComponent.Speed,
                        Mass         = 1,
                        MaxForce     = weaponComponent.MaxImpactForce,
                        Destinations = new Queue <MoveOrder>(new[]
                        {
                            new MoveOrder
                            {
                                MovementMode = MovementMode.Direct,
                                Destination  = target
                            }
                        })
                    },
                }
            };

            return(projectile);
        }
예제 #2
0
        public object Clone()
        {
            var clone = (Bullet)this.MemberwiseClone();

            clone.m_location = (LocationComponent)m_location.Clone();
            clone.m_move     = (MoveComponent)m_move.Clone();

            return((object)clone);
        }