public static Room MoveMobileEntityTo(MobileEntity mob, Point roomCoordinates) { var targetRoom = mob.CurrentRoom.Zone.Rooms.First(o => o.Coordinates == roomCoordinates); mob.CurrentRoom = targetRoom; return targetRoom; }
public Entity Convert(MobileEntity item) { bool coversionResult = false; Entity entity = null; // ReSharper disable once CanBeReplacedWithTryCastAndCheckForNull if (item is MobileUser) { MobileUser mobUser = ((MobileUser)item); User user; coversionResult = this.Convert(mobUser, out user); entity = user; } else if (item is MobileEvent) { MobileEvent mobEvent = ((MobileEvent)item); Event @event; coversionResult = this.Convert(mobEvent, out @event); entity = @event; } /* * else if (item is Category) * { * Category category = ((Category)item); * MobileCategory mobCategory; * coversionResult = Convert(category, out mobCategory); * mobEntity = mobCategory; * } */ else { throw new InvalidOperationException(); } if (!coversionResult || entity == null) { throw new InvalidOperationException("Could not convert from MobileEntity to Entity"); } return(entity); }
public override int CalculateProjectileDamage(ItemEntity item, MobileEntity defender) { if (item is ProjectileWeapon weapon) { var baseMinimumDamage = weapon.MinimumDamage; var baseMaximumDamage = weapon.MaximumDamage; var hitAdds = Stats.DexterityAdds + weapon.GetAttackBonus(this, defender); var skillLevel = GetSkillLevel(Skill.Bow); var skillMultiplier = (skillLevel * 0.1 + 1.0); var minimumDamage = (int)((baseMinimumDamage + hitAdds) * skillMultiplier); var maximumDamage = (int)((baseMaximumDamage + hitAdds) * skillMultiplier); return(Utility.RandomBetween(Math.Max(1, minimumDamage), Math.Max(1, maximumDamage))); } return(0); }
public void OnConsume(MobileEntity entity, Consumable item) { if (entity is PlayerEntity player) { var age = player.Age; if (age > Aging.Young) { age -= Aging.Young * 2; } if (age < Aging.Young) { age = Aging.Young; } player.Age = age; player.SendLocalizedMessage(6300346); } }
public void OnConsume(MobileEntity entity, Consumable item) { if (entity is PlayerEntity player) { var dexterity = player.Stats.BaseDexterity; if (dexterity.Value < dexterity.Max) { dexterity.Value++; } player.SendLocalizedMessage(6100102); /* You feel more agile. */ if (Utility.RandomBetween(1, 2) >= 2) { player.Blind(4); } player.Stun(12); } }
protected override bool OnEquip(MobileEntity entity) { if (!base.OnEquip(entity)) { return(false); } if (!entity.GetStatus(typeof(WaterWalkingStatus), out var status)) { status = new WaterWalkingStatus(entity); status.AddSource(new ItemSource(this)); entity.AddStatus(status); } else { status.AddSource(new ItemSource(this)); } return(true); }
public void OnConsume(MobileEntity entity, Consumable item) { if (entity is PlayerEntity player) { var strength = player.Stats.BaseStrength; if (strength.Value < strength.Max) { strength.Value++; } player.SendLocalizedMessage(6100100); /* You feel a little bit more like Hercules. */ if (Utility.RandomBetween(1, 2) >= 2) { player.Blind(4); } player.Stun(12); } }
public void ThrowAt(MobileEntity source, Consumable item, Point2D location) { var segment = source.Segment; var tile = segment.FindTile(location); if (tile is null || !tile.AllowsSpellPath()) { return; } // TODO: Check for hole/sky? var spell = new BonfireSpell() { Item = item, SkillLevel = 6, Cost = 0, }; spell.Warm(source); spell.CastAt(location); }
/// <summary> /// Called when this <see cref="ItemEntity" /> is unquipped by the specified <see cref="MobileEntity" /> /// </summary> protected override bool OnUnequip(MobileEntity entity) { if (!base.OnUnequip(entity)) { return(false); } if (_isActive && entity.IsAlive) /* Only teleport the entity if they are alive. */ { var sourceSegment = entity.Segment; var sourceLocation = entity.Location; var targetSegment = BoundSegment; var targetLocation = BoundLocation; var sourceSound = targetLocation.GetDistanceToMax(sourceLocation) > 3; if (targetSegment != default(Segment)) { targetSegment.PlaySound(targetLocation, 66, 3, 6); } if (sourceSound) { sourceSegment.PlaySound(sourceLocation, 66, 3, 6); } if (!entity.Deleted && entity.IsAlive) { entity.Teleport(targetLocation, targetSegment); } _isActive = false; Delete(); } return(true); }
public override int CalculateJumpkickDamage(ItemEntity item, MobileEntity defender) { var minimumDamage = 0; var maximumDamage = 0; var encumbrancePenalty = 2 * Encumbrance; var handSkill = GetSkillLevel(Skill.Hand); var effectiveSkill = handSkill - encumbrancePenalty; if (item is Boots boots) { effectiveSkill -= 2; } var skillMultiplier = (Math.Max(0, effectiveSkill) * 0.5) + 2.0; minimumDamage = (int)((Stats.StrengthAdds + 1) * skillMultiplier); maximumDamage = (int)((Stats.StrengthAdds + 5) * skillMultiplier); return(Utility.RandomBetween(Math.Max(1, minimumDamage), Math.Max(1, maximumDamage))); }
private bool CheckMapBoundary(MobileEntity entity) { if (entity.Coordinates.X < 0 && entity.Direction == Direction.Left) { return(true); } if (entity.Coordinates.X > mapSize.Width - entity.Sprite.Width && entity.Direction == Direction.Right) { return(true); } if (entity.Coordinates.Y < 0 && entity.Direction == Direction.Up) { return(true); } if (entity.Coordinates.Y > mapSize.Height - entity.Sprite.Height && entity.Direction == Direction.Down) { return(true); } return(false); }
/// <summary> /// 发生短信 /// </summary> /// <param name="info"></param> protected override string GetSendStatus(MobileEntity info) { var json = Configuration.ConfigurationManager.GetSetting <string>("YunXinLiuKeSms").DeserializeJson <dynamic>(); if (json == null) { return(""); } var status = WebRequestHelper.SendPostRequest(json.Url.ToString(), new Dictionary <string, string> { { "Msg", System.Web.HttpUtility.UrlEncode(info.Body, Encoding.GetEncoding("UTF-8")) }, { "DesNo", string.Join(",", info.ToMobiles) }, { "UserCode", json.UserCode.ToString() }, { "UserPass", json.UserPass.ToString() }, { "Channel", "0" } }); string reg = "<string(.*?)>(?<num>.*?)</string>"; Regex r = new Regex(reg, RegexOptions.IgnoreCase); Match mc = r.Match(status); return(mc.Groups["num"].ToString()); }
/// <summary> /// 得到状态 /// </summary> /// <param name="info"></param> /// <returns></returns> protected override string GetSendStatus(MobileEntity info) { var json = Configuration.ConfigurationManager.GetSetting <string>("MengWangSms").DeserializeJson <dynamic>(); if (json == null) { return(""); } var status = WebRequestHelper.SendPostRequest(json.Url.ToString(), Encoding.GetEncoding("GBK"), new Dictionary <string, string> { { "pszMsg", System.Web.HttpUtility.UrlEncode(info.Body) }, { "iMobiCount", info.ToMobiles.Length.ToString() }, { "pszMobis", string.Join(",", info.ToMobiles) }, { "pszSubPort", "*" }, { "UserId", json.UserId.ToString() }, { "Password", json.Password.ToString() } }); string reg = "<string(.*?)>(?<num>.*?)</string>"; Regex r = new Regex(reg, RegexOptions.IgnoreCase); Match mc = r.Match(status); return(mc.Groups["num"].ToString()); }
/// <summary> /// Determines whether this instance can be equipped. /// </summary> public override bool CanEquip(MobileEntity entity) { /* The presence of high levels of the Dark Power prevents you from removing the ring. */ var segment = entity.Segment; var location = entity.Location; var subregion = segment.GetSubregion(location); if (subregion != null && !subregion.AllowRecall) { entity.SendLocalizedMessage(6300353); /* The presence of high levels of the Dark Power prevents you from putting on the ring. */ return(false); } var worldTile = segment.FindTile(location); if (!worldTile.CanEnter(entity)) { entity.SendLocalizedMessage(Color.Red, 6300062); /* You may not put on that ring here. */ return(false); } return(base.CanEquip(entity)); }
public void AddItems <T>(IEnumerable <T> items) { List <MobileEntity> convertedItems = new List <MobileEntity>(); foreach (T item in items) { try { MobileEntity mobEntity = converterService.Convert((item as Entity)); convertedItems.Add(mobEntity); } catch (Exception) { //ToDo trace continue; } } //http://stackoverflow.com/questions/36774326/poor-performance-sqlite-net-extensions this.sqliteConnection.RunInTransaction(() => { this.sqliteConnection.InsertOrReplaceAllWithChildren(convertedItems, true); }); }
/// <inheritdoc /> protected override bool OnEquip(MobileEntity entity) { var onEquip = base.OnEquip(entity); if (!entity.GetStatus(typeof(FeatherFallStatus), out var status)) { status = new FeatherFallStatus(entity) { Inscription = new SpellInscription() { SpellId = 14 } }; status.AddSource(new ItemSource(this)); entity.AddStatus(status); } else { status.AddSource(new ItemSource(this)); } return(onEquip); }
/// <summary> /// Called when this <see cref="ItemEntity" /> is equipped by the specified <see cref="MobileEntity" /> /// </summary> protected override bool OnEquip(MobileEntity entity) { /* Recalls rings trigger their effect when equipped. When the world is loaded, each item is * called to be equipped on the respective entity. Recall rings that are not active and * in a container slot, would inappropriately trigger to be equipped. */ if (PersistenceManager.IsLoading) { return(false); } if (_isActive || !base.OnEquip(entity)) { return(false); } BoundSegment = entity.Segment; BoundLocation = entity.Location; entity.SendLocalizedMessage(6300061); /* You feel a tingling sensation.*/ _isActive = true; return(true); }
/// <summary> /// 计算mobile在交叉口内部可以走多少步 /// </summary> /// <param name="rN"></param> /// <param name="pCurrent">current position</param> /// <param name="Gap">return value</param> /// <returns></returns> private bool GetXNodeGap(XNode node, OxyzPoint opCurr, out int iGap, MobileEntity mobile) { //indicator to tell whether or not a mobile is blocked //bool bReachEnd = false; bool bOccupied = false; int iCount = 0; OxyzPoint p = mobile.Track.NextPoint(opCurr); while ((bOccupied = node.IsOccupied(p)) == false) { if (p._X == 0 && p._Y == 0) { // bReachEnd = true; break; } p = mobile.Track.NextPoint(p); iCount++; } iGap = iCount; //return bReachEnd return(bOccupied); }
public WaterWalkingStatus(MobileEntity entity) : base(entity) { }
public Corpse(MobileEntity owner, int body) : base(body) { Owner = owner; }
public override bool ThrowAt(MobileEntity source, Point2D location) { source.SendLocalizedMessage(6300357); /* Even given the strength of the ghods, you could not throw this. */ return(true); }
/// <summary> /// 发送短信 /// </summary> /// <param name="info"></param> public virtual string Send(MobileEntity info) { return(MobileRepository.Send(info)); }
public void OnConsume(MobileEntity entity, Consumable item) { entity.Poison(item.Owner, new Poison(TimeSpan.Zero, _potency)); }
/// <summary> /// Initializes a new instance of the <see cref="BalmTimer"/> class. /// </summary> public BalmTimer(MobileEntity entity, int healthPerTick = 14) : base(TimeSpan.Zero, entity.GetRoundDelay(1d / 3d)) { _entity = entity; _healthPerTick = healthPerTick; }
public CharacterBattleModeController(MobileEntity entity) { }
public void OnConsume(MobileEntity entity, Consumable item) { entity.BalmTimer = new BalmTimer(entity); }
public EntityStateData(MobileEntity e) { EntityID = e.id; groundState = e.groundState; facingState = e.facing; movingState = e.moving; }
public void OnConsume(MobileEntity entity, Consumable item) { entity.SendLocalizedMessage(6300345); entity.ApplyDamage(entity, 10); }
/// <summary> /// Apply any data in the EntityStateData to the given entity /// </summary> public void apply(MobileEntity e) { e.groundState = groundState; e.moving = movingState; e.facing = facingState; }
public DetectCollision(MobileEntity damagingEntity, MobileEntity damagedEntity) { DamagingEntity = damagingEntity ?? throw new ArgumentNullException(nameof(damagedEntity)); DamagedEntity = damagedEntity ?? throw new ArgumentNullException(nameof(damagedEntity)); }
/// <inheritdoc /> public override bool CanEquip(MobileEntity entity) { if (entity is PlayerEntity { Profession : MartialArtist })
/* Bows actually take two turns to shoot, so the skill gain multiplier should be double. */ public override TimeSpan GetSwingDelay(MobileEntity entity) { return(entity.GetRoundDelay(0.75)); }
public void OnConsume(MobileEntity entity, Consumable item) { entity.Health += _amount; }