void Start()
    {
        //GameObject dayObject = GameObject.Find("TimeText");
        TimeScript timeScript = dayObject.GetComponent <TimeScript>();

        Day = timeScript.dayNumber;
    }
Esempio n. 2
0
    public static String getBestTime()
    {
        string   path = Application.persistentDataPath + "/Database.s3db"; //Path to database.
        string   sqlQuery;
        DateTime min = new DateTime(2000, 01, 01, 00, 00, 00);

        if (!File.Exists(path))
        {
            return(TimeScript.getTimeOnly(min));
        }
        string conn = "URI=file:" + path;

        using (SqliteConnection dbconn = new SqliteConnection(conn))
        {
            dbconn.Open();
            sqlQuery = "CREATE TABLE IF NOT EXISTS HighScores(RunTime DATETIME)";
            using (IDbCommand cmd = (IDbCommand) new SqliteCommand(sqlQuery, dbconn))
            {
                cmd.ExecuteNonQuery();
            }
            sqlQuery = "SELECT MIN(RunTime) " + "FROM HighScores";
            using (IDbCommand cmd = (IDbCommand) new SqliteCommand(sqlQuery, dbconn))
            {
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        min = reader.GetDateTime(0);
                    }
                }
            }
        }
        return(TimeScript.getTimeOnly(min)); //parses timedate as time
    }
Esempio n. 3
0
    void Start()
    {
        float Time = TimeScript.GetTime();                           //TimeScriptからクリアタイムを取得

        CleartimeText.text = "クリア—タイム : " + Time.ToString("f2");     //クリアタイムを表示する
        //print(Time);
    }
Esempio n. 4
0
    public MapData GetMapData()
    {
        if (_items == null)
        {
            Debug.Log("Footholds not found!");
            return(null);
        }

        if (_startRow < 0 || _startColumn < 0)
        {
            Debug.Log("Frog not found!");
            return(null);
        }

        int rows    = _items.GetRow();
        int columns = _items.GetColumn();

        int[,] footholds = new int[rows, columns];
        StringBuilder durations = new StringBuilder();

        for (int i = 0; i < rows; i++)
        {
            int row = rows - 1 - i;

            for (int j = 0; j < columns; j++)
            {
                MapItem item = _items[row, j];

                if (item == null)
                {
                    footholds[i, j] = FootholdType.None.ToInt();
                }
                else
                {
                    footholds[i, j] = (int)item.type;

                    if (item.type == ItemType.FootholdTime)
                    {
                        TimeScript time = item.item.GetComponent <TimeScript>();

                        durations.AppendFormat("{0}:{1} ", i * columns + j, time.duration);
                    }
                }
            }
        }

        MapData mapData = new MapData();

        mapData.footholds   = footholds;
        mapData.startRow    = rows - 1 - _startRow;
        mapData.startColumn = _startColumn;
        mapData.direction   = _direction;

        if (durations.Length > 0)
        {
            mapData.timeFootholdDurations = durations.ToString().Substring(0, durations.Length - 1);
        }

        return(mapData);
    }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 6
0
    void Start()
    {
        Timer = GetComponent <TimeScript>();
        aux   = new GameObject();
        Sucesso.SetActive(false);
        Falha.SetActive(false);
        Fim.SetActive(false);
        Debug.Log("Começou...");

        waitTime   = startWaitTime;
        RandomRoom = Random.Range(0, myCanvas.Length);
        TypeOfGame = Random.Range(0, 2);
        if (TypeOfGame == 0)
        {
            myCanvas[RandomRoom].transform.Find("VirusError").gameObject.SetActive(false);
            myCanvas[RandomRoom].transform.Find("InternetError").gameObject.SetActive(true);
        }
        else
        {
            myCanvas[RandomRoom].transform.Find("InternetError").gameObject.SetActive(false);
            myCanvas[RandomRoom].transform.Find("VirusError").gameObject.SetActive(true);
        }
        myCanvas[RandomRoom].gameObject.SetActive(true);
        myRooms[RandomRoom].SendMessage("setState", true, SendMessageOptions.DontRequireReceiver);
    }
