Exemple #1
0
    void Awake()
    {
        playerInstance = GameObject.Find("Player").GetComponent <Player>();

        gameControlInstance       = gc.GetComponent <GameControl> ();
        gameControlGUIInstance    = gc.GetComponent <GameControlGUI> ();
        shopControlInstance       = gc.GetComponent <ShopControl> ();
        shopControlGUIInstance    = gc.GetComponent <ShopControlGUI> ();
        clickControlInstance      = gc.GetComponent <ClickControl> ();
        gridControlInstance       = gc.GetComponent <GridControl>();
        optionControlInstance     = gc.GetComponent <OptionControl>();
        dragControlInstance       = gc.GetComponent <DragControl>();
        eventGUIInstance          = gc.GetComponent <EventGUI>();
        enemyLibraryInstance      = gc.GetComponent <EnemyLibrary>();
        cardLibraryInstance       = gc.GetComponent <CardLibrary>();
        goalLibraryInstance       = gc.GetComponent <GoalLibrary>();
        guiStyleLibraryInstance   = gc.GetComponent <GUIStyleLibrary>();
        mainMenuInstance          = gc.GetComponent <MainMenu>();
        encyclopediaMenuInstance  = gc.GetComponent <EncyclopediaMenu>();
        godChoiceMenuInstance     = gc.GetComponent <GodChoiceMenu>();
        customizeMenuInstance     = gc.GetComponent <CustomizeMenu>();
        gridCursorControlInstance = gc.GetComponent <GridCursorControl>();
        menuControlInstance       = gc.GetComponent <MenuControl>();
        tutorialInstance          = gc.GetComponent <Tutorial>();
        deckAnimateInstance       = deck.GetComponent <DeckAnimate>();

        shopAndGoalParentCanvasInstance = goalandshopparent
                                          .GetComponent <ShopAndGoalParentCanvas>();
        shopGridCanvasInstance = shopgrid
                                 .GetComponent <ShopGridCanvas>();
        gridCursorControlGUIInstance = gridcursorcontrolgui
                                       .GetComponent <GridCursorControlGUI>();
    }
Exemple #2
0
    IEnumerator SpawnWaves()
    {
        yield return(new WaitForSeconds(initialDelay));

        while (true)
        {
            for (int i = 0; i < enemiesPerWave; i++)
            {
                Vector3    spawnPos      = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
                Quaternion spawnRotation = new Quaternion();
                GameObject GO            = (GameObject)Instantiate(Resources.Load(EnemyLibrary.GetRandomAsteroid()), spawnPos, spawnRotation);
                if (GO != null)
                {
                    Value script = GO.GetComponent <Value>();
                    if (script != null)
                    {
                        script.BindToTime();
                    }
                }
                yield return(new WaitForSeconds(spawnDelay));
            }
            yield return(new WaitForSeconds(waveDelay));

            if (bGameOver)
            {
#if UNITY_ANDROID
#else
                //restartText.text = "Press 'r' for Restart";
#endif
                bRestart = true;
                break;
            }
        }
    }
Exemple #3
0
    void Start()
    {
        useGUILayout = false;
        FindAllGridUnits();
        enemyL    = gameObject.GetComponent <EnemyLibrary>();
        obstacleL = gameObject.GetComponent <ObstacleLibrary>();

        //S.GameControlInst.= GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameControl> ();
    }
    public static EnemyLibrary Get()
    {
        if (instance == null)
        {
            instance = new EnemyLibrary();
            instance.Init();
        }

        return(instance);
    }
    public static EnemyLibrary Get()
    {
        if (instance == null)
        {
            instance = new EnemyLibrary();
            instance.Init();
        }

        return instance;
    }
Exemple #6
0
 public static void Initialize(GameControl gc, Player pl)
 {
     gameControl     = gc;
     shopControl     = gc.gameObject.GetComponent <ShopControl>();
     clickControl    = gc.gameObject.GetComponent <ClickControl>();
     gridControl     = gc.gameObject.GetComponent <GridControl>();
     shopControlGUI  = gc.gameObject.GetComponent <ShopControlGUI>();
     obstacleLibrary = gc.gameObject.GetComponent <ObstacleLibrary>();
     enemyLibrary    = gc.gameObject.GetComponent <EnemyLibrary>();
     player          = pl;
 }
Exemple #7
0
 private void MakeThisObjectSingleton()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
 public void ConStruct()
 {
     EnemyLibrary = Resources.Load <EnemyLibrary>("Libraries/EnemyLibrary");
 }
