Beispiel #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        leftGameMode   = GameObject.Find("Canvas/Left/GameMode");
        leftReplayMode = GameObject.Find("Canvas/Left/ReplayMode");
        blackAllTime   = GameObject.Find("Canvas/Left/GameMode/Black/AllTime/Value").GetComponent <Text>();
        blackStepTime  = GameObject.Find("Canvas/Left/GameMode/Black/StepTime/Value").GetComponent <Text>();
        redAllTime     = GameObject.Find("Canvas/Left/GameMode/Red/AllTime/Value").GetComponent <Text>();
        redStepTime    = GameObject.Find("Canvas/Left/GameMode/Red/StepTime/Value").GetComponent <Text>();
        lostHp         = GameObject.Find("Canvas/Left/ReplayMode/LostLife/Label").GetComponent <Text>();
        addAttr        = GameObject.Find("Canvas/Left/ReplayMode/AddAttr/Label").GetComponent <Text>();
        /*****************中******************/
        GridsTrans = GameObject.Find("Grids").transform;
        cells      = new GameObject[9, 10];
        for (int y = 0; y <= 9; y++)
        {
            Transform row = GridsTrans.FindChild("row" + y);
            for (int x = 0; x <= 8; x++)
            {
                cells[x, y] = row.FindChild("cell" + x).gameObject;
                cells[x, y].GetComponent <Image>().enabled = false;
            }
        }
        GameCache.SetCoords(cells);     //将场景找到的cell作为参数,处理写入映射缓存

        beginBtn        = GameObject.Find("Canvas/Middle/BeginBtn");
        addAtrrPanel    = GameObject.Find("Canvas/Middle/AddAttrPanel");
        addChessName    = GameObject.Find("Canvas/Middle/AddAttrPanel/ChessName").GetComponent <Text>();
        addHpValue      = GameObject.Find("Canvas/Middle/AddAttrPanel/Grid/Hp/Value").GetComponent <Text>();
        addAttackValue  = GameObject.Find("Canvas/Middle/AddAttrPanel/Grid/Attack/Value").GetComponent <Text>();
        addDefenceValue = GameObject.Find("Canvas/Middle/AddAttrPanel/Grid/Defence/Value").GetComponent <Text>();
        endPanel        = GameObject.Find("Canvas/Middle/EndPanel");
        winer           = GameObject.Find("Canvas/Middle/EndPanel/ResultLabel").GetComponent <Text>();
        /******************右******************/
        rightGameMode    = GameObject.Find("Canvas/Right/GameMode");
        rightReplayMode  = GameObject.Find("Canvas/Right/ReplayMode");
        blackDetailPanel = GameObject.Find("Canvas/Right/BlackAttrDetail");
        b_Name           = blackDetailPanel.transform.FindChild("ChessName").GetComponent <Text>();
        b_Hp             = blackDetailPanel.transform.FindChild("Grid/Hp/Value").GetComponent <Text>();
        b_Attack         = blackDetailPanel.transform.FindChild("Grid/Attack/Value").GetComponent <Text>();
        b_Defence        = blackDetailPanel.transform.FindChild("Grid/Defence/Value").GetComponent <Text>();
        b_Combat         = blackDetailPanel.transform.FindChild("Combat/Value").GetComponent <Text>();
        redDetailPanel   = GameObject.Find("Canvas/Right/RedAttrDetail");
        r_Name           = redDetailPanel.transform.FindChild("ChessName").GetComponent <Text>();
        r_Hp             = redDetailPanel.transform.FindChild("Grid/Hp/Value").GetComponent <Text>();
        r_Attack         = redDetailPanel.transform.FindChild("Grid/Attack/Value").GetComponent <Text>();
        r_Defence        = redDetailPanel.transform.FindChild("Grid/Defence/Value").GetComponent <Text>();
        r_Combat         = redDetailPanel.transform.FindChild("Combat/Value").GetComponent <Text>();
        stepsLabel       = rightReplayMode.transform.FindChild("Step/StepsLabel").GetComponent <Text>();

        AddAttrCompleteEvent                += HideAddAttrPanel;
        AddAttrCompleteEvent                += HideAttrPanel;
        ReplayModeEvent                     += ResetChessBoardPoints;
        ReplayModeEvent                     += UpdateReplayModeText;
        UndoEvent                           += ResetChessBoardPoints;
        UndoEvent                           += UpdateAttrPanel;
        TimeManager.TimeUpEventWithParam    += ShowEndPanel;
        TimeManager.TimeUpEvent             += ResetChessBoardPoints;
        TimeManager.TimeUpEvent             += HideAddAttrPanel;
        Chess_Boss.BossKilledEventWithParam += ShowEndPanel;
        Chess_Boss.BossKilledEvent          += ResetChessBoardPoints;
        Chess_Boss.BossKilledEvent          += HideAddAttrPanel;
    }