Ejemplo n.º 1
0
 public SpotLight(Vector2 a_position, string a_sprite, float a_layer, float a_rotation, bool a_lit)
     : base(a_position, a_sprite, a_layer)
 {
     m_rotate = a_rotation;
     m_lit = a_lit;
     if (a_lit)
     {
         (Game.getInstance().getState()).addObject(m_light = new LightCone(this, "Images//LightCone//Ljus", m_img.getSize().X, a_layer + 0.001f, 246f, 245f, a_layer - 0.01f, "Images//LightCone//ljusboll"));
         m_lightLink = m_light.getId();
     }
 }
Ejemplo n.º 2
0
 public SpotLight(Vector2 a_position, string a_sprite, float a_layer, float a_rotation, bool a_lit)
     : base(a_position, a_sprite, a_layer)
 {
     m_rotate = a_rotation;
     m_lit = a_lit;
     if (a_lit)
     {
         m_light = new LightCone(this, "Images//LightCone//Ljus", a_layer + 0.001f, 300f, 300f);
         (Game.getInstance().getState()).addObject(m_light);
         m_lightLink = m_light.getId();
     }
 }
Ejemplo n.º 3
0
 public GuardCamera(Vector2 a_position, String a_sprite, float a_layer, float a_rotation, float a_leftRotation, float a_rightRotation, bool a_lit)
     : base(a_position, a_sprite, a_layer)
 {
     if (a_rotation < 0 || a_rotation > 2 * Math.PI ||
         a_leftRotation < 0 || a_leftRotation > 2 * Math.PI ||
         a_rightRotation < 0 || a_rightRotation > 2 * Math.PI)
     {
         throw new ArgumentException("rotations has to be between 0 and 2PI");
     }
     else
     {
         m_aiState = AIStatepatroling.getInstance();
         m_rotate = a_rotation;
         m_leftRotation = a_leftRotation;
         m_rightRotation = a_rightRotation;
     }
     m_lit = a_lit;
     if (a_lit)
     {
         m_light = new LightCone(this, "Images//LightCone//Ljus", m_img.getSize().X, m_layer + 0.001f, 400f, 100f, m_layer - 0.01f, "Images//LightCone//ljusboll");
         m_lightLink = m_light.getId();
         (Game.getInstance().getState()).addObject(m_light);
     }
 }
Ejemplo n.º 4
0
        public override void loadContent()
        {
            base.loadContent();
            if (m_lightLink > 0)
            {
                try
                {
                    m_light = (LightCone)Game.getInstance().getState().getObjectById(m_lightLink);
                }
                catch (InvalidCastException)
                {
                    (Game.getInstance().getState()).addObject(m_light = new LightCone(this, "Images//LightCone//Ljus", m_img.getSize().X, m_layer + 0.001f, 246f, 245f, m_layer - 0.01f, "Images//LightCone//ljusboll"));
                    m_lightLink = m_light.getId();
                }
            }
            if (m_light != null)
            {
                m_light.getPosition().setParentPosition(m_position);
            }

            m_imgOffsetY = -m_rotationPoint.Y * m_YScale;

            float t_halfHeight = m_img.getSize().Y / 2;
            float t_width = m_img.getSize().X;
            float t_cosRotate = (float)Math.Cos(m_rotate);
            float t_sinRotate = (float)Math.Sin(m_rotate);

            m_rotationPoint.Y = t_halfHeight;
            m_rotationPoint.X = 0;

            m_collisionShape = new CollisionRectangle((float)Math.Min(Math.Min(Math.Min(t_halfHeight * -t_sinRotate, t_halfHeight * t_sinRotate),
                t_halfHeight * -t_sinRotate + (t_width * t_cosRotate)),
                t_halfHeight * t_sinRotate + (t_width * t_cosRotate)),
                (float)Math.Min(Math.Min(Math.Min((t_halfHeight) * t_cosRotate,
                t_halfHeight * -t_cosRotate),
                t_halfHeight * t_cosRotate + (t_width * t_sinRotate)),
                t_halfHeight * -t_cosRotate + (t_width * t_sinRotate)),
                (float)(Math.Max(Math.Max(Math.Max((t_halfHeight) * -t_sinRotate, t_halfHeight * t_sinRotate),
                t_halfHeight * -t_sinRotate + (t_width * t_cosRotate)),
                t_halfHeight * t_sinRotate + (t_width * t_cosRotate)) -
                Math.Min(Math.Min(Math.Min((t_halfHeight) * -t_sinRotate, t_halfHeight * t_sinRotate),
                t_halfHeight * -t_sinRotate + (t_width * t_cosRotate)),
                t_halfHeight * t_sinRotate + (t_width * t_cosRotate))),
                (float)(Math.Max(Math.Max(Math.Max((t_halfHeight) * t_cosRotate,
                t_halfHeight * -t_cosRotate),
                t_halfHeight * t_cosRotate + (t_width * t_sinRotate)),
                t_halfHeight * -t_cosRotate + (t_width * t_sinRotate)) -
                (Math.Min(Math.Min(Math.Min((t_halfHeight) * t_cosRotate,
                t_halfHeight * -t_cosRotate),
                t_halfHeight * t_cosRotate + (t_width * t_sinRotate)),
                t_halfHeight * -t_cosRotate + (t_width * t_sinRotate)))),
                m_position);
        }
Ejemplo n.º 5
0
 public void toggleLight()
 {
     if (!m_turnedOffForEver)
     {
         m_lit = !m_lit;
         if (m_lit)
         {
             if (m_light == null)
             {
                 m_light = new LightCone(this, "Images//LightCone//Ljus", m_img.getSize().X, m_layer + 0.001f, 246f, 245f, m_layer - 0.01f, "Images//LightCone//ljusboll");
                 Game.getInstance().getState().addObject(m_light);
                 m_lightLink = m_light.getId();
             }
         }
         else
         {
             Game.getInstance().getState().removeObject(m_light);
             //just in case
             m_light.kill();
             m_light = null;
             m_lightLink = 0;
         }
     }
 }
Ejemplo n.º 6
0
 public override void loadContent()
 {
     base.loadContent();
     m_rotationPoint = new Vector2(0, m_img.getSize().Y / 2);
     m_imgOffsetY = -m_rotationPoint.Y * m_YScale;
     if (m_lightLink > 0)
     {
         m_light = (LightCone)Game.getInstance().getState().getObjectById(m_lightLink);
         m_light.getPosition().setParentPosition(m_position);
     }
     else
     {
         m_light = new LightCone(this, "Images//LightCone//Ljus", m_layer + 0.001f, 300f, 100f);
         m_lightLink = m_light.getId();
         (Game.getInstance().getState()).addObject(m_light);
     }
     m_light.setRotation(m_rotate);
 }