예제 #1
0
파일: Ship.cs 프로젝트: velhelm/SpaceIsFun
        public Ship(Texture2D spriteTexture, Vector2 position)
            : base()
        {
            hp = 10;
            energy = 5;
            shields = 2;

            sprite = new Drawable(spriteTexture, position);
        }
예제 #2
0
 public Grid(Texture2D spriteTexture, Texture2D highlight, Vector2 position, Vector2 gPosition)
     : base()
 {
     gridTexture = spriteTexture;
     sprite = new Drawable(gridTexture, position);
     gridPosition = gPosition;
     highlightTexture = highlight;
     hullBreach = false;
     aflame = false;
 }
예제 #3
0
        /// <summary>
        /// construtor of crewman
        /// </summary>
        /// <param name="position">starting position of the crewman</param>
        /// <param name="crewTexture">texture of the crewman when not selected</param>
        /// <param name="crewSelectedTexture">texture of the crewman when selected</param>
        public Crew(Vector2 position, Vector2 gPosition ,Texture2D crewTexture, Texture2D crewSelectedTexture)
            : base()
        {
            maxHP = currentHP = 100;
            this.position = gPosition;

            this.crewTexture = crewTexture;
            this.crewSelectedTexture = crewSelectedTexture;
            this.selected = false;

            sprite = new Drawable(crewTexture, position, gPosition);
        }
예제 #4
0
        /// <summary>
        /// constructor for a room
        /// </summary>
        /// <param name="texture">texture for the room</param>
        /// <param name="highlightTexture">texture for the room when its highlighted</param>
        /// <param name="x">x-position of the top-left grid position</param>
        /// <param name="y">y-position of the top-left grid position</param>
        public Room(Texture2D texture, Texture2D highlightTexture, int x, int y, Vector2 shipOffset, Globals.roomShape shape, Globals.roomType type, int w, int h)
        {
            #region room state machine setup
            roomStateMachine = new StateMachine();

            normal = new State { Name = "normal" };
            damaged = new State { Name = "damaged" };
            inoperable = new State { Name = "inoperable" };
            disabled = new State { Name = "disabled" };

            roomStateMachine.Start(normal);

            normal.Transitions.Add(damaged.Name, damaged);
            normal.Transitions.Add(disabled.Name, disabled);
            normal.Transitions.Add(inoperable.Name, inoperable);

            damaged.Transitions.Add(normal.Name, normal);
            damaged.Transitions.Add(inoperable.Name, inoperable);
            damaged.Transitions.Add(disabled.Name, disabled);

            inoperable.Transitions.Add(normal.Name, normal);
            inoperable.Transitions.Add(damaged.Name, damaged);
            inoperable.Transitions.Add(disabled.Name, disabled);

            disabled.Transitions.Add(normal.Name, normal);
            disabled.Transitions.Add(damaged.Name, damaged);
            disabled.Transitions.Add(inoperable.Name, inoperable);

            #endregion

            setupNormal();
            setupDamaged();
            setupInoperable();
            setupDisabled();

            position = new Vector2((x * 32) + shipOffset.X, (y * 32) + shipOffset.Y);
            roomTexture = texture;
            roomHighlightTexture = highlightTexture;
            sprite = new Drawable(highlightTexture, position);
            roomPosition = new Vector2(x, y);
            isMannable = new bool();
            isMannable = false;
            roomType = (int)type;
            roomHealth = 200;

            roomShape = shape;
            width = w;
            height = h;
            aflame = false;
            hullBreach = false;

            roomGrids = new List<int>();
        }
예제 #5
0
        /// <summary>
        /// constructor for a ship object
        /// </summary>
        /// <param name="shipTexture">texture used to draw the ship's sprite</param>
        /// <param name="gridTexture">texture used to draw the ship's grid</param>
        /// <param name="highlightTexture">texture used to draw the ship's grid when a grid is selected</param>
        /// <param name="position">initial position of the ship's sprite</param>
        public Ship(Texture2D shipTexture, 
                    Texture2D gridTexture, 
                    Texture2D highlightTexture, 
                    Vector2 position,
                    List<int> roomUIDs,
                    List<int> gridUIDs,
                    List<int> weaponUIDs,
                    bool[] roomTypes,
                    int[,] shipGrid,
                    int owner)
            : base()
        {
            roomList = new bool[11];
            roomGridDict = new Dictionary<int,int>();
            System.Diagnostics.Debug.WriteLine("initting ship");
            // set some default values
            maxHP = currentHP = 10;
            energy = 5;
            maxShields = currentShields = 2;

            // create the ship's drawable
            sprite = new Drawable(shipTexture, position);
            // create the ship's grid; each grid is 32-wide, so we get the amount of grids needed by dividing the ship's sprite up into 32x32 chunks
            gridWidth = shipTexture.Bounds.Width / 32;
            gridHeight = shipTexture.Bounds.Height / 32;
            //this.shipGrid = new int[gridWidth, gridHeight];
            this.shipGrid = shipGrid;

            this.owner = owner;

            roomUIDList = roomUIDs;
            gridUIDList = gridUIDs;
            weaponUIDList = weaponUIDs;

            weaponSlots = new int[4];

            weaponSlots[0] = weaponUIDList[0];
            weaponSlots[1] = -1;
            weaponSlots[2] = -1;
            weaponSlots[3] = -1;

            //Default_weap = new Weapon(gridTexture, 0, 0, 2, 10, 3);
            // we need to move the rooms to align ontop of the ship; probably find a better way to do this in the future
            /*
            foreach (Room room in roomList)
            {
                room.Sprite.MoveBy(new Vector2(50, 50));
            }
            */

            //setRoomGridDictionary();
            //setUnwalkableGrids();
        }