Esempio n. 7
0
 void UpdateTimer()
 {
     //deltaTime is the amount of time the last frame took
     timer  += Time.deltaTime;
     seconds = (int)timer - (minutes * 60); //total seconds, minus complete minutes
     minutes = ((int)timer) / 60;
     hours   = ((int)timer) / (60 * 60);
     if (seconds < 10) //makes string on screen appear as '09' instead of '9' if 9 seconds have passed
     {
         secString = TimeScript.timeFormatter(seconds);
     }
     else
     {
         secString = seconds.ToString();
     }
     if (minutes < 10)
     {
         minString = TimeScript.timeFormatter(minutes);
     }
     else
     {
         minString = minutes.ToString();
     }
     timerText.text = minString + ":" + secString;
 }
Esempio n. 8
0
 private void Awake()
 {
     main        = this;
     gameControl = GetComponent <ButtonScript>();
     timeControl = GetComponent <TimeScript>();
     display     = GetComponent <GenerationDisplay>();
 }
Esempio n. 9
0
    void Start()
    {
        ballsGO = new List <GameObject> ();
        ballsGO.Add((GameObject)Instantiate(Resources.Load(NameUtils.GO_BALL)));
        paddleGO    = GameObject.Find(NameUtils.GO_PADDLE);
        timeScript  = (TimeScript)GameObject.Find(NameUtils.GO_TIME_SCORE).GetComponent(typeof(TimeScript));
        scoreScript = (ScoreScript)GameObject.Find(NameUtils.GO_POINTS_SCORE).GetComponent(typeof(ScoreScript));

        lives     = PlayerPrefs.GetInt(ScoreUtils.LIVES);
        listLives = new List <GameObject> ();

        for (int i = 0; i < lives; i++)
        {
            GameObject live     = (GameObject)Instantiate(Resources.Load(NameUtils.GO_LIVE));
            Vector3    position = live.transform.position;
            position.x += (i * LIVE_OFFSET_X);
            live.transform.position = position;
            listLives.Insert(i, live);
        }

        GameObject[] gos = GameObject.FindGameObjectsWithTag(TagUtils.TAG_BRICKS);
        numberBricks = gos.Length;

        int levelNumber = StringUtils.getLevelBySceneName(PlayerPrefs.GetString(ScoreUtils.CURRENT_LEVEL_USER));

        basicScoreModifier = ScoreUtils.SCORE_LEVEL_MODIFIER * (levelNumber - 1);

        Time.timeScale = 1.0f;

        enableUI();

        SoundManager.GetInstance().changeAudio(sounds [IDX_SOUND_IN_GAME]);
        SoundManager.GetInstance().volumeDown(0.5f);
    }
    // Start is called before the first frame update
    void Start()
    {
        GameManager      = GameObject.Find("Scripts").GetComponent <GameManager>();
        pastPositions    = new List <Vector3>();
        score_controller = GameObject.Find("PlayerDetails").GetComponent <HighScoreScript>();
        TimeManager      = GameObject.Find("Canvas").GetComponent <TimeScript>();

        if (SceneManager.GetActiveScene().name == "Lvl2")
        {
            snakeLength = 5;
        }

        if (SceneManager.GetActiveScene().name == "Lvl3")
        {
            snakeLength = 1;
        }

        for (int i = 0; i < snakeLength; i++)
        {
            GameObject g = Instantiate(tailPrefab, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + (i + 1), 0f), Quaternion.identity);

            // Keep track of it in our tail list
            tailPositions.Insert(tailPositions.Count, g.transform);
        }
    }
Esempio n. 11
0
 // Use this for initialization
 void Start()
 {
     txt               = GetComponent <Text>();
     txt.text          = "";
     cherryCountScript = GameObject.Find("CherryCount").GetComponent <CherryCountScript>();
     timeScript        = GameObject.Find("TimeCount").GetComponent <TimeScript>();
     playerSoulScript  = GameObject.Find("PlayerSoul").GetComponent <PlayerSoulScript>();
 }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     PlaySE = this.GetComponent<AudioSource>();
     scoreS = scoreText.GetComponent<ScoreScript>();
     bonusSpawn = bonusSpawner.GetComponent<BonusSpawnerScript>();
     bonuschance = bonusLevelText.GetComponent<BonusChanceScript>();
     timeScript = TimeText.GetComponent<TimeScript>();
 }
