예제 #1
0
 public void Initial()
 {
     map               = GlobalMap.GetMap();
     mapSize           = GlobalMap.GetMapSize();
     mapIndex          = 0;
     resurrectionIndex = 0;
     GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz);
     GlobalMap.SetWinFlag(0);
     transform.position = new Vector3(0, 0, 0);
     now_x = transform.position.x;
     //now_y = transform.position.y;
     now_z                    = transform.position.z;
     ground_index             = 0;
     resurrectionPoint        = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5);
     ground[ground_index]     = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5);
     ground[1 - ground_index] = new MyPoint((int)now_x + dx, (int)now_z + dz, 2.5, 2.5);
     rotation_count           = 0;
     isalive                  = 1;
     speed                    = spee_default;
     max_x                    = min_x = (int)now_x;
     max_z                    = min_z = (int)now_z;
     nowScore                 = 0;
     lastScore                = 0;
     continueCount            = 3;
     ui_gameSystem.ContinueTextUpdate(continueCount);
     transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
 }
예제 #2
0
 public void Initial()
 {
     map      = GlobalMap.GetMap();
     mapSize  = GlobalMap.GetMapSize();
     mapIndex = 0;
     now_x    = (int)hero.position.x;
     now_y    = (int)hero.position.y - 2;
     now_z    = (int)hero.position.z;
     dx       = 0;
     dz       = 5;
     while (groundQueue.Count > 0)
     {
         Destroy(groundQueue.Peek());
         groundQueue.Dequeue();
     }
     while (scoreQueue.Count > 0)
     {
         Destroy(scoreQueue.Peek());
         scoreQueue.Dequeue();
     }
     for (int i = 0; i < groundList.Count; ++i)
     {
         Destroy(groundList [i]);
     }
     groundList.Clear();
     GlobalMap.SetWinFlag(0);
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        now_x = transform.position.x;
        now_z = transform.position.z;


        if (isalive == 1 && !ground [ground_index].IsInPoint(now_x, now_z))
        {
            if (!ground [1 - ground_index].IsInPoint(now_x, now_z))
            {
                speed   = 0;
                isalive = 0;
                ui_gameSystem.ActiveContinuePanel(true);
            }
            else
            {
                if (mapIndex == mapSize - 1 && !GlobalMap.GetWinFlag())
                {
                    speed   = 0;
                    isalive = 0;
                    myCamera.transform.position = new Vector3((min_x + max_x) >> 1, 300, (min_z + max_z) >> 1);
                    myCamera.transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0));
                    GlobalMap.SetWinFlag(1);
                    ui_gameSystem.ActiveEndPanel(true);
                    //Debug.Log ("ENDENDEND");
                }
                else
                {
                    if (map [mapIndex].materialType == 2)
                    {
                        resurrectionIndex = mapIndex;
                        resurrectionPoint.Set(ground [ground_index]);
                        lastScore = nowScore;
                    }
                    if (now_x > max_x)
                    {
                        max_x = (int)now_x;
                    }
                    if (now_x < min_x)
                    {
                        min_x = (int)now_x;
                    }
                    if (now_z > max_z)
                    {
                        max_z = (int)now_z;
                    }
                    if (now_z < min_z)
                    {
                        min_z = (int)now_z;
                    }
                    mapIndex++;
                    GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz);
                    //ChangeDxy ();
                    //Debug.Log ("dx:"+dx+" dz:"+dz);
                    ground_index = 1 - ground_index;
                    ground [1 - ground_index].Set(ground [ground_index]);
                    ground [1 - ground_index].Updata(dx, dz);
                    //Debug.Log ("dx:"+dx+" dz:"+dz);
                    //Debug.Log ("now_x:"+ now_x+" now_z:"+ now_z);
                    //Debug.Log ("x0:"+ground [ground_index].x+" z0:"+ground [ground_index].z+" x1:"+ground [1 - ground_index].x+"  z1:"+ground [1 - ground_index].z);
                    speed    += 0.1;
                    nowScore += 10;
                    tmpScore  = nowScore - 5;
                }
            }
        }
        else
        {
            if (dx != 0)
            {
                tmpScore = nowScore + (int)((transform.position.x - ground [ground_index].x) * 10 / dx);
            }
            else
            {
                tmpScore = nowScore + (int)((transform.position.z - ground [ground_index].z) * 10 / dz);
            }
        }
        ui_gameSystem.ScoreTextUpdate(tmpScore);
        if (scoreQueue.Count > 0)
        {
            scoreTransform = scoreQueue.Peek().transform;
            if (GlobalMap.ReachTest(scoreTransform, this.transform))
            {
                speed = spee_default;
                Destroy(scoreQueue.Peek());
                //Debug.Log ("this:"+this.transform.position.x+" " + this.transform.position.z);
                //Debug.Log ("score:"+scoreTransform.position.x+" " + scoreTransform.position.z);
                //Debug.Log ("dx:"+dx+" dz:"+dz);
                Debug.Log("reach");
                scoreQueue.Dequeue();
            }
            else if (GlobalMap.OverTest(this.transform, scoreTransform, dx, dz))
            {
                //Debug.Log ("this:"+this.transform.position.x+" " + this.transform.position.z);
                //Debug.Log ("score:"+this.scoreTransform.position.x+" " + this.scoreTransform.position.z);
                //Debug.Log ("dx:"+dx+" dz:"+dz);
                Debug.Log("over");
                Destroy(scoreQueue.Peek(), 2);
                scoreQueue.Dequeue();
            }
        }

        if (!GlobalMap.GetWinFlag())
        {
            transform.Translate(Vector3.forward * (float)speed * Time.deltaTime, Space.Self);
        }
        while (groundQueue.Count > 0 && ground [ground_index].IsInPoint(groundQueue.Peek().transform.position.x, groundQueue.Peek().transform.position.z))
        {
            groundQueue.Dequeue();
        }
    }