示例#1
0
文件: Common.cs 项目: mmorfin/CreeSer
 public static int getStatusNumber(Common.STATUS status)
 {
     if (status == STATUS.Solved)
     {
         return(1);
     }
     if (status == STATUS.Process)
     {
         return(2);
     }
     if (status == STATUS.Canceled)
     {
         return(3);
     }
     if (status == STATUS.User_Response)
     {
         return(4);
     }
     if (status == STATUS.Diagnostic)
     {
         return(5);
     }
     if (status == STATUS.New)
     {
         return(6);
     }
     if (status == STATUS.Review)
     {
         return(7);
     }
     return(0);
 }
示例#2
0
        public void setIntegrationStatus(Common.STATUS S)
        {
            if (InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate
                {
                    switch (S)
                    {
                    case Common.STATUS.GRAY:
                        btnEnt.Image = imageListMain.Images[3];
                        break;

                    case Common.STATUS.GREEN:
                        btnEnt.Image = imageListMain.Images[0];
                        break;

                    case Common.STATUS.RED:
                        btnEnt.Image = imageListMain.Images[2];
                        break;

                    case Common.STATUS.YELLOW:
                        btnEnt.Image = imageListMain.Images[1];
                        break;

                    case Common.STATUS.WORKING:
                        btnEnt.Image = imageListMain.Images[4];
                        break;
                    }
                }));
            }
            else
            {
                switch (S)
                {
                case Common.STATUS.GRAY:
                    btnEnt.Image = imageListMain.Images[3];
                    break;

                case Common.STATUS.GREEN:
                    btnEnt.Image = imageListMain.Images[0];
                    break;

                case Common.STATUS.RED:
                    btnEnt.Image = imageListMain.Images[2];
                    break;

                case Common.STATUS.YELLOW:
                    btnEnt.Image = imageListMain.Images[1];
                    break;

                case Common.STATUS.WORKING:
                    btnEnt.Image = imageListMain.Images[4];
                    break;
                }
            }



            Application.DoEvents();
        }
示例#3
0
        private void setIntegrationStatus(Common.STATUS S)
        {
            if (Program.frmMain == null)
            {
                return;
            }

            Program.frmMain.setIntegrationStatus(S);
        }
示例#4
0
 void Bad(bool redraw = true)
 {
     restartButton.interactable = false;
     if (redraw)
     {
         objScene[myPosX, myPosY].sprite = spriteMyc;
         objScene[myPosX, myPosY].transform.SetAsLastSibling();
     }
     audioBgm.Stop();
     audioBad.Play();
     status = Common.STATUS.BAD;
 }
示例#5
0
 void DecreaseLeftMyNumber(bool fromRestartButton = false)
 {
     if (--leftMyNumber > 0)
     {
         // restart
         SceneManager.LoadScene(Common.SCENE_MAIN);
     }
     else
     {
         if (fromRestartButton)
         {
             restartButton.interactable = false;
             audioBgm.Stop();
         }
         audioGameOver.Play();
         status = Common.STATUS.GAMEOVER;
     }
 }
示例#6
0
 public SyncEventArgs(Common.STATUS S)
 {
     status = S;
 }