Esempio n. 13
0
 public void Setup()       //Can't trust Start() to be called in time
 {
     time_ctrl   = transform.parent.gameObject.GetComponent <TimeScript>();
     origin_time = time_ctrl.current_time;
     origin_dist = current_dist = time_ctrl.ship_dist;
     label       = gameObject.GetComponentInChildren <Text>();
     label.text  = origin_dist.ToString();
 }
Esempio n. 14
0
 /// <summary>
 /// total days in the game
 /// </summary>
 public static int GetTotalDays()
 {
     if (_instnace == null)
     {
         _instnace = Camera.main.GetComponent <TimeScript>();
     }
     return(_instnace.TotalDays);
 }
Esempio n. 15
0
 /// <summary>
 /// Return finished items from queue and make new items
 /// </summary>
 /// <param name="worked"> not used </param>
 public override void Working(long worked)
 {
     StorageSize = 100000;
     if (_duration > 0)
     {
         int          indx = TimeScript.GetTotalDays() % _duration;
         ProcessItems itm  = m_itemsStarted[indx];
         m_count         += itm.m_itemsCount;
         itm.m_itemsCount = 0;
     }
     base.Working(worked);
     StorageSize = m_count;
 }
    private void CacheTimeScript()
    {
        var timeObject = GameObject.Find("TimeObject");

        if (timeObject != null)
        {
            Debug.Log("TimeObject Update");
            this.timeScript = timeObject.GetComponent <TimeScript>();
        }
        else
        {
            Debug.LogError("TimeObject not found");
        }
    }
Esempio n. 17
0
    /// <summary>
    /// Save the game to the json string.
    /// String should be written into a file or send to server
    /// </summary>
    /// <returns>game save</returns>
    public string Save()
    {
        foreach (AbstractObject itm in AbstractObject.m_sEverything)
        {
            switch (itm.GetType().FullName)
            {
            case nameof(Science): m_allScience.Add(itm as Science); break;

            case nameof(Population): m_population = itm as Population; break;

            case nameof(Items): m_allItems.Add(itm as Items); break;

            case nameof(GameMaterial): m_allMaterails.Add(itm as GameMaterial); break;

            case nameof(Buildings): m_allBuildings.Add(itm as Buildings); break;

            case nameof(Army): m_allArmy.Add(itm as Army); break;

            case nameof(Resource): m_allResources.Add(itm as Resource); break;

            case nameof(Process): m_allProcesses.Add(itm as Process); break;

            case nameof(WildAnimal): m_allWildAnimals.Add(itm as WildAnimal); break;

            case nameof(DomesticAnimal): m_allDomestic.Add(itm as DomesticAnimal); break;
            }
        }

        foreach (GameObject go in MainScript.m_sAllItems)
        {
            IconScript ics = go.GetComponent <IconScript>();
            GameIcon   gic = new GameIcon();
            gic.m_pos     = ics.transform.position;
            gic.m_itmName = ics.m_thisItem.m_name;
            m_allGameIcons.Add(gic);
        }

        TimeScript tsc = Camera.main.GetComponent <TimeScript>();

        m_speed = tsc.m_speed;
        m_day   = tsc.m_day;
        m_year  = tsc.m_year;

        m_canShowTooltips = LearningTip.m_sCanShow;

        string json = JsonUtility.ToJson(this);

        return(json);
    }
Esempio n. 18
0
    void Start()
    {
        List <DateTime> times = DBConnect.getHighScores(); //reads scores currently in DB

        String[] tempArray = new String[5] {
            "--:--:--", "--:--:--", "--:--:--", "--:--:--", "--:--:--"
        };
        for (int i = 0; i < times.Count && i < 5; i++)
        {
            tempArray[i] = TimeScript.getTimeOnly(times[i]); //Formating times before putting them in List
        }
        Score1.text = tempArray[0];                          //These text objects are displayed in textboxes in the leaderboard scene
        Score2.text = tempArray[1];
        Score3.text = tempArray[2];
        Score4.text = tempArray[3];
        Score5.text = tempArray[4];
    }
