IEnumerator Spawn(PlayerSleepData data)
    {
        while (true)
        {
            if (IsPlayerSleeping(data))
            {
                Vector3 position = Vector3.zero;
                //GetSpawnPosition(
                //PlayerFactory.mMainPlayer.transform.position,
                //data.minRadius,
                //data.maxRadius);

                Quaternion rot = Quaternion.identity;
                //Quaternion.LookRotation(PlayerFactory.mMainPlayer.transform.position - position, Vector3.up);

                int pathID = 0;

                int typeID = (int)AiUtil.GetPointType(position);

                if (Application.loadedLevelName.Equals(GameConfig.MainSceneName))
                {
                    pathID = AISpawnDataStory.GetRandomPathIDFromType(typeID, position);
                }
                else if (Application.loadedLevelName.Equals(GameConfig.AdventureSceneName))
                {
                    int mapID  = AiUtil.GetMapID(position);
                    int areaID = AiUtil.GetAreaID(position);
                    pathID = AISpawnDataAdvSingle.GetPathID(mapID, areaID, typeID);
                }

                AIResource.Instantiate(pathID, position, rot, OnSleepSpawned);
            }
            yield return(new WaitForSeconds(data.interval));
        }
    }
Exemple #2
0
    //Ai_hatch hatch;

    public override IEnumerator SpawnGroup()
    {
        if (res == null)
        {
            yield break;
        }

        yield return(new WaitForSeconds(delayTime));

        //if (hatch != null && hatch.dead)
        //    yield break;

        //hatch.ApplyDamage(hatch.maxLife + 100.0f);

        int count = Random.Range(minCount, maxCount);

        for (int i = 0; i < count; i++)
        {
            Vector3 position = transform.position + Random.insideUnitSphere * radius;

            if (AiUtil.CheckPositionOnGround(ref position, 10.0f, AiUtil.groundedLayer))
            {
                AIResource.Instantiate(id, position, Quaternion.identity, OnSpawned);
                yield return(new WaitForSeconds(0.1f));
            }
        }

        yield return(new WaitForSeconds(0.5f));

        yield break;
    }
Exemple #3
0
    void InstantiateSingleMode()
    {
        if (isActive)
        {
            mWaitForSpawned = true;

            int pathid = pathID;

            AssetReq req;

            if (mRevisePosition)
            {
                req = AIResource.Instantiate(pathid, AIResource.FixedHeightOfAIResource(pathid, position), transform.rotation, OnSpawned);
            }
            else
            {
                req = AIResource.Instantiate(pathid, transform.position, transform.rotation, OnSpawned);
            }

            if (req != null)
            {
                mReqList.Add(req);
            }
        }
    }
Exemple #4
0
 void Start()
 {
     buildingTypes = new HashSet <int> ();
     queue         = new Queue <string> ();
     airesource    = aihandler.airesource;
     InvokeRepeating("Recalculate", 3 + Random.value * 3, 4);
 }
Exemple #5
0
    void Start()
    {
        tree = aihandler.player.techTree;

        aibuilding = aihandler.aibuilding;
        airesource = aihandler.airesource;
        InvokeRepeating("Recalculate", 7 + Random.value * 3, 10);
    }
Exemple #6
0
 void InstantiateMultiMode(int fixId = -1)
 {
     if (isActive)
     {
         int     pathid = pathID;
         Vector3 pos    = AIResource.FixedHeightOfAIResource(pathid, position);
         SPTerrainEvent.instance.RegisterAIToServer(index, pos, pathid);
     }
 }
Exemple #7
0
    void Start()
    {
        InvokeRepeating("Recalculate", 5 + Random.value * 3, 5);
        airesource = aihandler.airesource;
        aibuilding = aihandler.aibuilding;
        bpa        = aihandler.bpa;

        fields = new List <TrainingField> ();
    }
    IEnumerator SpawnAI()
    {
        while (count > 0)
        {
            yield return(new WaitForSeconds(interval));

            if (active && IsRevisePosition())
            {
                int      id  = pathIDs[Random.Range(0, pathIDs.Length)];
                AssetReq req = AIResource.Instantiate(id, position, Quaternion.identity, OnSpawned);
                reqList.Add(req);

                count--;
            }
        }
    }
Exemple #9
0
    public void RegisterAIToServer(IntVector4 index, Vector3 position, int pathID)
    {
        if (!GameConfig.IsMultiMode || null == PlayerNetwork.mainPlayer)
        {
            return;
        }

        if (AIResource.IsGroup(pathID))
        {
            NetworkManager.WaitCoroutine(PlayerNetwork.RequestCreateGroupAi(pathID, position));
        }
        else
        {
            NetworkManager.WaitCoroutine(PlayerNetwork.RequestCreateAi(pathID, position, -1, -1, -1));
        }
    }
Exemple #10
0
    public void Instantiate(int id, Vector3 pos, Quaternion rot)
    {
        Vector3 fixPosition = AIResource.FixedHeightOfAIResource(id, pos);

        if (GameConfig.IsMultiMode)
        {
            //AIGroupNetWork group = Netlayer as AIGroupNetWork;
            //if (null == group)
            //	return;

            //uLink.NetworkViewID tdViewID = group.AiTD == null ? uLink.NetworkViewID.unassigned : group.AiTD.OwnerView.viewID;
            //         IntVector4 _inx = new IntVector4(mIndex.x, mIndex.y, mIndex.z, curCount);
            //RPCServer(EPacketType.PT_AG_SpawnAIGroupMemberAtPoint, _inx, fixPosition, id, 2, tdViewID);
        }
        else
        {
            mSpawnedCount++;
            AssetReq req = AIResource.Instantiate(id, fixPosition, rot, OnSpawned);
            mReqs.Add(req);
        }
    }
Exemple #11
0
 void Awake()
 {
     res = AIResource.Find(id);
     //hatch = GetComponent<Ai_hatch>();
 }
Exemple #12
0
 void Awake()
 {
     res = AIResource.Find(id);
 }