Example #1
0
		public void RemoteActivation(Creature _creature, Point _worldCoords)
		{
			var creatureLiveCell = _creature[0, 0];
			var delta = _worldCoords - creatureLiveCell.WorldCoords;
			var myCell = _creature[delta.X, delta.Y];

			switch (Effect)
			{
				case EMagicPlateEffect.RANDOM_MONSTER_APPEAR:

					if (myCell.Creature==null)
					{
						var monster = (AbstractMonster)EssenceHelper.GetRandomFakedCreature<AbstractMonster>(World.Rnd).Essence.Clone(_creature);
						monster.Behaviour=EMonsterBehaviour.IDLE;
						World.TheWorld.CreatureManager.AddCreature(monster, myCell.WorldCoords, myCell.LiveCoords);

						MessageManager.SendMessage(this, new SoundTextMessage("послышался всплеск"));
					}
					else
					{
						MessageManager.SendMessage(this, new SoundTextMessage("послышался треск"));
					}
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
		}
Example #2
0
		public void CreaturesAdd(Creature _creature, Point _inBlockCoords)
		{
			if(Creatures.Any(_pair => _pair.Value == _inBlockCoords))
			{
				throw new ApplicationException();
			}
			//var busy = new List<Point>();
			//while (Creatures.Any(_pair => _pair.Value == _inBlockCoords))
			//{
			//    busy.Add(_inBlockCoords);
			//    var lt = _creature[0, 0].InBlockCoords;

			//    foreach (var point in new Point(Constants.MAP_BLOCK_SIZE / 2, Constants.MAP_BLOCK_SIZE / 2).GetSpiral(Constants.MAP_BLOCK_SIZE / 2 - 1))
			//    {

			//        if (_creature[point - lt].GetIsPassableBy(_creature) > 0 && !busy.Contains(point))
			//        {
			//            _inBlockCoords = point;
			//            break;
			//        }
			//    }
			//}

			Creatures.Add(_creature, _inBlockCoords);
			//if (_creature.GeoInfo != null)
			//{
			//    _creature.GeoInfo.WorldCoords = WorldCoords + _inBlockCoords;
			//}
		}
Example #3
0
		public override EActResults Do(Creature _creature)
		{
			var intelligent = (Intelligent) _creature;
			EssenceDescriptor descriptor;
			if (!TryGetParameter(out descriptor))
			{
				MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.SELECT_THINGS_FROM_BACK_PACK, ESelectItemDialogBehavior.SELECT_ONE, new[] {EItemCategory.POTION}));
				return EActResults.NEED_ADDITIONAL_PARAMETERS;
			}
			if (descriptor == EssenceDescriptor.Empty)
			{
				return EActResults.QUICK_FAIL;
			}
			var total = intelligent.GetBackPackItems().Where(_thingDescriptor => _thingDescriptor.Essence.Equals(descriptor)).ToArray();

			if (total.Length == 0)
			{
				throw new ApplicationException("в рюкзаке нет такого предмета");
			}
			var item = (Potion) descriptor.Essence;

			if (!item.IsAllowToDrink(_creature))
			{
				return EActResults.QUICK_FAIL;
			}

			intelligent.RemoveFromBackpack(item);
			item.Drinked(_creature);

			MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_DRINKS_IT, _creature, item));
			return EActResults.DONE;
		}
Example #4
0
		public override EActResults Do(Creature _creature)
		{
			LiveMapCell liveMapCell;

			var find = FindCreature(_creature, (_crt, _cell) => _crt!=_creature, out liveMapCell);
			switch (find)
			{
				case EActResults.QUICK_FAIL:
					if (_creature.IsAvatar)
					{
						MessageManager.SendMessage(this, new SimpleTextMessage(EMessageType.INFO, "направление атаки?"));
					}
					else
					{
						throw new ApplicationException("Только аватар может не указывать направление при атаке.");
					}
					return find;
				case EActResults.NONE:
					break;
				default:
					return find;

			}

			return World.TheWorld.BattleProcessor.Atack(_creature, liveMapCell.Creature);
		}
Example #5
0
		protected override IEnumerable<Item> GenerateItems(Creature _creature)
		{
			var cnt = _creature.GetLuckRandom*5.0;
			for (var i = 0; i < cnt; i++)
			{
				yield return EssenceHelper.GetRandomFakedItem(World.Rnd);
			}
		}
