Exemple #1
0
 public LightCone(GameObject a_parent, string a_sprite, float a_layer, float a_length, float a_width)
     : base((Position)new CartesianCoordinate(Vector2.Zero,a_parent.getPosition()), a_sprite, a_layer, a_parent.getRotation())
 {
     if (a_length <= 0)
     {
         throw new ArgumentException("length has to be positive. was " + a_length);
     }
     if (a_width <= 0)
     {
         throw new ArgumentException("width has to be positive. was " + a_width);
     }
     m_length = a_length;
     m_width = a_width;
     m_XScale = a_length / 500;
     m_YScale = a_width / 500;
     m_imgOffsetY = -m_rotationPoint.Y * m_YScale;
 }
Exemple #2
0
 public LightCone(GameObject a_parent, string a_sprite, float a_offset, float a_layer, float a_length, float a_width, float a_backLayer, string a_backSprite)
     : base((Position)new PolarCoordinate(a_offset, a_parent.getRotation(), a_parent.getPosition()), a_sprite, a_layer, a_parent.getRotation())
 {
     if (a_length <= 0)
     {
         throw new ArgumentException("length has to be positive. was " + a_length);
     }
     if (a_width <= 0)
     {
         throw new ArgumentException("width has to be positive. was " + a_width);
     }
     m_length = a_length;
     m_width = a_width;
     m_XScale = a_length / m_img.getSize().X;
     m_YScale = a_width / m_img.getSize().Y;
     m_imgOffsetY = -m_rotationPoint.Y * m_YScale;
     m_backLayer = a_backLayer;
     if (a_backSprite != null)
     {
         m_backLightSprite = a_backSprite;
         m_backLight = new GameObject(new CartesianCoordinate(Vector2.Zero, m_position), m_backLightSprite, a_backLayer);
         m_backLight.getPosition().setLocalCartesian(-m_backLight.getImg().getSize() / 2f);
     }
 }
Exemple #3
0
 public virtual void removeObject(GameObject a_object)
 {
 }
Exemple #4
0
        public static void copyAsset(Vector2 a_position, GameObject a_asset)
        {
            Vector2 t_position;
            if (a_position == null)
            {
                t_position = a_asset.getPosition().getGlobalCartesian();
            }
            else
            {
                t_position = a_position;
            }
            string t_imagePath = a_asset.getImg().getImagePath();

            if (a_asset is Player)
            {
                createPlayer(t_position);
            }
            if (a_asset is Platform)
            {
                if (a_asset is FlickeringSign)
                {
                    createFlickringSign(t_position, t_imagePath);
                }
                createPlatform(t_position, t_imagePath);
            }
            if (a_asset is Ladder)
            {
                createLadder(t_position, t_imagePath);
            }
            if (a_asset is SpotLight)
            {
                createSpotLight(t_position, t_imagePath);
            }
            if (a_asset is Environment)
            {
                if (a_asset.getImg().getImagePath().StartsWith("Content//Images//Prop//"))
                {
                    createProp(t_position, t_imagePath);
                }
                else if (a_asset is ParallaxEnvironment)
                {
                    createParallax(t_position, t_imagePath);
                }
                else
                {
                    createBackground(t_position, t_imagePath);
                }
            }
            if (a_asset is Guard)
            {
                createGuard(t_position, t_imagePath);
            }
            if (a_asset is Wall)
            {
                createWall(t_position, t_imagePath);
            }
            if (a_asset is DuckHideObject)
            {
                createDuckHideObject(t_position, t_imagePath);
            }
            if (a_asset is StandHideObject)
            {
                createStandHideObject(t_position, t_imagePath);
            }
            if (a_asset is GuardDog)
            {
                createGuardDog(t_position, t_imagePath);
            }
            if (a_asset is LampSwitch)
            {
                createLightSwitch(t_position, t_imagePath);
            }
            if (a_asset is CrossVentilation)
            {
                createCrossVent(t_position, t_imagePath);
            }
            if (a_asset is TVentilation)
            {
                createTVent(t_position, t_imagePath);
            }
            if (a_asset is StraightVentilation)
            {
                createStraightVent(t_position, t_imagePath);
            }
            if (a_asset is CornerVentilation)
            {
                createCornerVent(t_position, t_imagePath);
            }
            if (a_asset is VentilationDrum)
            {
                createVentrance(t_position, t_imagePath);
            }
            if (a_asset is Foreground)
            {
                createForeground(t_position, t_imagePath);
            }
            if (a_asset is Rope)
            {
                createRope(t_position);
            }
            if (a_asset is GuardCamera)
            {
                createCamera(t_position, t_imagePath);
            }
            if (a_asset is Window)
            {
                createWindow(t_position, t_imagePath);
            }
            if (a_asset is SecurityDoor)
            {
                createSecDoor(t_position, t_imagePath);
            }
            if (a_asset is CornerHang)
            {
                createCornerHang(t_position, t_imagePath);
            }
            if (a_asset is CheckPoint)
            {
                createCheckPoint(t_position);
            }
            if (a_asset is Consumable)
            {
                if (a_asset is ConsumableGoal)
                {
                    createObjective(t_position, t_imagePath);
                }
                else if (a_asset is ConsumableKey)
                {
                    createKey(t_position, t_imagePath);
                }
                else if (a_asset is ConsumableHeart)
                {
                    createHeart(t_position, t_imagePath);
                }
                else
                {
                    createConsumable(t_position, t_imagePath);
                }
            }
            if (a_asset is LockedDoor)
            {
                createClosedDoor(t_position, t_imagePath);
            }
            if (a_asset is CoveringShadow)
            {
                createCoveringShadow(t_position, t_imagePath);
            }
            if (a_asset is VentilationEnd)
            {
                createVentEnd(t_position, t_imagePath);
            }
            if (a_asset is LockedDoor)
            {
                createDoor(t_position, t_imagePath);
            }
        }
