Exemple #1
0
        public void setHurtEnemy()
        {
            state = 1;
            DrawComponent drawComp = ( DrawComponent )myEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

            if (drawComp != null)
            {
                int imgIndex = drawComp.getSprite().currentImageIndex;
                drawComp.setSprite(this.goodShooterName, false);
                drawComp.getSprite().currentImageIndex = imgIndex;
            }
        }
Exemple #2
0
        public void setHurtPlayer()
        {
            state = 0;
            DrawComponent drawComp = ( DrawComponent )myEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

            if (drawComp != null)
            {
                int imgIndex = drawComp.getSprite().currentImageIndex;
                drawComp.setSprite(this.badSpriteName, false);
                drawComp.getSprite().currentImageIndex = imgIndex;
            }
        }
Exemple #3
0
        public ColliderComponent(Entity myEntity, string colliderType, float width, float height)
        {
            this.componentName = GlobalVars.COLLIDER_COMPONENT_NAME;
            this.colliderType  = colliderType;

            this.myEntity = myEntity;

            this.width  = width;
            this.height = height;

            if (myEntity.hasComponent(GlobalVars.DRAW_COMPONENT_NAME))
            {
                drawComponent = ( DrawComponent )myEntity.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
            }

            myEntity.level.colliderAdded(myEntity);
        }
        public void setActive(bool val)
        {
            this.activated = val;
            DrawComponent drawComp = ( DrawComponent )myEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

            if (drawComp == null)
            {
                Console.WriteLine("Error: Trying to activate a switch with no draw component.");
                return;
            }
            if (isActive())
            {
                drawComp.setSprite(animImageName);
                AnimationComponent animComp = ( AnimationComponent )myEnt.getComponent(GlobalVars.ANIMATION_COMPONENT_NAME);
                animComp.imageAfterCycleName = checkedImageName;
                animComp.animationOn         = true;
            }
            else
            {
                drawComp.setSprite(uncheckedImageName);
            }
        }
Exemple #5
0
        public bool hasTransparentPixels = true; //If an object's image has no transparent pixels, setting this to false can save a lot of time.

        public ColliderComponent(Entity myEntity, string colliderType)
        {
            this.componentName = GlobalVars.COLLIDER_COMPONENT_NAME;
            this.colliderType  = colliderType;

            this.myEntity = myEntity;


            if (myEntity.hasComponent(GlobalVars.DRAW_COMPONENT_NAME))
            {
                drawComponent = ( DrawComponent )myEntity.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                this.width    = drawComponent.width;
                this.height   = drawComponent.height;
            }
            else
            {
                this.width  = 0;
                this.height = 0;
                Console.WriteLine("Error: Could not find drawComponent for width and height of collider: " + myEntity);
            }

            myEntity.level.colliderAdded(myEntity);
        }