Exemple #9
0
    void Start()
    {
        useGUILayout = false;
        FindAllGridUnits ();
        enemyL = gameObject.GetComponent<EnemyLibrary>();
        obstacleL = gameObject.GetComponent<ObstacleLibrary>();

        //S.GameControlInst.= GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameControl> ();
    }
        /**/
        //Debugging win field
        //levelGen.trigger.Add(new TriggerObject("endoflevel", new Vector2(0, 19)));

        return(levelGen);
    }

    private Tile[,] BuildStructure()
    {
        Tile[,] levelGenStructure = new Tile[32, 32];

        for (int i = 0; i < levelGenStructure.GetLength(0); i++)
        {
            for (int j = 0; j < levelGenStructure.GetLength(1); j++)
            {
                levelGenStructure[i, j] = new Tile("floor", ClipType.FLOOR);
            }
        }

        return(levelGenStructure);
    }

    private PickUp SpawnPickup(Level level, int index)
    {
        PickUp pickUp = new PickUp(ItemLibrary.Get().generics[index], 1); //rng.Next(1,3));
        bool   found  = false;

        //enemy position

        while (!found)
        {
            int a = rng.Next(0, (level.structure.GetLength(0)));
            int b = rng.Next(0, (level.structure.GetLength(1)));

            if (level.structure[a, b].substance == ClipType.FLOOR)
            {
                for (int i = 0; i < level.doors.Count; i++)
                {
                    if (level.doors[i].position.x == a && level.doors[i].position.y == b)
                    {
                        found = false;
                        break;
                    }
                }
                if (level.pickUps.Count > 0)
                {
                    for (int i = 0; i < level.pickUps.Count; i++)
                    {
                        if (!(level.pickUps[i].position.x == a && level.pickUps[i].position.y == b))
                        {
                            found = true;
                        }
                        else
                        {
                            found = false;
                            break;
                        }
                    }
                }
                else
                {
                    found = true;
                }

                if (found)
                {
                    pickUp.position = new Vector2(a, b);
                }
            }
        }

        return(pickUp);
    }

    /**/

    private Actor SpawnEnemy(Level level)
    {
        Actor enemy = new Actor();
        bool  found = false;

        //bool spawn = false;

        while (true)
        {
            int index = rng.Next(0, 3);
            if (index == 0 && meleeCount < maxMeleeCount)
            {
                //enemy = EnemyLibrary.Get().meleeList[rng.Next(0, EnemyLibrary.Get().meleeList.Count)];
                enemy = new Actor(EnemyLibrary.Get().meleeList[rng.Next(0, EnemyLibrary.Get().meleeList.Count)]);
                meleeCount++;
                break;
            }
            if (index == 1 && rangedCount < maxRangedCount)
            {
                //enemy = EnemyLibrary.Get().meleeList[rng.Next(0, EnemyLibrary.Get().meleeList.Count)];
                enemy = new Actor(EnemyLibrary.Get().rangedList[rng.Next(0, EnemyLibrary.Get().rangedList.Count)]);
                rangedCount++;
                break;
            }
            if (index == 2 && bossCount < maxBossCount)
            {
                //enemy = EnemyLibrary.Get().meleeList[rng.Next(0, EnemyLibrary.Get().meleeList.Count)];
                enemy = new Actor(EnemyLibrary.Get().bossList[rng.Next(0, EnemyLibrary.Get().bossList.Count)]);
                bossCount++;
                break;
            }
        }
        /***/
        //enemy = new Actor(EnemyLibrary.Get().meleeList[0]);

        //enemy position
        while (!found)
        {
            int a = rng.Next(1, (level.structure.GetLength(0)));
            int b = rng.Next(1, (level.structure.GetLength(1)));


            if (level.structure[a, b].substance == ClipType.FLOOR)
            {
                if (level.enemies.Count > 0)
                {
                    for (int i = 0; i < level.enemies.Count; i++)
                    {
                        if (!(level.enemies[i].position.x == a && level.enemies[i].position.y == b))
                        {
                            found = true;
                        }
                        else
                        {
                            found = false;
                            break;
                        }
                    }
                }
                else
                {
                    found = true;
                }


                if (found)
                {
                    enemy.position = new Vector2(a, b);
                    //Console.Write("| " + enemy.position.x + " " + enemy.position.y);
                }
            }
        }

        //enemy.position = new Vector2(19, 2);
        Application.GetData().collision.Add(enemy);

        return(enemy);
    }
Exemple #11
0
    void Awake()
    {
        playerInstance = GameObject.Find("Player").GetComponent<Player>();

        gameControlInstance = gc.GetComponent<GameControl> ();
        gameControlGUIInstance = gc.GetComponent<GameControlGUI> ();
        shopControlInstance = gc.GetComponent<ShopControl> ();
        shopControlGUIInstance = gc.GetComponent<ShopControlGUI> ();
        clickControlInstance = gc.GetComponent<ClickControl> ();
        gridControlInstance = gc.GetComponent<GridControl>();
        optionControlInstance = gc.GetComponent<OptionControl>();
        dragControlInstance = gc.GetComponent<DragControl>();
        eventGUIInstance = gc.GetComponent<EventGUI>();
        enemyLibraryInstance = gc.GetComponent<EnemyLibrary>();
        cardLibraryInstance = gc.GetComponent<CardLibrary>();
        goalLibraryInstance = gc.GetComponent<GoalLibrary>();
        guiStyleLibraryInstance = gc.GetComponent<GUIStyleLibrary>();
        mainMenuInstance = gc.GetComponent<MainMenu>();
        encyclopediaMenuInstance = gc.GetComponent<EncyclopediaMenu>();
        godChoiceMenuInstance = gc.GetComponent<GodChoiceMenu>();
        customizeMenuInstance = gc.GetComponent<CustomizeMenu>();
        gridCursorControlInstance = gc.GetComponent<GridCursorControl>();
        menuControlInstance = gc.GetComponent<MenuControl>();
        tutorialInstance = gc.GetComponent<Tutorial>();
        deckAnimateInstance = deck.GetComponent<DeckAnimate>();

        shopAndGoalParentCanvasInstance = goalandshopparent
                                          .GetComponent<ShopAndGoalParentCanvas>();
        shopGridCanvasInstance = shopgrid
                                 .GetComponent<ShopGridCanvas>();
        gridCursorControlGUIInstance = gridcursorcontrolgui
                                       .GetComponent<GridCursorControlGUI>();
    }