コード例 #1
0
        //子弹信息添加
        private GameObject AddBulletData(GameObject bullet, BulletData bulletData)
        {
            bullet.GetComponent <AutoAnimation_ef>().sprites = bulletData.AutpAnimationElements;
            BullectArrtibute bulletAtr = bullet.GetComponent <BullectArrtibute>();

            bulletAtr.moveSpeed   = bulletData.moveSpeed;
            bulletAtr.webWaitTime = bulletData.webWaitTime;
            bulletAtr.damage      = bulletData.damage;
            bullet.GetComponent <BoxCollider2D>().size    = bulletData.EdgeRadius;
            bullet.GetComponent <SpriteRenderer>().sprite = bulletData.sprite;
            bullet.name = bulletData.name;


            return(bullet);
        }
コード例 #2
0
ファイル: PlayerManager.cs プロジェクト: daxingyou/FishMaster
        //生成子弹
        private void CreatBullet()
        {
            GunAttribute gunAtr = guns[currentGunIndex];
            //GameObject bulletGo = Instantiate(bulletPre[bullectIndex], gunAtr.firePosTran.position, gunAtr.firePosTran.rotation);
            GameObject bulletGo = MainPoolManager.Instance.GetGameObject(PoolType.BULLET, bullectIndex);

            bulletGo.transform.position = gunAtr.firePosTran.position;
            bulletGo.transform.rotation = gunAtr.firePosTran.rotation;
            BullectArrtibute bullectAtr = bulletGo.GetComponent <BullectArrtibute>();

            //移动效果
            AutoMove_EF moveef = bulletGo.GetComponent <AutoMove_EF>();

            if (moveef == null)
            {
                moveef = bulletGo.AddComponent <AutoMove_EF>();
            }
            moveef.dir   = Vector3.up;
            moveef.speed = bullectAtr.moveSpeed;
            //网的效果
            AddWeb_EF webef = bulletGo.GetComponent <AddWeb_EF>();

            if (webef == null)
            {
                webef = bulletGo.AddComponent <AddWeb_EF>();
            }
            webef.gunIndex    = currentGunIndex;
            webef.lvInWeb     = gunAtr.lvInGun;         //获取这种类型枪威力的等级
            webef.webTotaLv   = GunToBullet;
            webef.webWaitTime = bullectAtr.webWaitTime; //设置网的停留时间
            webef.damage      = bullectAtr.damage;
            webef.SetColor();
            //碰撞鱼销毁效果
            AutoTriggerDestroy_EF trigEF = bulletGo.GetComponent <AutoTriggerDestroy_EF>();

            if (trigEF == null)
            {
                trigEF          = bulletGo.AddComponent <AutoTriggerDestroy_EF>();
                trigEF.checkTag = new string[] { "Fish", "Wall" };
            }
        }