Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (playerStat != Units.unitStat.stop)
     {
         if (transform.position.z != direction.z)
         {
             Vector3 m    = new Vector3(0, 0, 1.25f);
             float   step = smoothTime * Time.deltaTime;
             transform.position = Vector3.MoveTowards(transform.position, direction, step);
             playerStat         = Units.unitStat.moving;
         }
         else
         {
             playerStat = Units.unitStat.idle;
             //if(playerMoveIndex == gm.tracks.Length - 1 && gm.activePlayer == 0){
             if (gm.activePlayer == 0 && activeBox != null && activeBox.GetComponent <BoxUnit>().canBeDeployed)
             {
                 if (gm.tracksOut[playerMoveIndex].GetComponent <TrackOut>().trackOutType == activeBox.GetComponent <BoxUnit>().packetType)
                 {
                     if (boxState == Units.unitBoxState.inHand)
                     {
                         playerStat = Units.unitStat.stop;
                         StartCoroutine(Turn());
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
    IEnumerator Turn()
    {
        Debug.Log("TURN");
        this.transform.RotateAround(this.transform.position, Vector3.up, -180);
        this.GetComponent <UnitControler>().rotationState = UnitControler.unitRotate.nonoriginal;
        this.GetComponent <UnitControler>().canControll   = false;
        this.GetComponent <UnitControler>().boxState      = Units.unitBoxState.offHand;
        yield return(new WaitForSeconds(0.3f));

        Debug.Log("TURN END");
        this.activeBox.GetComponent <BoxUnit>().finalEndPoint = gm.tracksOut[playerMoveIndex].transform.GetChild(0).transform.TransformPoint(Vector3.zero);
        this.canControll = true;
        this.playerStat  = Units.unitStat.idle;
        this.activeBox.GetComponent <BoxUnit>().boxStates = BoxUnit.boxState.trackOut;
        this.activeBox.transform.parent = null;
    }