Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="teamId"></param>
    void OnAIDied(int teamId)
    {
        AIBase ai = m_AIs[teamId];

        // move ai from alive buffer to leaderboard
        m_AliveAIs.Remove(ai);
        m_Leaderboard.Insert(0, ai);

        // deactivate ai
        ai.XKActive = false;
        XKLog.Log("Info", string.Format("An AI has died: {0} ({1}) ", ai.GetType().ToString(), ai.TeamId));

        if (m_AliveAIs.Count == 1)
        {
            // store the winner
            m_Leaderboard.Insert(0, m_AliveAIs[0]);

            // deactivate gameboard, no need to keep it active
            XKActive = false;
            XKLog.Log("Info", string.Format("The last AI has died, the winner is: {0} ({1}) ", m_AliveAIs[0].GetType().ToString(), m_AliveAIs[0].TeamId));

            // announce the game is over to whom ants to listen
            if (OnGameOver != null)
            {
                OnGameOver(m_Leaderboard);
            }
        }
    }
Ejemplo n.º 2
0
    bool IHome.LaunchBoldies(IHome to, EAmount amount, AIBase ai)
    {
        // error control
        if (TeamId < 0)
        {
            XKLog.Log("Error", "Home.LaunchBodies() failed - home does not belong to any team");
            return(false);
        }

        // error control
        if (TeamId != ai.TeamId)
        {
            XKLog.LogRed("Error", "Home.LaunchBodies() failed - Wrong AI asked a move from unowned Home, are you such a cheater? - " + ai.GetType().ToString());
            return(false);
        }

        // error control
        if (to == null)
        {
            XKLog.LogRed("Error", "Home.LaunchBodies() failed - (IHome)to is null");
            return(false);
        }

        // avoid StackOverFlow exception
        if (!CanLaunchBoldies((Home)to))
        {
            return(false);
        }

        // compute boldiCount to launch
        int boldiCount = m_BoldiCount;

        switch (amount)
        {
        case EAmount.Quarter:
            boldiCount = (int)(m_BoldiCount * 0.25f);
            break;

        case EAmount.Half:
            boldiCount = (int)(m_BoldiCount * 0.5f);
            break;

        case EAmount.ThreeQuarter:
            boldiCount = (int)(m_BoldiCount * 0.75f);
            break;
        }

        // launch them
        if (!m_ToLaunch.ContainsKey((Home)to))
        {
            m_ToLaunch.Add((Home)to, boldiCount);
        }
        else
        {
            m_ToLaunch[(Home)to] += boldiCount;
        }

        // notify who wants to listen
        m_Gameboard.OnBoldiLaunch(this, to);

        return(true);
    }
Ejemplo n.º 3
0
    void CreateAI(int aiId)
    {
        AIBase ai = null;

        switch (aiId)
        {
        case 0:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 1:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 2:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 3:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 4:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 5:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 6:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 7:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 8:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 9:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 10:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 11:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 12:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 13:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 14:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 15:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 16:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 17:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 18:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 19:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 20:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 21:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 22:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 23:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 24:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 25:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 26:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        case 27:
            ai = m_Gameboard.CreateAI <YW.NicoJ.AITester>();
            break;

        default:
            XKLog.Log("Error", "MatchMaker.CreateAi(" + aiId + ") failed - aiId unknown");
            break;
        }

        // nothing to do?
        if (ai != null)
        {
            if (!m_IdToName.ContainsKey(aiId))
            {
                m_IdToName.Add(aiId, ai.GetType().ToString());
            }
        }
    }