예제 #1
0
 public void moveGoti(int current, int next, int goti_number)
 {
     if (next >= 0)
     {
         for (int i = 0; i < goti.Length; i++)
         {
             if (goti[i].GetComponent <GotiScript>().index == goti_number)
             {
                 if (goti[i].GetComponent <GotiScript>().currentPosition != next)
                 {
                     // Debug.Log("Start Moving Goti");
                     goti[i].GetComponent <GotiScript>().currentPosition = next;
                     if (!goti[i].GetComponent <GotiScript>().isMoving)
                     {
                         StartCoroutine(moveGotiSteps(current, next, goti[i]));
                     }
                 }
                 break;
             }
         }
     }
     if (next == -1)
     {
         for (int i = 0; i < goti.Length; i++)
         {
             if (goti[i].GetComponent <GotiScript>().index == goti_number)
             {
                 goti[i].GetComponent <GotiScript>().currentPosition = next;
                 GameDelegate.showCloseGoti();
                 goti[i].GetComponent <GotiScript>().CellNumber      = -1;
                 goti[i].GetComponent <GotiScript>().currentPosition = -1;
                 goti[i].transform.position = goti[i].GetComponent <GotiScript>().InitialPositionVector;
                 //iTween.MoveTo (goti [i], goti [i].GetComponent<GotiScript> ().InitialPositionVector, 0.2f);
                 GameDelegate.showMoveGoti(-1);
                 break;
             }
         }
     }
 }
예제 #2
0
        IEnumerator moveGotiSteps(int current, int next, GameObject goti)
        {
            goti.GetComponent <GotiScript> ().isMoving = true;
            int i = current + 1;

            while (i <= goti.GetComponent <GotiScript> ().currentPosition)
            {
                int Object  = 0;
                int nextPos = 0;
                try {
                    if (i >= 51)
                    {
                        nextPos = goti.GetComponent <GotiScript> ().homeEntryPoint + i - 51;
                        Object  = nextPos;
                    }
                    else
                    {
                        nextPos = goti.GetComponent <GotiScript> ().initialPosition + i;
                        Object  = nextPos > 52 ? nextPos - 52 : nextPos;
                    }
                    // Debug.Log("Move Goti "+Object);
                    GameObject pos = GameObject.Find("" + Object);
                    goti.GetComponent <GotiScript> ().CellNumber = Object;
                    goti.transform.position = pos.transform.position;
                    GameDelegate.showMoveGoti(Object);
                    //goti.transform.position = Vector3.SmoothDamp(goti.transform.position,pos.transform.position,ref ss,0.2f);
                    //iTween.MoveTo (goti, pos.transform.position, 0.2f);
                } catch (System.Exception ex) {
                    // Debug.Log ("moveGotiSteps Exception " + ex.Message);
                }
                i++;
                yield return(new WaitForSeconds(0.2f));
            }

            goti.GetComponent <GotiScript> ().isMoving = false;
        }