Esempio n. 19
0
    /// <summary>
    /// check should be boost destroyed and how many time it has
    /// </summary>
    void CheckBoost()
    {
        TimeScript ts = m_timeScr;

        if (m_isItBoost)
        {
            if (m_isItBoost && ts.TotalDays > _startBoostDay + _boostDuration)
            {
                m_isItBoost = false;
                Destroy(m_emojiBoost);
            }
            else
            {
                Slider sldr = m_emojiBoost.transform.Find("Slider").
                              gameObject.GetComponent <Slider>();
                sldr.value = ((float)ts.TotalDays - (float)_startBoostDay) / (float)_boostDuration;
            }
        }
    }
Esempio n. 20
0
    public void GameOver()
    {
        CancelInvoke();
        endScreen.SetActive(true);
        TimeScript time = timeObject.GetComponent <TimeScript> ();

        time.stopTime = true;
        timeObject.SetActive(false);
        changeDeviceBtn.SetActive(false);
        pauseGameBtn.SetActive(false);
        if (globalscripts.language == "pt")
        {
            goverText.GetComponent <TextMeshProUGUI> ().text += "\n Você sobreviveu:\n" + time.time + " segundos!";
        }
        else
        {
            goverText.GetComponent <TextMeshProUGUI> ().text += "\n You survived:\n" + time.time + " seconds!";
        }
        player.GetComponent <Player> ().UnsubscribeMot();
    }
    void Start()
    {
        Star = 0;
        TempoS = GameObject.Find("Canvas").GetComponent<TimeScript>();
        try
        {
            MainLevel = GameObject.Find("LevelController").GetComponent<LevelControl>();
            counterToWin = 0;
            counter = 0;
            j = 0;
            i = 0;
            ToWin = 0;
            FacesMini = GameObject.Find("MiniCube").GetComponent<ColorDefault>();
            FacesBig = GameObject.Find("CubeM").GetComponent<ColorDefault>();
            FacesToMini = FacesMini.Faces;
            FacesToBig = FacesBig.Faces;
         }
         catch
         {

         }
    }
Esempio n. 22
0
    /// <summary>
    /// Event of work finished
    /// </summary>
    /// <param name="productsFinished"> how many items was produced/repaired </param>
    /// <param name="mulEffect"> multiplier to final product after waiting.</param>
    public override void WorkComplite(float productsFinished, float mulEffect)
    {
        float inProc = TotalInWaiting();

        if (productsFinished > 0)
        {
            m_mulEffect = (m_mulEffect + mulEffect) / 2;
        }
        else if (inProc < 0.1)
        {
            m_mulEffect = 0;
        }

        if (_duration > 0)
        {
            int          indx = TimeScript.GetTotalDays() % _duration;
            ProcessItems itm  = m_itemsStarted[indx];
            itm.m_itemsCount += productsFinished;
        }
        else
        {
            m_count += productsFinished;
        }
    }
Esempio n. 23
0
    // Use this for initialization
    void Start()
    {
        A         = 0.0f;                // 加速度
        posY      = 0.0f;                // Y座標
        JUMPPOWER = 0.98f * 6.0f / 8.0f; // 加速度
        G         = 0.98f / 12.0f;       // 重力

        B = 0.0f;

        i = 0;

        collider2D        = GetComponent <Collider2D>();
        animator          = GetComponent <Animator>();
        cherryCountScript = GameObject.Find("CherryCount").GetComponent <CherryCountScript>();
        timeScript        = GameObject.Find("TimeCount").GetComponent <TimeScript>();
        mainCamera        = GameObject.FindWithTag("MainCamera");
        resultScript      = GameObject.Find("Text").GetComponent <ResultScript>();

        animator.SetBool("idle", true);
        animator.SetBool("run", false);

        this.rigidbody2D = GetComponent <Rigidbody2D>();
        A = JUMPPOWER;
    }
	void OnLevelWasLoaded()
	{
		GameObject ti = GameObject.Find ("Main Camera/Canvas/TimeDisplay");
		if(ti != null)
			time = ti.GetComponent<TimeScript> ();
	}
