Exemplo n.º 1
0
 public Guard(Vector2 a_posV2, String a_sprite, float a_patrolPoint, Boolean a_hasFlashLight, float a_layer)
     : base(a_posV2, a_sprite, a_layer)
 {
     m_hasPatrol = false;
     m_hasFlashLight = a_hasFlashLight;
     m_leftPatrolPoint = a_patrolPoint;
     m_rightPatrolPoint = a_patrolPoint;
     m_aiState = AIStatepatroling.getInstance();
     m_FlashLightAddicted = a_sprite == "Images//Sprite//Guard//guard_flash_idle";
     if (m_hasFlashLight && m_FlashLightAddicted)
     {
         m_flashLight = new FlashCone(this, new Vector2(0, -7), "Images//LightCone//light_guard_idle", m_facingRight, 0.249f);
         Game.getInstance().getState().addObject(m_flashLight);
         m_flashLightId = m_flashLight.getId();
     }
     m_gravity = 1000;
     m_guardFaceRight = m_facingRight;
 }
Exemplo n.º 2
0
 internal void toggleFlashLight()
 {
     if (m_aiActive)
     {
         m_speed.X = 0;
         m_aiActive = false;
         if (m_flashLight == null)
         {
             m_img.setSprite("Images//Sprite//Guard//guard_pick_up_flash");
             if (m_facingRight)
             {
                 Game.getInstance().getState().addObject(new Particle(new Vector2(m_position.getGlobalX() + 72, m_position.getGlobalY() - 10), "Images//Sprite//Guard//qmark", 10f, m_layer));
             }
             else
             {
                 Game.getInstance().getState().addObject(new Particle(new Vector2(m_position.getGlobalX() - 22, m_position.getGlobalY() - 10), "Images//Sprite//Guard//qmark", 10f, m_layer));
             }
             m_img.setAnimationSpeed(PICKUPSPEED);
         }
         else
         {
             m_img.setSprite("Images//Sprite//Guard//guard_put_down_flash");
             m_flashLight.kill();
             m_flashLightId = 0;
             m_flashLight = null;
         }
         m_img.setLooping(false);
     }
 }
Exemplo n.º 3
0
 internal void strike()
 {
     if (canStrike())
     {
         if (m_flashLight != null)
         {
             m_flashLight.kill();
             m_flashLightId = 0;
             m_flashLight = null;
         }
         m_striking = true;
         m_strikeReloadTime = 1f;
         m_aiActive = false;
         m_img.setSprite("Images//Sprite//Guard//guard_strike");
         m_img.setLooping(false);
     }
 }
Exemplo n.º 4
0
 internal void setRunning(bool a_running)
 {
     m_running = a_running;
     if (m_speed.X != 0)
     {
         if (m_running)
         {
             m_img.setSprite("Images//Sprite//Guard//guard_run");
             m_img.setAnimationSpeed(CHASINGANIMATIONSPEED);
             if (m_speed.X < 0)
             {
                 m_speed.X = -CHASINGSPEED;
             }
             else
             {
                 m_speed.X = CHASINGSPEED;
             }
         }
         else
         {
             m_img.setSprite("Images//Sprite//Guard//guard_walk");
             m_img.setAnimationSpeed(WALKINGANIMATIONSPEED);
             if (m_speed.X < 0)
             {
                 m_speed.X = -MOVEMENTSPEED;
             }
             else
             {
                 m_speed.X = MOVEMENTSPEED;
             }
         }
     }
     if (m_running && m_flashLight != null)
     {
         m_flashLight.kill();
         m_img.setSprite("Images//Sprite//Guard//guard_idle");
         m_flashLightId = 0;
         m_flashLight = null;
     }
 }
