Beispiel #1
0
 //检测碰撞
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.transform)
     {
         int index = Convert.ToInt32(collision.gameObject.name);
         listZidan[BullteType.Bullte][Convert.ToInt32(index)].Hide();
         BulletBomEffect boe = GetBullteBom(BullteType.BomEff);
         boe.StartPlay();
         transform.DOMoveX(transform.position.x + 0.3f, 0.2f).SetLoops(2, LoopType.Yoyo);
         if (upTween.IsPlaying())
         {
             shootNum++;
         }
         if (SDKManager.Instance.gameXP != null && shootNum >= 3)
         {
             shootNum = -100;
             if (SDKManager.Instance.gameXP.catchty == CatchTy.Drop)//掉落
             {
                 StopShoot();
                 PoliceSay(true);
                 SDKManager.Instance.gameXP.DropIe();
             }
         }
     }
 }
Beispiel #2
0
 //射击
 private IEnumerator Shoot()
 {
     while (true)
     {
         if (isStartShoot)
         {
             AudioManager.Instance.PlayByName(AudioType.Continuous, AudioNams.shoot, false);
             BulletBomEffect zd = GetBullteBom(BullteType.Bullte);
             zd.Show();
             float time = Mathf.Abs((1400 - zd.bullet.transform.localPosition.x) * 0.4f / 1400);
             zd.bullet.transform.DOLocalMoveX(1400, time).OnComplete(() => zd.Hide());
         }
         yield return(new WaitForSeconds(space_time));
     }
 }
Beispiel #3
0
    //获得没使用的子弹 炸弹
    private BulletBomEffect GetBullteBom(BullteType bt)
    {
        List <BulletBomEffect> tplist;
        BulletBomEffect        zd;

        if (listZidan.ContainsKey(bt))
        {
            tplist = listZidan[bt];
        }
        else
        {
            tplist = new List <BulletBomEffect>();
            listZidan.Add(bt, tplist);
        }
        zd = tplist.FirstOrDefault(e => !e.isShoot);
        if (zd == null)
        {
            Transform md   = null;
            Vector3   scal = Vector3.zero;
            if (bt == BullteType.Bullte)
            {
                scal = Vector3.one * 1.5f;
                md   = zidan;
            }
            else
            {
                scal = Vector3.one * 2;
                md   = bom;
            }
            GameObject go = CommTool.InstantiateObj(md.gameObject, md.parent.gameObject, Vector3.zero, scal, tplist.Count.ToString());
            zd = new BulletBomEffect(go);
            tplist.Add(zd);
            listZidan[bt] = tplist;
        }
        return(zd);
    }