Esempio n. 1
0
        public roomInfo BuildingIntoRoom(Building thisBuilding)
        {
            roomInfo ThisRoom = new roomInfo();

            ThisRoom.RoomName = thisBuilding.BuildingName;
            ThisRoom.Description = thisBuilding.Description;
            ThisRoom.AltDescription = thisBuilding.AltDescription;
            ThisRoom.CanMove = thisBuilding.CanMove;
            ThisRoom.LockedIn = thisBuilding.LockedIn;
            ThisRoom.SuicideAction = thisBuilding.SuicideAction;
            //ThisRoom.ImagePath = thisBuilding.ImagePath;

            ThisRoom.Events = new List<Event>();
            ThisRoom.Civilians = new List<CivilianProfile>();
            ThisRoom.items = new List<itemInfo>();
            ThisRoom.Enemy = new List<EnemyProfile>();

            DataTypes dt = new DataTypes();

            if (thisBuilding.Events != null) foreach (Event newEvent in thisBuilding.Events) { ThisRoom.Events.Add(dt.CloneEvent(newEvent)); }
            if (thisBuilding.Civilians != null) foreach (CivilianProfile NPC in thisBuilding.Civilians) { ThisRoom.Civilians.Add(dt.CloneNPC(NPC)); }
            if (thisBuilding.items != null) foreach (itemInfo NewItem in thisBuilding.items) { ThisRoom.items.Add(dt.CloneItem(NewItem)); }
            if (thisBuilding.Enemy != null) foreach (EnemyProfile Enemy in thisBuilding.Enemy) { ThisRoom.Enemy.Add(dt.CloneEnemy(Enemy)); }

            return ThisRoom;
        }
        public frmRoomEditor(DataTypes.roomInfo thisRoom, int floors, bool Building)
        {
            InitializeComponent();

            ChangeMade = false;
            isBuilding = Building;
            Room = thisRoom;
            FloorCount = floors;
            PopulateFields();
            //DrawEnvironment();
        }
 public static void SaveWorld()
 {
     if (Player.InBuilding == true)
     {
         DataTypes dt = new DataTypes();
         ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]].Building = dt.RoomIntoBuilding(CurrentRoom);
     }
     else ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]] = CurrentRoom;
     world[Player.CurrentPos[2]] = ThisFloor;
     WorldState.WorldState = world;
 }
        public static Building LeaveBuilding(roomInfo thisRoom)
        {
            Building thisBuilding = new Building();

            LoDConsole.WriteLine("Leaving " + thisRoom.RoomName);
            //Thread.Sleep(1000);

            DataTypes dt = new DataTypes();
            thisBuilding = dt.RoomIntoBuilding(thisRoom);
            Player.InBuilding = false;

            return thisBuilding;
        }
        public static roomInfo GoIntoBuilding(Building thisBuilding)
        {
            LoDConsole.WriteLine("Entering " + thisBuilding.BuildingName);
            //Thread.Sleep(1000);

            DataTypes dt = new DataTypes();
            roomInfo ThisRoom = new roomInfo();
            ThisRoom = dt.BuildingIntoRoom(thisBuilding);
            Player.InBuilding = true;

            return ThisRoom;
        }
        public static roomInfo GetRoomInfo(int[] UserPos)
        {
            //SaveWorld();

            roomInfo ThisRoom = new roomInfo();

            //ThisFloor = world[UserPos[2]];

            ThisFloor = world[UserPos[2]];

            DataTypes dt = new DataTypes();
            if (Player.InBuilding) ThisRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[UserPos[0], UserPos[1]].Building);
            else ThisRoom = ThisFloor.CurrentFloor[UserPos[0], UserPos[1]];

            return (ThisRoom);
        }
        public static Event EventAction(Event thisEvent)
        {
            if (thisEvent.Triggered == false)
            {
                thisEvent.Triggered = true;

                if (thisEvent.Action.ToLower() == "unlockroom")   //unlock
                {
                    if (thisEvent.Coodinates != null)
                    {
                        ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].CanMove = true;
                    }
                }
                else if (thisEvent.Action.ToLower() == "lockroom")   //lock
                {
                    if (thisEvent.Coodinates != null)
                    {
                        ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].CanMove = false;
                    }

                }
                else if (thisEvent.Action.ToLower() == "unlockbuilding")   //unlock
                {
                    if (thisEvent.Coodinates != null)
                    {
                        ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.CanMove = true;
                    }
                }
                else if (thisEvent.Action.ToLower() == "lockbuilding")   //lock
                {
                    if (thisEvent.Coodinates != null)
                    {
                        ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.CanMove = false;
                    }

                }
                else if (thisEvent.Action.ToLower() == "lockin")
                {
                    if (!CurrentRoom.LockedIn) CurrentRoom.LockedIn = true;
                    else CurrentRoom.LockedIn = false;
                    SaveWorld();
                }
                else if (thisEvent.Action.ToLower() == "kill all enemies") //kill all
                {
                    //do some other things
                    if (CurrentRoom.Enemy != null)
                    {
                        if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>();

                        foreach (EnemyProfile ThisEnemy in CurrentRoom.Enemy)
                        {
                            CurrentRoom.items.Add(ThisEnemy.Weapon);

                            itemInfo newItem = new itemInfo();

                            newItem.Name = string.Concat(ThisEnemy.name, "'s body");
                            newItem.Class = "Object";
                            newItem.Examine = string.Concat("The slashed and torn body of enemy ", ThisEnemy.name);
                            newItem.CanPickUp = false;
                            newItem.InteractionName = new List<string>();
                            newItem.InteractionName.Add("body");
                            newItem.InteractionName.Add("corpse");
                            newItem.InteractionName.Add("enemy");
                            newItem.InteractionName.Add(string.Concat(ThisEnemy.name, "'s body"));
                            newItem.InteractionName.Add(ThisEnemy.name);
                            CurrentRoom.items.Add(newItem);

                            GainXPfromEnemy(ThisEnemy);
                        }
                        EventTrigger("killallenemies");
                        CurrentRoom.Enemy.Clear();   //Overwrite all enemies
                    }
                }
                else if (thisEvent.Action.ToLower() == "remove all npcs") //remove all npcs
                {
                    CurrentRoom.Civilians.Clear();
                    SaveWorld();
                }
                else if (thisEvent.Action.ToLower() == "remove all items") //remove all npcs
                {
                    CurrentRoom.items.Clear();
                    SaveWorld();
                }
                else if (thisEvent.Action.ToLower() == "change description" || thisEvent.Action.ToLower() == "custom description") //change description
                {
                    if (thisEvent.Coodinates[2] != Player.CurrentPos[2]) //If change is not on this floor
                    {
                        Floor TempFloor;
                        TempFloor = world[thisEvent.Coodinates[2]];

                        if (!thisEvent.ApplyToBuilding)
                        {
                            if (thisEvent.Action.ToLower() == "change description") TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription;
                            else TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue;
                        }
                        else if (thisEvent.ApplyToBuilding == true && TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.BuildingName != null)
                        {
                            roomInfo TempRoom = new roomInfo();
                            DataTypes dt = new DataTypes();
                            TempRoom = dt.BuildingIntoRoom(TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building);
                            if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription;
                            else TempRoom.Description = thisEvent.EventValue;
                            TempFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom);
                        }
                        world[thisEvent.Coodinates[2]] = TempFloor;
                    }
                    else if (Player.CurrentPos[0] != thisEvent.Coodinates[0] || Player.CurrentPos[1] != thisEvent.Coodinates[1])    //Change is not in this cell
                    {
                        if (!thisEvent.ApplyToBuilding)
                        {
                            if (thisEvent.Action.ToLower() == "change description") ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription;
                            else ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue;
                        }
                        else if (thisEvent.ApplyToBuilding == true && ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building.BuildingName != null)
                        {
                            roomInfo TempRoom = new roomInfo();
                            DataTypes dt = new DataTypes();
                            TempRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building);
                            if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription;
                            else TempRoom.Description = thisEvent.EventValue;
                            ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom);
                        }
                    }
                    else
                    {
                        if ((!thisEvent.ApplyToBuilding && !Player.InBuilding) || (thisEvent.ApplyToBuilding && Player.InBuilding))   //Applying to the non-building area the player is in
                        {
                            if (thisEvent.Action.ToLower() == "change description") CurrentRoom.Description = CurrentRoom.AltDescription;
                            else CurrentRoom.Description = thisEvent.EventValue;
                        }
                        else if (!thisEvent.ApplyToBuilding && Player.InBuilding == true)   //Applies to current cell but player is in building
                        {
                            if (thisEvent.Action.ToLower() == "change description") ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].AltDescription;
                            else ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Description = thisEvent.EventValue;
                        }
                        else if (thisEvent.ApplyToBuilding == true && Player.InBuilding == false)   //Applies to building in current Cell
                        {
                            roomInfo TempRoom = new roomInfo();
                            DataTypes dt = new DataTypes();
                            TempRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building);
                            if (thisEvent.Action.ToLower() == "change description") TempRoom.Description = TempRoom.AltDescription;
                            else TempRoom.Description = thisEvent.EventValue;
                            ThisFloor.CurrentFloor[thisEvent.Coodinates[0], thisEvent.Coodinates[1]].Building = dt.RoomIntoBuilding(TempRoom);
                        }
                    }
                    SaveWorld();
                    CurrentRoom = GetRoomInfo(Player.CurrentPos);   //retreive new room info
                }
                else if (thisEvent.Action.ToLower() == "change location") //change floor
                {
                    bool newFloor = false;
                    if (thisEvent.Coodinates[2] != Player.CurrentPos[2]) newFloor = true;   //If the player is changing floors

                    //ThisEvent will remain bool untriggered as will allow multiple re-use
                    //Thread.Sleep(5000);
                    world[Player.CurrentPos[2]] = ThisFloor;    //save floor to list.
                    Player.CurrentPos[0] = thisEvent.Coodinates[0];
                    Player.CurrentPos[1] = thisEvent.Coodinates[1];   //set players position to start of new room
                    Player.CurrentPos[2] = thisEvent.Coodinates[2];
                    ThisFloor = world[Player.CurrentPos[2]];    //retreive new floor
                    if (!thisEvent.ApplyToBuilding) Player.InBuilding = false;
                    else Player.InBuilding = true;
                    CurrentRoom = GetRoomInfo(Player.CurrentPos);   //retreive new room info

                    //else if (!string.IsNullOrEmpty(ThisFloor.CurrentFloor[Player.CurrentPos[0], Player.CurrentPos[1]].Building.BuildingName))   //move player into building.
                    //{
                    //    DataTypes dt = new DataTypes();
                    //    CurrentRoom = dt.BuildingIntoRoom(ThisFloor.CurrentFloor[Player.CurrentPos[0],Player.CurrentPos[1]].Building);
                    //}
                    LoDConsole.Clear();    //clear the screen
                    LoDConsole.WriteLine(WordWrap(CurrentRoom.Description));

                    if (newFloor == true && ThisFloor.FloorSong != null && File.Exists(ThisFloor.FloorSong))
                    {
                        MusicPlayer.SoundLocation = ThisFloor.FloorSong;
                        Music("Start");
                    }
                }
                else if (thisEvent.Action.ToLower() == "change objective")
                {
                    Player.Objective = thisEvent.EventValue;
                    LoDConsole.WriteLine("\nYour current objective has changed.");
                }
                /*
                else if (thisEvent.Action.ToLower() == "custom description")
                {
                    CurrentRoom.Description = thisEvent.EventValue;
                    SaveWorld();
                }
                */
                else if (thisEvent.Action.ToLower() == "output text")
                {
                    LoDConsole.WriteLine("");
                    LoDConsole.WriteLine(WordWrap(thisEvent.EventValue));
                }
                else if (thisEvent.Action == "spawnItems")
                {
                    if (CurrentRoom.items == null) CurrentRoom.items = new List<itemInfo>();
                    foreach (itemInfo Item in thisEvent.Items)
                    {
                        CurrentRoom.items.Add(Item);
                    }
                    SaveWorld();
                }
                else if (thisEvent.Action == "spawnNPC")
                {
                    if (CurrentRoom.Civilians == null) CurrentRoom.Civilians = new List<CivilianProfile>();
                    foreach (CivilianProfile NPC in thisEvent.NPCs)
                    {
                        CurrentRoom.Civilians.Add(NPC);
                    }
                    SaveWorld();
                }
                else if (thisEvent.Action == "spawnEnemy")
                {
                    if (CurrentRoom.Enemy == null) CurrentRoom.Enemy = new List<EnemyProfile>();
                    foreach (EnemyProfile Enemy in thisEvent.Enemies)
                    {
                        CurrentRoom.Enemy.Add(Enemy);
                    }
                    SaveWorld();
                }
                else if (thisEvent.Action == "giveXP")
                {
                    int n;
                    if (int.TryParse(thisEvent.EventValue, out n)) Player.XP = Player.XP + n;
                }
                else if (thisEvent.Action == "EndCredits")
                {
                    Console.ReadKey();
                    EndCredits();
                }
                else thisEvent.Triggered = false;

                //If an event is re-usable allow it to be triggered again
                if (thisEvent.Triggered == true && thisEvent.ReUsable == true) thisEvent.Triggered = false;
                if (thisEvent.Coodinates != null && thisEvent.Coodinates[0] == Player.CurrentPos[0] && thisEvent.Coodinates[1] == Player.CurrentPos[1] && thisEvent.Coodinates[2] == Player.CurrentPos[2])
                    CurrentRoom = GetRoomInfo(Player.CurrentPos);
            }
            return thisEvent;
        }
        private void txtBuilding_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            DataTypes dt = new DataTypes();
            DataTypes.Building Building = new DataTypes.Building();

            if (Room.Building.BuildingName != null) Building = Room.Building;
            frmRoomEditor NewForm = new frmRoomEditor(dt.BuildingIntoRoom(Building),FloorCount,true);
            NewForm.ShowDialog();

            if (NewForm.ChangeMade == true)
            {
                Building = dt.RoomIntoBuilding(NewForm.Room);
                Room.Building = Building;
                txtBuilding.Text = Building.BuildingName;
            }
        }
 private void cmdCloneNPC_Click(object sender, EventArgs e)
 {
     if (lstNPCs.SelectedIndex > -1)
     {
         DataTypes dt = new DataTypes();
         Room.Civilians.Add(dt.CloneNPC(Room.Civilians[lstNPCs.SelectedIndex]));
         GetAllNPCs();
     }
     else MessageBox.Show("Select an NPC to Clone");
 }
 private void cmdCloneItem_Click(object sender, EventArgs e)
 {
     if (lstItems.SelectedIndex > -1)
     {
         DataTypes dt = new DataTypes();
         Room.items.Add(dt.CloneItem(Room.items[lstItems.SelectedIndex]));
         GetAllItems();
     }
     else MessageBox.Show("Select an item to clone");
 }
 private void cmdCloneEvent_Click(object sender, EventArgs e)
 {
     if (lstEvents.SelectedIndex > -1)
     {
         DataTypes dt = new DataTypes();
         Room.Events.Add(dt.CloneEvent(Room.Events[lstEvents.SelectedIndex]));
         GetAllEvents();
     }
     else MessageBox.Show("Select an Event to Clone");
 }
 private void cmdCloneEnemy_Click(object sender, EventArgs e)
 {
     if (lstEnemies.SelectedIndex > -1)
     {
         DataTypes dt = new DataTypes();
         Room.Enemy.Add(dt.CloneEnemy(Room.Enemy[lstEnemies.SelectedIndex]));
         GetAllEnemies();
     }
     else MessageBox.Show("Select an enemy to clone");
 }