コード例 #1
0
ファイル: SpikeTrap.cs プロジェクト: lab132/owlicity
        public SpikeTrap()
        {
            FixedOrigin = new SpatialComponent(this);

            TargetSensor = new TargetSensorComponent(this)
            {
                SensorType = TargetSensorType.Rectangle,
                TargetCollisionCategories = CollisionCategory.Friendly,
            };
            TargetSensor.AttachTo(FixedOrigin);

            MovingBodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = MovingBodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Shopkeeper_Idle_Front
                },
            };
            Animation.AttachTo(this);
        }
コード例 #2
0
        public Shop()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            ShopAnimation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Shop,
                },
            };
            ShopAnimation.AttachTo(BodyComponent);

            ShopkeeperAnimation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Shopkeeper_Idle_Front,
                },
            };
            ShopkeeperAnimation.Spatial.Position.Y -= Conversion.ToMeters(100);
            ShopkeeperAnimation.AttachTo(ShopAnimation);
        }
コード例 #3
0
        public override void Initialize()
        {
            base.Initialize();

            if (BodyComponent == null)
            {
                BodyComponent = Owner.GetComponent <BodyComponent>();
                Debug.Assert(BodyComponent != null);
            }

            if (Chaser == null)
            {
                Chaser = Owner.GetComponent <HomingComponent>();
            }

            if (Health == null)
            {
                Health = Owner.GetComponent <HealthComponent>();
                Debug.Assert(Health != null);
            }

            if (Animation == null)
            {
                Animation = Owner.GetComponent <SpriteAnimationComponent>();
                Debug.Assert(Animation != null);
            }
        }
コード例 #4
0
ファイル: BonbonPickup.cs プロジェクト: lab132/owlicity
        public BonbonPickup()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };

            BodyComponent.BeforeInitialize += () =>
            {
            };
            this.RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>(),
            };
            Animation.AttachTo(RootComponent);

            MoneyBag = new MoneyBagComponent(this)
            {
                InitialAmount = 10,
            };

            Homing = GameObjectFactory.CreateDefaultHomingCircle(this, BodyComponent,
                                                                 sensorRadius: 1.0f,
                                                                 homingType: HomingType.ConstantSpeed,
                                                                 homingSpeed: 3.0f);

            Pickup = new PickupComponent(this)
            {
                BodyComponent = BodyComponent,
            };
        }
コード例 #5
0
        public KeyPickup()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            this.RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>(),
            };
            Animation.AttachTo(RootComponent);

            KeyRing = new KeyRingComponent(this);

            Pickup = new PickupComponent(this)
            {
                BodyComponent = BodyComponent,
            };

            Homing = GameObjectFactory.CreateDefaultHomingCircle(this, BodyComponent,
                                                                 sensorRadius: 1.0f,
                                                                 homingType: HomingType.ConstantSpeed,
                                                                 homingSpeed: 3.0f);
        }
コード例 #6
0
 public Flora()
 {
     Animation = new SpriteAnimationComponent(this)
     {
         AnimationTypes = new List <SpriteAnimationType>(),
         DepthReference = null, // Don't determine depth automatically
     };
     Animation.AttachTo(this);
 }
