Exemplo n.º 1
0
 void INIT()
 {
     waitTime = 1.0f;
     if (pos != DIRECTION.CENTER)
     {
         mov = DIRECTION.CENTER;
     }
     state = STETS.REDRAW;
 }
Exemplo n.º 2
0
 void StartTongAttack(int direction)
 {
     if (direction <= 49)
     {
         dnetist.MoveUp();
         dir = DIRECTION.UP;
     }
     else
     {
         dnetist.MoveDown();
         dir = DIRECTION.DOWN;
     }
     time  = 1.0f - 0.05f * (winCounter > 10 ? 10 : winCounter);
     state = STETS.ATTACK;
 }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (state == STETS.REDRAW && !dnetist.IsMoving())
     {
         state = STETS.BREAK;
         if (winCounter % 6 == 0 && winCounter > 0)
         {
             winCounter++;
             INIT();
         }
     }
     if (Input.GetKeyDown(KeyCode.W) && mov == pos && pos == DIRECTION.CENTER)
     {
         mov = DIRECTION.UP;
     }
     else if (Input.GetKeyDown(KeyCode.S) && mov == pos && pos == DIRECTION.CENTER)
     {
         mov = DIRECTION.DOWN;
     }
     if (waitTime >= 0)
     {
         waitTime -= Time.deltaTime;
     }
     if (state == STETS.BREAK &&
         Random.Range(0, 100) < triggerChance &&
         waitTime < 0)
     {
         StartTongAttack(Random.Range(0, 100));
     }
     switch (state)
     {
     case STETS.ATTACK:
     {
         if (pos != DIRECTION.CENTER)
         {
             if (mov != dir)
             {
                 Lose();
             }
             else
             {
                 Win();
             }
         }
     }
     break;
     }
     if (state == STETS.ATTACK && time < 0)
     {
         Lose();
     }
     else
     {
         time -= Time.deltaTime;
     }
     if (mov != pos)
     {
         if (mouthMov >= 0.2f)
         {
             if (pos == DIRECTION.CENTER)
             {
                 setMovment(0.2f, mov == DIRECTION.UP ? 0.04f : -0.04f);
             }
             else
             {
                 setMovment(0.2f, pos == DIRECTION.UP ? -0.04f : 0.04f);
             }
         }
         else
         {
             mouthMov += Time.deltaTime;
             if (mouthMov >= 0.2f)
             {
                 pos      = mov;
                 mouthMov = 4.2f;
                 if (pos != DIRECTION.CENTER && state != STETS.ATTACK)
                 {
                     mov = DIRECTION.CENTER;
                 }
             }
             else
             {
                 head.Translate(new Vector3(0, 1, 0) * timeToSpeed(mouthMov));
             }
         }
     }
 }