Example #6
0
		public Essence ResolveFakeItem(Creature _creature, FakedItem _fakedItem)
		{
			Debug.WriteLine("RESOLVE " + _fakedItem);
			GetItems(_creature).Remove(_fakedItem);
			var item = (Item)_fakedItem.Essence.Clone(_creature);
			GetItems(_creature).Add(item);
			return item;
		}
Example #7
0
		public override EActResults Do(Creature _creature)
		{
			var intelligent = (Intelligent) _creature;
			var descriptors = GetParameter<EssenceDescriptor>().ToArray();
			if (descriptors.Length == 0)
			{
				MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.SELECT_THINGS_FROM_BACK_PACK, ESelectItemDialogBehavior.ALLOW_CHANGE_FILTER | ESelectItemDialogBehavior.SELECT_ONE));
				return EActResults.NEED_ADDITIONAL_PARAMETERS;
			}

			if (descriptors.Length > 1)
			{
				foreach (var thingDescriptor in descriptors)
				{
					_creature.AddActToPool(new DropAct(), thingDescriptor);
				}
				return EActResults.QUICK_FAIL;
			}

			var descriptor = descriptors[0];

			if (descriptor == EssenceDescriptor.Empty)
			{
				return EActResults.QUICK_FAIL;
			}

			var total = intelligent.GetBackPackItems().Where(_thingDescriptor => _thingDescriptor.Essence.GetName(_creature) == descriptor.Essence.GetName(_creature)).Count();
			if (total == 0)
			{
				throw new ApplicationException("в рюкзаке нет такого предмета");
			}
			if (total > 1)
			{
				int cnt;
				if (TryGetParameter(out cnt))
				{
					Count = cnt;
				}
				else
				{
					MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.HOW_MUCH, descriptor, total));
					return EActResults.NEED_ADDITIONAL_PARAMETERS;
				}
			}
			else
			{
				Count = 1;
			}
			var item = (Item) descriptor.Essence;
			for (var i = 0; i < Count; ++i)
			{
				intelligent.RemoveFromBackpack(item);
				_creature[0, 0].AddItem(item);
			}

			MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_DROPS_IT, _creature, item, Count));
			return EActResults.DONE;
		}
		public CreatureBattleInfo(Creature _creature, int _dv, int _pv, Dice _hitDice)
		{
			DV = _dv;
			PV = _pv;
			Creature = _creature;
			HP = _hitDice.Roll();
			HPMax = _hitDice.Max;
			Agro = new Dictionary<Creature, int>();
		}
Example #9
0
		public override EActResults Do(Creature _creature)
		{
			IEnumerable<Point> way;

			var max = int.MaxValue;
			TryGetParameter(out max);

			if (TryGetParameter(out way))
			{
				var result = EActResults.DONE;
				var pnt = way.First();
				var longWay = way.Count() > 1;
				foreach (var point in way)
				{
					var dpoint = point - pnt;
					if (dpoint != Point.Zero)
					{
						_creature.AddActToPool(new MoveAct(), dpoint, longWay);
						result = EActResults.ACT_REPLACED;
						max--;
						if (max <= 0)
						{
							break;
						}
					}
					pnt = point;
				}
				return result;
			}

			Point target;
			if (!TryGetParameter(out target))
			{
				MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.ASK_DESTINATION));
				return EActResults.NEED_ADDITIONAL_PARAMETERS;
			}

			var current = _creature[0, 0].WorldCoords;
			if (target == current)
			{
				return EActResults.QUICK_FAIL;
			}
			var nextPoint = current.GetLineToPoints(target).ToArray()[1];
			var delta = nextPoint - current;
			var nextCell = _creature[delta];
			if (nextCell.GetIsPassableBy(_creature) > 0)
			{
				_creature.AddActToPool(new MoveAct(), delta);
				return EActResults.ACT_REPLACED;
			}
			if (nextCell.Thing != null && nextCell.Thing.Is<ClosedDoor>())
			{
				_creature.AddActToPool(new OpenAct(), delta);
				return EActResults.ACT_REPLACED;
			}
			return EActResults.FAIL;
		}