コード例 #7
0
ファイル: Owliver.cs プロジェクト: lab132/owlicity
        public Owliver()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            Movement = new MovementComponent(this)
            {
                BodyComponent         = BodyComponent,
                ManualInputProcessing = true,
                MaxMovementSpeed      = 3.5f,
            };

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Owliver_Idle_Stick_Left,
                    SpriteAnimationType.Owliver_Idle_Stick_Right,
                    SpriteAnimationType.Owliver_Walk_Stick_Left,
                    SpriteAnimationType.Owliver_Walk_Stick_Right,
                    SpriteAnimationType.Owliver_Attack_Stick_Left,
                    SpriteAnimationType.Owliver_Attack_Stick_Right,
                    SpriteAnimationType.Owliver_Idle_FishingRod_Left,
                    SpriteAnimationType.Owliver_Idle_FishingRod_Right,
                    SpriteAnimationType.Owliver_Walk_FishingRod_Left,
                    SpriteAnimationType.Owliver_Walk_FishingRod_Right,
                    SpriteAnimationType.Owliver_Attack_FishingRod_Left,
                    SpriteAnimationType.Owliver_Attack_FishingRod_Right,
                },
            };
            Animation.AttachTo(BodyComponent);

            Health = new HealthComponent(this)
            {
                MaxHealth = 5,
            };
            Health.OnHit += OnHit;

            GameObjectFactory.CreateOnHitSquasher(this, Health, Animation).SetDefaultCurves(HitDuration);

            GameObjectFactory.CreateOnHitBlinkingSequence(this, Health, Animation).SetDefaultCurves(HitDuration);

            MoneyBag = new MoneyBagComponent(this)
            {
                InitialAmount = 0,
            };

            KeyRing = new KeyRingComponent(this);
        }
コード例 #8
0
ファイル: Screen.cs プロジェクト: lab132/owlicity
        public void LoadContent(Level level)
        {
            string groundTextureName    = string.Format(level.ContentNameFormat_Ground, GridPosition.Y, GridPosition.X);
            string collisionContentName = string.Format(level.ContentNameFormat_Collision, GridPosition.Y, GridPosition.X);
            string layoutContentName    = string.Format(level.ContentNameFormat_Layout, GridPosition.Y, GridPosition.X);

            //
            // Screen game object
            //
            {
                _screenGameObject = new BackgroundScreen();
                _screenGameObject.Spatial.Position        += WorldPosition;
                _screenGameObject.ShapeContentName         = collisionContentName;
                _screenGameObject.Sprite.SpriteContentName = groundTextureName;

                Global.Game.AddGameObject(_screenGameObject);
            }

            List <ScreenLayoutInfo> layoutInfos = Global.Game.Content.Load <List <ScreenLayoutInfo> >(layoutContentName);

            foreach (ScreenLayoutInfo layout in layoutInfos)
            {
                var deco = GameObjectFactory.CreateKnown(layout.ObjectType);

#if false
                SpriteAnimationComponent sa = deco.GetComponent <SpriteAnimationComponent>();
                // Choose random initial frame
                sa.OnPostInitialize += delegate()
                {
                    int startFrame = level.Random.Next(3);
                    for (int frameIndex = 0; frameIndex < startFrame; frameIndex++)
                    {
                        sa.ActiveAnimation.AdvanceFrameIndex();
                    }
                };
#endif
                deco.Spatial.Position += layout.OffsetInMeters;
                deco.AttachTo(_screenGameObject);

                Global.Game.AddGameObject(deco);

                _decorationObjects.Add(deco);
            }
        }
コード例 #9
0
ファイル: Projectile.cs プロジェクト: lab132/owlicity
        public Projectile()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            this.RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Bonbon_Red,
                },
            };
            Animation.Spatial.Rotation.Degrees -= 40.0f;
            Animation.AttachTo(BodyComponent);

            AutoDestruct = new AutoDestructComponent(this);
        }
コード例 #10
0
        public Tankton()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Tankton_Idle_Left,
                    SpriteAnimationType.Tankton_Idle_Right,
                },
            };
            Animation.Spatial.Position.Y += Conversion.ToMeters(100);
            Animation.AttachTo(BodyComponent);

            Health = new HealthComponent(this)
            {
                MaxHealth = 20,
            };
            Health.OnHit   += OnHit;
            Health.OnDeath += OnDeath;

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health               = Health,
                HealthIcon           = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
                InitialDisplayOrigin = HealthDisplayComponent.DisplayOrigin.Bottom,
                NumIconsPerRow       = 5,
            };
            HealthDisplay.AttachTo(Animation);

            GameObjectFactory.CreateOnHitSquasher(this, Health, Animation).SetDefaultCurves(
                duration: HitDuration,
                extremeScale: new Vector2(0.9f, 1.1f));

            GameObjectFactory.CreateOnHitBlinkingSequence(this, Health, Animation).SetDefaultCurves(HitDuration);
        }
