Inheritance: MonoBehaviour
示例#1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag != "Bullet(Player)")
        {
            return;
        }

        // 총알의 Power를 가져와서
        // 스크립트에 있는 변수 값을 가져오고싶다.
        // GameObject -> GetComponent<Script>
        BulletCtrl ObjCs = other.GetComponent <BulletCtrl>();

        // 현재 HP 깎는다.
        iCurrentHp -= ObjCs.iBulletDamage;

        // 충돌한 총알을 삭제한다.
        Destroy(other.gameObject);

        // 체력이 0이하가되면? 삭제
        if (iCurrentHp <= 0)
        {
            Explode();  // 삭제이전에 폭발이펙트 연출

            Destroy(this.gameObject);
        }
        else    // 데미지를 입었는데 안죽었을때,
        {
            cAnimator.SetTrigger("isHit");
        }
    }
示例#2
0
    void Fire()
    {
        //Raycasting for when a weapon is firing from a gun
        Debug.Log("Fire() Method has been entered");
        RaycastHit hit;
        GameObject bullet = Instantiate(Resources.Load("blast", typeof(GameObject))) as GameObject;

        bullet.transform.localScale = new Vector3(1f, 1f, 1f);
        BulletCtrl bc        = bullet.GetComponent <BulletCtrl>();
        var        boltSound = bullet.GetComponent <AudioSource>();

        boltSound.Play();
        // Debug.Log("Debug: Bullet Spawned");
        //Get the bullet's rigid body component and set its position and rotation equal to that of the spawnPoint
        Rigidbody rb = bullet.GetComponent <Rigidbody>();

        bullet.transform.rotation = spawnPoint.transform.rotation;
        bullet.transform.position = spawnPoint.transform.position;

        //add force to the bullet in the direction of the spawnPoint's forward vector
        rb.AddForce(spawnPoint.transform.forward * 5000f);
        //destroy the bullet after 1 second
        Destroy(bullet, 3);

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, weapon.weaponRange, mask))
        {
            Debug.Log(hit.collider.name + "Has Been Shot!");
        }
    }
示例#3
0
    private void LaunchBouquet()
    {
        Quaternion rot = this.gameObject.transform.rotation;
        Vector3    pos = this.transform.position + (rot * m_launchPoint);

        int bonusCharm = m_magazine.UseBonusCharmBullet();

        UnityAction <Vector3> act = (vec) =>
        {
            GameObject obj = XFunctions.Instance(m_bulletBouquet, pos, rot);
            Rigidbody  rb  = obj.GetComponent <Rigidbody>();
            rb.AddForce(vec * m_shotPower, ForceMode.Impulse);
            BulletCtrl ctrl = obj.GetComponent <BulletCtrl>();
            ctrl.SetUserID(m_parent.GetComponent <UserData>().userID);
            ctrl.AddBonusCharm(bonusCharm);
        };

        act.Invoke(this.transform.forward);
        if (m_magazine.UseBonus3WayBullet())
        {
            act.Invoke(Quaternion.AngleAxis(-m_shot3WayAngle, Vector3.up) * this.transform.forward);
            act.Invoke(Quaternion.AngleAxis(m_shot3WayAngle, Vector3.up) * this.transform.forward);
        }
        else
        {
            m_magazine.SubBullet(m_costChargeBullet);
        }
        m_knockback += m_knockbackTime;
    }
示例#4
0
    public void Shot() {
        int i = 0;
        BulletCtrl ctrl = new BulletCtrl();

        //리스트에서 오브젝트를 찾아요.
        for (i = 0; i < GameManager.instance.Bullets.Count; i++) {
            if (GameManager.instance.Bullets[i].CompareTag(weapon.bullet.tag) && GameManager.instance.Bullets[i].activeSelf == false) {
                GameManager.instance.Bullets[i].transform.position = bulletPos.transform.position;
                GameManager.instance.Bullets[i].transform.rotation = bulletPos.transform.rotation;
                ctrl = GameManager.instance.Bullets[i].GetComponent<BulletCtrl>();
                GameManager.instance.Bullets[i].SetActive(true);
                break;
            }
        }
        //없으면 생성해요.
        if(i == GameManager.instance.Bullets.Count)
        {
            GameObject temp = Instantiate(weapon.bullet, bulletPos.transform.position, bulletPos.transform.rotation) as GameObject;
            ctrl = temp.GetComponent<BulletCtrl>();
            
        }

        //투사체 세팅을 해요.
        ctrl.dmg = (weapon.dmg * weapon.builed) + pulsDMG;
        ctrl.speed = weapon.bulletSpeed;


    }
