|
@@ -46,63 +46,46 @@ namespace ET
|
|
|
break;
|
|
|
case (int)KeyCode.F1:
|
|
|
var units = new int[] { 101, 111, 121, 131 };
|
|
|
- var centerpos = GetCurBattleCenter();
|
|
|
var rand = new Random();
|
|
|
foreach (var id in units)
|
|
|
{
|
|
|
- float r = (float)Math.Sqrt(rand.Next(2500)) + 10;
|
|
|
- double ang = rand.Next(22) / 180.0f * Math.PI + Math.PI*150f/180f;
|
|
|
- float x = centerpos.X + (float)(r * Math.Cos(ang));
|
|
|
- float y = centerpos.Y - (float)(r * Math.Sin(ang));
|
|
|
-
|
|
|
+ var pos = GetRandomPos(2);
|
|
|
session.Call(new C2G_AddUnitsToMap()
|
|
|
{
|
|
|
UnitId = id,
|
|
|
Force = 1,
|
|
|
- X = (int)x,
|
|
|
- Y = (int)y
|
|
|
+ X = (int)pos.X,
|
|
|
+ Y = (int)pos.Y
|
|
|
}).Coroutine();
|
|
|
}
|
|
|
break;
|
|
|
case (int)KeyCode.F2:
|
|
|
- centerpos = GetCurBattleCenter();
|
|
|
var units2 = new int[] { 102, 112, 122, 132 };
|
|
|
rand = new Random();
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
{
|
|
|
- var id = units2[rand.Next(units2.Length)];
|
|
|
- float r = (float)Math.Sqrt(rand.Next(3136)) + 10;
|
|
|
- double ang = rand.Next(20) / 180.0f * Math.PI + Math.PI * 76f / 180f;
|
|
|
- float x = centerpos.X + (float)(r * Math.Cos(ang));
|
|
|
- float y = centerpos.Y - (float)(r * Math.Sin(ang));
|
|
|
-
|
|
|
+ var pos = GetRandomPos(1);
|
|
|
session.Call(new C2G_AddUnitsToMap()
|
|
|
{
|
|
|
- UnitId = id,
|
|
|
+ UnitId = units2[rand.Next(units2.Length)],
|
|
|
Force = 1,
|
|
|
- X = (int)x,
|
|
|
- Y = (int)y
|
|
|
+ X = (int)pos.X,
|
|
|
+ Y = (int)pos.Y
|
|
|
}).Coroutine();
|
|
|
}
|
|
|
break;
|
|
|
case (int)KeyCode.F3:
|
|
|
- centerpos = GetCurBattleCenter();
|
|
|
var units3 = new int[] { 103, 113, 123, 133 };
|
|
|
rand = new Random();
|
|
|
for (int i = 0; i < 1; i++)
|
|
|
{
|
|
|
- var id = units3[rand.Next(units3.Length)];
|
|
|
- float r = (float)Math.Sqrt(rand.Next(2500)) + 10;
|
|
|
- double ang = rand.Next(22) / 180.0f * Math.PI + Math.PI * 78f / 180f + Math.PI;
|
|
|
- float x = centerpos.X + (float)(r * Math.Cos(ang));
|
|
|
- float y = centerpos.Y - (float)(r * Math.Sin(ang));
|
|
|
-
|
|
|
+ var pos = GetRandomPos(0);
|
|
|
session.Call(new C2G_AddUnitsToMap()
|
|
|
{
|
|
|
- UnitId = id,
|
|
|
+ UnitId = units3[rand.Next(units3.Length)],
|
|
|
Force = 1,
|
|
|
- X = (int)x,
|
|
|
- Y = (int)y
|
|
|
+ X = (int)pos.X,
|
|
|
+ Y = (int)pos.Y
|
|
|
}).Coroutine();
|
|
|
}
|
|
|
break;
|
|
@@ -162,21 +145,35 @@ namespace ET
|
|
|
//EventSystem.Instance.Publish<SoundMuteEvent>();
|
|
|
}
|
|
|
|
|
|
- //获得当前战场focus中心(当前塔位置)
|
|
|
+ //获得当前战场(当前塔位置),随机位置
|
|
|
private Vector2 vecTemp = new Vector2();
|
|
|
- private Vector2 GetCurBattleCenter()
|
|
|
+ private Vector2 GetRandomPos(int index)
|
|
|
{
|
|
|
- foreach(var tid in ConstGame.TowerTemplateIDs)
|
|
|
+ Vector2[] TowerPos = { new Vector2(){ X = 103, Y = 197 }, new Vector2() { X = 190, Y = 133 }, new Vector2() { X = 104, Y = 69 } };
|
|
|
+
|
|
|
+ var tower = TowerPos[index];
|
|
|
+ var rand = new Random();
|
|
|
+ float r;
|
|
|
+ double ang;
|
|
|
+ if(index == 0)
|
|
|
{
|
|
|
- var tower = BattleMgr.Instance.GetUnitByTemplateID(tid);
|
|
|
- if(tower != null && !tower.IsDead)
|
|
|
- {
|
|
|
- vecTemp.X = tower.ZUnit.X;
|
|
|
- vecTemp.Y = tower.ZUnit.Y;
|
|
|
- return vecTemp;
|
|
|
- }
|
|
|
+ r = (float)Math.Sqrt(rand.Next(2500)) + 10;
|
|
|
+ ang = rand.Next(22) / 180.0f * Math.PI + Math.PI * 78f / 180f + Math.PI;
|
|
|
+ }
|
|
|
+ else if(index == 1)
|
|
|
+ {
|
|
|
+ r = (float)Math.Sqrt(rand.Next(3136)) + 10;
|
|
|
+ ang = rand.Next(20) / 180.0f * Math.PI + Math.PI * 76f / 180f;
|
|
|
}
|
|
|
- return new Vector2(0, 0);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ r = (float)Math.Sqrt(rand.Next(2500)) + 10;
|
|
|
+ ang = rand.Next(22) / 180.0f * Math.PI + Math.PI * 150f / 180f;
|
|
|
+ }
|
|
|
+
|
|
|
+ vecTemp.X = tower.X + (float)(r * Math.Cos(ang));
|
|
|
+ vecTemp.Y = tower.Y - (float)(r * Math.Sin(ang));
|
|
|
+ return vecTemp;
|
|
|
}
|
|
|
}
|
|
|
|