Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    private void SpawnNewAsteriod()
    {
        var prefabIndex = GetRandomAsteriodPrefab();

        Vector3 randomPosition;

        if (Xaxis)
        {
            randomPosition = new Vector3(Random.Range(MinSpawnPoint.position.x, MaxSpawnPoint.position.x), MaxSpawnPoint.position.y, 0);
        }
        else
        {
            randomPosition = new Vector3(MaxSpawnPoint.position.x, Random.Range(MinSpawnPoint.position.y, MaxSpawnPoint.position.y), 0);
        }

        GameObject        newAsteriod              = Instantiate(AsteriodPrefab[prefabIndex], randomPosition, Quaternion.identity) as GameObject;
        AsteriodCollision newAsteriodCollision     = newAsteriod.GetComponent <AsteriodCollision>();
        PlaceResources    newAsteriodResourceSpots = newAsteriod.GetComponent <PlaceResources>();

        AsteriodCount++;
        newAsteriod.name = AsteriodPrefab[prefabIndex].name + AsteriodCount;

        List <int> resourcesToAdd = RandomResourceRewardInts(AsteriodPrefab[prefabIndex].name);

        //newAsteriodCollision.ResourcesAfterCollision = RandomResourceReward(AsteriodPrefab[prefabIndex].name);

        for (int i = 0; i < resourcesToAdd.Count; i++)
        {
            newAsteriodCollision.ResourcesAfterCollision.Add(Resources[resourcesToAdd[i]]);
            newAsteriodCollision.DecoratorsForAsteriod.Add(DecoratorResources[resourcesToAdd[i]]);
        }

        newAsteriodResourceSpots.PlaceRandomResources(newAsteriodCollision.DecoratorsForAsteriod);
    }
Ejemplo n.º 2
0
    void Start()
    {
        this.objetivos = new ArrayList();

        // Set the initial resource amounts
        resourceAmounts = new Dictionary<RTSObject.ResourceType, float>();
        resourceAmounts[RTSObject.ResourceType.Food] = initialFood;
        resourceAmounts[RTSObject.ResourceType.Gold] = initialGold;
        resourceAmounts[RTSObject.ResourceType.Wood] = initialWood;

        Texture2D cursorTexture = Resources.Load("HUD/Cursors/cursor_normal") as Texture2D;
        Cursor.SetCursor(cursorTexture, Vector2.zero, CursorMode.Auto);

        // Spawn initial elements
        if (human==true) {
            SpawnInitialTownCenter();
            SpawnInitialCivilUnit();
            SpawnInitialMilitaryUnit();
            PlaceResources pr = new PlaceResources();
            pr.Start();
        }
    }