コード例 #11
0
ファイル: Slurp.cs プロジェクト: lab132/owlicity
        public Slurp()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Slurp_Idle_Left,
                    SpriteAnimationType.Slurp_Idle_Right,
                },
            };
            Animation.AttachTo(BodyComponent);

            Health = GameObjectFactory.CreateDefaultHealth(this,
                                                           maxHealth: 3,
                                                           hitDuration: HitDuration,
                                                           deathParticleTimeToLive: TimeSpan.FromSeconds(1));

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health = Health,
                InitialDisplayOrigin = HealthDisplayComponent.DisplayOrigin.Bottom,
                HealthIcon           = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
            };
            HealthDisplay.AttachTo(Animation);

            GameObjectFactory.CreateOnHitSquasher(this, Health, Animation).SetDefaultCurves(HitDuration);

            GameObjectFactory.CreateOnHitBlinkingSequence(this, Health, Animation).SetDefaultCurves(HitDuration);

            Homing = GameObjectFactory.CreateDefaultHomingCircle(this, BodyComponent,
                                                                 sensorRadius: 3.0f,
                                                                 homingType: HomingType.ConstantSpeed,
                                                                 homingSpeed: 0.5f);
        }
コード例 #12
0
        public Gate()
        {
            LeftEdgeOffset = new SpatialComponent(this);
            {
                SpriteAnimationData anim    = SpriteAnimationFactory.GetAnimation(SpriteAnimationType.Gate_Closed);
                Vector2             hotspot = anim.Config.Hotspot * anim.Config.Scale;
                float offset = Conversion.ToMeters(hotspot.X - 128);
                LeftEdgeOffset.Spatial.Position.X -= offset;
            }
            LeftEdgeOffset.AttachTo(this);

            InnerBodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            InnerBodyComponent.AttachTo(LeftEdgeOffset);

            OuterBodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            OuterBodyComponent.AttachTo(LeftEdgeOffset);

            Trigger = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            Trigger.AttachTo(this);

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Gate_Closed,
                    SpriteAnimationType.Gate_Open,
                },
            };
            Animation.AttachTo(this);
        }
コード例 #13
0
ファイル: Singer.cs プロジェクト: lab132/owlicity
        public Singer()
        {
            BodyComponent = new BodyComponent(this)
            {
                InitMode = BodyComponentInitMode.Manual,
            };
            RootComponent = BodyComponent;

            TargetSensor = new TargetSensorComponent(this)
            {
                SensorType                = TargetSensorType.Circle,
                CircleSensorRadius        = SensorReach,
                TargetCollisionCategories = CollisionCategory.Friendly,
            };
            TargetSensor.AttachTo(RootComponent);

            Animation = new SpriteAnimationComponent(this)
            {
                AnimationTypes = new List <SpriteAnimationType>
                {
                    SpriteAnimationType.Singer_Idle_Left,
                    SpriteAnimationType.Singer_Idle_Right,
                },
            };
            Animation.AttachTo(RootComponent);

            Health = GameObjectFactory.CreateDefaultHealth(this,
                                                           maxHealth: 3,
                                                           hitDuration: HitDuration,
                                                           deathParticleTimeToLive: TimeSpan.FromSeconds(1));

            HealthDisplay = new HealthDisplayComponent(this)
            {
                Health     = Health,
                HealthIcon = SpriteAnimationFactory.CreateAnimationInstance(SpriteAnimationType.Cross),
            };
            HealthDisplay.AttachTo(Animation);
        }
コード例 #14
0
ファイル: GameObjectFactory.cs プロジェクト: lab132/owlicity
        public static BlinkingSequenceComponent CreateOnHitBlinkingSequence(GameObject go, HealthComponent health, SpriteAnimationComponent animation)
        {
            var result = new BlinkingSequenceComponent(go)
            {
                Animation = animation,
            };

            health.OnHit += (damage) =>
            {
                result.StartSequence();
            };

            return(result);
        }