Esempio n. 1
0
 public SuperCity(WorldLayer _layer, params Point[] _cityBlockIds):base(_layer, _cityBlockIds)
 {
     if (Constants.WORLD_MAP_SIZE >= 32)
     {
         AddBuildings();
     }
 }
Esempio n. 2
0
		protected Creature(EALNouns _name, WorldLayer _layer, int _speed)
			: base(_name, EssenceHelper.GetMaterial<BodyMaterial>())
		{
			Speed = _speed;
			Luck = 25;
			m_layer = _layer;
		}
Esempio n. 3
0
		public Spider(WorldLayer _layer)
			: base(EALNouns.Spider, _layer, 120 + World.Rnd.Next(20))
		{
			var lcd = 0.5f + (Nn % 20 - 10) / 10f;
			LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble()/2, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble()/2);
			Behaviour = EMonsterBehaviour.IDLE;
		}
Esempio n. 4
0
		public Wolf(WorldLayer _layer)
			: base(EALNouns.Wolf, _layer, 80 + World.Rnd.Next(20))
		{
			var lcd = 0.5f + (Nn % 10 - 5) / 10f;
			LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble() / 2f);
			Behaviour = EMonsterBehaviour.IDLE;
		}
Esempio n. 5
0
		public SplatterDropper(WorldLayer _layer, LiveMapCell _from, int _strength, FColor _color, LiveMapCell _to): base(EALNouns.NONE, _layer, 0)
		{
			m_strenght = _strength;
			m_color = _color;

			var d = _to.PathMapCoords - _from.PathMapCoords;
			World.TheWorld.CreatureManager.AddCreature(this, _from.WorldCoords, _from.LiveCoords, _layer);
			m_path = _from.LiveCoords.GetLineToPoints(_from.LiveCoords + d * 10).ToList();
		}
Esempio n. 6
0
		public CreatureGeoInfo AddCreature(Creature _creature, Point _worldCoords, Point _liveCoords, WorldLayer _layer = null)
		{
			if(_creature is FakedCreature)
			{
				_creature = (Creature)((FakedCreature)_creature).Essence.Clone(World.TheWorld.Avatar);
			}

			if(InfoByCreature.ContainsKey(_creature))
			{
				throw new ApplicationException();
			}

			if(_layer==null)
			{
				_layer = World.TheWorld.Avatar.GeoInfo.Layer;
			}

			CreatureGeoInfo geoInfo;
			if(!OutOfScope.TryGetValue(_creature, out geoInfo))
			{
				geoInfo = new CreatureGeoInfo(_creature, _worldCoords) {Layer = _layer};
			}
			else
			{
				OutOfScope.Remove(_creature);
			}

			InfoByCreature.Add(_creature, geoInfo);
			
			PointByCreature.Add(geoInfo, _worldCoords);
			if (_creature is AbstractDummyCreature)
			{
				List<CreatureGeoInfo> list;
				if(!DummyCreatureByPoint.TryGetValue(_worldCoords, out list))
				{
					list = new List<CreatureGeoInfo>();
					DummyCreatureByPoint.Add(_worldCoords, list);
				}
				list.Add(geoInfo);
			}
			else
			{
				CreatureByPoint.Add(_worldCoords, geoInfo);
			}

			geoInfo.LiveCoords = _liveCoords;

			_creature.GeoInfo = geoInfo;
			geoInfo[0,0].ResetCached();

			if (_creature.GeoInfo.WorldCoords != _worldCoords)
			{
				throw new ApplicationException();
			}

			return geoInfo;
		}
Esempio n. 7
0
		public Rat(WorldLayer _layer)
			: base(EALNouns.Rat, _layer, 100 + World.Rnd.Next(20))
		{
			Sex = ESex.FEMALE;

			var lcd = 0.5f + (Nn % 3 - 1) / 10f;
			LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble());

			Behaviour = EMonsterBehaviour.IDLE;
		}
Esempio n. 8
0
		public EActResults MoveToLayer(Creature _creature)
		{
			if (m_leadToLayer == null)
			{
				m_leadToLayer = World.TheWorld.GenerateNewLayer(_creature, this);
			}
			World.TheWorld.CreatureManager.MoveCreature(_creature, _creature.GeoInfo.WorldCoords, m_leadToLayer);

			return EActResults.DONE;
		}
Esempio n. 9
0
		public static void Fill(this BaseMapBlock _block, Random _rnd, WorldLayer _layer, IEnumerable<ETerrains> _defaultTerrains, Rct _rct)
		{
			var def = _defaultTerrains.ToArray();
			for (var i = 0; i < _rct.Width; ++i)
			{
				for (var j = 0; j < _rct.Height; ++j)
				{
					_block.Map[i + _rct.Left, j + _rct.Top] = def.RandomItem(_rnd);
				}
			}
		}
