private void Start()
    {
        EventMessenger.Subscribe(GameEvent.ConnetorSwitchToOn, this, OnConnetorSwitchToOn);

        _UIRoot = GameObject.Find("UI Root");
        if (_UIRoot == null)
        {
            Debug.LogError("UI Root not found");
        }

        if (_needRoomContentGeneration)
        {
            RoomContentGenerator.Generate();
            EventMessenger.SendMessage(GameEvent.CompleteContentGeneration, this);
        }

        if (_needShapesGeneration)
        {
            ShapesGenerator.Generate();
            EventMessenger.SendMessage(GameEvent.CompleteNodesGeneration, this);
        }

        Invoke("StartGameProcess", 0.3f);
        //StartGameProcess();
    }
 private void OnClick()
 {
     if (MainSceneManager.CurrentGameMode == MainSceneManager.GameMode.Normal)
     {
         EventMessenger.SendMessage(GameEvent.InvokeAdjuster, this);
         MainSceneManager.CurrentGameMode = MainSceneManager.GameMode.InvokeAdjuster;
     }
 }
    //private void OnDrawGizmos()
    //{
    //    for (float i = 30; i >= 0; i-=0.2f)
    //    {
    //        int x = (int) Mathf.Pow(1.2589254117941672104239541063958f, i);
    //        Debug.LogWarning(1000-x);
    //    }
    //}


    private void StartGameProcess()
    {
        if (!Application.loadedLevelName.Contains("Tutorial"))
        {
            var totalScore = PlayerPrefs.GetInt("totalScore");
            var scoreLabel = _UIRoot.transform.FindChild("MainGamePanel/01_spriteForText/02_lblScore");
            scoreLabel.GetComponent <UILabel>().text = totalScore.ToString();
        }

        //Debug.LogWarning("StartGame");
        CurrentGameMode = GameMode.Normal;
        EventMessenger.SendMessage(GameEvent.StartGameProcess, this);
    }
Ejemplo n.º 4
0
    private void SwitchToOn()
    {
        if (IsConnected)
        {
            return;
        }
        renderer.material.color = Color.green;
        IsConnected             = true;

        if (Device != null)
        {
            Device.SwitchToOn();
        }

        EventMessenger.SendMessage(GameEvent.ConnetorSwitchToOn, this);
    }
Ejemplo n.º 5
0
    public void FillTable(List <GPGScore> scores)
    {
        UIScrollView sv = UIRoot.list[0].transform.Find("Panel1/Scroll View").GetComponent <UIScrollView>();

        sv.ResetPosition();

        Debug.Log("loadScoresSucceededEvent");
        Prime31.Utils.logObject(scores);

        List <GameObject> destroyedItems = (from Transform tr in _grid select tr.gameObject).ToList();

        foreach (GameObject go in destroyedItems)
        {
            DestroyImmediate(go);
        }

        int index = 0;
        //int yPos = 0;
        int visibleScores = (MySocialMain.Instance.MaxVisibleScores > 0) ? MySocialMain.Instance.MaxVisibleScores : int.MaxValue;

        foreach (var score in scores.Take(visibleScores))
        {
            var lineItemGO = NGUITools.AddChild(_grid.gameObject, _linePrefab);
            //var lineItemUI = lineItemGO.GetComponent<UIWidget>();

            index++;

            if (index < 10)
            {
                lineItemGO.name = "00" + index.ToString();
            }
            else if (index > 9 && index < 100)
            {
                lineItemGO.name = "0" + index.ToString();
            }
            else if (index > 99)// && yPos < 1000)
            {
                lineItemGO.name = index.ToString();
            }

            AddGridLine(score, lineItemGO.transform.GetChild(0));
        }
        _grid.GetComponent <UIGrid>().Reposition();

        EventMessenger.SendMessage(GameEvent.OnFillRecordsTable, this);
        Debug.Log("loadScoresSucceededEvent_end");
    }
    private IEnumerator ChangeAlphaCoroutine()
    {
        //System.DateTime t1 = default(System.DateTime), t2 = default(System.DateTime);
        //t1 = System.DateTime.Now;
        var c = renderer.material.GetColor(_colorPropertyName);

        //Debug.LogWarning("t1");
        while (c.a < 1f)
        {
            var speed = Time.deltaTime / _time;  //speed=путь*Time.deltaTime/time
            c.a += speed;
            renderer.material.SetColor(_colorPropertyName, c);
            yield return(null);
        }
        //t2 = System.DateTime.Now;
        //Debug.LogWarning("time: "+(t2 - t1).TotalMilliseconds);

        EventMessenger.SendMessage(GameEvent.OnTutorialCompleteShowText, this);
    }
