package com.tankalfa;
import android.graphics.*;
import com.osnova.*;

 

public class Sna extends Os{
  
    
   
 // Сегодня 15.10.23 поправил
 // Снаряд ✓
  public int vs=0,vt=0; 
  private int p1=0,p2=0,p3=0,p4=0;  
  private  int x1=-200,y1=-200;
  public int dal=400; 
  private int npc_fire;
 ///////
 
 
  
 
 ///////setImage///08.01.24////
  public void setSna(int a){
  
  if(a==1){setImage(D.s1,7,7);}
  if(a==2){setImage(D.s2,7,7);}
  if(a==3){setImage(D.s3,7,7);}
 }
 
 
 
 ///////////////
 public Sna(Bitmap bi,int fx,int fy,int ae) {
    
   super(bi,fx,fy,ae);     
     
    
     Ul(10);
   hero=false;
 
 }  
     
  
 
 /////////////
 
 public void p(Grap g){
  g.Text("vt= "+vt+" vs= "+vs+" voz= ",30,30,30,-2); 
  //paint(Ran.c);
 //vz.setPosition(vx,vy);
 // vz.paint(Ran.c);
 }

 
 /// Hero
   public void Ds(int sot,int sk){
        
    
    
  
  
  setPosition(x1-D.x,y1-D.y);   
  paint(Ran.c);  
  
  
  
  
      if(vs==0){
     if(sot==1){p1=sk;p2=0;p3=0;p4=0;vs=1;}
     if(sot==2){p2=sk;p1=0;p3=0;p4=0;vs=1;}
     if(sot==3){p3=sk;p1=0;p2=0;p4=0;vs=1;}
     if(sot==4){p4=sk;p1=0;p2=0;p3=0;vs=1;}}
 
 
    
      
   y1-=p1;
   y1+=p2;
   x1-=p3;
   x1+=p4;
  
    vt+=5;  
  
  if(vt>=dal & vs==1){vt=dal;x1=-200;y1=-200;vs=0;}
  
  
  
  
   
  if(Ran.kp.k[7].getK() & vt>=dal){vt=0;KP();}  
   
 
  if(x1<0){vt=dal;}
  if(x1>Map.W){vt=dal;}
  if(y1<0){vt=dal;}
  if(y1>Map.H){vt=dal;}
 } 
    
 
 
 
 // НПС
 public void Dsn(int sot,int sk,int x,int y){
        
  
  setPosition(x1-D.x,y1-D.y);   
   paint(Ran.c);
  
  
  
     npc_fire=Ran.rnd(10);
  
      if(vs==0){
     if(sot==1){p1=sk;p2=0;p3=0;p4=0;vs=1;}
     if(sot==2){p2=sk;p1=0;p3=0;p4=0;vs=1;}
     if(sot==3){p3=sk;p1=0;p2=0;p4=0;vs=1;}
     if(sot==4){p4=sk;p1=0;p2=0;p3=0;vs=1;}}
 

    
      
   y1-=p1;
   y1+=p2;
   x1-=p3;
   x1+=p4;
  
    vt+=5;  
  
  if(vt>=dal & vs==1){vt=dal;x1=-200;y1=-200;vs=0;}
   
   
       
       // Здесь Выстрел !  
    if(npc_fire==5 & vt>=dal){vt=0;KP(x,y);}  
   
  if(x1<0){vt=dal;}
  if(x1>Map.W){vt=dal;}
  if(y1<0){vt=dal;}
  if(y1>Map.H){vt=dal;}
 
 } 
 
 
 
 // Hero
   public void KP(){
  
  
  x1=D.hx+34;
  y1=D.hy+33;
  
 }
 // НПС
 public void KP(int x,int y){
  
  
  x1=x+34;
  y1=y+33;
  
 }
 ///////Hero//////27.12.23//01:54//
 public void Stolk(Hero h){
   
  if(collides(h)){h.ib=D.urv;vt=dal;h.mBron();}
  
 }
 ////////////
 
 
public void dba(int d,int c){
 
 if(d>=1&c==1){D.ba1=1;}
 if(d>=2&c==2){D.ba1=2;}
 if(d>=3&c==3){D.ba1=3;}
 if(d>=4&c==4){D.ba1=4;}
 if(d==5&c==5){D.ba1=5;}
}
 
 /////////////////
    @Override 
    public void StolkMap(Sprite c,int op){
     
     if(hero){
    if(collides(c) & op==1){vt=dal;dba(D.baH,5);}  
    if(collides(c) & op==2){vt=dal;dba(D.baH,1);}  
    if(collides(c) & op==3){dba(D.baH,3);}
    if(collides(c,0,40,0,0) & op==4){vt=dal;dba(D.baH,2);}
    if(collides(c,40,0,0,0) & op==5){vt=dal;dba(D.baH,4);} 
     }
      
   
   if(!hero){
    if(collides(c) & op==1){vt=dal;dba(D.baN,5);}  
    if(collides(c) & op==2){vt=dal;dba(D.baN,1);}  
    if(collides(c) & op==3){dba(D.baN,3);}
    if(collides(c,0,40,0,0) & op==4){vt=dal;dba(D.baN,2);}
    if(collides(c,40,0,0,0) & op==5){vt=dal;dba(D.baN,4);} 
     }
  
 }
  ///////////
 public void StolkMapNN(Sprite c,int op){
 
 if(!hero){
    if(collides(c) & op==1){vt=dal;dba(D.baNN,5);}  
    if(collides(c) & op==2){vt=dal;dba(D.baNN,1);}  
    if(collides(c) & op==3){dba(D.baNN,3);}
    if(collides(c,0,40,0,0) & op==4){vt=dal;dba(D.baNN,2);}
    if(collides(c,40,0,0,0) & op==5){vt=dal;dba(D.baNN,4);} 
     }
 
 
 
 }        
   /* ////////
    public int vv(){
 ig=1;
 ik++;
if(ik>1&voz==0){
  vz.nextFrame(0);
  vx=x1-30;vy=y1-40;}
 if(ik>=15){voz=0; ik=0;} 
 
  return voz;
}*/
    //// e c ////
}