Esempio n. 25
0
 public void SetaTabela()
 {
     System.IO.StreamReader file = new System.IO.StreamReader(pathTable);
     for (int i = 0; i < colunas.Length; i++)
     {
         colunas[i].text = "";
     }
     while ((line = file.ReadLine()) != null)
     {
         if (endGame)
         {
             endGame.SetActive(false);
         }
         // Debug.Log("oque?" + line);
         if (line == "NOVA TABELA VERDADE")    //verifica se é um tabela
         {
             line         = file.ReadLine();
             _tableNumber = Convert(line[0]); // pega o numero dessa tabela e convert p int
             if (_tableNumber == counter)     //instruçoes de leitura aqui
             // Debug.Log("Tabela " + tableNumber);
             {
                 line           = file.ReadLine();   //pega expressao
                 expressao.text = line;
                 expr           = SplitString(line); //separa expr pra associar uma coluna da tabela a uma variavel
                 line           = file.ReadLine();   //pega num de linhas da tabela
                 _numLinhas     = Convert(line[0]);  //Debug.Log(numLinhas); Debug.Log(expr);
                 double totalDeLinhas = Math.Pow(2, System.Convert.ToDouble(_numLinhas));
                 _acertos = new int[System.Convert.ToInt32(totalDeLinhas)];
                 Debug.Log(totalDeLinhas);
                 for (int i = 0; i < totalDeLinhas; i++)                                                               //a partir da conta do total de linhas pega tdas as linhas
                 {
                     line      = file.ReadLine();                                                                      //linha da tabela
                     inputs[i] = Instantiate(inputPrefab, new Vector3(0, -75.5f - (85f * i), 0), Quaternion.identity); //seta novo input em sua coordenada
                     inputs[i].transform.SetParent(_resultadoTransform, false);                                        //seta como child de Resultados
                     SetId inputScript = inputs[i].GetComponent <SetId>();                                             //busca script pra setar o id de cada input
                     inputScript.Id           = i;
                     inputs[i].characterLimit = 1;                                                                     //seta limite de caracteres como apenas 1
                     if (_vars > _numLinhas)
                     {
                         expr2 = KnowWhatIterate(expr, i);
                         foreach (var item in expr2)
                         {
                             if (item.Contains("-"))
                             {
                                 colunas[(_convertColunas[item].GetHashCode() - 5)].text += line[_count] + "\n"; //escreve a linha da tabela no postivo
                                 if (line[_count] == 'V')                                                        // nega a linha da tabela e escreve no negativo
                                 {
                                     colunas[_convertColunas[item].GetHashCode()].text += 'F' + "\n";
                                 }
                                 else
                                 {
                                     colunas[_convertColunas[item].GetHashCode()].text += 'V' + "\n";
                                 }
                                 _count += 2;
                             }
                             else
                             {
                                 colunas[_convertColunas[item].GetHashCode()].text += line[_count] + "\n";
                                 _count += 2;
                             }
                         }
                         _count = 0;
                     }
                     else
                     {
                         foreach (var item in expr)   //associa cada coluna da tabela a uma variavel e printa na tela
                         {
                             if (item != null)
                             {
                                 if (item.Contains("-"))
                                 {
                                     colunas[(_convertColunas[item].GetHashCode() - 5)].text += line[_count] + "\n"; //escreve a linha da tabela no postivo
                                     if (line[_count] == 'V')                                                        // nega a linha da tabela e escreve no negativo
                                     {
                                         colunas[_convertColunas[item].GetHashCode()].text += 'F' + "\n";
                                     }
                                     else
                                     {
                                         colunas[_convertColunas[item].GetHashCode()].text += 'V' + "\n";
                                     }
                                     _count += 2;
                                 }
                                 else
                                 {
                                     colunas[_convertColunas[item].GetHashCode()].text += line[_count] + "\n";
                                     _count += 2;
                                 }
                             }
                         }
                         _count = 0;
                     }
                 }
                 file.ReadLine();            //lê o espaço entre a tabela e as respostas
                 resps = file.ReadLine();
                 resp  = SplitString(resps); //separa o vetor de respostas p associar aos inputs
                 counter++;
                 break;
             }
         }
         if ((line = file.ReadLine()) == null)   //vai para algum lugar, fim do arquivo de tabelas**
         {
             TimeScript timer = time.GetComponent <TimeScript>();
             _tempos[userCount] = timer.EndGame();// Debug.Log("atualiza text");
             for (int i = 0; i < _tempos.Length; i++)
             {
                 if (_users[i] != null)   //Debug.Log("USERS " + users[i] + "TEMPOS " + tempos[i]);
                 {
                     userTable.text += String.Format("{0,-12}{1,24}\n", _users[i], _tempos[i] + " segundos");
                 }
             }
             endFile.SetActive(true); //Debug.Log("não tem mais tabela");
             file.DiscardBufferedData();
             //line = file.ReadLine();
             //path = "";
             //pathTable = "/Assets/NewAdds/";
             // file.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
         }
     }
 }