Example #10
0
		public override EActResults Do(Creature _creature)
		{
			if (_creature.IsAvatar)
			{
				World.TheWorld.Avatar.Tactic = ETactics.COWARD;
				MessageManager.SendMessage(this, new SimpleTextMessage(EMessageType.INFO, "Текущий " + Name));
			}
			return EActResults.DONE;
		}
Example #11
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;
		}
Example #12
0
		internal override Essence Clone(Creature _resolver)
		{
			var clone = (StackOfItems)base.Clone(_resolver);
			if (clone.Count == 0)
			{
				clone.Count = clone.GetStartCount(_resolver);
			}
			return clone;
		}
Example #13
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;
		}
Example #14
0
		public EActResults Open(Creature _creature, LiveMapCell _liveMapCell)
		{
			var door = new OpenDoor(Material);
			door.SetLockType(m_eLockType);
			_liveMapCell.Thing = door;

			if (_creature.IsAvatar)
			{
				MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_OPENS_IT, _creature, this));
			}
			return EActResults.DONE;
		}
Example #15
0
		public EActResults Close(Creature _creature, LiveMapCell _liveMapCell)
		{
			var door = new ClosedDoor(Material);
			door.SetLockType(m_eLockType);
			_liveMapCell.Thing = door;
			if (_creature.IsAvatar)
			{
				MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_CLOSES_IT, _creature, this));
				//MessageManager.SendMessage(this, this[EPadej.IMEN] + " закрыта.");
			}
			return EActResults.DONE;
		}
Example #16
0
		public override EActResults Do(Creature _creature)
		{
			var thing = _creature[0, 0].GetResolvedThing(_creature);
			if (!(thing is StairUp))
			{
				if (_creature.IsAvatar)
				{
					MessageManager.SendMessage(this, "куда? “ут нет лестницы");
				}
				return EActResults.QUICK_FAIL;
			}
			return ((Stair) thing).MoveToLayer(_creature);
		}
Example #17
0
		public CreatureBattleInfo this[Creature _creature, bool _try = false]
		{
			get
			{
				CreatureBattleInfo info;
				if (!m_creatures.TryGetValue(_creature, out info) && !_try)
				{
					info = _creature.CreateBattleInfo();
					m_creatures[_creature] = info;
				}
				return info;
			}
		}
Example #18
0
		public ItemBattleInfo this[Item _item, Creature _creature, bool _try = false]
		{
			get
			{
				ItemBattleInfo info;
				if (!m_items.TryGetValue(_item, out info) && !_try)
				{
					info = _item.CreateItemInfo(_creature);
					m_items[_item] = info;
				}
				return info;
			}
		}
Example #19
0
		public override EActResults Do(Creature _creature)
		{
			var building = _creature[0, 0].InBuilding;
			if (building != null)
			{
				var coords = _creature[0, 0].WorldCoords;
				var p = building.OutDoorWorldCoords.RandomItem(World.Rnd);
				if (_creature[p - coords].GetIsPassableBy(_creature) > 0)
				{
					_creature.AddActToPool(new MoveToAct(), p);
					return EActResults.ACT_REPLACED;
				}
				return EActResults.QUICK_FAIL;
			}
			return EActResults.DONE;
		}
Example #20
0
		public static string Died(Creature _nameProvider)
		{
			var name = Sklonenia.NounToPadej(EPadej.IMEN, _nameProvider.Name.Text, _nameProvider.IsCreature, _nameProvider.Sex);
			switch (_nameProvider.Sex)
			{
				case ESex.MALE:
					return name + " мертв";
				case ESex.FEMALE:
					return name + " издохла";
				case ESex.IT:
					return name + " скончалось";
				case ESex.PLURAL:
					return name + " отдали концы";
				default:
					throw new ArgumentOutOfRangeException();
			}
		}