Esempio n. 10
0
		public Missile(WorldLayer _layer, LiveMapCell _from, int _speed, Item _ammo, LiveMapCell _to)
			: base(_ammo.ENoun, _layer, _speed)
		{
			Ammo = _ammo;
			var d = (_to.PathMapCoords - _from.PathMapCoords)*10;
			if(d.Lenght>32)
			{
				d = d*31/(int)d.Lenght;
			}
			World.TheWorld.CreatureManager.AddCreature(this, _from.WorldCoords, _from.LiveCoords, _layer);
			m_path = _from.LiveCoords.GetLineToPoints(_from.LiveCoords + d).ToList();
			m_light = new LightSource(10, new FColor(2f, 1f, 0.8f, 0.4f));
		}
Esempio n. 11
0
		public override void AddStair(WorldLayer _enterFromLayer, Point _worldCoords, Stair _stair)
		{
			var blockId = BaseMapBlock.GetBlockId(EnterCoords);
			var inBlockCoords = BaseMapBlock.GetInBlockCoords(EnterCoords);
			var block = this[blockId];

			if (_stair is StairUp)
			{
				block.AddEssence(new StairDown(_enterFromLayer, EssenceHelper.GetFirstFoundedMaterial<MineralMaterial>()), inBlockCoords);
			}
			else
			{
				block.AddEssence(new StairUp(_enterFromLayer, EssenceHelper.GetFirstFoundedMaterial<MineralMaterial>()), inBlockCoords);
			}
		}
Esempio n. 12
0
		public Avatar(WorldLayer _surface)
			: base(EALNouns.Avatar, _surface, 100, EIntellectGrades.INT)
		{
			if (!Constants.GAME_MODE) return;

			Tactic = ETactics.NORMAL;
			Luck = 6;
			AddRole(new AvatarRole());
			Equip(EEquipmentPlaces.RIGHT_HAND, EssenceHelper.GetRandomFakedItem<AbstractMeleeWeapon>(World.Rnd));
			Equip(EEquipmentPlaces.MISSILE_WEAPON, EssenceHelper.GetFirstFoundedItem<AbstractRangedWeapon>());
			Tactic = ETactics.BERSERK;
			
			var ammo = EssenceHelper.GetRandomFakedItem<StackOfAmmo>(World.Rnd).Essence.Clone(this) as StackOfAmmo;
			ammo.Count = 100;
			Equip(EEquipmentPlaces.MISSILES, ammo);
			Equip(EEquipmentPlaces.TOOL, EssenceHelper.GetFirstFoundedItem<AbstractTorch>());
		}
Esempio n. 13
0
		protected Intelligent(EALNouns _name, WorldLayer _layer, int _speed, EIntellectGrades _intellectGrades)
			: base(_name, _layer, _speed)
		{
			Sex = World.Rnd.Next(2) == 0 ? ESex.MALE : ESex.FEMALE;
			m_intellectGrades = _intellectGrades;
			switch (_intellectGrades)
			{
				case EIntellectGrades.SEMI_INT:
					m_equipment.Add(EEquipmentPlaces.RIGHT_HAND, null);
					m_equipment.Add(EEquipmentPlaces.LEFT_HAND, null);
					break;
				case EIntellectGrades.INT:
					m_backPack = new BackPack();

					foreach (var eEquipmentPlacese in EquipmentPlacesAttribute.AllValues)
					{
						m_equipment.Add(eEquipmentPlacese, null);
					}
					break;
				default:
					throw new ArgumentOutOfRangeException("_intellectGrades");
			}
		}
Esempio n. 14
0
		protected Stair(EALNouns _name, WorldLayer _leadToLayer, Material _material)
			: base(_name, _material)
		{
			m_leadToLayer = _leadToLayer;
			Sex = ESex.FEMALE;
		}
Esempio n. 15
0
		protected AbstractMonster(EALNouns _name, WorldLayer _layer, int _speed)
			: base(_name, _layer, _speed)
		{
		}
		protected AbstractDummyCreature(EALNouns _name, WorldLayer _layer, int _speed) : base(_name, _layer, _speed)
		{
		}