Exemple #5
0
        private void updateKeyboard()
        {
            if (KeyboardHandler.keyClicked(Keys.Escape))
            {
                guiButtonClick(m_btnSelect);
            }

            if (m_layerTextField.isWriting())
            {
                if (KeyboardHandler.keyClicked(Keys.Enter))
                {
                    m_selectedObject.setLayer(float.Parse(m_layerTextField.getText()) / 1000);
                    clearSelectedObject();
                    m_layerTextField.setWrite(false);
                }
                return;
            }

            if (m_parallaxScrollTF.isWriting())
            {
                if (KeyboardHandler.keyClicked(Keys.Enter) && m_selectedObject != null && m_selectedObject is ParallaxEnvironment)
                {
                    ((ParallaxEnvironment)m_selectedObject).setParrScroll(Math.Max(- int.Parse(m_parallaxScrollTF.getText()), -100000));
                    clearSelectedObject();
                    m_parallaxScrollTF.setWrite(false);
                }
                return;
            }

            if (KeyboardHandler.keyClicked(Keys.F5))
            {
                m_currentLayer = 0;
                Game.getInstance().setState(new GameState(m_levelToLoad));
            }

            if (KeyboardHandler.keyClicked(Keys.F6))
            {
                m_currentLayer = 0;
                Game.getInstance().setState(new EventDevelopment(this, m_events));
            }

            if (KeyboardHandler.ctrlMod())
            {
                if (KeyboardHandler.keyClicked(Keys.S))
                {
                    if (m_selectedObject != null)
                    {
                        m_selectedObject.setColor(Color.White);
                        m_selectedObject = null;
                    }
                    Level t_saveLevel = new Level();
                    t_saveLevel.setLevelObjects(m_gameObjectList);
                    t_saveLevel.setEvents(m_events);
                    Serializer.getInstance().SaveLevel(Serializer.getInstance().getFileToStream(m_levelToLoad, true), t_saveLevel);
                }

                if (KeyboardHandler.keyClicked(Keys.O))
                {
                    Level t_newLevel = Serializer.getInstance().loadLevel(Serializer.getInstance().getFileToStream(m_levelToLoad, false));
                    m_gameObjectList = t_newLevel.getGameObjects();
                    foreach (LinkedList<GameObject> t_arr in m_gameObjectList)
                    {
                        foreach (GameObject f_gb in t_arr)
                        {
                            f_gb.loadContent();
                        }
                    }
                }

                if (KeyboardHandler.keyClicked(Keys.C))
                {
                    if (m_selectedObject != null)
                    {
                        m_copyTarget = m_selectedObject;
                    }
                }

                if (KeyboardHandler.keyClicked(Keys.V))
                {
                    if (m_copyTarget != null)
                    {
                        AssetFactory.copyAsset(m_copyTarget.getPosition().getGlobalCartesian(), m_copyTarget);
                    }
                }

                if (KeyboardHandler.keyClicked(Keys.N) && m_selectedObject != null)
                {
                    if (m_selectedObject is Window)
                    {
                        ((Window)m_selectedObject).toggleOpen();
                    }
                    else if (m_selectedObject is VentilationDrum)
                    {
                        ((VentilationDrum)m_selectedObject).toggleLocked();
                    }
                    else if (m_selectedObject is Guard)
                    {
                        ((Guard)m_selectedObject).toggleFlashLightAddicted();
                    }
                    else if (m_selectedObject is Consumable)
                    {
                        ((Consumable)m_selectedObject).toggleBling();
                    }
                    else if (m_selectedObject is Environment)
                    {
                        ((Environment)m_selectedObject).toggleMapVisible();
                    }
                    m_textObjectInfo.setText(m_selectedObject.ToString());
                }

                if (KeyboardHandler.keyClicked(Keys.F))
                {
                    if (m_selectedObject != null && m_selectedObject is Guard)
                    {
                        ((Guard)m_selectedObject).toggleFlashLightAddicted();
                        m_textObjectInfo.setText(m_selectedObject.ToString());
                    }
                }
            }

            if (KeyboardHandler.keyClicked(Keys.R))
            {
                if (m_selectedObject != null)
                {
                    m_selectedObject.addRotation((float)(Math.PI) / 2.0f);
                }
            }

            if (KeyboardHandler.keyClicked(Keys.Y))
            {
                if (m_selectedObject != null)
                {
                    m_selectedObject.flip();
                }
            }

            if (KeyboardHandler.keyClicked(Keys.M))
            {
                if (m_selectedObject != null)
                {
                    if (m_selectedObject is LampSwitch)
                    {
                        ((LampSwitch)m_selectedObject).toggleConnectToAll();
                        showLightSwitchInfo((LampSwitch)m_selectedObject);
                    }
                }
            }

            if (KeyboardHandler.keyClicked(Keys.Space))
            {
                if (m_gameObjectList != null)
                {
                    Game.getInstance().m_camera.setPosition(Vector2.Zero);
                }
            }
        }
Exemple #6
0
 public override void addObject(GameObject a_object)
 {
     m_gameObjectList[m_currentLayer].AddLast(a_object);
 }
