예제 #1
0
 public void TurnStep()
 {
     if (active)
     {
         spriteTF.localRotation = Quaternion.Euler(0f, 0f, (float)dir);
         currentPos             = new V2Int((int)transform.position.x, (int)transform.position.y);
         tg = vm.GetTargetCell(currentPos, dir);
         transform.position = new Vector2(tg.x, tg.y);
     }
 }
예제 #2
0
    void ShootCannon()
    {
        GameObject go = Instantiate(bulletPref);

        V2Int currentPos = new V2Int((int)transform.position.x, (int)transform.position.y);
        V2Int tg         = vm.GetTargetCell(currentPos, dir);

        go.transform.position = new Vector2(tg.x, tg.y);
        MoveForward gomf = go.GetComponent <MoveForward>();

        gomf.dir    = dir;
        gomf.active = true;
    }
예제 #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         dir = collision.GetComponent <MoveForward>().dir;
         spriteTF.localRotation = Quaternion.Euler(0, 0, (int)dir);
         V2Int newCratePos = vm.GetTargetCell(new V2Int((int)transform.position.x, (int)transform.position.y), dir);
         transform.position = new Vector2(newCratePos.x, newCratePos.y);
     }
     if ((lethalLayers.value & 1 << collision.gameObject.layer) != 0)
     {
         if (collision.CompareTag("Water"))
         {
             Destroy(collision.gameObject);
         }
         Destroy(gameObject);
     }
 }