Esempio n. 26
0
    void Start()
    {
        ballsGO = new List<GameObject> ();
        ballsGO.Add((GameObject)Instantiate(Resources.Load(NameUtils.GO_BALL)));
        paddleGO = GameObject.Find(NameUtils.GO_PADDLE);
        timeScript = (TimeScript) GameObject.Find(NameUtils.GO_TIME_SCORE).GetComponent(typeof(TimeScript));
        scoreScript = (ScoreScript) GameObject.Find(NameUtils.GO_POINTS_SCORE).GetComponent(typeof(ScoreScript));

        lives = PlayerPrefs.GetInt(ScoreUtils.LIVES);
        listLives = new List<GameObject> ();

        for (int i = 0; i < lives; i++) {
            GameObject live = (GameObject)Instantiate(Resources.Load(NameUtils.GO_LIVE));
            Vector3 position = live.transform.position;
            position.x += (i * LIVE_OFFSET_X);
            live.transform.position = position;
            listLives.Insert(i, live);
        }

        GameObject[] gos = GameObject.FindGameObjectsWithTag(TagUtils.TAG_BRICKS);
        numberBricks = gos.Length;

        int levelNumber = StringUtils.getLevelBySceneName (PlayerPrefs.GetString (ScoreUtils.CURRENT_LEVEL_USER));
        basicScoreModifier = ScoreUtils.SCORE_LEVEL_MODIFIER * (levelNumber - 1);

        Time.timeScale = 1.0f;

        enableUI ();

        SoundManager.GetInstance ().changeAudio (sounds [IDX_SOUND_IN_GAME]);
        SoundManager.GetInstance ().volumeDown (0.5f);
    }
