Exemple #1
0
    void Awake()
    {
        instance = this;
        Transform bg = transform.Find("BG");

        defaultMenu = bg.transform.Find("DEFAULT_BUTTONS").gameObject;
        actionMenu  = bg.transform.Find("ACTION_BUTTONS").gameObject;

        default_buttons[0] = defaultMenu.transform.Find("MOVE").GetComponent <Button>();
        default_buttons[1] = defaultMenu.transform.Find("ACT").GetComponent <Button>();
        default_buttons[2] = defaultMenu.transform.Find("POTION").GetComponent <Button>();
        default_buttons[3] = defaultMenu.transform.Find("INTERACT").GetComponent <Button>();
        default_buttons[4] = defaultMenu.transform.Find("WAIT").GetComponent <Button>();

        action_buttons[0] = actionMenu.transform.Find("ACTION 1").GetComponent <Button>();
        action_buttons[1] = actionMenu.transform.Find("ACTION 2").GetComponent <Button>();
        action_buttons[2] = actionMenu.transform.Find("ACTION 3").GetComponent <Button>();
        action_buttons[3] = actionMenu.transform.Find("ACTION 4").GetComponent <Button>();
        action_buttons[4] = actionMenu.transform.Find("BACK").GetComponent <Button>();
    }
Exemple #2
0
    void Init()
    {
        map_manager        = GetComponent <MapManager>();
        enemySpawner       = GetComponent <EnemySpawner>();
        environmentSpawner = GetComponent <EnvironmentSpawner>();
        tileSelector       = GameObject.FindGameObjectWithTag("Selector").GetComponent <TileSelector>();

        map_manager.Init(this);
        tileSelector.Init(map_manager);
        environmentSpawner.Init(map_manager);

        turn_manager = GetComponent <TurnManager>();
        turn_manager.Init(this);

        map_manager.spawnChests(randomChest);
        List <Client> players         = Network.getPeers();
        List <Pos>    spawn_locations = map_manager.findSpawnpoints(players.Count);

        Pos level_end = spawn_locations[0];

        map_manager.instantiate_environment(endportal, level_end, false);

        Debug.Log("Spawned " + players.Count + " players");
        // spawn players
        for (int i = 0; i < players.Count; i++)
        {
            if (players[i].playerObject == null)
            {
                Debug.Log(spawn_locations[i + 1] + "," + players.Count);
                Player instance = map_manager.instantiate(playerPrefab, spawn_locations[i + 1], null, players[i].nickname).GetComponent <Player>();
                instance.SetCharacterClass(players[i].classname);
                players[i].playerObject = instance;
                if (players[i].ID == NetworkManager.clientID)
                {
                    localPlayer = instance;
                }
            }
            else
            {
                Debug.Log("Respawning player");
                map_manager.re_instantiate(players[i].playerObject.gameObject, spawn_locations[i + 1]);
            }
        }
        // spawn enemies
        if (level % 3 != 0)
        {
            enemySpawner.Init(map_manager);
        }
        else
        {
            map_manager.SPAWN_ILMI_DEVOURER_OF_WORLDS(ilmiPrefab, level / 3);
            UI_TextAlert.DisplayText("A cold chill goes across your spine...", 1000);
        }

        tileSelector.setPlayer(localPlayer);
        Camera.main.GetComponent <CameraControl>().SetTarget(localPlayer.gameObject);
        UI_BattleMenu.SetActButtons(localPlayer.getActionNames());

        turn_manager.StartLoop();
        Network.submitCommand(new ReadyCommand(NetworkManager.clientID));
    }