示例#5
0
 public void BulletActive(BulletCtrl bullet)
 {
     muzzleFlash.Play();
     SoundManager.instance.PlaySE(Constant.shoot);
     bullet.barrelLocation = barrelLocation;
     bullet.damage         = damage;
     bullet.gameObject.SetActive(true);
 }
示例#6
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.gameObject.CompareTag("laser"))
     {
         BulletCtrl laser = (BulletCtrl)collider.gameObject.GetComponent(typeof(BulletCtrl));
         getDamaged(laser.getDamage(), collider.gameObject);
         Destroy(collider.gameObject);
     }
 }
示例#7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "BULLET")
     {
         BulletCtrl bulletCtrl = collision.collider.GetComponent <BulletCtrl>();
         hp -= bulletCtrl.damage;
         Destroy(collision.collider.gameObject);
         StartCoroutine(onDamage());
     }
 }
示例#8
0
 /// <summary>
 /// 총알 생성 함수
 /// </summary>
 /// <param name="bulletCount">생성할 총알 갯수</param>
 public void InstanceBullet(float bulletCount = 0)
 {
     for (int i = 0; i < bulletCount; i++)
     {
         BulletCtrl bulletTmp = Instantiate(bullet, bulletBox);
         bulletManager.Add(bulletTmp);
         bulletTmp.transform.name = "Bullet" + i.ToString();
         bulletTmp.gameObject.SetActive(false);
     }
 }
示例#9
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Bullet")
     {
         BulletCtrl ctrl = col.gameObject.GetComponent <BulletCtrl>();
         if (ctrl.userID != m_userdata.userID)
         {
             ctrl.SendHit();
         }
     }
 }
示例#10
0
    public void Fire()
    {
        //パーティクルのオブジェクト作成
        //Instantiate(FireParticle, transform.position, transform.rotation, transform);


        //弾を作成
        createdBullet = Instantiate(bullet, transform.position, bulletRotation);
        //弾にデータを与える
        bulletCtrl = createdBullet.GetComponent <BulletCtrl>();
        createdBullet.GetComponent <Rigidbody>().AddForce(createdBullet.transform.forward * initialVelocity, ForceMode.VelocityChange);
    }
示例#11
0
 public void OnTriggerEnter(Collider other)
 {
     //플레이어가 쏜 불꽃에 맞았을때
     if (other.CompareTag("Fire"))
     {
         //수정해줘 동미니니니니니ㅣ니나
         BulletCtrl bullet = other.GetComponent <BulletCtrl>();
         bullet.Boom();
         Damage(bullet.Damage);
         other.gameObject.GetComponent <BulletCtrl>().OffBullet();
     }
 }
    public bool AllocateBullets(Bullet bullet, BulletPool pool, int idx, int bulletCnt, bool active = false)
    {
        if (m_bulletPool[(int)pool].Count == 0)
        {
            Debug.Log("The bulletPool is not allocted");
            return(false);
        }

        if (idx < 0 || idx >= m_bulletPool[(int)pool].Count)
        {
            Debug.Log("the bullet idx is out of the range");
            return(false);
        }

        if (m_bulletPool[(int)pool][idx].Count > 0)
        {
            Debug.Log("the bullets at the idx is created already");
            return(false);
        }

        GameObject source = FindSourceBullet(bullet);

        if (source == null)
        {
            Debug.Log("Finding the source of bullet failed");
            return(false);
        }

        m_bulletPool[(int)pool][idx].Capacity = bulletCnt;

        Transform parentTrsf = GameObject.FindGameObjectWithTag("BATTLESTATIC")?.GetComponent <Transform>();

        for (int i = 0; i < bulletCnt; ++i)
        {
            GameObject obj = null;

            obj = Instantiate(source, parentTrsf);

            obj.SetActive(active);

            BulletCtrl ctrl = obj.GetComponent <BulletCtrl>();
            ctrl.Clone = true;

            m_bulletPool[(int)pool][idx].Add(ctrl);
        }

        m_bulletPoolIndex[(int)pool][idx] = 0;

        return(true);
    }
示例#13
0
 public override void InstanceBullet(float bulletCount = 0)       //총알 재생성 함수
 {
     if (bulletCount == 0)
     {
         bulletCount = this.bulletCount;
     }
     for (int i = 0; i < bulletCount; i++)
     {
         BulletCtrl bulletTmp = Instantiate(bullet, firePos.transform);
         bulletTmp.transform.name = "Rifle_Bullet" + i.ToString();
         bulletManager.Add(bulletTmp);
         bulletTmp.gameObject.SetActive(false);
     }
 }