Esempio n. 27
0
    /// <summary>
    /// load game from json string
    /// !!! move it to Game !!!
    /// </summary>
    void Load(string json)
    {
        Game       gm = Game.Load(json);
        MainScript ms = Camera.main.GetComponent <MainScript>();

        ms.ClearEverything();
        ms.Loading();

        CopyItems(gm.m_allArmy);
        CopyItems(gm.m_allBuildings);
        CopyItems(gm.m_allItems);
        CopyItems(gm.m_allMaterails);
        CopyItems(gm.m_allScience);
        CopyItems(gm.m_allResources);
        CopyItems(gm.m_allProcesses);
        CopyItems(gm.m_allWildAnimals);
        CopyItems(gm.m_allDomestic);

        AbstractObject.m_sEverything[AbstractObject.m_sEverything.Count - 1].
        Copy(gm.m_population);

        ms.PlaceOpenedItems(AbstractObject.GetOpennedItems());

        CopyTools(gm.m_allArmy);
        CopyTools(gm.m_allBuildings);
        CopyTools(gm.m_allItems);
        CopyTools(gm.m_allMaterails);
        CopyTools(gm.m_allProcesses);

        foreach (GameObject go in MainScript.m_sAllItems)
        {
            try
            {
                IconScript    ics = go.GetComponent <IconScript>();
                Game.GameIcon gic = null;
                foreach (var itm in gm.m_allGameIcons)
                {
                    if (itm.m_itmName == ics.m_thisItem.m_name)
                    {
                        gic = itm;
                        break;
                    }
                }
                if (gic == null)
                {
                    continue;             //throw new System.Exception("Object not found");
                }
                gm.m_allGameIcons.Remove(gic);
                ics.transform.position = gic.m_pos;
            }
            catch (Exception ex)
            {
                Debug.Log(ex.Message);
            }
        }

#if !UNITY_WEBGL
        Localization.GetLocalization().ChangeLanguage(Settings.GetSettings().m_localization.m_currentLanguage);
#endif
        TimeScript tsc = Camera.main.GetComponent <TimeScript>();
        tsc.m_day   = gm.m_day;
        tsc.m_year  = gm.m_year;
        tsc.m_speed = gm.m_speed;

        LearningTip.m_sCanShow = gm.m_canShowTooltips;

        gameObject.SetActive(false);
    }
Esempio n. 28
0
    public List <CheckedPoint> checkedPoints;   // = new List<CheckedPoint>();

    void Awake()
    {
        timeScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <TimeScript>();
    }
