예제 #1
0
파일: SpotLight.cs 프로젝트: theKyuu/GLhf
 public override void kill()
 {
     base.kill();
     if (m_lit)
     {
         m_light.kill();
         Game.getInstance().getState().removeObject(m_light);
         m_light = null;
         m_lit = false;
     }
 }
예제 #2
0
파일: SpotLight.cs 프로젝트: theKyuu/GLhf
 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();
     }
 }
예제 #3
0
파일: SpotLight.cs 프로젝트: Yuma-Shi/GLhf
 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();
     }
 }
예제 #4
0
파일: GuardCamera.cs 프로젝트: theKyuu/GLhf
 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);
     }
 }
예제 #5
0
파일: SpotLight.cs 프로젝트: theKyuu/GLhf
        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);
        }
예제 #6
0
파일: SpotLight.cs 프로젝트: theKyuu/GLhf
 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;
         }
     }
 }
예제 #7
0
파일: GuardCamera.cs 프로젝트: theKyuu/GLhf
 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);
     }
     if (m_light != null)
     {
         m_light.getPosition().setParentPosition(m_position);
         m_light.setRotation(m_rotate);
     }
 }
예제 #8
0
파일: SpotLight.cs 프로젝트: Yuma-Shi/GLhf
 public override void loadContent()
 {
     base.loadContent();
     if (m_lightLink > 0)
     {
         m_light = (LightCone)Game.getInstance().getState().getObjectById(m_lightLink);
     }
     if(m_light != null)
     {
         m_light.getPosition().setParentPosition(m_position);
     }
     m_rotationPoint.Y = m_img.getSize().Y / 2;
     m_rotationPoint.X = 0;
     m_imgOffsetY = -m_rotationPoint.Y * m_YScale;
     m_collisionShape = new CollisionRectangle((float)Math.Min(Math.Min(Math.Min((m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate), (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate))),
         (float)Math.Min(Math.Min(Math.Min((m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))),
         (float)(Math.Max(Math.Max(Math.Max((m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate), (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate))) -
         Math.Min(Math.Min(Math.Min((m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate), (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Cos(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Cos(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Cos(m_rotate)))),
         (float)(Math.Max(Math.Max(Math.Max((m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))) -
         (Math.Min(Math.Min(Math.Min((m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate)),
         (m_img.getSize().Y / 2) * Math.Sin(0.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))),
         (m_img.getSize().Y / 2) * Math.Sin(1.5 * Math.PI + m_rotate) + (m_img.getSize().X * Math.Sin(m_rotate))))),
         m_position);
 }
예제 #9
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);
 }