Ejemplo n.º 7
0
    private void Awake()
    {
        EventMessenger.SendMessage(GameEvent.OnCreateSignal, this);

        transform.parent = SceneContainers.Signals;
        if (NodesGrid.Grid == null)
        {
            Debug.LogError("NodesGrid.Grid is not initialized");
            return;
        }
        VectorInt2 nodeIndex = transform.position;

        _currentShape = NodesGrid.Grid[nodeIndex.x, nodeIndex.y].Shape;
        TryAddShapeToList(_currentShape);

        if (_currentShape.IsInRotateProcess)
        {
            DestroySelf();
        }
    }
    //public static bool MouseOverGUI = false;

    private void Update()
    {
        if (!_isAcrive)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, _clickableMmask))
            {
                if (hit.transform == _target)
                {
                    hit.transform.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
                    EventMessenger.SendMessage(GameEvent.OnTutorial_ClickByTarget, this);
                    EventMessenger.SendMessage(GameEvent.EngGameProcess, this);
                    _isAcrive = false;
                }
            }
        }
    }
    private void Victory()
    {
        bool isUsedHelp = (CurrentGameMode == GameMode.InvokeAdjuster);

        //Debug.LogWarning("<color=green>VICTORY</color>");
        CurrentGameMode = GameMode.Victory;
        EventMessenger.SendMessage(GameEvent.EngGameProcess, this);

        if (Application.loadedLevelName.Contains("Tutorial"))
        {
            return;
        }


        var victoryPanel = _UIRoot.transform.Find("VictoryPanel");

        NGUITools.SetActive(victoryPanel.gameObject, true);
        var timer = _UIRoot.GetComponentsInChildren <LabelTimer>().FirstOrDefault();

        timer.enabled = false;


        int score = isUsedHelp ? 0 : ScoreCounter.TimeToStore(timer.StartTime, timer.RemainTime);

        var prevScore = PlayerPrefs.GetInt(Application.loadedLevelName + "_score");

        //Debug.LogWarning(Application.loadedLevelName + "_score = " + prevScore);

        if (prevScore < score)
        {
            PlayerPrefs.SetInt(Application.loadedLevelName + "_score", score);
        }


        var scoreLabel = _UIRoot.transform.FindChild("MainGamePanel/01_spriteForText/02_lblScore");

        var victorySpriteTransform   = _UIRoot.transform.FindChild("VictoryPanel/02_spriteTop");
        var scoreLabelInVictoryPanel = victorySpriteTransform.FindChild("03_lblScore");

        scoreLabelInVictoryPanel.GetComponent <UILabel>().text = score.ToString();

        var victorySprite = victorySpriteTransform.GetComponent <UISprite>();

        switch (ScoreCounter.GetCountStars(score))
        {
        case 1:
            victorySprite.spriteName = "08_result_1_star";
            break;

        case 2:
            victorySprite.spriteName = "09_result_2_star";
            break;

        case 3:
            victorySprite.spriteName = "10_result_3_star";
            break;
        }

        StartCoroutine(
            SumScoreCoroutine(scoreLabel.GetComponent <UILabel>(), scoreLabelInVictoryPanel.GetComponent <UILabel>(), score));
    }
Ejemplo n.º 10
0
 private void OnDestroy()
 {
     EventMessenger.SendMessage(GameEvent.OnDestroySignal, this);
 }