Exemple #1
0
    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();
    }