Exemple #7
0
        private void selectAsset(Button a_button)
        {
            string t_newAsset = "";
            Vector2 t_assetPosition = m_worldMouse + new Vector2(-36, -36);

            if (a_button != null)
            {
                t_newAsset = a_button.getText();
                foreach (Button t_button in m_assetButtonList)
                {
                    t_button.setState(0);
                }
                a_button.setState(3);
            }

            switch (m_itemToCreate)
            {
                case State.Platform:
                    m_objectPreview = new Platform(t_assetPosition, "Images//Tile//Floor//" + t_newAsset, 0.000f);
                    break;
                case State.Wall:
                    m_objectPreview = new Wall(t_assetPosition, "Images//Tile//Wall//" + t_newAsset, 0.000f);
                    break;
                case State.Delete:
                    m_objectPreview = null;
                    break;
                case State.Guard:
                    m_objectPreview = new Guard(t_assetPosition, "Images//Sprite//Guard//guard_idle", m_worldMouse.X, true, 0.000f);
                    break;
                case State.Ladder:
                    m_objectPreview = new Ladder(t_assetPosition, "Images//Tile//Ladder//" + t_newAsset, 0.000f);
                    break;
                case State.None:
                    m_objectPreview = null;
                    break;
                case State.Player:
                    m_objectPreview = new Player(t_assetPosition, "Images//Sprite//Hero//hero_stand", 0.000f);
                    break;
                case State.SpotLight:
                    m_objectPreview = new SpotLight(t_assetPosition, "Images//LightCone//" + t_newAsset, 0.000f, 0.0f, false);
                    break;
                case State.Background:
                    m_objectPreview = new Environment(t_assetPosition, "Images//Background//" + t_newAsset, 0.000f);
                    break;
                case State.DuckHidingObject:
                    m_objectPreview = new DuckHideObject(t_assetPosition, "Images//Prop//DuckHide//" + t_newAsset, 0.000f);
                    break;
                case State.StandHidingObject:
                    m_objectPreview = new StandHideObject(t_assetPosition, "Images//Prop//StandHide//" + t_newAsset, 0.000f);
                    break;
                case State.GuardDog:
                    m_objectPreview = new GuardDog(t_assetPosition, "Images//Sprite//GuardDog//" + t_newAsset, m_worldMouse.X, m_worldMouse.X, 0.000f);
                    break;
                case State.LightSwitch:
                    m_objectPreview = new LampSwitch(t_assetPosition, "Images//Prop//Button//" + t_newAsset, 0.000f);
                    break;
                case State.CrossVent:
                    m_objectPreview = new CrossVentilation(t_assetPosition, "Images//Tile//Ventilation//Cross//" + t_newAsset, 0.000f);
                    break;
                case State.CornerVent:
                    m_objectPreview = new CornerVentilation(t_assetPosition, "Images//Tile//Ventilation//Corner//" + t_newAsset, 0.000f);
                    break;
                case State.StraVent:
                    m_objectPreview = new StraightVentilation(t_assetPosition, "Images//Tile//Ventilation//Straight//" + t_newAsset, 0.000f);
                    break;
                case State.TVent:
                    m_objectPreview = new TVentilation(t_assetPosition, "Images//Tile//Ventilation//TVent//" + t_newAsset, 0.000f);
                    break;
                case State.Ventrance:
                    m_objectPreview = new VentilationDrum(t_assetPosition, "Images//Tile//Ventilation//Drum//" + t_newAsset, 0.000f);
                    break;
                case State.Window:
                    m_objectPreview = new Window(t_assetPosition, "Images//Tile//Window//" + t_newAsset, 0.000f);
                    break;
                case State.Foreground:
                    m_objectPreview = new Foreground(t_assetPosition, "Images//Foregrounds//" + t_newAsset, 0.000f);
                    break;
                case State.CornerHang:
                    m_objectPreview = new CornerHang(t_assetPosition, "Images//Automagi//cornerthingy", 0.000f);
                    break;
                case State.Checkpoint:
                    m_objectPreview = new CheckPoint(t_assetPosition, "Images//Prop//Clutter//backdrop_door", 0.000f);
                    break;
                case State.Camera:
                    m_objectPreview = new GuardCamera(t_assetPosition, "Images//Sprite//Camera//camera", 0.200f, (float)(Math.PI * 0.5), (float)(Math.PI * 0.75), (float)(Math.PI * 0.25), false);
                    break;
                case State.Prop:
                    m_objectPreview = new Environment(t_assetPosition, "Images//Prop//Clutter//" + t_newAsset, 0.000f);
                    break;
                case State.Rope:
                    m_objectPreview = new Rope(t_assetPosition, "", 0.000f);
                    break;
                case State.Heart:
                    m_objectPreview = new ConsumableHeart(t_assetPosition, "Images//Prop//Consumables//shinyheart", 0.000f);
                    break;
                case State.Key:
                    m_objectPreview = new ConsumableKey(t_assetPosition, "Images//Automagi//derp_key", 0.000f);
                    break;
                case State.Objective:
                    m_objectPreview = new ConsumableGoal(t_assetPosition, "Images//Prop//Consumables//Objective//" + t_newAsset, 0.000f);
                    break;
                case State.Shadow:
                    m_objectPreview = new CoveringShadow(t_assetPosition, "Images//Foregrounds//Shadow//" + t_newAsset, 0.000f);
                    break;
                case State.EndVent:
                    m_objectPreview = new VentilationEnd(t_assetPosition, "Images//Tile//Ventilation//EndVent//" + t_newAsset, 0.000f);
                    break;
                case State.Parallax:
                    m_objectPreview = new ParallaxEnvironment(t_assetPosition, "Images//Background//Parallax//" + t_newAsset, 0.000f);
                    break;
                case State.LockedDoor:
                    m_objectPreview = new LockedDoor(t_assetPosition, "Images//Prop//SecurityDoor//door", 0.000f);
                    break;
                case State.FlickeringSign:
                    m_objectPreview = new FlickeringSign(t_assetPosition, "Images//Tile//Sign//" + t_newAsset, 0.000f);
                    break;
                case State.Consumable:
                    m_objectPreview = new Consumable(t_assetPosition, "Images//Prop//Consumables//" + t_newAsset, 0.000f);
                    break;
            }
        }
Exemple #8
0
 public override void setPlayer(Player a_player)
 {
     m_player = a_player;
 }
Exemple #9
0
 public override void removeObject(GameObject a_object)
 {
     for (int i = 0; i < m_gameObjectList.Length; i++)
     {
         m_gameObjectList[i].Remove(a_object);
     }
 }
Exemple #10
0
 public override void addObject(GameObject a_object, int a_layer)
 {
     m_addList[a_layer].Push(a_object);
 }
Exemple #11
0
 public override void addObject(GameObject a_object)
 {
     m_addList[m_currentList].Push(a_object);
 }
Exemple #12
0
 public bool collidesWith(GameObject a_gameObject)
 {
     return a_gameObject.getBox().Intersects(getBox());
 }
Exemple #13
0
 public virtual void addObject(GameObject a_object, int a_layer)
 {
 }
Exemple #14
0
 public virtual void addObject(GameObject a_object)
 {
 }
Exemple #15
0
 public virtual void removeObject(GameObject a_object, int a_layer)
 {
 }
Exemple #16
0
        public void deleteObject(GameObject a_gameObject)
        {
            a_gameObject.kill();

            if (a_gameObject is SpotLight)
            {
                LightCone t_lightCone = ((SpotLight)a_gameObject).getLightCone();
                for (int i = 0; i < m_gameObjectList.Length; i++)
                {
                    foreach (GameObject t_gameObject in m_gameObjectList[i])
                    {
                        if (t_gameObject is LampSwitch && ((LampSwitch)t_gameObject).isConnectedTo((SpotLight)a_gameObject))
                        {
                            ((LampSwitch)t_gameObject).disconnectSpotLight((SpotLight)a_gameObject);
                        }
                    }
                }
                if (t_lightCone != null)
                {
                    for (int i = 0; i < m_gameObjectList.Length; i++)
                    {
                        m_gameObjectList[i].Remove(t_lightCone);
                    }
                }
            }
            m_gameObjectList[m_currentLayer].Remove(a_gameObject);

            if (a_gameObject is Player)
            {
                Game.getInstance().getState().setPlayer(null);
            }
            m_selectedInfoV2 = Vector2.Zero;
            m_selectedObject = null;
        }