Esempio n. 29
0
 // Use this for initialization
 void Start()
 {
     animator   = GetComponent <Animator>();
     hour       = GameObject.Find("hour").gameObject;
     timeScript = hour.GetComponent <TimeScript>();
 }
 //
 void Awake()
 {
     DontDestroyOnLoad(gameObject);
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
Esempio n. 31
0
 void Awake()
 {
     me = this;
 }
Esempio n. 32
0
 // Use this for initialization
 void Awake()
 {
     instancePlayer = GetComponent <InstancePlayer>();
     timeScript     = GetComponent <TimeScript>();
 }
Esempio n. 33
0
    // Load from file
    public bool Load(string fileName)
    {
        MapData mapData = null;

        Helper.Load <MapData>(fileName, ref mapData);

        if (mapData == null)
        {
            Debug.Log("Map not found!");
            return(false);
        }

//		mapData.Log();

        // Clear items
        Clear();

        // Get footholds
        int[,] footholds = mapData.footholds;

        // Set rows
        rows = footholds.GetRow();

        // Set columns
        columns = footholds.GetColumn();

        // Create map items
        _items = new MapItem[rows, columns];

        for (int i = 0; i < rows; i++)
        {
            int row = rows - 1 - i;

            for (int j = 0; j < columns; j++)
            {
                FootholdType footholdType = footholds[i, j].ToFootholdType();

                if (footholdType != FootholdType.None)
                {
                    ItemType itemType = footholdType.ToItemType();

                    AddItem(itemType, GetItemPrefab(itemType), row, j);
                }
            }
        }

        // Set start cell
        _startRow    = rows - 1 - mapData.startRow;
        _startColumn = mapData.startColumn;

        // Set direction
        _direction = mapData.direction;

        // Set time foothold duration
        mapData.DeserializeTimeFootholds((row, column, duration) => {
            MapItem item = _items[rows - 1 - row, column];

            if (item != null)
            {
                TimeScript time = item.item.GetComponent <TimeScript>();

                if (time != null)
                {
                    time.duration = duration;
                }
                else
                {
                    //Log.Debug("TimeScript required!");
                }
            }
            else
            {
                //Log.Debug("TimeFoothold is null!");
            }
        });

        // Get foothold
        GameObject foothold = _items[_startRow, _startColumn].item;

        if (foothold != null)
        {
            // Create frog
            GameObject frog = Instantiate(GetItemPrefab(ItemTypeHelper.GetFrog(_direction))) as GameObject;
            frog.name = "Frog";
            frog.transform.SetParent(foothold.transform);
            frog.transform.localPosition = Vector3.zero;
        }

        return(true);
    }
Esempio n. 34
0
 // Start is called before the first frame update
 void Start()
 {
     _thisDayTime = Time.time;
     _instnace    = this;
 }
Esempio n. 35
0
    /// <summary>
    /// Game initialization.
    /// Loading data, placing objects
    /// </summary>
    public void GameInitialization()
    {
        if (m_sAllItems == null)
        {
            m_sAllItems = new List <GameObject>();
        }
        m_mainMenuPanel.SetActive(false);
        MainMenu.m_sActiveMenu = null;

        transform.position = new Vector3(0, 0, -10);
        _range             = 30f;
        GameObject arrowPanel = Instantiate(m_arrowLegendPanelPrefab);

        arrowPanel.transform.SetParent(m_mainCanvas.transform);
        _arrowPanel = arrowPanel.GetComponent <Image>();
        _arrowPanel.rectTransform.anchoredPosition = new Vector2(-53, -32f);

        GameObject rightPanel = Instantiate(m_rightGamePanelPrefab);
        GameObject leftPanel  = Instantiate(m_leftGamePanelPrefab);

        rightPanel.transform.SetParent(m_mainCanvas.transform);
        GameObject rootRightPanel = rightPanel.transform.Find("Root").gameObject;

        leftPanel.transform.SetParent(m_mainCanvas.transform);
        m_toolTipText = leftPanel.transform.Find("TooltipText").gameObject.GetComponent <Text>();

        People pl = CheckComponent <People>();

        pl.m_publicEmoji = leftPanel.transform.Find("Emoji").GetComponent <Image>();
        pl.m_hungry      = leftPanel.transform.Find("Hungry").gameObject.GetComponent <Image>();
        var leftColorPanel = leftPanel.transform.Find("ImageTimeText");

        pl.m_peopleText = leftColorPanel.transform.Find("PopulationValue").
                          gameObject.GetComponent <Text>();
        pl.m_workersText = leftColorPanel.transform.Find("WorkersValue").
                           gameObject.GetComponent <Text>();

        CameraScript csc = CheckComponent <CameraScript>();
        TimeScript   tsc = CheckComponent <TimeScript>();

        TimeScript.m_isItPaused = true;
        tsc.m_timeText          = leftColorPanel.transform.Find("TimeText").GetComponent <Text>();
        tsc.Initialization(leftPanel);
        pl.m_timeScr = tsc;

        Storage str = CheckComponent <Storage>();

        str.m_territoryText = rootRightPanel.transform.Find("TerritoryValue").
                              gameObject.GetComponent <Text>();
        str.m_heavyText = rootRightPanel.transform.Find("HeavyStorageValue").
                          gameObject.GetComponent <Text>();
        str.m_lightText = rootRightPanel.transform.Find("LightStorageValue").
                          gameObject.GetComponent <Text>();
        str.m_livingText = rootRightPanel.transform.Find("LivingSpaceValue").
                           gameObject.GetComponent <Text>();

        str.m_territoryObject = rootRightPanel.transform.Find("TerritoryText").
                                gameObject.GetComponent <Text>();
        str.m_heavyObject = rootRightPanel.transform.Find("HeavyStorageText").
                            gameObject.GetComponent <Text>();
        str.m_lightObject = rootRightPanel.transform.Find("LightStorageText").
                            gameObject.GetComponent <Text>();
        str.m_livingObject = rootRightPanel.transform.Find("LivingSpaceText").
                             gameObject.GetComponent <Text>();
        str.m_people = pl;
        pl.m_storage = str;

        Image lft = leftPanel.GetComponent <Image>();

        lft.rectTransform.anchoredPosition = new Vector2(191.45f, -86f);
        Image rht = rightPanel.GetComponent <Image>();

        rht.rectTransform.anchoredPosition = new Vector2(-125.1f, -35f);
        _leftPanel  = lft;
        _rightPanel = rht;

        Button settings = lft.transform.Find("Settings").gameObject.GetComponent <Button>();

        settings.onClick.AddListener(ShowMainMenu);
        TimeScript.m_isItPaused = false;
    }