Beispiel #1
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               Die
    /////////////////////////////////////////////////////////////////////////////
    protected void Die(bool bInstantiateFlag = true)
    {
        string strFunction = "IAIBase::Die()";

        switch (m_eTeam)
        {
        case ETeam.TEAM_BLUE:

            m_liActiveBlues.Remove(gameObject);

            break;

        case ETeam.TEAM_RED:

            m_liActiveReds.Remove(gameObject);

            break;

        default:

            // Unassigned NPC detected, report the issue.
            Debug.LogError(string.Format("{0} {1}: {2}", strFunction, ErrorStrings.ERROR_UNASSIGNED_NPC, transform.position));

            return;
        }

        // We need to drop the flag if we're holding it.
        if (true == m_bHasFlag && true == bInstantiateFlag)
        {
            GameObject goFlag = (GameObject)Network.Instantiate(m_goFlagPrefab, transform.position, Quaternion.identity, 0);
            goFlag.name    = Names.NAME_FLAG;
            m_goFlagHolder = null;
        }

        // We only want to send the death message to the server if the attacker object has been defined.
        //  The Die function is called on several occasions, one of them being when the drone has lost
        //  its path and doesn't know how to go back, this means that the attacker may be undefined.
        if (null != m_Attacker)
        {
            // Inform the server who killed this AI character.
            ServerManager cServer = RoleManager.roleManager as ServerManager;
            cServer.SendGameMessage(new MsgPlayerDied()
            {
                PlayerName = gameObject.name,
                KillerName = m_Attacker.AttackerName,
                PlayerTeam = m_eTeam,
                KillerTeam = m_Attacker.Team
            });
        }

        if (gameObject)
        {
            Network.Instantiate(m_goExplosionParticles, transform.position, Quaternion.identity, 0);
            Network.Destroy(gameObject);
        }

        CSpawner.SpawnNPC(m_eTeam, m_eNPCType);
    }
        public void GamePlayStarted()
        {
            networkView.RPC("RPCGamePlayStarted", RPCMode.Others);
            // Spawn the flag.
            CSpawner.SpawnFlag();

            // Get the number of required red AI characters.
            int iNumberOfRequiredNPCs = Constants.GAME_MAX_PLAYERS_PER_TEAM - RedTeam.TeamDisplayNames.Length;

            for (int i = 0; i < iNumberOfRequiredNPCs; ++i)
            {
                CSpawner.SpawnNPC(IAIBase.ETeam.TEAM_RED, IAIBase.ENPCType.TYPE_DRONE);
            }

            // Get the number of required blue AI characters.
            iNumberOfRequiredNPCs = Constants.GAME_MAX_PLAYERS_PER_TEAM - BlueTeam.TeamDisplayNames.Length;
            for (int i = 0; i < iNumberOfRequiredNPCs; ++i)
            {
                CSpawner.SpawnNPC(IAIBase.ETeam.TEAM_BLUE, IAIBase.ENPCType.TYPE_DRONE);
            }
        }