Example #21
0
		public override EActResults Do(Creature _creature)
		{
			var intelligent = (Intelligent) _creature;
			var item = intelligent[EEquipmentPlaces.MISSILES];
			if (item == null)
			{
				if (_creature.IsAvatar)
				{
					MessageManager.SendMessage(this, "Экипируйте снаряд для метания");
					return EActResults.FAIL;
				}
				else
				{
					throw new ApplicationException("Нечем стрелять");
				}
			}

			Point dPoint;
			if (!TryGetParameter(out dPoint))
			{
				MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.ASK_SHOOT_TARGET, 10));
				return EActResults.NEED_ADDITIONAL_PARAMETERS;
			}

			if (item is StackOfItems)
			{
				var stack = (StackOfItems) item;
				item = stack.GetOne();
				if (stack.Count == 0)
				{
					intelligent.TakeOff(EEquipmentPlaces.MISSILES);
					intelligent.RemoveFromBackpack(stack);
				}
			}
			else
			{
				intelligent.TakeOff(EEquipmentPlaces.MISSILES);
				intelligent.RemoveFromBackpack(item);
			}
			if (dPoint == Point.Zero)
			{
				return EActResults.QUICK_FAIL;
			}
			new Missile(_creature.GeoInfo.Layer, _creature[0, 0], 2, item, _creature[dPoint.X, dPoint.Y]);
			return EActResults.DONE;
		}
Example #22
0
		public override EActResults Do(Creature _creature)
		{
			var intelligent = (Intelligent) _creature;
			var tool = intelligent[EEquipmentPlaces.TOOL];

			if (tool == null)
			{
				if (_creature.IsAvatar)
				{
					MessageManager.SendMessage(this, new SimpleTextMessage(EMessageType.INFO, "Ни один инструмент не экипирован!"));
				}
				return EActResults.QUICK_FAIL;
			}

			((ITool) tool).UseTool(intelligent);

			return EActResults.DONE;
		}
Example #23
0
		/// <summary>
		/// 	Если контейнер не инициализирован, то на основании характеристик открывшего существа генерируется наполнение
		/// </summary>
		/// <param name = "_creature"></param>
		/// <returns></returns>
		public ItemsCollection GetItems(Creature _creature)
		{
			if (m_items == null)
			{
				m_items = new ItemsCollection();
				foreach (var item in GenerateItems(_creature))
				{
					if (item is IFaked)
					{
						m_items.Add((Item) ((IFaked) item).Essence.Clone(_creature));
					}
					else
					{
						m_items.Add(item);
					}
				}
			}
			return m_items;
		}
Example #24
0
		public override EActResults Do(Creature _creature)
		{
			LiveMapCell liveMapCell;

			var find = Find(_creature, (_essence, _cell) => _essence.CanBeClosed(_cell, _creature), out liveMapCell);
			switch (find)
			{
				case EActResults.QUICK_FAIL:
					if (_creature.IsAvatar) MessageManager.SendMessage(this, new SimpleTextMessage(EMessageType.INFO, "открыть что?"));
					return find;
				case EActResults.NONE:
					break;
				default:
					return find;
			}

			//выясняем, что нужно закрыть
			{
				var list = new List<EssenceDescriptor>();
				if (liveMapCell.Thing.Is<ICanbeClosed>())
				{
					list.Add(new EssenceDescriptor(liveMapCell.Thing, liveMapCell, null, _creature));
				}
				list.AddRange(liveMapCell.GetAllAvailableItemDescriptors<Thing>(_creature).Where(_descriptor => _descriptor.Essence.CanBeClosed(liveMapCell, _creature)));
				if (liveMapCell.LiveCoords == _creature.GeoInfo.LiveCoords)
				{
					list.AddRange(_creature.GetBackPackItems().Where(_descriptor => _descriptor.Essence.CanBeClosed(liveMapCell, _creature)));
				}
				var descriptors = list.Distinct();
				if (GetParameter<EssenceDescriptor>().Any())
				{
					descriptors = GetParameter<EssenceDescriptor>().Intersect(descriptors);
				}
				var arr = descriptors.ToArray();
				if (arr.Length > 1)
				{
					MessageManager.SendMessage(this, new AskMessageNg(this, EAskMessageType.SELECT_THINGS, arr, ESelectItemDialogBehavior.SELECT_MULTIPLE | ESelectItemDialogBehavior.ALLOW_CHANGE_FILTER));
				}
				return ((ICanbeClosed)arr[0].Essence).Close(_creature, liveMapCell);
			}
		}