Exemplo n.º 5
0
 internal void goRight()
 {
     if (m_aiActive)
     {
         if (m_facingRight)
         {
             if (m_speed.X == 0)
             {
                 if (m_flashLight == null)
                 {
                     if (m_running)
                     {
                         m_speed.X = CHASINGSPEED;
                         m_img.setAnimationSpeed(CHASINGANIMATIONSPEED);
                         m_img.setSprite("Images//Sprite//Guard//guard_run");
                     }
                     else
                     {
                         m_speed.X = MOVEMENTSPEED;
                         m_img.setAnimationSpeed(WALKINGANIMATIONSPEED);
                         m_img.setSprite("Images//Sprite//Guard//guard_walk");
                     }
                 }
                 else
                 {
                     if (m_running)
                     {
                         m_flashLight.kill();
                         m_flashLightId = 0;
                         m_flashLight = null;
                         m_speed.X = CHASINGSPEED;
                         m_img.setAnimationSpeed(CHASINGANIMATIONSPEED);
                         m_img.setSprite("Images//Sprite//Guard//guard_run");
                     }
                     else
                     {
                         m_flashLight.getPosition().setLocalX(0);
                         m_flashLight.setSprite("Images//LightCone//light_guard_walk");
                         m_flashLight.setFacingRight(true);
                         m_speed.X = MOVEMENTSPEED;
                         m_img.setAnimationSpeed(WALKINGANIMATIONSPEED);
                         m_img.setSprite("Images//Sprite//Guard//guard_flash_walk");
                     }
                 }
             }
         }
         else
         {
             m_speed.X = 0;
             m_aiActive = false;
             if (m_flashLight == null)
             {
                 m_img.setSprite("Images//Sprite//Guard//guard_turn");
             }
             else
             {
                 m_img.setSprite("Images//Sprite//Guard//guard_flash_turn");
                 m_flashLight.setSprite("Images//LightCone//light_guard_turn");
                 m_flashLight.getImg().setAnimationSpeed(TURNANIMATIONSPEED);
                 m_flashLight.setImageOffset(new Vector2(-4, 0));
                 if (m_running)
                 {
                     m_flashLight.getImg().setAnimationSpeed(TURNQUICKANIMATIONSPEED);
                 }
                 else
                 {
                     m_flashLight.getImg().setAnimationSpeed(TURNANIMATIONSPEED);
                 }
             }
             if (m_running)
             {
                 m_img.setAnimationSpeed(TURNQUICKANIMATIONSPEED);
             }
             else
             {
                 m_img.setAnimationSpeed(TURNANIMATIONSPEED);
             }
             m_img.setLooping(false);
         }
     }
 }
Exemplo n.º 6
0
        internal void chasePlayer()
        {
            Player t_player = Game.getInstance().getState().getPlayer();
            m_chaseTarget = t_player;
            if (!t_player.isChase())
            {
                t_player.activateChaseMode(this);
            }
            if (m_flashLight != null)
            {
                m_flashLight.kill();
                m_flashLightId = 0;
                m_flashLight = null;

                if (m_img.isTexture(t2d_flashTurn))
                {
                    m_img.setSpriteSilently("Images//Sprite//Guard//guard_turn");
                    m_img.setLooping(false);
                }
                else if (m_img.isTexture(t2d_flashIdle))
                {
                    m_img.setSpriteSilently("Images//Sprite//Guard//guard_idle");
                }
                else if (m_img.isTexture(t2d_flashWalk))
                {
                    m_img.setSpriteSilently("Images//Sprite//Guard//guard_walk");
                }
            }
        }
Exemplo n.º 7
0
        public override void update(GameTime a_gameTime)
        {
            if (!m_aiActive)
            {
                if (m_img.isStopped())
                {
                    m_aiActive = true;
                    if (m_striking)
                    {
                        m_striking = false;
                        m_img.setSprite("Images//Sprite//Guard//guard_idle");
                    }
                    else if (m_img.isTexture(t2d_turn))
                    {
                        m_img.setSprite("Images//Sprite//Guard//guard_idle");
                        m_facingRight = !m_facingRight;
                    }
                    else if (m_img.isTexture(t2d_flashTurn))
                    {
                        m_img.setSprite("Images//Sprite//Guard//guard_flash_idle");
                        m_facingRight = !m_facingRight;
                        m_flashLight.setSprite("Images//LightCone//light_guard_idle");
                        m_flashLight.setImageOffset(Vector2.Zero);
                        m_flashLight.setFacingRight(m_facingRight);
                        if (m_facingRight)
                        {
                            m_flashLight.getPosition().setLocalX(0);
                        }
                        else
                        {
                            m_flashLight.getPosition().setLocalX(-178);
                        }

                    }
                    else if (m_img.isTexture(t2d_pickUpFlash))
                    {
                        m_flashLight = new FlashCone(this, new Vector2(0, -7), "Images//LightCone//light_guard_idle", m_facingRight, 0.249f);
                        m_flashLightId = m_flashLight.getId();
                        if (!m_facingRight)
                        {
                            m_flashLight.getPosition().setLocalX(m_img.getSize().X - m_flashLight.getImg().getSize().X);
                        }
                        Game.getInstance().getState().addObject(m_flashLight);
                        m_img.setSprite("Images//Sprite//Guard//guard_flash_idle");
                    }
                    else if (m_img.isTexture(t2d_putDownFlash))
                    {
                        m_img.setSprite("Images//Sprite//Guard//guard_idle");
                    }
                }
                else if (m_img.isTexture(t2d_flashTurn))
                {
                    if (m_img.getSubImageIndex() > 5 && m_flashLight != null)
                    {
                        if (m_facingRight)
                        {
                            m_flashLight.setFacingRightCollision(false);
                        }
                        else
                        {
                            m_flashLight.setFacingRightCollision(true);
                        }
                    }
                }
            }

            base.update(a_gameTime);

            m_strikeReloadTime = Math.Max(m_strikeReloadTime - (a_gameTime.ElapsedGameTime.Milliseconds / 1000f), 0);

            if ((m_aiState != AIStateChasing.getInstance()) && canSeePlayer())
            {
                chasePlayer();
                m_aiState = AIStateChasing.getInstance();
            }

            if (m_facingRight)
            {
                m_spriteEffects = SpriteEffects.None;
            }
            else
            {
                m_spriteEffects = SpriteEffects.FlipHorizontally;
            }
            if (m_flashLight != null)
            {
                m_flashLight.setSubImage(m_img.getSubImageIndex());
            }
        }
