private void HandleLaunch(BoardWar launcher, BoardWar victim, int player) { BoardWar.LaunchInfo lI = launcher.launchInfo; int invertedX = victim.width - lI.x - 1; int depth = victim.TakeDamage(invertedX, lI.len, lI.type); HandleLaunchAnimations(launcher, victim, depth, lI.type); if (depth > 0) { launcher.AddToScore(PD.GetScore(depth, lI.len, lI.bonus)); } if (player == 1 && player1Human || player == 2 && player2Human) { GameObject zGo = GetGameObject(Vector3.zero, "zGo", null, false, "Zapper"); ZappyGun z = zGo.AddComponent <ZappyGun>(); Vector3 pos = victim.GetMirror().GetScreenPosFromXY(invertedX, victim.GetHitDepth(invertedX, lI.len, lI.type)); z.Init(PD, lI.type, lI.len, launcher.GetScreenPosFromXY(lI.x, lI.topy), pos.y - 0.4f); zaps.Add(z); } if (player == 1 && player2Human || player == 2 && player1Human) { GameObject zGoMirror = GetGameObject(Vector3.zero, "zGoMirror", null, false, "Zapper"); ZappyGun mirrorZ = zGoMirror.AddComponent <ZappyGun>(); Vector3 pos = victim.GetScreenPosFromXY(invertedX, victim.GetHitDepth(invertedX, lI.len, lI.type)); mirrorZ.Init(PD, lI.type, lI.len, launcher.GetMirror().GetScreenPosFromXY(lI.x, lI.topy), pos.y - 0.4f, true); zaps.Add(mirrorZ); } launcher.AcceptLaunch(); }
private int GetLaunchConflictWinner(BoardWar.LaunchInfo l1, BoardWar.LaunchInfo l2) { if (l1.x != width - l2.x - 1) { return(0); } int t1 = l1.type, t2 = l2.type; if (t1 == t2) { return(0); } if (t1 == 0) { return(t2 == 1 ? 1 : 2); } if (t1 == 1) { return(t2 == 0 ? 2 : 1); } if (t1 == 2) { return(t2 == 0 ? 1 : 2); } return(0); }