Exemple #1
0
    public void train()
    {
        if (castle.canPurchase(getPrice()))
        {
            // Start training!
            NeuralNode node = NeuralNode.create(neuralNodeType);
            cFire.node = node;
            float noise = getNoise();

            for (int i = 1; i <= TOTAL_ENEMY_UNITS; i++)
            {
                for (int j = 0; j < getQuantityOfEnemy(i); j++)
                {
                    Unit unit = uGen.MakeUnit(true, ENEMY_INDICES[i - 1], farOff, noise, true);
                    if (unit is UnitAnimated)
                    {
                        UnitAnimated ua     = (UnitAnimated)unit;
                        Texture2D[]  texes  = ua.textures;
                        int          texIdx = j % texes.Length;
                        ua.setTexture(texes[texIdx]);
                    }

                    node.AddToTrainingSet(unit, isEnemyTarget(i));
                    unit.DestroyMe();
                }
            }

            for (int i = 1; i <= TOTAL_ALLY_UNITS; i++)
            {
                for (int j = 0; j < getQuantityOfAlly(i); j++)
                {
                    Unit unit = uGen.MakeUnit(false, ALLY_INDICES[i - 1], farOff, noise, true);
                    if (unit is UnitAnimated)
                    {
                        UnitAnimated ua     = (UnitAnimated)unit;
                        Texture2D[]  texes  = ua.textures;
                        int          texIdx = j % texes.Length;
                        ua.setTexture(texes[texIdx]);
                    }

                    node.AddToTrainingSet(unit, isAllyTarget(i));
                    unit.DestroyMe();
                }
            }

            node.LearnUnits();
            castle.makePurchase(getPrice());
            Time.timeScale = previousTimeScale;

            // Close window
            GetComponent <Canvas> ().enabled = false;
            Camera.main.GetComponent <BuildingPlacement> ().placeableBuildingOld.SetSelected(true);
        }
    }
Exemple #2
0
 public void spawnTower1()
 {
     if (castle.canPurchase(200))
     {
         Debug.Log("spawnTower1() triggered");
         currentTower = buildingPlacement.SetItem(buildings[0]);
         castle.makePurchase(200);
         lastPurchaseAmount = 200;
         initOnce           = false;
     }
     else
     {
         // TODO Produce an alert that says you cannot make that purchase
     }
 }