Exemplo n.º 8
0
        public override void loadContent()
        {
            base.loadContent();
            m_collisionShape = new CollisionRectangle(10, 10, m_img.getSize().X - 20, m_img.getSize().Y - 10, m_position);
            m_lampSwitchTargets = new LinkedList<LampSwitch>();
            if (m_flashLightId > 0)
            {
                m_flashLight = ((FlashCone)(Game.getInstance().getState().getObjectById(m_flashLightId)));
                m_flashLight.getPosition().setParentPosition(this.getPosition());
            }
            if (m_lampSwitchTargetsId == null)
            {
                m_lampSwitchTargetsId = new LinkedList<int>();
            }
            foreach (int t_lsti in m_lampSwitchTargetsId)
            {
                m_lampSwitchTargets.AddLast((LampSwitch)Game.getInstance().getState().getObjectById(t_lsti));
            }
            m_facingRight = m_spriteEffects == SpriteEffects.None;
            m_huhSound = new Sound("Game//104696__grunz__grunz-huh");
            m_huhSound.setVolume(7);

            #region Texture Loading
            t2d_run				= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_run");
            t2d_walk			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_walk");
            t2d_flashWalk		= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_walk");
            t2d_flashIdle		= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_idle");
            t2d_flashTurn		= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_turn");
            t2d_idle			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_idle");
            t2d_pickUpFlash		= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_pick_up_flash");
            t2d_putDownFlash	= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_put_down_flash");
            t2d_strike			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_strike");
            t2d_turn			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_turn");
            t2d_qmark			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//qmark");
            t2d_emark			= Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//Exclmarks");
            #endregion
            if (m_img.isTexture(t2d_flashTurn) || m_img.isTexture(t2d_turn) || m_img.isTexture(t2d_pickUpFlash) || m_img.isTexture(t2d_putDownFlash))
            {
                m_img.setLooping(false);
            }
            if (m_img.isTexture(t2d_walk) || m_img.isTexture(t2d_flashWalk))
            {
                m_img.setAnimationSpeed(WALKINGANIMATIONSPEED);
            }
        }
Exemplo n.º 9
0
 public override void kill()
 {
     base.kill();
     if (m_flashLight != null)
     {
         Game.getInstance().getState().removeObject(m_flashLight);
         m_flashLight.kill();
         m_flashLightId = 0;
         m_flashLight = null;
     }
 }
Exemplo n.º 10
0
        public override void loadContent()
        {
            base.loadContent();
            m_collisionShape = new CollisionRectangle(20, 10, m_img.getSize().X - 40, m_img.getSize().Y - 10, m_position);
            m_lampSwitchTargets = new LinkedList<LampSwitch>();
            if (m_lampSwitchTargetsId == null)
            {
                m_lampSwitchTargetsId = new LinkedList<int>();
            }
            foreach (int t_lsti in m_lampSwitchTargetsId)
            {
                m_lampSwitchTargets.AddLast((LampSwitch)Game.getInstance().getState().getObjectById(t_lsti));
            }
            if (m_flashLightId > 0)
            {
                m_flashLight = (FlashCone)Game.getInstance().getState().getObjectById(m_flashLightId);
                m_flashLight.getPosition().setParentPosition(m_position);
            }
            m_facingRight = m_spriteEffects == SpriteEffects.None;

            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_run");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_walk");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_walk");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_idle");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_flash_turn");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_idle");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_pick_up_flash");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_put_down_flash");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_strike");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//guard_turn");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//qmark");
            Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Guard//Exclmarks");
        }