コード例 #1
0
ファイル: CSpawner.cs プロジェクト: XiaoHongLove/Mothership
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               SpawnNPC
    /////////////////////////////////////////////////////////////////////////////
    public static void SpawnNPC(IAIBase.ETeam eTeam, IAIBase.ENPCType eType)
    {
        foreach (GameObject goObject in m_liSpawnPoints)
        {
            CSpawner cSpawner = goObject.GetComponent <CSpawner>();

            if (cSpawner.SpawnerType != ESpawnerType.TYPE_NPC)
            {
                continue;
            }

            if (cSpawner.Team == eTeam && true == cSpawner.CanSpawn)
            {
                cSpawner.Spawn(NPCResource.GetObjectByType(eTeam, eType));
                break;
            }
        }
    }
コード例 #2
0
ファイル: CNPCSO.cs プロジェクト: XiaoHongLove/Mothership
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               GetObjectByType
    /////////////////////////////////////////////////////////////////////////////
    public GameObject GetObjectByType(IAIBase.ETeam eTeam, IAIBase.ENPCType eType)
    {
        bool bMatchFound = false;

        if (eTeam == IAIBase.ETeam.TEAM_BLUE)
        {
            UpdateBlueTeamObjects();

            foreach (GameObject goObject in m_liBlueTeamNPCs)
            {
                switch (eType)
                {
                case IAIBase.ENPCType.TYPE_DRONE:

                    CDroneAI cDrone = goObject.GetComponent <CDroneAI>();
                    if (null == cDrone)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_HEALER:
                    break;

                case IAIBase.ENPCType.TYPE_TANK:

                    CTankAI cTank = goObject.GetComponent <CTankAI>();
                    if (null == cTank)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_WARRIOR:

                    CWarriorAI cWarrior = goObject.GetComponent <CWarriorAI>();
                    if (null == cWarrior)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;
                }

                if (true == bMatchFound)
                {
                    return(goObject);
                }
            }
        }
        else if (eTeam == IAIBase.ETeam.TEAM_RED)
        {
            UpdateRedTeamObjects();

            foreach (GameObject goObject in m_liRedTeamNPCs)
            {
                switch (eType)
                {
                case IAIBase.ENPCType.TYPE_DRONE:

                    CDroneAI cDrone = goObject.GetComponent <CDroneAI>();
                    if (null == cDrone)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_HEALER:
                    break;

                case IAIBase.ENPCType.TYPE_TANK:

                    CTankAI cTank = goObject.GetComponent <CTankAI>();
                    if (null == cTank)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_WARRIOR:

                    CWarriorAI cWarrior = goObject.GetComponent <CWarriorAI>();
                    if (null == cWarrior)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;
                }

                if (true == bMatchFound)
                {
                    return(goObject);
                }
            }
        }

        return(null);
    }