예제 #1
0
 public HealthRenderer(IEntity owner, HealthComponent healthComponent)
     : base(owner)
 {
     this.healthComponent = healthComponent;
     this.isRelativeToPosition = true;
     initialize();
 }
예제 #2
0
 public HealthRenderer(IEntity owner, HealthComponent healthComponent, int posX, int posY)
     : base(owner)
 {
     this.healthComponent = healthComponent;
     this.posX = posX;
     this.posY = posY;
     this.isRelativeToPosition = false;
     initialize();
 }
예제 #3
0
        /// <summary>
        /// Carga inicial despues de haber construido el objeto, solo debe hacerse una vez
        /// </summary>
        public void LoadContent()
        {
            if (hasLoaded == false)
            {
                // Aquí inicializo todo lo referente a la entidad principal ya que aún no se donde ponerlo
                DrawableEntity goemon = new DrawableEntity(GlobalIDs.MAIN_CHARACTER_ID);
                this.mainEntity = goemon;
                goemon.Position = new Vector2(175 + 100, 200 + 200);
                //HERE DEADEVENT SE DEBERÏA MOVER PERO SI NO PRODUCE BUG
                //el orden de creación de los componentes influye en el orden en que se envían los eventos
                goemon.addComponent(new DeadComponent(goemon));

                /************** Inicialización animación Goemon **********/
                Animation runningAnimation = new Animation(ActionsList.Running, 30, 38, 8, 40, 9, new Vector2(3.84f, 5f), 0, 0);
                runningAnimation.addAllDefaultFrames(6);
                Animation attackAnimation = new Animation(ActionsList.Attack, 55, 52, 5, 4, 185, new Vector2(3.84f, 5f), 10, 10);
                attackAnimation.addAllDefaultFrames(2);
                attackAnimation.addFrame(new AnimationFrame(new Rectangle(110, 185, 48, 52), 5, null, new Vector2(3.84f, 5f), 10, 10));
                attackAnimation.addFrame(new AnimationFrame(new Rectangle(162, 185, 55, 52), 5, null, new Vector2(3.84f, 5f), -10, 10));
                attackAnimation.addFrame(new AnimationFrame(new Rectangle(220, 185, 55, 52), 5,
                    "Rectangle TestBody False 180 70 0 -20 False;FeInwork.collision.responses.SingleHitCollisionResponse!TestBody;10",
                    new Vector2(3.84f, 5f), -10, 10));

                Animation deadAnimation = new Animation(ActionsList.Dead, 76, 78, 6, 192, 577, new Vector2(1.7f, 1.7f));
                deadAnimation.addAllDefaultFrames(4);
                Animation stillAnimation = new Animation(ActionsList.Default, 28, 34, 60, 315, 10, new Vector2(3.84f, 5f), 0, 0);
                stillAnimation.addAllDefaultFrames(4);

                //Todas las animiaciones se deben agregar al animation manager que necesita una por defecto
                AnimationManagerComponent animationManager = new AnimationManagerComponent(goemon, new AliveAttackerActionChooser(goemon), stillAnimation);
                animationManager.addAction(attackAnimation);
                animationManager.addAction(runningAnimation);
                animationManager.addAction(deadAnimation);
                /************** FIN de Inicialización animación Goemon **********/

                // Efectos de dibujo a aplicarle al personaje principal
                goemon.addDrawEffect(new HaloEffect(goemon));
                goemon.addDrawEffect(new FadeEffect(goemon, 0.02f, 0.4f, 1.0f));
                goemon.addComponent(new AnimationRenderer(goemon, AssetNames.GOEMON_ASSET, animationManager, 5, 5));

                goemon.addComponent(new ControlComponent(goemon));
                goemon.addComponent(new PhysicalAttackComponent(goemon, 10));
                goemon.addComponent(new SpecialActionManagerComponent(goemon));
                HealthComponent hp = new HealthComponent(goemon, null, 100, 70, 120);
                goemon.addComponent(hp);
                //goemon.addComponent(new HealthRenderer(goemon, hp, 10, 10));

                PhysicsData goemonPhysics = new PhysicsData();
                goemonPhysics.MinimumVelocity = new Vector2(-500, -5000);
                goemonPhysics.MaximumVelocity = new Vector2(500, 2000);
                goemonPhysics.Weight = 20;
                goemonPhysics.RunningImpulse = 30000;
                goemonPhysics.AirImpulse = 15000;
                goemonPhysics.JumpImpulse = 1200000;
                goemon.addComponent(new BasicPhysicsComponent(goemon, goemonPhysics));

                Box goemonMainBody = ShapeFactory.CreateRectangle("goemonMainBody", goemon, true, false, 90, 160, goemon.Position, true, GameLayers.MIDDLE_PLAY_AREA, GameConstants.TANGIBLE_BODY_TAG);
                Box goemonPortalBody = ShapeFactory.CreateRectangle("goemonPortalBody", goemon, true, false, 20, 20, goemon.Position, true, GameLayers.MIDDLE_PLAY_AREA, GameConstants.OPEN_DOOR_TAG);
                Box goemonInteractBody = ShapeFactory.CreateRectangle("goemonInteractBody", goemon, false, false, 95, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.Blue);
                Box goemonTriggerBody = ShapeFactory.CreateRectangle("goemonTriggerBody", goemon, false, false, 95, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.AliceBlue);

                Box goemonTriggerBody2 = ShapeFactory.CreateRectangle("goemonTriggerBody2", goemon, false, false, 200, 140, new Vector2(135 + 100, 130 + 200), false, GameLayers.MIDDLE_PLAY_AREA, Color.AliceBlue);

                List<CollisionBody> goemonBodies = new List<CollisionBody>();
                goemonBodies.Add(goemonMainBody);
                goemonBodies.Add(goemonPortalBody);
                goemonBodies.Add(goemonInteractBody);
                goemonBodies.Add(goemonTriggerBody);
                //goemonBodies.Add(goemonTriggerBody2);
                //goemonBodies.Add(earthCastingArea);
                goemon.addComponent(new AnimatedCollisionComponent(goemon, goemonBodies));

                // listener general de colisiones para mario
                EventManager.Instance.addCollisionListener(goemon, new SoftBodyCollisionResponse(goemon));

                Camera2D camera = new Camera2D(Program.GAME, goemon);
                Program.GAME.Camera = camera;
                // mover camara a un target random lejos
                camera.MoveSpeed = 2f;

                // debería ir código para cargar la lista de rooms y doors de los xml
                AreaEntity roomTestM = new AreaTestMetroid();

                this.hasLoaded = true;
            }
            else
            {
                throw new InvalidOperationException("El WorldManager ya ha sido cargado anteriormente.");
            }
        }