コード例 #1
0
        protected override IAspect CloneSubclass()
        {
            AgeAspect ageAspect = new AgeAspect();

            ageAspect.KillOwnerUponDeath = this.KillOwnerUponDeath;
            ageAspect.Alive = this.Alive;
            ageAspect.deathTimerSet = this.deathTimerSet;
            ageAspect.deathTime = this.deathTime;
            ageAspect.deathListener = this.deathListener;

            return ageAspect;
        }
コード例 #2
0
        protected override void LoadSubclassContent()
        {
            var template = new Entity()
            {
                IsTemplate = true,
                Game = Owner.Game,
                Name = "PROJETILE",
                Enabled = false
            };

            var projectileSprite = new SpriteAspect()
            {
                ImageFile = "Sprites/hobosquirrel",
                ImageFrame = new Rectangle(0, 154, 19, 12),
                OwnerID = template.EntityID,
                OrientationAspect = "orientation",
                LayerDepth = 0.3f,
                CoordinateType = CoordinateType.World,
                Scale = new Vector2(1.5f, 1.5f)
            };
            template.Aspects.Add(projectileSprite);

            var orientation = new BoxCollisionAspect()
            {
                Name = "orientation",
                OwnerID = template.EntityID,
                Mass = 50f,
                CollisionGroup = EntityTemplates.PlayerCollisionGroup,
                OnCollision = (geom1, geom2, contactList) =>
                {
                    Entity e2 = Entity.GetEntityByID(BoxCollisionAspect.FindEntityByGeomID(geom2.Id));
                    if (e2 != null && e2.Name == "Enemy1")
                    {
                        e2.Aspects.FindFirst<RespawnAspect>().Respawn();
                    }
                    return false;
                }
            };
            template.Aspects.Add(orientation);

            var rotater = new PinwheelRotaterAspect()
            {
                RotationSpeed = .015f,
                OwnerID = template.EntityID
            };
            template.Aspects.Add(rotater);

            var age = new AgeAspect() { OwnerID = template.EntityID };
            template.Aspects.Add(age);

            var render = new RenderingAspect()
            {
                OwnerID = template.EntityID,
                Visible = false
            };
            template.Aspects.Add(render);

            for (int i = 0; i < MaxNumberOfProjectiles; i++)
            {
                Projectiles[i] = (Entity)template.Clone();
                Projectiles[i].Initialize();
                Projectiles[i].LoadContent();
                projectileDirections[i] = 1;
                bool foo = Projectiles[i].Enabled;
            }
        }