예제 #6
0
        void setupOverworld()
        {
            overworld.enter += () =>
            {
                // setup gui elements here

                // for now, these probably will just be buttons arranged on a map to spawn certain battles / narrative events

                //

                setNodes();

                for (int i = 0; i < starNodes.Count; i++)
                {
                    if (i == (int)NodeState.Narrative1 || i == (int)NodeState.Battle1)
                    {
                        starNodeDraws.Add(new Drawable(starTexture, starNodes[i]));
                    }
                    else if (i == (int)NodeState.Battle2 || i == (int)NodeState.Narrative2)
                    {
                        starNodeDraws.Add(new Drawable(starGreyedTexture, starNodes[i]));
                    }
                }
                /*
                foreach (Vector2 item in starNodes) {
                    starNodeDraws.Add(new Drawable(starTexture, item));
                }
                 * */
            };

            overworld.update += (GameTime gameTime) =>
            {
                #region input handling

                if (currentKeyState.IsKeyUp(Keys.Up) && previousKeyState.IsKeyDown(Keys.Up))
                {
                    traverseStarsUp();
                }
                else if (currentKeyState.IsKeyUp(Keys.Down) && previousKeyState.IsKeyDown(Keys.Down))
                {
                    traverseStarsDown();
                }
                else if (currentKeyState.IsKeyUp(Keys.Left) && previousKeyState.IsKeyDown(Keys.Left))
                {
                    traverseStarsLeft();
                }
                else if (currentKeyState.IsKeyUp(Keys.Right) && previousKeyState.IsKeyDown(Keys.Right))
                {
                    traverseStarsRight();
                }

                if (currentKeyState.IsKeyUp(Keys.LeftControl) && previousKeyState.IsKeyDown(Keys.LeftControl))
                {
                    resetNodes();
                }

                if (battle1Resolved && narrative1Resolved)
                {
                    starNodeDraws[1].SpriteTexture = starTexture;
                }
                if (narrative2Resolved)
                {
                    starNodeDraws[3].SpriteTexture = starTexture;
                }
                if (battle1Resolved)
                {
                    starNodeDraws[2].SpriteTexture = starGreyedTexture;
                }
                if (narrative1Resolved)
                {
                    starNodeDraws[0].SpriteTexture = starGreyedTexture;
                }
                if (narrative2Resolved)
                {
                    starNodeDraws[1].SpriteTexture = starGreyedTexture;
                }
                if (battle2Resolved)
                {
                    starNodeDraws[3].SpriteTexture = starGreyedTexture;
                }

                if (narrative1Resolved && narrative2Resolved && battle1Resolved && battle2Resolved)
                {
                    //Generate you win message here
                }

                //Upon Enter press, check if the
                if (currentKeyState.IsKeyUp(Keys.Enter) && previousKeyState.IsKeyDown(Keys.Enter))
                {
                    if (starNodeSelectedIndex == (int)NodeState.Narrative1)
                    {
                        if (narrative1Resolved == false)
                        {
                            //Do some shit
                            System.Diagnostics.Debug.WriteLine("Narrative1");
                            narrative1Resolved = true;
                        }
                    }
                    else if (starNodeSelectedIndex == (int)NodeState.Narrative2)
                    {
                        if (narrative1Resolved && battle1Resolved)
                        {
                            //Do some more shit if narrative2
                            System.Diagnostics.Debug.WriteLine("Narrative2");
                            narrative2Resolved = true;
                        }
                    }
                    else if (starNodeSelectedIndex == (int)NodeState.Battle1)
                    {
                        if (battle1Resolved == false)
                        {
                            //Battle some shit
                            System.Diagnostics.Debug.WriteLine("Penises, Penises and lollipops.  Unicorn on top.");
                            battle1Resolved = true;
                        }
                    }
                    else if (starNodeSelectedIndex == (int)NodeState.Battle2)
                    {
                        if (narrative2Resolved)
                        {
                            //Battle some more shit
                            System.Diagnostics.Debug.WriteLine("Penises, Penises and lollipops.  Big floppy penises, just don't stop.");
                            battle2Resolved = true;
                        }
                    }
                }

                //If user hits down, traverseStarsLeft
                //If user hits right, traverseStarsRight

                #endregion

               //This is where it would draw if it weren't dumb

                cursorCoords = starNodes[starNodeSelectedIndex];
                overworldCursorDraw = new Drawable(overworldCursorTexture, cursorCoords);

            };

            overworld.leave += () =>
            {
                // remove gui elements here
            };
        }