示例#7
0
    // Start is called before the first frame update
    void Start()
    {
        // init
        dotNum        = myPosX = myPosY = playingHit = afterHit = 0;
        status        = Common.STATUS.NORMAL;
        timeElapsed   = 0;
        numDictionary = new Dictionary <char, int>
        {
            [Common.MAP_T1]    = 0,
            [Common.MAP_T2]    = 0,
            [Common.MAP_BLOCK] = 0
        };
        posDictionary = new Dictionary <char, int[, ]>
        {
            [Common.MAP_T1]    = new int[Common.MAX_T1_NUM, 2],
            [Common.MAP_T2]    = new int[Common.MAX_T2_NUM, 2],
            [Common.MAP_BLOCK] = new int[Common.MAX_BLOCK_NUM, 2]
        };
        foreach (char key in posDictionary.Keys)
        {
            for (int i = 0; i < posDictionary[key].GetLength(0); i++)
            {
                posDictionary[key][i, 0] = -1;
                posDictionary[key][i, 1] = -1;
            }
        }
        action   = false;
        sceneMap = new char[Common.WIDTH, Common.HEIGHT, 2];
        objScene = new Image[Common.WIDTH, Common.HEIGHT];
        objHit   = new List <Image>();

        // hi score & score
        highScore = PlayerPrefs.GetInt(Common.SAVEDATA_HISH_SCORE, 0);
        DisplayScore();

        // scene
        scene          = PlayerPrefs.GetInt(Common.SAVEDATA_START_SCENE, 1);
        textSence.text = $"{scene}";

        // time
        time          = Common.INITIAL_TIME;
        textTime.text = $"{time}";

        // sptites
        objDictionary = new Dictionary <char, Sprite>();
        objDictionary[Common.MAP_MY]    = spriteMyd;
        objDictionary[Common.MAP_WALL]  = spriteWall;
        objDictionary[Common.MAP_BLOCK] = spriteBlock;
        objDictionary[Common.MAP_DOT]   = spriteDot;
        objDictionary[Common.MAP_T1]    = spriteT1;
        objDictionary[Common.MAP_T2]    = spriteT2;

        // left my number
        for (int i = 0; i < leftMyNumber - 1; i++)
        {
            Display(Common.MAP_MY, Common.X_BAR_2ND + 1 + i * 2, 1);
        }

        // outer wall
        for (int i = 0; i < Common.WIDTH; i++)
        {
            Display(Common.MAP_WALL, i, 0);
            Display(Common.MAP_WALL, i, 3);
            Display(Common.MAP_WALL, i, Common.HEIGHT - 1);
        }
        for (int i = 1; i <= 2; i++)
        {
            Display(Common.MAP_WALL, 0, i);
            Display(Common.MAP_WALL, Common.X_BAR_1ST, i);
            Display(Common.MAP_WALL, Common.X_BAR_2ND, i);
            Display(Common.MAP_WALL, Common.WIDTH - 1, i);
        }
        for (int i = 4; i < Common.HEIGHT; i++)
        {
            Display(Common.MAP_WALL, 0, i);
            Display(Common.MAP_WALL, Common.WIDTH - 1, i);
        }

        // inner map
        for (int i = 0; i < Common.INNER_HIGHT; i += 2)
        {
            for (int j = 0; j < Common.INNER_WIDTH; j += 2)
            {
                Display(Common.sceneData[scene - 1, i / 2][j / 2], j, i, true);
            }
        }

        // hide unnecessary texts and adjust screen
        textGameOver.SetActive(false);
        textCongratulations.SetActive(false);
        AdjustScreen(true);
    }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        AdjustScreen();
        timeElapsed += Time.deltaTime;
        switch (status)
        {
        case Common.STATUS.NORMAL:
            // check playingHit
            if (playingHit > 0)
            {
                if (audioHit.isPlaying)
                {
                    return;
                }
                if (--playingHit > 0)
                {
                    // play agein
                    audioHit.Play();
                    return;
                }
                // check bad
                if (afterHit < 0)
                {
                    Bad(false);
                    return;
                }
                // clear hit enemies
                foreach (Image obj in objHit)
                {
                    obj.enabled = false;
                }
                objHit.Clear();
            }
            if (timeElapsed >= Common.DURATION || afterHit != 0)
            {
                if (afterHit == 0)
                {
                    // inpuit & move
                    float inX = Input.GetAxisRaw("Horizontal");
                    float inY = Input.GetAxisRaw("Vertical");
                    if (inX == 0 && inY == 0)
                    {
                        for (int i = 0; i < Input.touchCount; i++)
                        {
                            Touch touch = Input.GetTouch(i);
                            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
                            {
                                if (UpdateInXYByInputPosition(touch.position, ref inX, ref inY))
                                {
                                    break;
                                }
                            }
                        }
                        if (inX == 0 && inY == 0 && Input.GetMouseButton(0))
                        {
                            UpdateInXYByInputPosition(Input.mousePosition, ref inX, ref inY);
                        }
                    }
                    int    dMyPosX = 0, dMyPosY = 0;
                    Sprite sprite = null;

                    if (inX < 0)
                    {
                        if (myPosX > 0)
                        {
                            dMyPosX--;
                        }
                        sprite = action ? spriteMyl1 : spriteMyl2;
                    }
                    else if (inX > 0)
                    {
                        if (myPosX < Common.INNER_WIDTH - 2)
                        {
                            dMyPosX++;
                        }
                        sprite = action ? spriteMyr1 : spriteMyr2;
                    }
                    else if (inY < 0)
                    {
                        if (myPosY < Common.INNER_HIGHT - 2)
                        {
                            dMyPosY++;
                        }
                        sprite = spriteMyd;
                    }
                    else if (inY > 0)
                    {
                        if (myPosY > 0)
                        {
                            dMyPosY--;
                        }
                        sprite = spriteMyu;
                    }
                    if (sprite != null)
                    {
                        objScene[myPosX, myPosY].sprite = sprite;
                    }
                    if (dMyPosX != 0 || dMyPosY != 0)
                    {
                        int nextX  = dMyPosX == 0 ? 1 : 0;
                        int nextY  = dMyPosY == 0 ? 1 : 0;
                        int addexX = myPosX + (dMyPosX > 0 ? 2 : dMyPosX);
                        int addedY = myPosY + (dMyPosY > 0 ? 2 : dMyPosY);

                        if (dMyPosX != 0 && CheckBlockMove(myPosX, myPosY, dMyPosX < 0) ||
                            MatchScene(addexX, addedY, nextX, nextY, false, true, Common.MAP_BLOCK, Common.MAP_WALL))
                        {
                            bool badFlag = CheckEnemyAndDot(addexX, addedY, nextX, nextY);
                            Move(myPosX, myPosY, dMyPosX, dMyPosY);
                            myPosX += dMyPosX;
                            myPosY += dMyPosY;

                            // score
                            DisplayScore();

                            // check bad
                            if (badFlag)
                            {
                                Bad();
                                return;
                            }
                        }
                    }

                    // check clear
                    if (dotNum <= 0)
                    {
                        // update score
                        score += 1000;
                        DisplayScore();
                        // wait until audioClear ends
                        restartButton.interactable = false;
                        audioBgm.Stop();
                        audioClear.Play();
                        status = Common.STATUS.CLEAR;
                        return;
                    }
                }

                // move blocks
                for (int i = afterHit > 0 ? afterHit : 0; i < posDictionary[Common.MAP_BLOCK].GetLength(0); i++)
                {
                    int  x       = posDictionary[Common.MAP_BLOCK][i, 0];
                    int  y       = posDictionary[Common.MAP_BLOCK][i, 1];
                    bool badFlag = false;
                    if (x >= 0 && y < Common.INNER_HIGHT - 2 &&
                        MatchScene(x, y + 2, 1, 0, false, true, Common.MAP_BLOCK, Common.MAP_DOT, Common.MAP_WALL))
                    {
                        // check bad
                        if (sceneMap[x, y + 2, 0] == Common.MAP_MY ||
                            sceneMap[x + 1, y + 2, 0] == Common.MAP_MY)
                        {
                            objScene[myPosX, myPosY].sprite = spriteMyb;
                            Move(myPosX, myPosY, 0, 1, true);
                            badFlag = true;
                        }
                        // check enemies
                        for (int j = 0; j <= 1; j++)
                        {
                            int currentX = x + j;
                            if (MatchScene(currentX, y + 2, 0, 0, true, true, Common.MAP_T1, Common.MAP_T2))
                            {
                                char character = sceneMap[currentX, y + 2, 0];
                                char id        = sceneMap[currentX, y + 2, 1];
                                int  tx        = posDictionary[character][id, 0];
                                int  ty        = posDictionary[character][id, 1];
                                objHit.Add(objScene[tx, ty]);
                                objScene[tx, ty].sprite = character == Common.MAP_T1 ? spriteT1b : spriteT2b;
                                Move(tx, ty, 0, 1, true);
                                posDictionary[character][id, 0] = -1;
                                posDictionary[character][id, 1] = -1;
                                playingHit++;
                            }
                        }
                        Move(x, y, 0, 1);
                    }
                    // hit sound
                    if (playingHit > 0)
                    {
                        // update score
                        score += 200 * playingHit;
                        DisplayScore();
                        // set afterHit
                        afterHit = badFlag ? -1 : i + 1;
                        // wait until audioHit ends
                        audioHit.Play();
                        return;
                    }
                    // check bad
                    if (badFlag)
                    {
                        Bad(false);
                        return;
                    }
                }

                // move enemies
                foreach (char character in new char[] { Common.MAP_T1, Common.MAP_T2 })
                {
                    for (int i = 0; i < posDictionary[character].GetLength(0); i++)
                    {
                        int x = posDictionary[character][i, 0];
                        int y = posDictionary[character][i, 1];
                        if (x >= 0)
                        {
                            // high priority direction
                            int high
                                = (character == Common.MAP_T1 || myPosY == y) && myPosX <x ? 0
                                                                                         : (character == Common.MAP_T1 || myPosY == y) && myPosX> x ? 1
                                    : myPosX == x && myPosY <y ? 2
                                                             : myPosX == x && myPosY> y ? 3
                                    : -1;
                            // shuffle array except high
                            int[] direction = new int[4];
                            if (high >= 0)
                            {
                                direction[0] = high;
                            }
                            for (int j = 0, k = high >= 0 ? 1 : 0; j < 4; j++)
                            {
                                if (j != high)
                                {
                                    direction[k++] = j;
                                }
                            }
                            for (int j = high >= 0 ? 1 : 0; j < direction.Length - 1; j++)
                            {
                                int k   = Random.Range(j, direction.Length);
                                int tmp = direction[k];
                                direction[k] = direction[j];
                                direction[j] = tmp;
                            }
                            // move
                            foreach (int j in direction)
                            {
                                int dx
                                    = j == 0 && x > 0 ? -1
                                        : j == 1 && x < Common.INNER_WIDTH - 2 ? 1
                                        : 0;
                                int dy
                                    = j == 2 && y > 0 ? -1
                                        : j == 3 && y < Common.INNER_HIGHT - 2 ? 1
                                        : 0;
                                if (dx != 0 || dy != 0)
                                {
                                    int ret = EnemyMove(x, y, dx, dy);
                                    // check bad
                                    if (ret < 0)
                                    {
                                        Bad();
                                        return;
                                    }
                                    // check moved
                                    if (ret != 0)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                // time
                textTime.text = $"{--time}";
                if (time <= 0)
                {
                    Bad();
                }

                // reset timeElapsed & afterHit
                timeElapsed = 0;
                afterHit    = 0;
            }
            break;

        case Common.STATUS.CLEAR:
            if (!audioClear.isPlaying)
            {
                // update SAVEDATA_MAX_SCENE
                if (++scene > PlayerPrefs.GetInt(Common.SAVEDATA_MAX_SCENE, 1))
                {
                    PlayerPrefs.SetInt(Common.SAVEDATA_MAX_SCENE, scene);
                }
                // check all clear
                if (scene <= Common.MAX_SCENE)
                {
                    // next scene
                    PlayerPrefs.SetInt(Common.SAVEDATA_START_SCENE, scene);
                    SceneManager.LoadScene(Common.SCENE_MAIN);
                }
                else
                {
                    ClearInner();
                    textCongratulations.SetActive(true);
                    status = Common.STATUS.WAIT4EVER;
                }
            }
            break;

        case Common.STATUS.BAD:
            if (!audioBad.isPlaying)
            {
                DecreaseLeftMyNumber();
            }
            break;

        case Common.STATUS.GAMEOVER:
            if (!audioGameOver.isPlaying)
            {
                ClearInner();
                textGameOver.SetActive(true);
                status      = Common.STATUS.WAIT2QUIT;
                timeElapsed = 0;
            }
            break;

        case Common.STATUS.WAIT2QUIT:
            if (timeElapsed >= Common.WAIT_GAMEOVER)
            {
                OnClickQuit();
            }
            break;
        }
    }