Example #25
0
		public static string HaveGotDamage(Creature _nameProvider, int _damage)
		{
			var name = Sklonenia.NounToPadej(EPadej.IMEN, _nameProvider.Name.Text, _nameProvider.IsCreature, _nameProvider.Sex);
			switch (_nameProvider.Sex)
			{
				case ESex.MALE:
					return name + " получил " + _damage.Пунктов() + " урона";
					break;
				case ESex.FEMALE:
					return name + " получила " + _damage.Пунктов() + " урона";
					break;
				case ESex.IT:
					return name + " получило " + _damage.Пунктов() + " урона";
					break;
				case ESex.PLURAL:
					return name + " получили " + _damage.Пунктов() + " урона";
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
		}
Example #26
0
		public EActResults Open(Creature _creature, LiveMapCell _liveMapCell)
		{
			if (ELockType != ELockType.OPEN)
			{
				MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_OPENS_IT, _creature, this));
				ELockType = ELockType.OPEN;

				var collection = GetItems(_creature);
				if (collection.Any)
				{
					//обязать по любасу показать диалог выбора предметов
					_creature.AddActToPool(new TakeAct(), true, collection.Items, _liveMapCell.LiveCoords);
				}
				else
				{
					MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CONTAINER_IS_EMPTY, _creature, this));
				}

				return EActResults.DONE;
			}
			throw new NotImplementedException();
		}
		public EssenceDescriptor(Essence _essence, LiveMapCell _cell, IContainer _container, Creature _creature)
		{
			m_creature = _creature;
			if (_essence is IFaked)
			{
				if (_container != null)
				{
					if (_essence is Item)
					{
						_essence = _container.ResolveFakeItem(_creature, (FakedItem)_essence);
					}
					else
					{
						throw new NotImplementedException("Как так?");
					}
				}
				else if(_cell!=null)
				{
					if (_essence is Item)
					{
						_essence = _cell.ResolveFakeItem(_creature, (FakedItem)_essence);
					}
					else if (_essence is Thing)
					{
						_essence = _cell.ResolveFakeThing(_creature);
					}
					
				}
				else
				{
					throw new NotImplementedException("Как так?");
				}
				
			}
			Essence = _essence;
			LiveCoords = _cell!=null?_cell.LiveCoords:null;
			Container = _container;
		}
Example #28
0
		public override EActResults Do(Creature _creature)
		{
			LiveMapCell liveMapCell;
			var find = Find(_creature, (_essence, _cell) => _essence is IInteractiveThing, out liveMapCell);
			switch (find)
			{
				case EActResults.QUICK_FAIL:
					if (_creature.IsAvatar)MessageManager.SendMessage(this, new SimpleTextMessage(EMessageType.INFO, "взаимодействовать с чем?"));
					return find;
				case EActResults.NONE:
					break;
				default:
					return find;
			}

			if (liveMapCell != null)
			{
				return ((IInteractiveThing)liveMapCell.Thing).Interract(_creature, liveMapCell);
			}
			else
			{
				throw new NotImplementedException();
			}
		}
Example #29
0
		public virtual void DamageTaken(CreatureBattleInfo _creatureBattleInfo, Creature _source, IWeapon _weapon, int _damage)
		{
			MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_TAKES_DAMAGE, _source, this, _damage, _weapon));
		}
Example #30
0
		public CreatureGeoInfo(Creature _creature, Point _position)
		{
			Creature = _creature;
			WorldCoords = _position;
		}
Example #31
-1
		public void ApplyDamage(int _damage, IWeapon _weapon, Creature _source)
		{
			var fact = Math.Min(_damage, HP);

			if (!(Creature is Avatar))
			{
				HP -= _damage;
			}
			Creature.DamageTaken(this, _source, _weapon, _damage);

			fact -= Creature[0, 0].AddSplatter(fact, FColor.Crimson);
			if (fact > 0)
			{
				var ro = World.Rnd.NextDouble() * Math.PI * 2;
				var x = (int)(Math.Sin(ro) * 20f);
				var y = (int)(Math.Cos(ro) * 20f);

				new SplatterDropper(Creature.GeoInfo.Layer, Creature[0, 0], fact, FColor.Crimson, Creature[x, y]);
			}

			if (HP <= 0)
			{
				MessageManager.SendXMessage(this, new XMessage(EALTurnMessage.CREATURE_KILLED, _source, Creature));
				Creature[0, 0].AddItem(new Corpse(Creature));
				World.TheWorld.CreatureManager.CreatureIsDead(Creature);
			}
		}