/// <summary> /// Projects a PointF along a specified direction /// </summary> public static PointF ProjectAlong(this PointF This, PointF direction) { var normalDirection = direction.Normalize(); var dist = This.DotProduct(normalDirection); return normalDirection.ScaledBy(dist); }
private void CalculateVelocityVectors(float velocity) { var vector = new PointF(_targetLocation.X - _floatX, _targetLocation.Y - _floatY); vector = vector.Normalize(velocity); VelocityX = vector.X; VelocityY = vector.Y; }
private void BombImp() { List<Living> playersAround = m_map.FindHitByHitPiont(GetCollidePoint(), m_radius); foreach (Living p in playersAround) { if (p.IsNoHole || p.NoHoleTurn) { p.NoHoleTurn = true; digMap = false; } p.SyncAtTime = false; } m_owner.SyncAtTime = false; try { //TrieuLSL DIG DIG DIG if (digMap) { m_map.Dig(m_x, m_y, m_shape, null); } m_actions.Add(new BombAction(m_lifeTime, ActionType.BOMB, m_x, m_y, digMap ? 1 : 0, 0)); switch (m_type) { case BombType.FORZEN: foreach (Living p in playersAround) { if (m_owner is SimpleBoss && new IceFronzeEffect(100).Start(p)) { m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, p.Id, 0, 0, 0)); } else { if (new IceFronzeEffect(2).Start(p)) { m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, p.Id, 0, 0, 0)); } else { m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, -1, 0, 0, 0)); m_actions.Add(new BombAction(m_lifeTime, ActionType.UNANGLE, p.Id, 0, 0, 0)); } } } break; case BombType.TRANFORM: //炸弹的飞行时间必须超过1 if (m_y > 10 && m_lifeTime > 0.04f) { //炸弹最后的落脚地点必须为空,否则向后退5像素 if (m_map.IsEmpty(m_x, m_y) == false) { PointF v = new PointF(-vX, -vY); v = v.Normalize(5); m_x -= (int)v.X; m_y -= (int)v.Y; } m_owner.SetXY(m_x, m_y); m_owner.StartMoving(); m_actions.Add(new BombAction(m_lifeTime, ActionType.TRANSLATE, m_x, m_y, 0, 0)); m_actions.Add(new BombAction(m_lifeTime, ActionType.START_MOVE, m_owner.Id, m_owner.X, m_owner.Y, m_owner.IsLiving ? 1 : 0)); } break; case BombType.CURE: foreach (Living p in playersAround) { double plus = 0; if (playersAround.Count > 1) plus = 0.4; else plus = 1; int blood = (int)(((Player)m_owner).PlayerDetail.SecondWeapon.Template.Property7 * Math.Pow(1.1, ((Player)m_owner).PlayerDetail.SecondWeapon.StrengthenLevel) * plus); p.AddBlood(blood); if (p is Player) { ((Player)p).TotalCure += blood; } m_actions.Add(new BombAction(m_lifeTime, ActionType.CURE, p.Id, p.Blood, blood, 0)); //Console.WriteLine("治疗{0},血量{1}", blood, p.Blood); } break; default: foreach (Living p in playersAround) { //Console.WriteLine("炸弹ID{0}", m_info.Name); //判断npc之间的阵营 if (m_owner.IsFriendly(p) == true) { continue; } int damage = MakeDamage(p); int critical = 0; if (damage != 0) { critical = MakeCriticalDamage(p, damage);//暴击 m_owner.OnTakedDamage(m_owner, ref damage, ref damage); if (p.TakeDamage(m_owner, ref damage, ref critical, "爆炸")) { m_actions.Add(new BombAction(m_lifeTime, ActionType.KILL_PLAYER, p.Id, damage + critical, critical != 0 ? 2 : 1, p.Blood)); } else { m_actions.Add(new BombAction(m_lifeTime, ActionType.UNFORZEN, p.Id, 0, 0, 0)); } if (p is Player) { m_actions.Add(new BombAction(m_lifeTime, ActionType.DANDER, p.Id, ((Player)p).Dander, 0, 0)); //(p as Player).StartMoving();//((int)((m_lifeTime + 1) * 1000), 12); } if (p is SimpleBoss) { ((PVEGame)m_game).OnShooted(); } } else if (p is SimpleBoss) { m_actions.Add(new BombAction(m_lifeTime, ActionType.PLAYMOVIE, p.Id, 0, 0, 2)); } m_owner.OnAfterKillingLiving(p, damage, critical); if (p.IsLiving) { // Console.WriteLine("爆炸之前Y:{0}", p.Y); p.StartMoving((int)((m_lifeTime + 1) * 1000), 12); // Console.WriteLine("爆炸之后Y:{0}", p.Y); Console.WriteLine("爆炸还活着?"+p.IsLiving.ToString()); m_actions.Add(new BombAction(m_lifeTime, ActionType.START_MOVE, p.Id, p.X, p.Y, p.IsLiving ? 1 : 0)); } } break; } this.Die(); } finally { m_owner.SyncAtTime = true; foreach (Living p in playersAround) { p.SyncAtTime = true; } } }
public static PointF GenerateVector() { var vector = new PointF(rand.Next(-100, 100), rand.Next(-100, 100)); return vector.Normalize(); }