コード例 #1
0
        public void Defrag()
        {
            for (int i = 0; i < m_sheep.Count; ++i)
            {
                try
                {
                    object o = m_sheep[i];

                    ShepherdsSheep sheep = o as ShepherdsSheep;

                    if (sheep == null || !sheep.Alive)
                    {
                        m_sheep.RemoveAt(i);
                        --i;
                    }

                    else if (sheep.Controlled || sheep.IsStabled)
                    {
                        sheep.ShepherdA = null;
                        m_sheep.RemoveAt(i);
                        --i;
                    }
                }
                catch {}
            }
            for (int i = 0; i < m_dog.Count; ++i)
            {
                try
                {
                    object o = m_dog[i];

                    ShepherdsDog dog = o as ShepherdsDog;

                    if (dog == null || !dog.Alive)
                    {
                        m_dog.RemoveAt(i);
                        --i;
                    }

                    else if (dog.Controlled || dog.IsStabled)
                    {
                        dog.ShepherdA = null;
                        m_dog.RemoveAt(i);
                        --i;
                    }
                }
                catch { }
            }
        }
コード例 #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                NextWoolTime = reader.ReadDeltaTime();
                break;
            }
            }

            m_shepherd = (Shepherd)reader.ReadMobile();
            m_dog      = (ShepherdsDog)reader.ReadMobile();
        }
コード例 #3
0
        public void SpawnBabies()
        {

            Defrag();
            int family1 = m_dog.Count;
            int family = m_sheep.Count;

            Map map = this.Map;

            if (map == null)
                return;

            int hr = (int)((this.RangeHome + 1) / 2);

            if (family1 == 0)
            {
                for (int i = family1; i < dogCount; ++i)
                {
                    ShepherdsDog dog = new ShepherdsDog();

                    bool validLocation = false;
                    Point3D loc = this.Location;

                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = X + Utility.Random(5) - 1;
                        int y = Y + Utility.Random(5) - 1;
                        int z = map.GetAverageZ(x, y);

                        if (validLocation = map.CanFit(x, y, this.Z, 16, false, false))
                            loc = new Point3D(x, y, Z);
                        else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                            loc = new Point3D(x, y, z);
                    }

                    dog.ShepherdA = this;
                    this.DogA = dog;
                    dog.Home = this.Location;
                    dog.RangeHome = (hr > 4 ? 4 : hr);
                    dog.MoveToWorld(loc, map);
                    m_dog.Add(dog);                    
                }
            }

            if (family == 0)
            {

                for (int i = family; i < sheepCount; ++i)
                {
                    ShepherdsSheep sheep = new ShepherdsSheep();

                    bool validLocation = false;
                    Point3D loc = this.Location;

                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = X + Utility.Random(5) - 1;
                        int y = Y + Utility.Random(5) - 1;
                        int z = map.GetAverageZ(x, y);

                        if (validLocation = map.CanFit(x, y, this.Z, 16, false, false))
                            loc = new Point3D(x, y, Z);
                        else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                            loc = new Point3D(x, y, z);
                    }

                    sheep.ShepherdA = this;
                    sheep.DogA = this.DogA;
                    //sheep.Team = this.Team;
                    sheep.Home = this.Location;
                    sheep.RangeHome = (hr > 4 ? 4 : hr);
                    sheep.MoveToWorld(loc, map);
                    m_sheep.Add(sheep);

                }
            }

            else
                return;
        }
コード例 #4
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 1:
				{
					NextWoolTime = reader.ReadDeltaTime();
					break;
				}
			}

			m_shepherd = (Shepherd)reader.ReadMobile();
            m_dog = (ShepherdsDog)reader.ReadMobile();
		}
コード例 #5
0
        public void SpawnBabies()
        {
            Defrag();
            int family1 = m_dog.Count;
            int family  = m_sheep.Count;

            Map map = this.Map;

            if (map == null)
            {
                return;
            }

            int hr = (int)((this.RangeHome + 1) / 2);

            if (family1 == 0)
            {
                for (int i = family1; i < dogCount; ++i)
                {
                    ShepherdsDog dog = new ShepherdsDog();

                    bool    validLocation = false;
                    Point3D loc           = this.Location;

                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = X + Utility.Random(5) - 1;
                        int y = Y + Utility.Random(5) - 1;
                        int z = map.GetAverageZ(x, y);

                        if (validLocation = map.CanFit(x, y, this.Z, 16, false, false))
                        {
                            loc = new Point3D(x, y, Z);
                        }
                        else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                        {
                            loc = new Point3D(x, y, z);
                        }
                    }

                    dog.ShepherdA = this;
                    this.DogA     = dog;
                    dog.Home      = this.Location;
                    dog.RangeHome = (hr > 4 ? 4 : hr);
                    dog.MoveToWorld(loc, map);
                    m_dog.Add(dog);
                }
            }

            if (family == 0)
            {
                for (int i = family; i < sheepCount; ++i)
                {
                    ShepherdsSheep sheep = new ShepherdsSheep();

                    bool    validLocation = false;
                    Point3D loc           = this.Location;

                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = X + Utility.Random(5) - 1;
                        int y = Y + Utility.Random(5) - 1;
                        int z = map.GetAverageZ(x, y);

                        if (validLocation = map.CanFit(x, y, this.Z, 16, false, false))
                        {
                            loc = new Point3D(x, y, Z);
                        }
                        else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                        {
                            loc = new Point3D(x, y, z);
                        }
                    }

                    sheep.ShepherdA = this;
                    sheep.DogA      = this.DogA;
                    //sheep.Team = this.Team;
                    sheep.Home      = this.Location;
                    sheep.RangeHome = (hr > 4 ? 4 : hr);
                    sheep.MoveToWorld(loc, map);
                    m_sheep.Add(sheep);
                }
            }

            else
            {
                return;
            }
        }