示例#14
0
    void Fire()
    {
        dir = new Vector2(
            Camera.main.ScreenToWorldPoint(Input.mousePosition).x - firePos.position.x,
            Camera.main.ScreenToWorldPoint(Input.mousePosition).y - firePos.position.y
            );
        dir = dir.normalized;
        Vector3 pos = new Vector3(
            firePos.position.x + rango * dir.x,
            firePos.position.y + rango * dir.y,
            0
            );
        BulletCtrl newBullet = Instantiate(bullet, pos, Quaternion.identity);

        newBullet.speed = bulletVelocity * dir.normalized;
    }
    public BulletData GetSourceBulletData(Bullet bullet)
    {
        string key = EnumToStr(bullet);

        GameObject source = null;

        if (false == m_sourceBullets.TryGetValue(key, out source))
        {
            //Debug.LogError("Finding source by " + key + " failed");
            return(null);
        }

        BulletCtrl ctrl = source.GetComponent <BulletCtrl>();

        return(ctrl.BulletData);
    }
示例#16
0
    public BulletCtrl CreateBulletEffect(CharacterData owner, CharacterData target, List <BuffCtrl> buffs, string Path, bool lastBullet)
    {
        passObj _obj = null;

        //if(owner.characterCtrl.activeAction.Skill.serverData.sample.sid==21113||
        //    owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 22113||
        //    owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 23113||
        //    owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 24113||
        //    owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 25113) {//关羽技能正反两面
        //        if (target.camp == 2) _obj = MonoBase.Create3Dobj(Path,"Guanyu_AOE_0");
        //        else _obj = MonoBase.Create3Dobj(Path ,"Guanyu_AOE_1");

        //} else if (owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 22117 ||
        //     owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 23117 ||
        //     owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 24117 ||
        //     owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 25117 ||
        //     owner.characterCtrl.activeAction.Skill.serverData.sample.sid == 26117||
        //    owner.characterCtrl.activeAction.Skill.serverData.sample.sid==21117)
        //{
        //    if (target.camp == 2) _obj = MonoBase.Create3Dobj(Path, "Xiaolongnv_AOE1");
        //    else _obj = MonoBase.Create3Dobj(Path, "Xiaolongnv_AOE2");
        //}
        int[] tempSid = CommandConfigManager.Instance.doubleEffectSkillSids;
        int   sidd    = owner.characterCtrl.activeAction.Skill.serverData.sample.sid;

        for (int i = 0; i < tempSid.Length; i++)
        {
            if (sidd == tempSid[i])
            {
                string fileNmae = PathKit.getFileName(Path);
                _obj = MonoBase.Create3Dobj(Path, fileNmae + (target.camp == 2 ? "1" : "2"));
                break;
            }
        }
        if (_obj == null)
        {
            _obj = MonoBase.Create3Dobj(Path);
        }
        //子弹类型数据在prefab上定义
        //passObj _obj = MonoBase.Create3Dobj (Path);
        BulletCtrl _ctrl = _obj.obj.GetComponent <BulletCtrl> ();

        _ctrl.transform.parent = BattleManager.Instance.battleFieldRoom.transform;
        _ctrl.initBullet(target, owner, buffs, lastBullet);
        AddEffect(_ctrl);
        return(_ctrl);
    }
示例#17
0
    private void LaunchBouquet()
    {
        Quaternion rot = this.gameObject.transform.rotation;
        Vector3    pos = this.transform.position + (rot * m_launchPoint);

        GameObject obj = XFunctions.Instance(m_bulletBouquet, pos, rot);
        Rigidbody  rb  = obj.GetComponent <Rigidbody>();

        rb.AddForce(this.transform.forward * m_shotPower, ForceMode.Impulse);
        BulletCtrl ctrl = obj.GetComponent <BulletCtrl>();

        ctrl.SetUserID(m_parent.GetComponent <UserData>().userID);
        ctrl.AddBonusCharm(m_magazine.UseBonusCharmBullet());

        m_magazine.SubBullet(m_costChargeBullet);

        m_knockback += m_knockbackTime;
    }
示例#18
0
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Bullet")
        {
            BulletCtrl ctrl = col.gameObject.GetComponent <BulletCtrl>();
            ctrl.SendHit();
        }
        else if (col.tag == "BulletTrigger")
        {
            AkiVACO.XLogger.Log("Hit!");
            BulletTrigger tr = col.GetComponent <BulletTrigger>();
            if (m_unit.AddCharm(tr.userID, tr.charm))
            {
                this.transform.GetChild(0).GetComponent <MeshMaterialCtrl>().SetMaterial(m_unit.topUserId + 1);  // -1 -> 0
            }
            OnHitBullet();
        }

        if (col.tag == "AttractField")
        {
            SetAttractField(col.gameObject);
            // TODO
        }
    }