Exemple #17
0
        public override void load()
        {
            if (File.Exists("Content\\levels\\" + m_levelToLoad))
            {
                Level t_loadedLevel = Loader.getInstance().loadLevel(m_levelToLoad);

                m_gameObjectList = t_loadedLevel.getGameObjects();
                m_events = t_loadedLevel.getEvents();
            }
            else
            {
                m_events = new LinkedList<Event>();
                for (int i = 0; i < m_gameObjectList.Length; ++i)
                {
                    m_gameObjectList[i] = new LinkedList<GameObject>();
                }
            }

            foreach (LinkedList<GameObject> t_ll in m_gameObjectList)
            {
                for (int i = 0; i < t_ll.Count(); i++)
                {
                    t_ll.ElementAt(i).loadContent();
                    if (t_ll.ElementAt(i) is Player)
                    {
                        m_player = t_ll.ElementAt(i);
                        Game.getInstance().m_camera.setPosition(m_player.getPosition().getGlobalCartesian());
                    }
                }
            }

            foreach (Event t_e in m_events)
            {
                t_e.loadContent();
            }

            m_buttonDict = new Dictionary<Button, State>();
            m_assetButtonList = new LinkedList<Button>();

            m_lineList			= new LinkedList<Line>();
            m_objectPreview		= null;

            m_guiList.AddLast(m_layerLabel			= new Text(new Vector2(350, 3)	, "", "VerdanaBold", Color.Black, false));
            m_guiList.AddLast(m_parallaxLabel		= new Text(new Vector2(460, 3)	, "Parallax Value:", "VerdanaBold", Color.Black, false));
            m_guiList.AddLast(m_textObjectInfo		= new Text(new Vector2(10, 3)	, "", "VerdanaBold", Color.Black, false));
            m_guiList.AddLast(m_textGuardInfo		= new Text(new Vector2(480, 3)	, "", "VerdanaBold", Color.Black, false));
            m_layerTextField	= new TextField(new Vector2(400, 0), 50, 25, false, true, false, 3);
            m_parallaxScrollTF	= new TextField(new Vector2(580, 0), 70, 25, false, true, false, 3);
            m_statusBar	= new Box(new Vector2(0, 0), (int)Game.getInstance().getResolution().X, 25, Color.LightGray, false);
            m_statusBar.setLayer(0.111f);

            Vector2 t_btnTextOffset = new Vector2(21, 17);
            Vector2 t_modV2 = new Vector2(15, 0);
            Button t_button;
            //-----------------------------------
            #region Buttons that are always shown
            m_buttonDict.Add(m_btnSelect = new Button("DevelopmentHotkeys//btn_select_hotkey", new Vector2(0, 32 * m_buttonDict.Count() + 25), "S", "VerdanaBold", Color.Black, t_btnTextOffset), State.None);
            m_btnSelect.setHotkey(new Keys[] { Keys.S }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_delete_hotkey", new Vector2(0, 32 * m_buttonDict.Count() + 25), "D", "VerdanaBold", Color.Black, t_btnTextOffset), State.Delete);
            t_button.setHotkey(new Keys[] { Keys.D }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Building mode buttons
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_ladder_hotkey",		new Vector2(0, 32 * m_buttonDict.Count() + 25), "L", "VerdanaBold", Color.Black, t_btnTextOffset), State.Ladder);
            t_button.setHotkey(new Keys[] { Keys.L }, guiButtonClick);
            m_buttonDict.Add(t_button	= new Button("DevelopmentHotkeys//btn_platform_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "P", "VerdanaBold", Color.Black, t_btnTextOffset), State.Platform);
            t_button.setHotkey(new Keys[] { Keys.P }, guiButtonClick);
            m_buttonDict.Add(m_btnBackground = new Button("DevelopmentHotkeys//btn_background_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "B", "VerdanaBold", Color.Black, t_btnTextOffset), State.Background);
            m_btnBackground.setHotkey(new Keys[] { Keys.B }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_hero_hotkey",		new Vector2(0, 32 * m_buttonDict.Count() + 25), "H", "VerdanaBold", Color.Black, t_btnTextOffset), State.Player);
            t_button.setHotkey(new Keys[] { Keys.H }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_spotlight_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "T", "VerdanaBold", Color.Black, t_btnTextOffset), State.SpotLight);
            t_button.setHotkey(new Keys[] { Keys.T }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_wall_hotkey",		new Vector2(0, 32 * m_buttonDict.Count() + 25), "W", "VerdanaBold", Color.Black, t_btnTextOffset), State.Wall);
            t_button.setHotkey(new Keys[] { Keys.W }, guiButtonClick);
            m_buttonDict.Add(t_button= new Button("DevelopmentHotkeys//btn_lightswitch_hotkey", new Vector2(0, 32 * m_buttonDict.Count() + 25), "s+T", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.LightSwitch);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.T }, guiButtonClick);
            m_buttonDict.Add(m_btnVent = new Button("DevelopmentHotkeys//btn_ventilation_hotkey", new Vector2(0, 32 * m_buttonDict.Count() + 25), "V", "VerdanaBold", Color.Black, t_btnTextOffset), State.Ventrance);
            m_btnVent.setHotkey(new Keys[] { Keys.V }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_window_hotkey",		new Vector2(0, 32 * m_buttonDict.Count() + 25), "N", "VerdanaBold", Color.Black, t_btnTextOffset), State.Window);
            t_button.setHotkey(new Keys[] { Keys.N }, guiButtonClick);
            m_buttonDict.Add(m_btnGuard = new Button("DevelopmentHotkeys//btn_guard_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "G", "VerdanaBold", Color.Black, t_btnTextOffset), State.Guard);
            m_btnGuard.setHotkey(new Keys[] { Keys.G }, guiButtonClick);
            m_buttonDict.Add(m_btnDuckHide = new Button("DevelopmentHotkeys//btn_duckhide_hotkey", new Vector2(0, 32 * m_buttonDict.Count() + 25), "A", "VerdanaBold", Color.Black, t_btnTextOffset), State.DuckHidingObject);
            m_btnDuckHide.setHotkey(new Keys[] { Keys.A }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_foreground_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "F", "VerdanaBold", Color.Black, t_btnTextOffset), State.Foreground);
            t_button.setHotkey(new Keys[] { Keys.F }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_rope_hotkey",		new Vector2(0, 32 * m_buttonDict.Count() + 25), "O", "VerdanaBold", Color.Black, t_btnTextOffset), State.Rope);
            t_button.setHotkey(new Keys[] { Keys.O }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_doorhang_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "s+W", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.CornerHang);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.W }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_checkpoint_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "K", "VerdanaBold", Color.Black, t_btnTextOffset), State.Checkpoint);
            t_button.setHotkey(new Keys[] { Keys.K }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_clutter_hotkey",	new Vector2(0, 32 * m_buttonDict.Count() + 25), "C", "VerdanaBold", Color.Black, t_btnTextOffset), State.Prop);
            t_button.setHotkey(new Keys[] { Keys.C }, guiButtonClick);
            m_buttonDict.Add(m_btnConsKey = new Button(null, new Vector2(0, 32 * m_buttonDict.Count() + 25), "c+A", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Consumable);
            m_btnConsKey.setHotkey(new Keys[] { Keys.LeftControl, Keys.A }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button(null, new Vector2(0, 32 * m_buttonDict.Count() + 25), "s+D", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.LockedDoor);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.D }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button(null, new Vector2(0, 32 * m_buttonDict.Count() + 25), "c+F", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.FlickeringSign);
            t_button.setHotkey(new Keys[] { Keys.LeftControl, Keys.F }, guiButtonClick);

            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Ventilation buttons
            Vector2 t_ventMenu = new Vector2(m_btnVent.getBox().X + 32, m_btnVent.getBox().Y);
            int t_buttonNumber = 0;

            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_tvent_hotkey", t_ventMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+V", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.TVent);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.V }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_svent_hotkey", t_ventMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+A", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.StraVent);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.A }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_cvent_hotkey", t_ventMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+C", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.CrossVent);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.C }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_ovent_hotkey", t_ventMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+R", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.CornerVent);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.R }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button(null, t_ventMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+E", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.EndVent);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.E }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Hiding object buttons
            t_buttonNumber = 0;
            Vector2 t_hideMenu = new Vector2(m_btnDuckHide.getBox().X + 32, m_btnDuckHide.getBox().Y);

            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_standhide_hotkey", t_hideMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+F", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.StandHidingObject);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.F }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Guard object buttons
            t_buttonNumber = 0;
            Vector2 t_guardMenu = new Vector2(m_btnGuard.getBox().X + 32, m_btnGuard.getBox().Y);

            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_dog_hotkey", t_guardMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+G", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.GuardDog);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.G }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_camera_hotkey", t_guardMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+Q", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Camera);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.Q }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Consumable Buttons
            t_buttonNumber = 0;
            Vector2 t_consMenu = new Vector2(m_btnConsKey.getBox().X + 32, m_btnConsKey.getBox().Y);

            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_key_hotkey", t_consMenu + new Vector2(t_buttonNumber++ * 32, 0), "Z", "VerdanaBold", Color.Black, t_btnTextOffset), State.Key);
            t_button.setHotkey(new Keys[] { Keys.Z }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button("DevelopmentHotkeys//btn_heart_hotkey", t_consMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+H", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Heart);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.H }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button(null, t_consMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+B", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Objective);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.B }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Background Buttons
            t_buttonNumber = 0;
            Vector2 t_bgMenu = new Vector2(m_btnBackground.getBox().X + 32, m_btnBackground.getBox().Y);

            m_buttonDict.Add(t_button = new Button(null, t_bgMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+X", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Shadow);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.X }, guiButtonClick);
            m_buttonDict.Add(t_button = new Button(null, t_bgMenu + new Vector2(t_buttonNumber++ * 32, 0), "s+Z", "VerdanaBold", Color.Black, t_btnTextOffset - t_modV2), State.Parallax);
            t_button.setHotkey(new Keys[] { Keys.LeftShift, Keys.Z }, guiButtonClick);
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Layer buttons
            m_buttonList.AddLast(m_layerButtonList = GuiListFactory.createNumeratedList(5, "DevelopmentHotkeys//btn_layer_chooser"));
            GuiListFactory.setListPosition(m_layerButtonList, new Vector2(40, Game.getInstance().getResolution().Y - (m_layerButtonList.First().getBox().Height)));
            GuiListFactory.setButtonDistance(m_layerButtonList, new Vector2(73, 0));
            GuiListFactory.setTextOffset(m_layerButtonList, new Vector2(34, 8));

            int k = 1;
            foreach (Button t_feButton in m_layerButtonList)
            {
                t_feButton.setHotkey(new Keys[] { (Keys)Enum.Parse(typeof(Keys), "D" + k++) }, setLayer);
            }
            #endregion
            //-----------------------------------

            setBuildingState(m_btnSelect, State.None);

            base.load();
        }
Exemple #18
0
 public override void moveObjectToLayer(GameObject a_go, int a_layer)
 {
     if (m_gameObjectList[a_go.getListLayer()].Contains(a_go))
     {
         removeObject(a_go, a_go.getListLayer());
         addObject(a_go, a_layer);
     }
     else
     {
         #if RELEASE
         ErrorLogger.getInstance().writeString("could not find " + a_go + " while changeing its layer. searches for it in other layers");
         #endif
         for (int i = 0; i < 5; ++i)
         {
             if (m_gameObjectList[i].Contains(a_go))
             {
                 addObject(a_go, a_layer);
                 removeObject(a_go, i);
                 return;
             }
         }
         throw new ArgumentException(a_go + " was not found");
     }
 }
Exemple #19
0
 public override void removeObject(GameObject a_object, int a_layer)
 {
     m_gameObjectList[a_layer].Remove(a_object);
 }
Exemple #20
0
 public override bool objectIsOnLayer(GameObject a_obj, int a_layer)
 {
     return m_gameObjectList[a_layer].Contains(a_obj);
 }
Exemple #21
0
 private void clearSelectedObject()
 {
     if (m_selectedObject != null)
     {
         m_selectedObject.setColor(Color.White);
         m_selectedObject = null;
         m_selectedInfoV2 = Vector2.Zero;
         m_layerLabel.setText("");
         m_textObjectInfo.setText("");
     }
     m_parallaxLabel.setVisible(false);
     m_parallaxScrollTF.setVisible(false);
     m_objectPreview = null;
     m_lineList.Clear();
 }
Exemple #22
0
 public override void removeObject(GameObject a_object)
 {
     m_removeList[m_currentList].Push(a_object);
 }
Exemple #23
0
        private void setBuildingState(Button a_button, State a_state)
        {
            m_building			= true;
            m_objectPreview		= null;

            if (a_state != m_itemToCreate)
            {
                clearSelectedObject();
                m_itemToCreate = a_state;
            }

            foreach (Button t_button in m_buttonDict.Keys)
            {
                t_button.setState(0);
            }
            a_button.setState(3);

            switch (m_itemToCreate)
            {
                case State.Platform:
                    createAssetList("Content//Images//Tile//Floor//");
                    break;
                case State.Ladder:
                    createAssetList("Content//Images//Tile//Ladder//");
                    break;
                case State.Background:
                    createAssetList("Content//Images//Background//");
                    break;
                case State.Delete:
                    createAssetList(null);
                    m_building = false;
                    break;
                case State.Player:
                    createAssetList(null);
                    break;
                case State.None:
                    createAssetList(null);
                    m_building = false;
                    break;
                case State.SpotLight:
                    createAssetList("Content//Images//LightCone//");
                    break;
                case State.Guard:
                    createAssetList(null);
                    break;
                case State.Wall:
                    createAssetList("Content//Images//Tile//Wall//");
                    break;
                case State.DuckHidingObject:
                    createAssetList("Content//Images//Prop//DuckHide//");
                    break;
                case State.StandHidingObject:
                    createAssetList("Content//Images//Prop//StandHide//");
                    break;
                case State.GuardDog:
                    createAssetList("Content//Images//Sprite//GuardDog//");
                    break;
                case State.LightSwitch:
                    createAssetList("Content//Images//Prop//Button//");
                    break;
                case State.CrossVent:
                    createAssetList("Content//Images//Tile//Ventilation//Cross//");
                    break;
                case State.CornerVent:
                    createAssetList("Content//Images//Tile//Ventilation//Corner//");
                    break;
                case State.TVent:
                    createAssetList("Content//Images//Tile//Ventilation//TVent//");
                    break;
                case State.StraVent:
                    createAssetList("Content//Images//Tile//Ventilation//Straight//");
                    break;
                case State.Ventrance:
                    createAssetList("Content//Images//Tile//Ventilation//Drum//");
                    break;
                case State.EndVent:
                    createAssetList("Content//Images//Tile//Ventilation//EndVent//");
                    break;
                case State.Camera:
                    createAssetList("Content//Images//Sprite//Camera//");
                    break;
                case State.Window:
                    createAssetList("Content//Images//Tile//Window//");
                    break;
                case State.Foreground:
                    createAssetList("Content//Images//Foregrounds//");
                    break;
                case State.Rope:
                    createAssetList(null);
                    break;
                case State.CornerHang:
                    createAssetList(null);
                    break;
                case State.Checkpoint:
                    createAssetList(null);
                    break;
                case State.Prop:
                    createAssetList("Content//Images//Prop//Clutter//");
                    break;
                case State.Key:
                    createAssetList(null);
                    break;
                case State.Heart:
                    createAssetList(null);
                    break;
                case State.Objective:
                    createAssetList("Content//Images//Prop//Consumables//Objective//");
                    break;
                case State.Shadow:
                    createAssetList("Content//Images//Foregrounds//Shadow//");
                    break;
                case State.Parallax:
                    createAssetList("Content//Images//Background//Parallax//");
                    break;
                case State.LockedDoor:
                    createAssetList(null);
                    break;
                case State.FlickeringSign:
                    createAssetList("Content//Images//Tile//Sign//");
                    break;
                case State.Consumable:
                    createAssetList("Content//Images//Prop//Consumables//");
                    break;
            }
            if (m_assetButtonList != null && m_assetButtonList.Count > 0)
            {
                selectAsset(m_assetButtonList.First());
            }
            else
            {
                selectAsset(null);
            }
        }
Exemple #24
0
 public override void removeObject(GameObject a_object, int a_layer)
 {
     m_removeList[a_layer].Push(a_object);
 }
Exemple #25
0
 public override void addObject(GameObject a_object, int a_layer)
 {
     m_gameObjectList[a_layer].AddLast(a_object);
 }
Exemple #26
0
        /*
        Update-metod, går igenom alla objekt i scenen och kallas på deras update
        och kollar sedan om de ska dö och läggs därefter i dödslistan.
        Dödslistan loopas sedan igenom och tar bort de objekt som ska dö ifrån
        objektlistan.
        */
        public override void update(GameTime a_gameTime)
        {
            m_currentList = -1;

            if (KeyboardHandler.keyClicked(Keys.I))
            {
                Game.getInstance().m_camera.printInfo();
            }
            else if (KeyboardHandler.ctrlMod())
            {
                if (KeyboardHandler.keyClicked(Keys.E))
                {
                    if (!Game.getInstance().getProgress().hasEquipment("hookshot"))
                        Game.getInstance().getProgress().setEquipment("hookshot", true);
                    else
                        Game.getInstance().getProgress().setEquipment("hookshot", false);
                }
                else if (KeyboardHandler.keyClicked(Keys.W))
                {
                    if (!Game.getInstance().getProgress().hasEquipment("boots"))
                        Game.getInstance().getProgress().setEquipment("boots", true);
                    else
                        Game.getInstance().getProgress().setEquipment("boots", false);
                }
                else if (KeyboardHandler.keyClicked(Keys.Q))
                {
                    Game.getInstance().setState(new DevelopmentState(m_currentLevel));
                }
            }
            else if (KeyboardHandler.keyClicked(Keys.F5))
            {
                Game.getInstance().setState(new GameState(m_currentLevel));
                Game.getInstance().m_camera.setLayer(0);
            }
            else if (KeyboardHandler.keyClicked(Keys.M) ||
                KeyboardHandler.keyClicked(Keys.Space) ||
                KeyboardHandler.keyClicked(Keys.Escape))
            {
                Game.getInstance().setState(new MapState(this));
                new Sound("Game//Karta").play();
            }

            foreach (LinkedList<GameObject> t_list in m_gameObjectList)
            {
                ++m_currentList;
                foreach (GameObject t_gameObject in t_list)
                {
                    #if DEBUG
                        t_gameObject.update(a_gameTime);
                    #else
                        try
                        {
                            t_gameObject.update(a_gameTime);
                        }
                        catch (Exception e)
                        {
                            ErrorLogger.getInstance().writeString("While updating " + t_gameObject + " got exception: " + e);
                        }
                    #endif
                    if (t_gameObject == m_finishFeedback && m_finishFeedback.isDead())
                    {
                        finishLevel();
                        return;
                    }
                }
            }

            m_currentList = -1;
            foreach (LinkedList<GameObject> t_list in m_gameObjectList)
            {
                ++m_currentList;
                foreach (GameObject t_firstGameObject in t_list)
                {
                    if (t_firstGameObject is MovingObject && (Game.getInstance().m_camera.isInCamera(t_firstGameObject) ||
                        (t_firstGameObject is NPE && (((NPE)t_firstGameObject).getAIState() is AIStateChasing || ((NPE)t_firstGameObject).getAIState() is AIStateChargeing))))
                    {
                        List<Entity> t_collided = new List<Entity>();
                        foreach (GameObject t_secondGameObject in t_list)
                        {
                            if (t_secondGameObject is Entity && t_firstGameObject != t_secondGameObject
                                && ((Entity)t_firstGameObject).getHitBox() != null && ((Entity)t_secondGameObject).getHitBox() != null
                                && checkBigBoxCollision(((Entity)t_firstGameObject).getHitBox().getOutBox(), ((Entity)t_secondGameObject).getHitBox().getOutBox()))
                            {
                                t_collided.Add((Entity)t_secondGameObject);
                            }
                        }
                        ((MovingObject)t_firstGameObject).collisionCheck(t_collided);
                        ((Entity)t_firstGameObject).updatePosition();
                    }
                    else if (t_firstGameObject is Entity)
                    {
                        ((Entity)t_firstGameObject).setGravity(0.0f);
                        ((Entity)t_firstGameObject).setSpeedY(0.0f);
                    }

                    if (t_firstGameObject.isDead() && !m_removeList[m_currentList].Contains(t_firstGameObject))
                    {
                        m_removeList[m_currentList].Push(t_firstGameObject);
                    }
                }
                while (m_addList[m_currentList].Count > 0)
                {
                    GameObject t_goToAdd = m_addList[m_currentList].Pop();
                    if (!t_list.Contains(t_goToAdd))
                    {
                        t_goToAdd.setListLayer(m_currentList);
                        t_list.AddLast(t_goToAdd);
                    }
                }

                while (m_removeList[m_currentList].Count > 0)
                {
                    GameObject t_objectToRemove = m_removeList[m_currentList].Pop();
                    if (t_objectToRemove is ConsumableGoal)
                    {
                        m_finishCond.Remove((ConsumableGoal)t_objectToRemove);
                        if (m_finishCond.Count == 0)
                        {
                            m_finishFeedback = ((ConsumableGoal)t_objectToRemove).getFeedback();
                        }
                    }
                    t_list.Remove(t_objectToRemove);
                }

                LinkedListNode<Event> t_eventNode = m_events.First;
                while (t_eventNode != null)
                {
                    LinkedListNode<Event> t_next = t_eventNode.Next;
                    #if DEBUG
                    if (t_eventNode.Value.Execute())
                    {
                        m_events.Remove(t_eventNode);
                    }
                    #else
                    try
                    {
                        if (t_eventNode.Value.Execute())
                        {
                            m_events.Remove(t_eventNode);
                        }
                    }
                    catch (Exception e)
                    {
                        ErrorLogger.getInstance().writeString("While updating " + t_eventNode.Value + " got exception: " + e);
                    }
                    #endif
                    t_eventNode = t_next;
                }

                if (player != null)
                {
                    LinkedListNode<Environment> t_enviroNode = m_unexplored.First;
                    while (t_enviroNode != null)
                    {
                        LinkedListNode<Environment> t_next = t_enviroNode.Next;
                        if (t_enviroNode.Value.collidesWith(player) && player.getListLayer() == t_enviroNode.Value.getListLayer())
                        {
                            t_enviroNode.Value.setExplored(true);
                            m_unexplored.Remove(t_enviroNode);
                        }
                        t_enviroNode = t_next;
                    }
                }
            }
        }
Exemple #27
0
 public bool isInCamera(GameObject a_gameObject)
 {
     return CollisionManager.Contains(m_cameraBox, a_gameObject.getPosition().getGlobalCartesian());
 }
Exemple #28
0
        public override void loadContent()
        {
            base.loadContent();
            if (!(Game.getInstance().getState() is DevelopmentState))
            {
                addHearts();
            }

            string[] t_heroSprites = Directory.GetFiles("Content//Images//Sprite//Hero//");
            foreach (string t_file in t_heroSprites)
            {
                string[] t_splitFile = Regex.Split(t_file, "//");
                string[] t_extless = t_splitFile[t_splitFile.Length - 1].Split('.');
                if (t_extless[1].Equals("xnb"))
                {
                    Game.getInstance().Content.Load<Texture2D>("Images//Sprite//Hero//" + t_extless[0]);
                }
            }

            m_img = new ImageManager("Images//Sprite//Hero//hero_stand");

            m_interactionArrow = new GameObject(new CartesianCoordinate(new Vector2(15, -70), m_position), "Images//GUI//GameGUI//interaction", m_layer - 0.1f, m_listLayer);
            setInteractionVisibility(false);
            m_interactionArrow.getImg().setAnimationSpeed(20f);
            m_standHitBox	= new CollisionRectangle(0, 0, 70, 127, m_position);
            m_rollHitBox	= new CollisionRectangle(0, 0, 70, 72, m_position);
            m_slideBox		= new CollisionRectangle(0, m_standHitBox.getOutBox().Height / 2, m_standHitBox.getOutBox().Width, 1, m_position);
            m_hangHitBox	= new CollisionRectangle(0, 0, 70, 80, m_position);
            m_swingHitBox	= new CollisionRectangle(-36, 0, 70, 127, m_position);
            m_collisionShape = m_standHitBox;
            m_ventilationDirection	= new List<Direction>();
            m_upDownList			= new List<Direction>();
            m_leftRightList			= new List<Direction>();
            m_noneList				= new List<Direction>();
            m_lastVentilationDirection = Direction.None;
            m_upDownList.Add(Direction.Up);
            m_upDownList.Add(Direction.Down);
            m_leftRightList.Add(Direction.Left);
            m_leftRightList.Add(Direction.Right);
            m_noneList.Add(Direction.None);
            m_playerCurrentSpeed = PLAYERSPEED;
            m_swingSpeed = 0;
            m_slideTimer = 0;
            m_currentVentilationImage = VENTIDLEIMAGE;
            m_currentSwingingImage = "hero_swing_still";
            m_position.plusYWith(-1);
            m_facingRight = true;

            m_hitSound1 = new Sound("Game//FirstHit");
            m_hitSound2 = new Sound("Game//SecHit");
            m_hitSound3 = new Sound("Game//LethalHit");
            m_jumpSound = new Sound("Game//hopp");
            m_landSound = new Sound("Game//landa2");
            m_landSound.setVolume(10);
            m_slideSound = new Sound("Game//32584__redjim__fabric-rustling");
            m_slideSound.setLooping(true);
            m_hangSound = new Sound("Game/ledgegrab");
            m_stepSound = new Sound("Game//walk");
            m_runSound = new Sound("Game//walk4");
            m_hideSound = new Sound("Game//hopp");
            m_ventilationMoveSound = new Sound("Game//ledgegrab");
            m_ladderSound = new Sound("Game//ledgegrab");
            m_rollSound = new Sound("Game//hopp");
            m_ledgeClimbSound = new Sound("Game//tygklatter");
            m_windowActionSound = new Sound("Game//tygklatter2");

            m_img.m_animationEvent += new ImageManager.animationDelegate(changedSubImage);
        }
Exemple #29
0
 public override void addObject(GameObject a_object)
 {
     //throw new NotImplementedException();
 }
Exemple #30
0
        private void updateMouse()
        {
            m_worldMouse = MouseHandler.worldMouse();

            //-----------------------------------
            #region Middle-mouse drag
            if (MouseHandler.mmbPressed())
            {
                Vector2 t_difference = Game.getInstance().m_camera.getPosition().getGlobalCartesian();
                t_difference.X = (Mouse.GetState().X - Game.getInstance().getResolution().X / 2) / 20 / Game.getInstance().m_camera.getZoom();
                t_difference.Y = (Mouse.GetState().Y - Game.getInstance().getResolution().Y / 2) / 20 / Game.getInstance().m_camera.getZoom();
                Game.getInstance().m_camera.getPosition().plusWith(t_difference);
            }
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Left Mouse Button Down
            if (MouseHandler.lmbDown())
            {
                //-----------------------------------
                #region Building
                if (m_itemToCreate == State.Background || m_itemToCreate == State.Parallax || m_itemToCreate == State.Prop)
                {
                    if (m_building && !collidedWithGui(MouseHandler.getMouseCoords()) && !collidedWithObject(m_worldMouse))
                    {
                        if (m_itemToCreate != State.None && m_itemToCreate != State.Delete)
                        {
                            AssetFactory.copyAsset(m_worldMouse, m_objectPreview);
                        }
                    }
                }
                #endregion
                //-----------------------------------

                //-----------------------------------
                #region Selecting
                if (!m_building && !collidedWithGui(MouseHandler.getMouseCoords()))
                {
                    clearSelectedObject();

                    if ((m_selectedObject = selectObject(m_worldMouse)) != null)
                    {
                        if (m_itemToCreate == State.Delete)
                        {
                            deleteObject(m_selectedObject);
                            return;
                        }
                        else if (m_selectedObject is Guard || m_selectedObject is GuardDog)
                        {
                            showGuardInfo((GuardEntity)m_selectedObject);
                        }
                        else if (m_selectedObject is LampSwitch)
                        {
                            showLightSwitchInfo((LampSwitch)m_selectedObject);
                        }
                        else if (m_selectedObject is ParallaxEnvironment)
                        {
                            m_parallaxScrollTF.setText((-((ParallaxEnvironment)m_selectedObject).getParrScroll()).ToString());
                            m_parallaxScrollTF.setVisible(true);
                            m_parallaxLabel.setVisible(true);
                        }

                        m_layerLabel.setText("Layer:");
                        m_layerTextField.setText((m_selectedObject.getLayer() * 1000).ToString());
                        m_textObjectInfo.setText(m_selectedObject.ToString());

                        m_selectedObject.setColor(Color.Yellow);
                        m_dragFrom = m_selectedObject.getPosition().getGlobalCartesian();
                    }
                }
                #endregion
                //-----------------------------------
            }
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Left Mouse Button Release
            if (MouseHandler.lmbUp())
            {
                if (m_selectedObject != null)
                {
                    if (m_selectedObject is Guard && m_selectedObject.getPosition().getGlobalCartesian() != m_dragFrom)
                    {
                        setGuardPoint((Guard)m_selectedObject, m_rightGuardPoint.getEndPoint().getGlobalCartesian(), true);
                        setGuardPoint((Guard)m_selectedObject, m_leftGuardPoint.getEndPoint().getGlobalCartesian(), false);
                        showGuardInfo((Guard)m_selectedObject);
                    }
                }
                m_dragFrom = Vector2.Zero;
                m_firstDrag = true;
            }
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Left Mouse Button Drag
            if (MouseHandler.lmbPressed())
            {
                if (m_selectedObject != null && !collidedWithGui(MouseHandler.getCurPos()))
                {
                    if (m_firstDrag)
                    {
                        m_dragOffset = new Vector2(
                            (float)Math.Floor((m_worldMouse.X - m_selectedObject.getPosition().getGlobalX()) / ((float)(Game.TILE_WIDTH))) * ((float)(Game.TILE_WIDTH)),
                            (float)Math.Floor((m_worldMouse.Y - m_selectedObject.getPosition().getGlobalY()) / ((float)(Game.TILE_HEIGHT)) * ((float)(Game.TILE_HEIGHT)))
                        );
                        m_firstDrag = false;
                    }

                    Vector2 t_mousePosition;
                    if (KeyboardHandler.shiftMod())
                    {
                        t_mousePosition = m_worldMouse - m_dragOffset;
                    }
                    else
                    {
                        t_mousePosition = getTileCoordinates(m_worldMouse - m_dragOffset);
                    }

                    if (m_selectedObject is SpotLight)
                    {
                        m_selectedObject.getPosition().setGlobalCartesian(new Vector2(t_mousePosition.X + m_selectedObject.getBox().Width,t_mousePosition.Y));
                    }
                    else if (m_selectedObject is Rope)
                    {
                        ((Rope)m_selectedObject).moveRope(new Vector2(getTileCoordinates(m_worldMouse).X - 36, getTileCoordinates(m_worldMouse).Y));
                    }
                    else if (m_selectedObject is VentilationDrum)
                    {
                        m_selectedObject.getPosition().setGlobalCartesian(t_mousePosition);
                        ((VentilationDrum)m_selectedObject).getPairedVentilation().getPosition().setGlobalCartesian(t_mousePosition);
                    }
                    else
                    {
                        m_selectedObject.getPosition().setGlobalCartesian(t_mousePosition);
                    }
                }

                if (m_itemToCreate != State.Background && m_itemToCreate != State.Parallax && m_itemToCreate != State.Prop)
                {
                    if (m_building && !collidedWithGui(MouseHandler.getMouseCoords()) && !collidedWithObject(m_worldMouse))
                    {
                        AssetFactory.copyAsset(m_worldMouse, m_objectPreview);
                    }
                }
            }
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Right Mouse Button Release
            if (MouseHandler.rmbUp())
            {
                if (m_selectedObject != null && m_selectedObject is Rope)
                {
                    ((Rope)m_selectedObject).setEndPoint(new Vector2(m_selectedObject.getPosition().getLocalX(), getTileCoordinates(m_worldMouse).Y + 72));
                }

                if (m_dragLine != null)
                {
                    if (m_selectedObject is LampSwitch)
                    {
                        foreach (GameObject t_gameObject in m_gameObjectList[m_currentLayer])
                        {
                            if (t_gameObject is SpotLight && ((Entity)t_gameObject).getHitBox().contains(m_worldMouse))
                            {
                                connectSpotLight((SpotLight)t_gameObject, (LampSwitch)m_selectedObject);
                                break;
                            }
                        }
                        showLightSwitchInfo((LampSwitch)m_selectedObject);
                    }
                    else if (m_selectedObject is Guard || m_selectedObject is GuardDog)
                    {
                        setGuardPoint((GuardEntity)m_selectedObject, m_worldMouse, (m_worldMouse.X > m_selectedObject.getPosition().getGlobalX()));
                        showGuardInfo((GuardEntity)m_selectedObject);
                    }
                    else if (m_selectedObject is GuardCamera)
                    {
                        setGuardCameraPoint((GuardCamera)m_selectedObject, m_worldMouse, m_worldMouse.X > m_selectedObject.getPosition().getGlobalX());
                    }
                    m_dragLine = null;
                }
                else
                {
                    clearSelectedObject();
                    foreach (Button t_button in m_buttonDict.Keys)
                    {
                        t_button.setState(0);
                    }
                    setBuildingState(m_btnSelect, State.None);
                }
                m_dragLine = null;
            }
            #endregion
            //-----------------------------------

            //-----------------------------------
            #region Right Mouse Button Drag
            if (MouseHandler.rmbPressed())
            {
                if (m_selectedObject != null)
                {
                    if (m_selectedObject is LampSwitch)
                    {
                        if (m_dragLine == null && ((Entity)m_selectedObject).getHitBox().contains(m_worldMouse))
                        {
                            m_dragLine = new Line(m_selectedObject.getPosition(), new CartesianCoordinate(m_worldMouse), new Vector2(36, 36), Vector2.Zero, Color.Yellow, 5, true);
                        }
                        else if (m_dragLine != null)
                        {
                            m_dragLine.setEndPoint(m_worldMouse);
                        }
                    }

                    if (m_selectedObject is Guard || m_selectedObject is GuardDog)
                    {
                        if (m_dragLine == null && ((Entity)m_selectedObject).getImageBox().contains(m_worldMouse))
                        {
                            m_dragLine = new Line(m_selectedObject.getPosition(), new CartesianCoordinate(new Vector2(m_worldMouse.X, m_selectedObject.getPosition().getGlobalY() + 36)), new Vector2(36, 36), Vector2.Zero, Color.Green, 5, true);
                        }
                        else if (m_dragLine != null)
                        {
                            m_dragLine.setEndPoint(new Vector2(m_worldMouse.X, m_selectedObject.getPosition().getGlobalY() + 36));
                        }
                    }

                    if (m_selectedObject is Rope)
                    {
                        ((Rope)m_selectedObject).setEndPoint(new Vector2(m_selectedObject.getPosition().getLocalX(), m_worldMouse.Y));
                    }

                    if (m_selectedObject is GuardCamera)
                    {
                        if (m_dragLine == null && ((Entity)m_selectedObject).getHitBox().contains(m_worldMouse))
                        {
                            m_dragLine = new Line(m_selectedObject.getPosition(), new CartesianCoordinate(m_worldMouse), Vector2.Zero, Vector2.Zero, Color.Red, 5, true);
                        }
                        else if (m_dragLine != null)
                        {
                            m_dragLine.setEndPoint(m_worldMouse);
                        }
                    }
                }
            }
            #endregion
            //-----------------------------------
        }