Esempio n. 17
0
 public virtual void AddStair(WorldLayer _enterFromLayer, Point _worldCoords, Stair _stair)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
		public void MoveCreature(Creature _creature, Point _worldCoord, WorldLayer _layer = null)
		{
			if (_layer == null)
			{
				_layer = World.TheWorld.Avatar.GeoInfo.Layer;
			}

			_creature[0, 0].ResetCached();

			var info = InfoByCreature[_creature];

			if (_creature.GeoInfo.WorldCoords != info.WorldCoords)
			{
				throw new ApplicationException();
			}

			if (_layer != info.Layer)
			{
				if (_creature.IsAvatar)
				{
					//Если аватар ушел на другой уровень
					var allCreatures = InfoByCreature.Keys.ToArray();
					foreach (var creature in allCreatures)
					{
						if (creature.IsAvatar)
						{
							continue;
						}
						if (creature is AbstractDummyCreature)
						{
							CreatureIsDead(creature);
						}
						else
						{
							ExcludeCreature(creature);
						}
					}
					info.Layer = _layer;
					World.TheWorld.LiveMap.Reset();
				}
				else
				{
					throw new NotImplementedException();
				}
			}
			else
			{
				if (info.WorldCoords == _worldCoord)
				{
					throw new ApplicationException();
				}

				PointByCreature.Remove(info);

				var oldBlockId = BaseMapBlock.GetBlockId(info.WorldCoords);
				var newBlockId = BaseMapBlock.GetBlockId(_worldCoord);

				var delta = _worldCoord - info.WorldCoords;
				if (oldBlockId != newBlockId)
				{
					var newCell = info[delta];
					if (_creature.IsAvatar)
					{
						World.TheWorld.LiveMap.AvatarChangesBlock(oldBlockId, newBlockId, newCell.LiveMapBlock.LiveMapBlockId);
					}
				}
				if (info.LiveCoords != null)
				{
					if (_creature is AbstractDummyCreature)
					{
						if (!DummyCreatureByPoint[info.WorldCoords].Remove(info))
						{
							throw new ApplicationException();
						}
						List<CreatureGeoInfo> list;
						if (!DummyCreatureByPoint.TryGetValue(_worldCoord, out list))
						{
							list = new List<CreatureGeoInfo>();
							DummyCreatureByPoint.Add(_worldCoord, list);
						}
						list.Add(info);
					}
					else
					{
						if (!CreatureByPoint.Remove(info.WorldCoords))
						{
							throw new ApplicationException();
						}
						CreatureByPoint.Add(_worldCoord, info);
					}
					info.LiveCoords += delta;
					info.WorldCoords = _worldCoord;

					PointByCreature.Add(info, _worldCoord);
				}
			}
			if (info.LiveCoords != null)
			{
				_creature[0, 0].ResetCached();
				if (_creature.IsAvatar)
				{
					MessageManager.SendMessage(this, WorldMessage.AvatarMove);
				}
			}
		}
Esempio n. 19
0
 public Citizen(WorldLayer _layer, Random _rnd, Noun _name)
     : base(EALNouns.Ctitzen, _layer, _rnd.Next(10) + 95, EIntellectGrades.INT)
 {
     Sex = _name.Sex;
     m_name = _name;
 }
Esempio n. 20
0
		public static void Clear(this BaseMapBlock _block, Random _rnd, WorldLayer _layer, IEnumerable<ETerrains> _defaultTerrains) { Fill(_block, _rnd, _layer, _defaultTerrains, BaseMapBlock.Rect); }
Esempio n. 21
0
		public StairDown(WorldLayer _leadToLayer, Material _material)
			: base(EALNouns.StairDown, _leadToLayer, _material) { }
Esempio n. 22
0
		public virtual void AddStair(WorldLayer _enterFromLayer, Point _worldCoords, Stair _stair) { throw new NotImplementedException(); }
Esempio n. 23
0
        public override void GenerateCityBlock(MapBlock _block, Random _rnd, WorldLayer _layer)
        {
            var roadPoints = new List<Point>();
            for (var i = 0; i < Constants.MAP_BLOCK_SIZE; ++i)
            {
                if (_rnd.Next(2) == 0) roadPoints.Add(new Point(0, i));
                if (_rnd.Next(2) == 0) roadPoints.Add(new Point(1, i));
                if (_rnd.Next(2) == 0) roadPoints.Add(new Point(i, 0));
                if (_rnd.Next(2) == 0) roadPoints.Add(new Point(i, 1));
            }

            if (roadPoints.All(point => TerrainAttribute.GetAttribute(_block.Map[point.X, point.Y]).IsPassable))
            {
                foreach (var point in roadPoints)
                {
                    _block.Map[point.X, point.Y] = ETerrains.ROAD;
                }
            }

            var terrains = m_buildings.Where(_building => _building.BlockId == _block.BlockId).ToDictionary(_b => _b, _building => _building.Room.AreaRectangle.AllPoints.Select(_point => _block.Map[_point.X, _point.Y]).Distinct().ToArray());
            foreach (var pair in terrains)
            {
                if (pair.Value.Any(_terrains => TerrainAttribute.GetAttribute(_terrains).IsNotPassable))
                {
                    m_buildings.Remove(pair.Key);
                }
            }

            var buildings = m_buildings.Where(_pair => _pair.BlockId == _block.BlockId).ToArray();
            foreach (var building in buildings)
            {
                _block.AddRoom(building.Room);
                building.Fill(_block, _layer);
                var citizens = m_citizens.Where(_citizen => _citizen.Roles.OfType<AbstractCitizenRole>().First().Building == building).ToArray();
                foreach (var citizen in citizens)
                {
                    if (m_already.Contains(citizen))
                    {
                        throw new ApplicationException();
                    }
                    m_already.Add(citizen);

                    Tuple<ETileset, FColor> tuple = null;
                    foreach (var color in citizen.Roles.First().Colors)
                    {
                        tuple = Tuple.Create(citizen.Tileset, color);
                        if (!m_conf.Contains(tuple))
                        {
                            break;
                        }
                    }
                    if (tuple == null)
                    {
                        throw new ApplicationException();
                    }

                    m_conf.Add(tuple);
                    citizen.SetLerpColor(tuple.Item2);
                    _block.CreaturesAdd(citizen, building.Room.RoomRectangle.Center);
                }
            }
        }