示例#19
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == bulletTag)
        {
            // 혈흔 효과를 생성하는 함수 호출
            ShowBloodEffect(collision);
            BulletCtrl bulletCtrl = collision.gameObject.GetComponent <BulletCtrl>();
            if (bulletCtrl != null)
            {
                hp -= collision.gameObject.GetComponent <BulletCtrl>().damage;

                hpBarImage.fillAmount = hp / initHp;
                if (hp <= 0.0f)
                {
                    GetComponent <EnemyAI>().state = EnemyAI.State.DIE;
                    hpBarImage.GetComponentsInParent <Image>()[1].color = Color.clear;
                    GameManager.instance.IncKillCount();
                    GetComponent <CapsuleCollider>().enabled = false;
                }
            }
            //Destroy(collision.gameObject);
            collision.gameObject.SetActive(false);
        }
    }
示例#20
0
 public void BulletActive(bool check, float damage, float disance, float speed, Transform pos, BulletCtrl bullet, bool passObstacles)
 {
     bullet.playerBullet       = check;
     bullet.transform.position = pos.position;
     bullet.transform.rotation = pos.rotation;
     bullet.damage             = damage;
     bullet.distance           = disance;
     bullet.speed        = speed;
     bullet.passObstacle = passObstacles;
     bullet.gameObject.SetActive(true);
     return;
 }
示例#21
0
    /// <summary>
/// 远程单体攻击的细分伤害
/// </summary>
    IEnumerator subRemoteAttack()
    {
        BuffCtrl damageBuff = null;
        int      damageAll  = 0;

        //找到对应的伤害buff,单体目标肯定只有1
        foreach (BuffCtrl each in activeAction.Skill.buffs)            // 先统计所有buff伤害
        {
            if (each.serverData.sample.getType() == BuffType.damage)
            {
                //算出单次伤害
                damageAll += each.serverData.serverDamage;
            }
        }
        List <BuffCtrl> tempTotalBuffs = new List <BuffCtrl>();

        //找到对应的伤害buff,单体目标肯定只有1
        foreach (BuffCtrl each in activeAction.Skill.buffs)           // 细分累计的伤害数据
        {
            if (each.serverData.sample.getType() == BuffType.damage)
            {
                int subDamage = (int)(damageAll / activeAction.Skill.serverData.sample.getAttackNum());
                each.serverData.serverDamage = subDamage;
                damageBuff = each;
            }
            else
            {
                tempTotalBuffs.Add(each);
            }
        }
        //移除本来的,后面会补完
        activeAction.Skill.RemoveBuffCtrl(damageBuff);
        //动画表现

        for (int i = 0; i < activeAction.Skill.serverData.sample.getAttackNum(); i++)
        {
            //一颗子弹一个buff
            BuffCtrl newbuff = copyDamageBuff(damageBuff);
            activeAction.Skill.AddBuffCtrl(newbuff);
            BulletCtrl      bullet  = null;
            List <BuffCtrl> tmplist = new List <BuffCtrl> ();
            tmplist.Add(newbuff);
            //表现连击
            UiManager.Instance.battleWindow.comboBar.init(i + 1, damageAll);
            playCharacterAnim(this, "cardThrowAnim");

            if (i == activeAction.Skill.serverData.sample.getAttackNum() - 1)
            {
                //最后一个伤害补足
                tempTotalBuffs.Add(newbuff);
                newbuff.serverData.serverDamage = damageAll - damageBuff.serverData.serverDamage * (activeAction.Skill.serverData.sample.getAttackNum() - 1);
                bullet           = EffectManager.Instance.CreateBulletEffect(characterData, activeAction.Skill.targets[0], tempTotalBuffs, activeAction.Skill.serverData.sample.getBulletEffect(), true);
                newbuff.bulletID = bullet.GetInstanceID();
                yield break;
            }
            else
            {
                bullet           = EffectManager.Instance.CreateBulletEffect(characterData, activeAction.Skill.targets [0], tmplist, activeAction.Skill.serverData.sample.getBulletEffect(), false);
                newbuff.bulletID = bullet.GetInstanceID();
                yield return(new WaitForSeconds(0.2f));
            }
        }
    }
示例#22
0
文件: EnemyCtrl.cs 项目: ray1203/BIN
    void Start() {

        bulletCtrl = bullet.GetComponent<BulletCtrl>();
        subCamera = GameObject.FindWithTag("SubCamera").GetComponent<Camera>();
        angle = 360f / (float)(spreadPoint);
    }