/// <summary> /// 所有集合內特性物件執行DoAfterDead方法 /// </summary> /// <param name="g">Graphics物件</param> public void AllDoAfterDead(ObjectBase killer, ObjectDeadType deadType) { for (int i = 0; i < _Collection.Count; i++) { _Collection[i].DoAfterDead(killer, deadType); } }
/// <summary> /// 發生在物件死亡時 /// </summary> /// <param name="sender">死亡物件</param> /// <param name="killer">殺手物件</param> protected virtual void OnDead(ObjectBase sender, ObjectBase killer, ObjectDeadType deadType) { if (Dead != null) { Dead(sender, killer, deadType); } }
protected void OnObjectDead(ObjectBase sender, ObjectBase killer, ObjectDeadType deadType) { if (ObjectDead != null) { ObjectDead(sender, killer, deadType); } }
public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if (Owner.DrawObject == DrawNull.Value || (DeadType & deadType) != deadType) { return; } double angle = Function.GetAngle(0, 0, Owner.MoveObject.MoveX, Owner.MoveObject.MoveY); for (int i = 0; i < ScrapCount; i++) { int speed = Global.Rand.Next(ScrapSpeedMin, Math.Max(ScrapSpeedMin, ScrapSpeedMax)); int fadeTime = Global.Rand.Next(ScrapLifeMin, Math.Max(ScrapLifeMin, ScrapLifeMax)); double scrapDirection = angle + (Global.Rand.NextDouble() - 0.5) * Radiation; MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1); moveObject.Target.SetOffsetByAngle(scrapDirection, 1000); ObjectSmoke newObject; if (ScrapDrawObject == null) { newObject = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, fadeTime, 1, 0, Owner.DrawObject.MainColor, moveObject); } else { DrawBase scrapDraw = ScrapDrawObject.Copy(); scrapDraw.Angle = Global.Rand.Next(360); newObject = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, ScrapWidth, ScrapHeight, fadeTime, 1, 0, scrapDraw, moveObject); newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 520), false, true)); } moveObject.Target.SetObject(newObject); Owner.Container.Add(newObject); } base.DoAfterDead(killer, deadType); }
/// <summary> /// 所有者死亡後執行動作(供上層呼叫),預設為取消特性 /// </summary> public virtual void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if (BreakAfterDead) { Break(); } }
/// <summary> /// 發生於物件死亡時 /// </summary> protected virtual void OnObjectDead(ObjectBase sender, ObjectBase killer, ObjectDeadType deadType) { if (sender.Equals(PlayerObject)) { SetEnd(false); } }
/// <summary> /// 擁有此特性的物件死亡時會逐漸縮小(放大)並淡出 /// </summary> /// <param name="fadeTime">縮小/淡出時間計時器(毫秒)</param> /// <param name="fadeTime">計時器結束時大小比例</param> /// <param name="fadeTime">計時器結束時透明度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> public PropertyDeadSmoke(int fadeTime, float finelScale, float finelOpacity, ObjectDeadType deadType) { DeadType = deadType; FadeTime = new CounterObject(fadeTime); FinelScale = finelScale; FinelOpacity = finelOpacity; BreakAfterDead = false; }
protected override void OnObjectDead(ObjectBase sender, ObjectBase killer, ObjectDeadType deadType) { if (killer != null && sender.League != LeagueType.Player && killer.League != LeagueType.Player && deadType == ObjectDeadType.Collision) { AddScoreToPlayer("借刀殺人", 350); } base.OnObjectDead(sender, killer, deadType); }
/// <summary> /// 殺死此物件 /// </summary> /// <param name="killer">殺手物件</param> /// <param name="deadType">死亡類型</param> public virtual void Kill(ObjectBase killer, ObjectDeadType deadType) { if (Status == ObjectStatus.Alive) { Status = ObjectStatus.Dead; Propertys.AllDoAfterDead(killer, deadType); OnDead(this, killer, deadType); } }
/// <summary> /// 新增破碎特性且使用所有者顏色,擁有此特性的物件死亡時會造成碎片飛散 /// </summary> /// <param name="scrapCount">產生碎片數量</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param /// <param name="radiation">擴散角度</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadBroken(int scrapCount, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int radiation, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) { DeadType = deadType; ScrapCount = scrapCount; ScrapWidth = scrapWidth; ScrapHeight = scrapHeight; Radiation = radiation; ScrapSpeedMax = scrapSpeedMax; ScrapSpeedMin = scrapSpeedMin; ScrapLifeMin = scrapLifeMin; ScrapLifeMax = scrapLifeMax; BreakAfterDead = false; }
/// <summary> /// 新增爆炸特性,擁有此特性的物件死亡時會造成爆炸 /// </summary> /// <param name="rangeMultiple">爆炸範圍倍數(以所有者大小為基準)</param> /// <param name="rangeConstant">爆炸範圍常數</param> /// <param name="collisionPower">爆炸的撞擊力量,撞擊力量小於等於此值會被摧毀</param> /// <param name="collisionLeague">爆炸的陣營判定,符合此陣營不會被傷害</param> /// <param name="color">爆炸顏色</param> /// <param name="ownerScaleFix">快爆炸時的大小調整倍數</param> /// <param name="ownerRFix">快爆炸時的紅色調整倍數</param> /// <param name="sharkPower">爆炸搖晃效果</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> public PropertyDeadExplosion(float rangeMultiple, int rangeConstant, int collisionPower, LeagueType collisionLeague, Color color, float ownerScaleFix, float ownerRFix, int sharkPower, ObjectDeadType deadType) { DeadType = deadType; RangeMultiple = rangeMultiple; RangeConstant = rangeConstant; CollisionPower = collisionPower; CollisionLeague = collisionLeague; Color = color; OwnerScaleFix = ownerScaleFix; OwnerRFix = ownerRFix; SharkPower = sharkPower; BreakAfterDead = false; DrawRange = true; }
/// <summary> /// 新增崩塌特性且使用所有者顏色,擁有此特性的物件死亡時會逐漸縮小並碎裂 /// </summary> /// <param name="buildTime">產生碎片週期(毫秒)</param> /// <param name="scrapCount">每回合產生碎片數量</param> /// <param name="shrinkTime">縮小時間(毫秒)</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadCollapse(int scrapCount, int shrinkTime, int buildTime, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) { DeadType = deadType; BuildTime = buildTime; ScrapCount = scrapCount; ScrapWidth = scrapWidth; ScrapHeight = scrapHeight; ShrinkTime = new CounterObject(shrinkTime); ScrapSpeedMax = scrapSpeedMax; ScrapSpeedMin = scrapSpeedMin; ScrapLifeMax = scrapLifeMax; ScrapLifeMin = scrapLifeMin; BreakAfterDead = false; }
public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if ((DeadType & deadType) != deadType) { return; } Affix = SpecialStatus.Remain; FadeTime.Value = 0; _Enabled = true; _BaseScale = Owner.Layout.Scale; _BaseOpacity = Owner.DrawObject.Colors.Opacity; base.DoAfterDead(killer, deadType); }
public override void Kill(ObjectBase killer, ObjectDeadType deadType) { if (Status != ObjectStatus.Alive) { return; } if (deadType == ObjectDeadType.Collision) { Scene.EffectObjects.Add(new EffectShark(Scene.Sec(0.6F), 10) { CanBreak = false }); } base.Kill(killer, deadType); }
public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if ((DeadType & deadType) != deadType) { return; } if (ScrapDrawObject == null) { _PropertyScraping = new PropertyScraping((int)(ShrinkTime.Limit * 0.8F), BuildTime, ScrapCount, ScrapWidth, ScrapHeight, ScrapSpeedMin, ScrapSpeedMax, ScrapLifeMin, ScrapLifeMax); } else { _PropertyScraping = new PropertyScraping(ScrapDrawObject, (int)(ShrinkTime.Limit * 0.8F), BuildTime, ScrapCount, ScrapWidth, ScrapHeight, ScrapSpeedMin, ScrapSpeedMax, ScrapLifeMin, ScrapLifeMax); } Owner.Propertys.Add(_PropertyScraping); Affix = SpecialStatus.Remain; ShrinkTime.Value = 0; _Enabled = true; base.DoAfterDead(killer, deadType); }
/// <summary> /// 新增破碎特性且指定碎片外觀,擁有此特性的物件死亡時會造成碎片飛散 /// </summary> /// <param name="scrapDrawObject">碎片外觀範本繪圖物件</param> /// <param name="scrapCount">產生碎片數量</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> /// <param name="radiation">擴散角度</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadBroken(DrawBase scrapDrawObject, int scrapCount, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int radiation, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) : this(scrapCount, scrapWidth, scrapHeight, deadType, radiation, scrapSpeedMin, scrapSpeedMax, scrapLifeMin, scrapLifeMax) { ScrapDrawObject = scrapDrawObject; }
public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if ((DeadType & deadType) != deadType) { return; } if (SharkPower > 0) { Scene.EffectObjects.Add(new EffectShark(Scene.Sec(0.2F), SharkPower)); } int explosionSize = (int)(RangeMultiple * (Owner.Layout.RectWidth + Owner.Layout.RectHeight) / 2) + RangeConstant; ObjectSmoke explosionObject = new ObjectSmoke(Owner.Layout.CenterX, Owner.Layout.CenterY, explosionSize, explosionSize, Scene.Sec(0.6F), 0.9F, 0, Color, MoveNull.Value); Owner.Container.Add(explosionObject); for (int i = 0; i < Owner.Container.Count; i++) { ObjectBase objectBase = Owner.Container[i]; if (objectBase.Status != ObjectStatus.Alive || Function.IsFriendly(objectBase.League, CollisionLeague)) { continue; } // 特殊狀態判定 具碰撞 非鬼魂 if ((objectBase.Propertys.Affix & SpecialStatus.Collision) != SpecialStatus.Collision || (objectBase.Propertys.Affix & SpecialStatus.Ghost) == SpecialStatus.Ghost) { continue; } // 碰撞判定 if (!Function.IsCollison(objectBase.Layout, explosionObject.Layout)) { continue; } // 檢查目標有無碰撞特性 int colliderPower = -1; for (int j = 0; j < objectBase.Propertys.Count; j++) { PropertyCollision checkCollision = objectBase.Propertys[j] as PropertyCollision; if (checkCollision != null && checkCollision.Status == PropertyStatus.Enabled) { colliderPower = Math.Max(colliderPower, checkCollision.CollisionPower); } } if (colliderPower < 0) { continue; } if (colliderPower <= CollisionPower) { objectBase.Kill(Owner, ObjectDeadType.Collision); } } base.DoAfterDead(killer, deadType); }
/// <summary> /// 新增破碎特性且指定碎片顏色,擁有此特性的物件死亡時會造成碎片飛散 /// </summary> /// <param name="color">產生碎片顏色</param> /// <param name="scrapCount">產生碎片數量</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param /// <param name="radiation">擴散角度</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadBroken(Color color, int scrapCount, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int radiation, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) : this(scrapCount, scrapWidth, scrapHeight, deadType, radiation, scrapSpeedMin, scrapSpeedMax, scrapLifeMin, scrapLifeMax) { ScrapDrawObject = new DrawBrush(color, ShapeType.Ellipse); }
/// <summary> /// 新增崩塌特性且指定碎片顏色,擁有此特性的物件死亡時會逐漸縮小並碎裂 /// </summary> /// <param name="color">產生碎片顏色</param> /// <param name="buildTime">產生碎片週期(毫秒)</param> /// <param name="scrapCount">每回合產生碎片數量</param> /// <param name="shrinkTime">縮小時間(毫秒)</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadCollapse(Color color, int scrapCount, int shrinkTime, int buildTime, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) : this(scrapCount, shrinkTime, buildTime, scrapWidth, scrapHeight, deadType, scrapSpeedMin, scrapSpeedMax, scrapLifeMin, scrapLifeMax) { ScrapDrawObject = new DrawBrush(color, ShapeType.Ellipse); }
/// <summary> /// 新增崩塌特性且指定碎片外觀,擁有此特性的物件死亡時會逐漸縮小並碎裂 /// </summary> /// <param name="scrapDrawObject">碎片外觀範本繪圖物件</param> /// <param name="buildTime">產生碎片週期(毫秒)</param> /// <param name="scrapCount">每回合產生碎片數量</param> /// <param name="shrinkTime">縮小時間(毫秒)</param> /// <param name="scrapWidth">碎片寬度</param> /// <param name="scrapHeight">碎片高度</param> /// <param name="deadType">符合指定的死亡方式才會觸發</param> /// <param name="scrapSpeedMax">碎片移動速度最大值</param> /// <param name="scrapSpeedMin">碎片移動速度最小值</param> /// <param name="scrapLifeMax">碎片生命週期最大值</param> /// <param name="scrapLifeMin">碎片生命週期最小值</param> public PropertyDeadCollapse(DrawBase scrapDrawObject, int scrapCount, int shrinkTime, int buildTime, int scrapWidth, int scrapHeight, ObjectDeadType deadType, int scrapSpeedMin, int scrapSpeedMax, int scrapLifeMin, int scrapLifeMax) : this(scrapCount, shrinkTime, buildTime, scrapWidth, scrapHeight, deadType, scrapSpeedMin, scrapSpeedMax, scrapLifeMin, scrapLifeMax) { ScrapDrawObject = scrapDrawObject; }
public override void DoAfterDead(ObjectBase killer, ObjectDeadType deadType) { if (Owner.DrawObject == DrawNull.Value || (DeadType & deadType) != deadType) { return; } double angle = Function.GetAngle(0, 0, Owner.MoveObject.MoveX, Owner.MoveObject.MoveY); DrawBase drawObject = Owner.DrawObject; Rectangle baseRectangle = Owner.Layout.Rectangle; Rectangle drawRectangle; if (drawObject.Scale > 1) { drawRectangle = drawObject.GetScaleRectangle(baseRectangle); baseRectangle.Location.Offset(-drawRectangle.Location.X, -drawRectangle.Location.Y); drawRectangle.Location = new Point(0, 0); } else { baseRectangle.Location = new Point(0, 0); drawRectangle = baseRectangle; } List <Point> getPoints = new List <Point>(); using (Bitmap image = new Bitmap(drawRectangle.Width, drawRectangle.Height)) using (Graphics g = Graphics.FromImage(image)) { Owner.DrawObject.Draw(g, baseRectangle); BitmapData bitData = image.LockBits(drawRectangle, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); IntPtr scan0 = bitData.Scan0; unsafe { byte *p = (byte *)scan0.ToPointer(); for (int y = 0; y < drawRectangle.Height; y++) { for (int x = 0; x < drawRectangle.Width; x++) { if (p[3] > 0) { getPoints.Add(new Point(x, y)); } p += 4; } } } image.UnlockBits(bitData); if (getPoints.Count == 0) { return; } int idxPlus = ((getPoints.Count - 1) / ScrapCount) + 1; int idx = Global.Rand.Next(idxPlus); for (int i = 0; i < ScrapCount; i++) { Point point = getPoints[idx]; PointF putPoint = new PointF(Owner.Layout.CenterX - (drawRectangle.Width / 2) + point.X, Owner.Layout.CenterY - (drawRectangle.Height / 2) + point.Y); int speed = Global.Rand.Next(ScrapSpeedMin, Math.Max(ScrapSpeedMin, ScrapSpeedMax)); int fadeTime = Global.Rand.Next(ScrapLifeMin, Math.Max(ScrapLifeMin, ScrapLifeMax)); double scrapDirection = angle + (Global.Rand.NextDouble() - 0.5) * Radiation; MoveStraight moveObject = new MoveStraight(null, 1, speed, 1, 0, 1); moveObject.Target.SetOffsetByAngle(scrapDirection, 1000); ObjectSmoke newObject; if (ScrapDrawObject == null) { Color drawColor = image.GetPixel(point.X, point.Y); newObject = new ObjectSmoke(putPoint.X, putPoint.Y, ScrapWidth, ScrapHeight, fadeTime, 1, 0, drawColor, moveObject); } else { DrawBase scrapDraw = ScrapDrawObject.Copy(); scrapDraw.Angle = Global.Rand.Next(360); newObject = new ObjectSmoke(putPoint.X, putPoint.Y, ScrapWidth, ScrapHeight, fadeTime, 1, 0, scrapDraw, moveObject); newObject.Propertys.Add(new PropertyRotate(-1, Global.Rand.Next(280, 520), false, true)); } moveObject.Target.SetObject(newObject); Owner.Container.Add(newObject); idx += idxPlus; if (idx >= getPoints.Count) { idx = Global.Rand.Next(idxPlus); } } } base.DoAfterDead(killer, deadType); }