Exemplo n.º 1
0
        /// <summary>
        /// This class also is responsible for creating visitors (normally the world/mainscreen when the game would be bigger)
        /// </summary>
        /// <param name="VisitorInfo"></param>
        /// <returns></returns>
        public Visitor CreateVisitor(Dictionary <string, string> visitorInfo)
        {
            // Create the factory to create visitors
            IFactory locationTypeFactory = Factory.AbstractFactory.Instance().Create("MovableCreatures");
            // Visitor his ID
            string id = null;

            foreach (KeyValuePair <string, string> item in visitorInfo)
            {
                for (int i = 0; i < item.Key.Length; i++)
                {
                    if (Char.IsDigit(item.Key[i]))
                    {
                        id += char.GetNumericValue(item.Key[i]);
                    }
                }
            }
            MovableParam initialiseParam = new MovableParam()
            {
                PathFinding = pathfinding, ID = Convert.ToInt32(id), Settings = this.hte
            };

            // Create two cleaners based on the string
            Visitor visitor = locationTypeFactory.CreateMovableCreatures("Visitor", initialiseParam) as Visitor;

            lobby.GetVisitor(visitor);

            // Give visitor to lobby
            return(visitor);
        }
Exemplo n.º 2
0
        /// <summary>
        /// In this class we want to create cleaners because we look at this game like Hotel is the world.
        /// If this game would be bigger, we could create humans in the mainscreen and give them a behaviour for example with the strategy pattern
        /// </summary>
        public void CreateCleaners()
        {
            LocationType location = null;

            foreach (var item in Facilities)
            {
                if (item.Position.X == 1 && item.Position.Y == 0)
                {
                    location = item;
                }
            }
            // List we will send to lobby
            List <Cleaner> cleaners = new List <Cleaner>();
            // Create the factory to create cleaners
            IFactory     locationTypeFactory = Factory.AbstractFactory.Instance().Create("MovableCreatures");
            MovableParam initializeParam     = new MovableParam()
            {
                PathFinding = pathfinding, StartLocation = location, Settings = this.hte
            };

            // Create two cleaners based on the string
            Cleaner cleaner1 = locationTypeFactory.CreateMovableCreatures("Cleaner", initializeParam) as Cleaner;
            Cleaner cleaner2 = locationTypeFactory.CreateMovableCreatures("Cleaner", initializeParam) as Cleaner;

            // Adding cleaners to the lsit we are going to send
            cleaners.Add(cleaner1);
            cleaners.Add(cleaner2);

            // sending cleaners to lobby
            lobby.GetCleaners(cleaners);
        }
Exemplo n.º 3
0
 /// <summary>
 /// constructor where we will initialise values
 /// </summary>
 /// <param name="humanParam"></param>
 public Visitor(MovableParam humanParam) : base(humanParam)
 {
     // Set properties
     Path        = new List <Node>();
     Image       = Image.FromFile("../../Resources/lemming.png");
     StatusHuman = StatusHuman.NONE;
     ID          = humanParam.ID;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="humanParam"></param>
 public Cleaner(MovableParam humanParam) : base(humanParam)
 {
     // defining properties
     Path          = new List <Node>();
     Image         = Image.FromFile("../../Resources/cleaner.png");
     StatusCleaner = StatusCleaner.NOT_WORKING;
     StatusHuman   = StatusHuman.WAITING;
     Location.SetLocationType(humanParam.StartLocation);
     Xpos = Location.LocationType.Position.X * Location.LocationType.oneDimensionSize.Width;
     Ypos = Location.LocationType.Position.Y * Location.LocationType.oneDimensionSize.Height;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="humanParam"></param>
 public Human(MovableParam humanParam)
 {
     // Defining properties / fields
     Settings               = humanParam.Settings;
     PathFinding            = humanParam.PathFinding;
     Xpos                   = 0;
     Ypos                   = 0;
     Size                   = new Size(20, 50);
     Location               = new Node();
     CurrentEvent           = new HotelEvent();
     CurrentEvent.EventType = HotelEventType.NONE;
 }
        /// <summary>
        /// Godzilla is created in the world(mainscreen)
        /// </summary>
        public void CreateGodzilla()
        {
            if (godzilla == null)
            {
                // Create the factory to create cleaners
                IFactory     locationTypeFactory = Factory.AbstractFactory.Instance().Create("MovableCreatures");
                LocationType biggest             = hotel.Facilities.Aggregate((i1, i2) => i1.Position.Y > i2.Position.Y ? i1 : i2);

                // The information godzilla needs to set his values
                //MovableParam initialiseParam = new MovableParam() { height = this.Height / 100 * 80, width = this.Width / 100 * 50, hotel = hotel };
                MovableParam initialiseParam = new MovableParam()
                {
                    Height = ((this.Height / 100) * 80), Width = ((this.Width / 100) * 50), Hotel = hotel, Settings = this.hte
                };

                // Create two cleaners based on the string
                godzilla = locationTypeFactory.CreateMovableCreatures("Godzilla", initialiseParam) as Godzilla;
            }
        }