Example #1
0
    public IEnumerator Init1()
    {
        transform.localEulerAngles = new Vector3(0, startAngle, 0);
        for (int i = 0; i < angleSpan.Length; i++)
        {
            yield return(Yielders.WaitSecond(delaySpan));

            float   tempAngle = (startAngle + angleSpan[i]);
            float   x1        = 1 * Mathf.Cos(tempAngle * Mathf.PI / 180);
            float   z1        = 1 * Mathf.Sin(tempAngle * Mathf.PI / 180);
            Vector3 moveDir   = new Vector3(x1, 0, z1).normalized;

            if (parent != null && target != null && target.isLive)
            {
                GameObject obj = Common.Generate(prefab, transform);
                obj.transform.position = parent.transform.position;
                //obj.transform.eulerAngles = new Vector3(0, 0, tempAngle);
                BulletMove bMove = obj.GetComponent <BulletMove>();
                bMove.SetEulerAngle(new Vector3(0, 0, startAngle + angleSpan[i]));
                Tag   myTag = Tag.Bullet;
                float atk   = 0;
                if (cardInfo != null)
                {
                    myTag = cardInfo.myTag;
                    atk   = cardInfo.Atk;
                }
                bMove.Init(myTag, atk, moveDir * moveSpeed);
            }
        }
    }
Example #2
0
    private void OnCollisionEnter(Collision other)
    {
        _sword  = other.transform.GetComponent <SwordMove>();
        _bullet = other.transform.GetComponent <BulletMove>();
        if (_bullet != null && other.gameObject.tag == "Player")
        {
            HP  -= _bullet._damage;
            _dir = other.transform.forward;
            StartCoroutine(HitBack(_bullet._hitback));
            Destroy(other.gameObject);
            _hud.BeHit(_bullet._damage);
        }
        if (_sword != null && other.gameObject.tag == "Player")
        {
            HP  -= _sword._damage;
            _dir = new Vector3((transform.position - other.transform.position).x, 0, (transform.position - other.transform.position).z).normalized;
            StartCoroutine(HitBack(_sword._hitback));
            _sword.GetComponent <BoxCollider>().isTrigger = true;
            _hud.BeHit(_sword._damage);
            if (SwardHit != null)
            {
                AudioSource.PlayClipAtPoint(SwardHit, transform.position);
            }
        }

        if (other.gameObject.tag == "PlayerBody")
        {
            PlayerManager.Instance._currHP -= damage;
        }
    }
Example #3
0
    public void CreateBullet()
    {
        //플레이어가 사라지면 실행x
        if (!m_Player)
        {
            return;
        }
        Vector2 pos       = GetRandomPosition();              //랜덤한 위치를 받아와서
        Vector2 direction = (Vector2)m_Player.position - pos; //플레이어 에게 향하도록 방향 조절

        BulletMove selectedBullet = BulletList.Find(o => o.m_isUsed == false);

        //현재 미사용중인 총알을 찾아서
        if (!selectedBullet)
        {
            Debug.Log("화면에 생성가능한 최대 총알수를 초과했습니다!, 최대 총알수를 늘려주세요");
        }
        else
        {
            //방향과 속도를 설정해준다
            selectedBullet.SetDirection(direction.normalized);
            selectedBullet.SetPosition(pos);
            selectedBullet.m_isUsed = true;
        }
    }
Example #4
0
    /**
     * @brief       총알 발사 후 지정된 방향으로 날아가는 코루틴 입니다.
     *
     * @param       muzzlePosition      발사 위치
     * @param       direction           날아가는 방향
     */
    IEnumerator CoroutineCreateBullet(Vector3 muzzlePosition, Vector3 direction)
    {
        int count = 0;

        while (count < bulletMaxCount)
        {
            // bullet을 objectPool 에서 꺼냄
            GameObject bulletObject = ObjectPoolManager.GetInstance().PopFromPool(bulletName);
            if (bulletObject && muzzle)
            {
                // pool에서 반환받은 bullet의 위치를 설정해줌
                bulletObject.transform.position = muzzlePosition + direction;
                // 현재 bullet 에셋을 기준으로 전방 방향은 up
                bulletObject.transform.up = direction;
                // 눈에보이도록 활성화 시킴
                bulletObject.SetActive(true);

                BulletMove _bullet = bulletObject.GetComponent <BulletMove>();
                _bullet.owner = _playerState.nickName;
            }

            // 발사한 총알 개수
            count++;

            // 일정 시간 후 다시 시작
            yield return(new WaitForSeconds(seriesAttackTime));
        }
    }
Example #5
0
    //public static BulletManager Instance;

    //void Awake()
    //{
    //    Instance = this;
    //}

    /// <summary>
    /// 发射子弹
    /// </summary>
    /// <param name="bulletModel"></param>
    /// <param name="pool"></param>
    public void DoShoot(BulletModel bulletModel, BasePool pool)
    {
        int num = bulletModel.Count / 2;

        for (int i = 0; i < bulletModel.Count; i++)
        {
            GameObject go         = pool.Get(bulletModel.InitPosition, bulletModel.LifeTime); //从对象池中获取 // 初始位置即enemy当前位置
            BulletMove bulletMove = go.GetComponent <BulletMove>();
            var        render     = go.GetComponent <MeshRenderer>();
            if (render != null)
            {
                go.GetComponent <MeshRenderer>().material?.SetColor("_EmissionColor", bulletModel.Color);
            }
            bulletMove.BulletSpeed = bulletModel.Speed;
            bulletMove.DelayTime   = bulletModel.DelayTime;

            if (bulletModel.Count % 2 == 1)
            {
                go.transform.rotation = bulletModel.Direction * Quaternion.Euler(0, 0, -(bulletModel.Angle * num)); // 绕Z轴旋转 , 要带负号
                go.transform.position = go.transform.position + go.transform.right * num * bulletModel.Distance;
                num--;
            }
            else
            {
                go.transform.rotation = bulletModel.Direction * Quaternion.Euler(0, 0, -(bulletModel.Angle / 2 + bulletModel.Angle * (num - 1)));  // 绕Z轴旋转
                go.transform.position = go.transform.position + go.transform.right * ((num - 1) * bulletModel.Distance + bulletModel.Distance / 2);
                num--;
            }
            go.transform.position = go.transform.position + go.transform.forward * bulletModel.ShiftInitPos;
        }
    }
Example #6
0
    public IEnumerator Init2()
    {
        yield return(null);

        float startFix = (startAngle - 0.5f * (count - 1) * angleSpan);

        for (int i = 0; i < count; i++)
        {
            float   tempAngle = (startFix + i * angleSpan);
            float   x1        = 1 * Mathf.Cos(tempAngle * Mathf.PI / 180);
            float   z1        = 1 * Mathf.Sin(tempAngle * Mathf.PI / 180);
            Vector3 moveDir   = new Vector3(x1, 0, z1).normalized;

            if (parent != null && target != null && target.isLive)
            {
                GameObject obj = Common.Generate(prefab, transform);
                obj.transform.position = parent.transform.position;
                //obj.transform.eulerAngles = new Vector3(0, 0, tempAngle);
                BulletMove bMove = obj.GetComponent <BulletMove>();
                bMove.SetEulerAngle(new Vector3(0, 0, tempAngle));
                Tag   myTag = Tag.Bullet;
                float atk   = 0;
                if (cardInfo != null)
                {
                    myTag = cardInfo.myTag;
                    atk   = cardInfo.Atk;
                }
                bMove.Init(myTag, atk, moveDir * moveSpeed);
            }
        }
    }
Example #7
0
    void Shot()
    {
        if (isShooting)
        {
            float gap        = bulletNum > 1 ? angle / (float)(bulletNum - 1) : 0;
            float startAngle = -angle / 2.0f;
            for (int i = 0; i < bulletNum; i++)
            {
                float gak = startAngle + gap * i;
                gak *= Mathf.Deg2Rad;
                if (unUsedBullets.Count == 0)
                {
                    BulletMove _bullet = Instantiate(bullet, this.gameObject.transform).GetComponent <BulletMove>();

                    _bullet.gameObject.transform.parent = null;
                    _bullet.transform.position          = new Vector3(_bullet.transform.position.x + 0.66f, _bullet.transform.position.y + 0.5f);
                    _bullet.SetDirection(new Vector3(Mathf.Cos(gak), Mathf.Sin(gak)));
                    _bullet.controller = gameObject.GetComponent <BulletShot>();
                }
                else
                {
                    BulletMove _bullet = unUsedBullets[0].GetComponent <BulletMove>();
                    unUsedBullets[0].transform.position = this.transform.position;
                    unUsedBullets[0].SetActive(true);
                    unUsedBullets.RemoveAt(0);
                    _bullet.transform.position = new Vector3(_bullet.transform.position.x + 0.66f, _bullet.transform.position.y + 0.5f);
                    _bullet.SetDirection(new Vector3(Mathf.Cos(gak), Mathf.Sin(gak)));
                    _bullet.controller = gameObject.GetComponent <BulletShot>();
                }
            }
            ShotCoroutine();
        }
    }
Example #8
0
    private IEnumerator YuLeiSpan()
    {
        yield return(Yielders.WaitSecond(yuStartDelay));

        for (int i = 0; i < yuLeiCount; i++)
        {
            yield return(Yielders.WaitSecond(yuSpanDelay));

            float   angle    = Random.Range(0, 360);
            float   x1       = fightRadius * Mathf.Cos(angle * Mathf.PI / 180);
            float   z1       = fightRadius * Mathf.Sin(angle * Mathf.PI / 180);
            Vector3 endPoint = fightPoint + new Vector3(x1, 0, z1) * Random.Range(0f, 1f);

            float tempAngle = -90;
            //
            GameObject obj = Common.Generate(prefab, transform);
            obj.transform.SetParent(transform.parent);
            obj.transform.position = endPoint;

            BulletMove bMove = obj.GetComponent <BulletMove>();
            bMove.SetEulerAngle(new Vector3(0, 0, tempAngle));
            Tag   myTag = Tag.Bullet;
            float atk   = 0;
            if (cardInfo != null)
            {
                myTag = cardInfo.myTag;
                atk   = cardInfo.Atk;
            }
            bMove.Init(myTag, atk, Vector3.down * moveSpeed);
        }
    }
Example #9
0
    public IEnumerator Init2()
    {
        yield return(Yielders.WaitSecond(delayYuLei));

        for (int i = 0; i < yuLeiAngle.Length; i++)
        {
            float   posAngle    = startAngle + (i * 360 / yuLeiAngle.Length);
            float   x1          = radius * Mathf.Cos(posAngle * Mathf.PI / 180);
            float   z1          = radius * Mathf.Sin(posAngle * Mathf.PI / 180);
            Vector3 setPosition = new Vector3(x1, 0, z1);

            float   lookAngle = startAngle + yuLeiAngle[i];
            float   x2        = radius * Mathf.Cos(lookAngle * Mathf.PI / 180);
            float   z2        = radius * Mathf.Sin(lookAngle * Mathf.PI / 180);
            Vector3 moveDir   = new Vector3(x2, 0, z2).normalized;

            if (parent != null && target != null && target.isLive)
            {
                GameObject obj = Common.Generate(prefab2, transform);
                obj.transform.position  = parent.transform.position;
                obj.transform.position += setPosition;
                //obj.transform.eulerAngles = new Vector3(0, 0, startAngle + yuLeiAngle[i]);
                BulletMove bMove = obj.GetComponent <BulletMove>();
                bMove.SetEulerAngle(new Vector3(0, 0, lookAngle));
                Tag   myTag = Tag.Bullet;
                float atk   = 0;
                if (cardInfo != null)
                {
                    myTag = cardInfo.myTag;
                    atk   = cardInfo.Atk;
                }
                bMove.Init(myTag, atk, moveDir * moveSpeed2);
            }
        }
    }
Example #10
0
    // movement behaviours
    public static void Move(this BulletMove bm, Bullet bullet)
    {
        switch (bm)
        {
        case BulletMove.Linear:
            LinearMove(bullet);
            break;

        case BulletMove.LinearGrowth:
            LinearGrowthMove(bullet);
            break;

        case BulletMove.SpinMove:
            SpinMove(bullet);
            break;

        case BulletMove.Weave:
            WeaveMove(bullet);
            break;

        case BulletMove.None:
            break;

        default:
            break;
        }

        Cull(bullet);
    }
Example #11
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         // counter for how many bullets this enemy has shot so far
         // the counter is used when naming each bullet
         bulletsShot++;
         GameObject clone = Instantiate(bulletPrefab, transform.position, Quaternion.identity) as GameObject;
         clone.name = string.Format("player-bullet-{0}", bulletsShot);
         BulletMove bm = clone.GetComponent <BulletMove>();
         bm.direction = 1;
         // set the bullet speed
         bm.speed = bulletSpeed;
         // set the bullet tag which is used in the trigger script
         bm.tag = "PlayerBullet";
         // player bullets are blue
         clone.GetComponent <SpriteRenderer>().color = Color.blue;
         // play sound ( choose between two clips )
         int randomNumber = Random.Range(-1, 1);
         if (randomNumber >= 0)
         {
             audioSource.clip = clip1;
         }
         else
         {
             audioSource.clip = clip2;
         }
         audioSource.Play();
     }
 }
Example #12
0
    GameObject Use(Queue <GameObject> pool, Vector3 position, Quaternion rotation, int degree = 90)
    {
        if (pool.Count > 1)
        {
            GameObject reuse = pool.Dequeue();
            reuse.transform.position = position;
            reuse.transform.rotation = rotation;
            reuse.SetActive(true);

            if (reuse.name.Contains("player_bullet_3"))
            {
                BulletMove bm = reuse.GetComponent <BulletMove>();
                bm.Degree = degree;
            }
            return(reuse);
        }
        else
        {
            GameObject reuse = pool.Peek();
            reuse.name = getName(reuse.name);
            GameObject go = Instantiate(reuse) as GameObject;
            go.transform.position = position;
            go.transform.rotation = rotation;
            go.SetActive(true);

            if (go.name.Contains("player_bullet_3"))
            {
                BulletMove bm = go.GetComponent <BulletMove>();
                bm.Degree = degree;
            }
            return(go);
        }
    }
Example #13
0
 // 生成されている全ての弾丸の速度変更
 public void SetAllBulletSpeed()
 {
     for (int i = 0; i < bulletParent.childCount; i++)
     {
         BulletMove bullet = bulletParent.GetChild(i).GetComponent <BulletMove> ();
         bullet.SetSpeed(stageSpeed);
     }
 }
Example #14
0
 void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     rb            = GetComponent <Rigidbody>();
     body          = GetComponent <Transform>();
     bullet_script = bullet.GetComponent <BulletMove>();
     green         = GameObject.Find("Canvas");
     gs            = green.GetComponent <Health>();
 }
Example #15
0
    void SetProperties(ref BulletMove bulletMove, Vector2 dir)
    {
        bulletMove.SetIsPiercing(isMainPiercing);
        bulletMove.SetBaseProperties(properties);
        bulletMove.SetDirection(dir);
        bulletMove.SetNewBulletSpeed(speedChangeList);

        bulletMove.BulletType = BulletManager.GroupIndex.PLAYER_MAIN;
    }
Example #16
0
    public void SecondaryWeaponShoot()
    {
        int            numOfMissle  = Mathf.FloorToInt(mPlayerController.powerLevel);
        List <Vector3> fairyPosList = secondaryAttackType.GetAllFairyPos();

        for (int i = 0; i < numOfMissle; i++)
        {
            if (bulletType == BulletType.PROJECTILE || bulletType == BulletType.PROJECTILE_LOCK_ON)
            {
                Transform currBullet = BulletManager.sSingleton.GetBulletTrans(BulletManager.GroupIndex.PLAYER_SECONDARY, secondaryBulletIndex);
                Vector3   pos        = fairyPosList[i];
                pos.x += secondaryBulletOffset.x;
                pos.y += secondaryBulletOffset.y;
                currBullet.position = pos;
                currBullet.gameObject.SetActive(true);

                BulletMove bulletMove = currBullet.GetComponent <BulletMove>();
                bulletMove.SetBaseProperties(properties);
                bulletMove.SetIsPiercing(isSecondaryPiercing);
                bulletMove.SetProperties(Template.SINGLE_SHOT, secondaryBulletDamage, secondaryBulletSpeed);
                bulletMove.BulletType = BulletManager.GroupIndex.PLAYER_SECONDARY;

                if (bulletType == BulletType.PROJECTILE)
                {
                    bulletMove.SetDirection(bulletDirection);
                }
                else if (bulletType == BulletType.PROJECTILE_LOCK_ON)
                {
                    Transform enemy = null;

                    if (!mPlayerController.IsShiftPressed)
                    {
                        enemy = withinRange.GetClosestEnemy();
                    }
                    else if (mPlayerController.IsShiftPressed)
                    {
                        enemy = withinRange.GetFurthestEnemy();
                    }

                    if (enemy == null)
                    {
                        bulletMove.SetDirection(bulletDirection);
                    }
                    else
                    {
                        Vector2 dir = enemy.position - fairyPosList[i];
                        bulletMove.SetDirection(dir.normalized);
                    }
                }
            }
            else if (bulletType == BulletType.LASER)
            {
                secondaryAttackType.ActivateSmallLaser(mPlayerController.playerID);
            }
        }
    }
Example #17
0
    [HideInInspector] public bool isTimer;                          // 일정 시간이 지난 뒤 재조준 체크

    private void Start()
    {
        bulletState    = GetComponent <BulletState>();
        bulletMove     = GetComponent <BulletMove>();
        playerPosition = GameObject.Find("CHARACTER").transform.Find("Player");

        changeCount = 0;

        StartCoroutine(Reaiming());
    }
Example #18
0
    void ShootAroundInCirlce()
    {
        if (startTurnDelay <= 0)
        {
            mIncreaseTRTimer += Time.deltaTime;
            if (turningRate < maxTR && mIncreaseTRTimer >= increaseTRTime)
            {
                turningRate += increaseTR;
                if (turningRate > maxTR)
                {
                    turningRate = maxTR;
                }
                mIncreaseTRTimer = 0;
            }
        }
        else
        {
            startTurnDelay -= shootDelay - Time.deltaTime;
        }

        for (int i = 0; i < segments; i++)
        {
            float x = Mathf.Sin(mAngle + (xOffset * Mathf.Deg2Rad)) * distance;
            float y = Mathf.Cos(mAngle + (yOffset * Mathf.Deg2Rad)) * distance;
            mAngle += (Mathf.PI * 2 / segments);

            Vector2 dir = Vector2.zero;
            if (isClockwise)
            {
                dir.x += x;  dir.y += y;
            }
            else
            {
                dir.x += y; dir.y += x;
            }

            Transform currBullet = null;
            if (ownerType == OwnerType.PLAYER)
            {
                currBullet = BulletManager.sSingleton.GetBulletTrans(BulletManager.GroupIndex.PLAYER_MAIN, mainBulletIndex);
            }
            else
            {
                currBullet = BulletManager.sSingleton.GetBulletTrans(BulletManager.GroupIndex.ENEMY, mainBulletIndex);
            }

            currBullet.position = owner.position;
            currBullet.gameObject.SetActive(true);

            BulletMove bulletMove = currBullet.GetComponent <BulletMove>();
            SetProperties(ref bulletMove, dir);
        }

        mAngle += (turningRate * Mathf.Deg2Rad);
    }
Example #19
0
    void TurdDropper()
    {
        GameObject Newbie = (GameObject)GameObject.Instantiate(enemyPref, transform.position, Quaternion.identity);
        BulletMove BMove  = Newbie.GetComponent <BulletMove>();

        if (BMove != null)
        {
            BMove.Kiln = Kiln;
            BMove.SetTarget(Kiln.transform.position);
            BMove.speed  = TurretBulletSpeed;
            BMove.Damage = TurretBulletDamage;
        }
    }
Example #20
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == TagManager.sSingleton.enemyTag)
        {
            Vector3 dir = (other.transform.position - transform.position).normalized;

            BulletMove bulletMove = GetComponentInParent <BulletMove>();
            if (bulletMove != null)
            {
                bulletMove.SetDirection(dir);
            }
        }
    }
Example #21
0
    public static void SetBullet(Tag ownTag, int bulletType, int index, float atk, Vector3 pos, float angle, Vector3 moveDir)
    {
        GameObject obj = null;

        obj = Common.Generate(DataController.prefabPath_Bullet + bulletType, GameManager.instance.transBullet);
        BulletMove bullet = obj.GetComponent <BulletMove>();

        bullet.SetEulerAngle(new Vector3(0, 0, angle));
        //
        obj.transform.position   = pos;
        obj.transform.localScale = Vector3.one;

        bullet.Init(ownTag, atk, moveDir);
    }
Example #22
0
    void Shoot(Collider2D enemy)
    {
        Vector3 startPos = startPosition.position;
        Vector3 enemyPos = enemy.transform.position;

        GameObject instBullet = (GameObject)Instantiate(bullet, startPos, Quaternion.identity);


        BulletMove bulletMove = instBullet.GetComponent <BulletMove>();

        bulletMove.startPosition  = startPos;
        bulletMove.finishPosition = enemyPos;
        bulletMove.goal           = enemy.gameObject;
    }
Example #23
0
    public void Shoot(string bulletname, Vector3 position, Vector3 direction, int bulletNumber, string shooter, PhotonMessageInfo info)
    {
        bulletNum++;
        float      angle         = Mathf.Atan2(direction.y, direction.x);
        GameObject spawnedBullet = Instantiate(Resources.Load <GameObject>(bulletname), position, Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg - 90));
        //GameObject spawnedBullet = Instantiate(bullets[Random.Range(0, bullets.Count)], position, Quaternion.Euler(direction));
        BulletMove bulletMoveScript = spawnedBullet.GetComponent <BulletMove>();

        bulletMoveScript.setStartPosition(position);
        bulletMoveScript.SetDirection(direction.normalized);
        bulletMoveScript.setPlayer(shooter);
        bulletMoveScript.setBulletNumber(bulletNumber);
        bulletMoveScript.setCreateTime(Mathf.Abs((float)Time.time));//info.SentServerTime
        spawnedProjectiles.Add(spawnedBullet);
    }
    /// 아직 반사 효과를 줄 패턴이 없으므로 나중에 수정할 것

    private void OnTriggerEnter2D(Collider2D collision)
    {
        // 충돌 대상이 적 탄막인지 확인
        if (collision.CompareTag("BULLET_ENEMY"))
        {
            BulletState bulletState = collision.gameObject.GetComponent <BulletState>();
            BulletMove  bulletMove  = collision.gameObject.GetComponent <BulletMove>();

            // 대상 탄막이 반사 특성을 가지고 있는지 확인
            if (!bulletState.bulletReflectState.Equals(BulletReflectState.BULLETREFLECTSTATE_NONE) && gameObject.CompareTag("REFLECTZONE"))
            {
                // 이미 1회 이상 반사된 탄막인지 체크
                if (bulletState.reflectCount < bulletState.reflectLimit)
                {
                    // 최초 반사일 경우 반사 카운트 증가
                    bulletState.reflectCount++;
                    // 충돌한 영역이 좌우 반사 영역일 경우의 처리
                    if (gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_LEFTRIGHT")))
                    {
                        bulletMove.ChangeRotateAngle(bulletMove.GetAngle() * -1);
                    }
                    // 충돌한 영역이 상하 반사 영역일 경우의 처리
                    else if ((gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_TOP"))) ||
                             (gameObject.layer.Equals(LayerMask.NameToLayer("REFLECTZONE_BOTTOM")) && bulletState.bulletReflectState.Equals(BulletReflectState.BULLETREFLECTSTATE_CONTAINBOTTOM)))
                    {
                        if (bulletMove.GetAngle() >= 0.0f && bulletMove.GetAngle() <= 180.0f)
                        {
                            bulletMove.ChangeRotateAngle(180.0f - bulletMove.GetAngle());
                        }
                        else
                        {
                            bulletMove.ChangeRotateAngle(-180.0f - bulletMove.GetAngle());
                        }
                    }

                    // 탄막이 반사될 때 스프라이트 변화 및 이펙트 출력이 설정되어 있을 경우의 처리
                    if (bulletState.isSpriteChange.Equals(true))
                    {
                        // spriteRenderer.sprite = enemyFire.spriteCollection[changeSpriteNumber];
                    }
                    if (bulletState.isEffectOutput.Equals(true))
                    {
                        // StartCoroutine(enemyFire.CreateBulletFireEffect(effectSpriteNumber, scaleDownSpeed, scaleDownTime, alphaUpSpeed, transform.position));
                    }
                }
            }
        }
    }
Example #25
0
    void Reset()
    {
        rigidbody2d = GetComponent<Rigidbody2D> ();
        animator = GetComponent<Animator> ();

        bullet = GameObject.Find ("Resources/Bullet").GetComponent<BulletMove>();

        foreach( var name in new string[]{"Pos1", "Pos2"}){
            if (GameObject.Find ( gameObject.name + "/" + name) == null) {
                var obj = new GameObject (name);
                obj.transform.SetParent (transform);
            }
        }
        pos1 = GameObject.Find ( gameObject.name + "/Pos1").transform;
        pos2 = GameObject.Find ( gameObject.name + "/Pos2").transform;
    }
        public IEnumerator BulletMoveTest3()
        {
            Vector3 pos           = new Vector3(0, 0, 0);
            float   rotation      = 0.0f;
            float   scale         = 2.0f;
            Vector3 desiredResult = new Vector3(0.0f, 2.0f, 0.0f);

            Vector3 result = BulletMove.CalculateNewPos(pos, rotation, scale);

            if (result.x > -0.000001 && result.x < 0.000001)
            {
                result.x = 0;
            }
            Assert.AreEqual(result, desiredResult);
            yield return(null);
        }
Example #27
0
 void Create()
 {
     if (transform.gameObject.activeSelf)
     {
         BulletMove bullet = BulletManage._bulletmage.takebullet(BulletType.monster);
         if (bullet == null)
         {
             GameObject go = Instantiate(MonsterBullet);
             bullet      = go.GetComponent <BulletMove>();
             bullet.type = BulletType.monster;
         }
         bullet.gameObject.SetActive(true);
         bullet.transform.position = transform.position;
         BulletManage._bulletmage.addbullet(bullet);
     }
 }
        private void Update()
        {
            var jobMove = new BulletMove {
                BulletData = _bulletDataArray.AsDeferredJobArray(), RaycastCommands = _raycastCommandArray.AsDeferredJobArray(), LayerMask = bulletCollisionLayer, DeltaTime = Time.deltaTime, Time = Time.time
            };

            var handlerMove = jobMove.Schedule(_transformAccessArray);

            handlerMove.Complete();

            var handlerRaycast = RaycastCommand.ScheduleBatch(_raycastCommandArray, _raycastHitArray, 16);

            handlerRaycast.Complete();

            MainThreadProcess();
        }
Example #29
0
    IEnumerator Shoot()
    {
        yield return(new WaitForSeconds(WakeUp));

        while (GunIsOn)
        {
            GameObject NewBullet = (GameObject)Instantiate(BulletObject, GunBarrelObject.transform.position, GunBarrelObject.transform.rotation);
            NewBullet.transform.Rotate(0, 0, Random.Range(-BulletSpread, BulletSpread));
            BulletMove bulletMove = NewBullet.GetComponent <BulletMove>();
            bulletMove.speed = bulletMove.speed + Random.Range(-BulletObjectSpeedGap, 0);
            float Gap = attackSpeedSeconds + Random.Range(0, BulletObjectGap);
            Busy = true;
            yield return(new WaitForSeconds(Gap));

            Busy = false;
        }
    }
Example #30
0
    public void PullTrigger(Collider2D other)
    {
        if (currHitPoint <= 0)
        {
            return;
        }

        float  damage     = 0;
        string otherLayer = LayerMask.LayerToName(other.gameObject.layer);

        if (otherLayer == TagManager.sSingleton.playerBulletLayer)
        {
            if (other.GetComponent <BulletMove>() != null)
            {
                BulletMove bulletMove = other.GetComponent <BulletMove>();
                damage = bulletMove.GetBulletDamage;

                if (bulletMove.GetIsMagnum)
                {
                    mIsMarkedByMagnum = true;
                }

                if (!bulletMove.GetIsPiercing())
                {
                    other.gameObject.SetActive(false);
                }

                GetDamaged(damage, other, bulletMove.BulletType);
            }
            else if (other.GetComponent <DamageWithinRadius>() != null && !isHitByMagnumRadius)
            {
                mIsMarkedByMagnum   = true;
                isHitByMagnumRadius = true;

                DamageWithinRadius dmgRad = other.GetComponent <DamageWithinRadius>();
                GetDamaged(dmgRad.damage, other, BulletManager.GroupIndex.PLAYER_MAIN);
            }
        }
        else if (otherLayer == TagManager.sSingleton.playerBulletNoDestroyLayer)
        {
            Laser laser = other.GetComponent <Laser>();
            damage = laser.GetDmgPerFrame;
            GetDamaged(damage, other, BulletManager.GroupIndex.PLAYER_SECONDARY);
        }
    }
Example #31
0
    IEnumerator Shoot()
    {
        yield return(new WaitForSeconds(WakeUp));

        while (GunOn)
        {
            //GameObject bullet = objectPool.SpawnFromPool("Bullets", Gun.transform.position, Gun.transform.rotation);
            GameObject bullet = (GameObject)Instantiate(Bullet, Gun.transform.position, Gun.transform.rotation);
            bullet.transform.Rotate(0, 0, Random.Range(-Spread, Spread));
            BulletMove bulletMove = bullet.GetComponent <BulletMove>();
            bulletMove.speed = bulletMove.speed + Random.Range(-BulletSpeedGap, 0);
            float Gap = attackSpeedSeconds + Random.Range(0, BulletGap);
            Busy = true;
            yield return(new WaitForSeconds(Gap));

            Busy = false;
        }
    }
Example #32
0
    public void PoolBullet(string bullet_name_, BulletMove bullet_move_, int amount_ = 40)
    {
        pooled_amount = amount_;

        temp_obj = new GameObject();
        temp_obj.SetActive(false);
        temp_obj.name = bullet_name_;
        temp_obj.AddComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Images/Bullet/" + bullet_name_);
        temp_obj.GetComponent<SpriteRenderer>().sortingLayerName = "Bullet";
        switch (bullet_name_)
        {
            case "bullet_enemy_A":
            case "bullet_enemy_B":
            case "bullet_enemy_C":
            case "bullet_enemy_D":
                temp_obj.AddComponent<CircleCollider2D>().radius = 10f;
            break;
            case "bullet_enemy_Han":
                temp_obj.AddComponent<CircleCollider2D>().radius = 20f;
            break;
            case "bullet_enemy_Yeon":
                temp_obj.AddComponent<CircleCollider2D>().radius = 30f;
            break;
            case "bullet_IceWitch1":
                temp_obj.AddComponent<CircleCollider2D>().radius = 25f;
            break;
            case "bullet_IceWitch2":
                temp_obj.AddComponent<CircleCollider2D>().radius = 27f;
            break;
            default :
                temp_obj.AddComponent<CircleCollider2D>().radius = 10f;
            break;
        }
        temp_obj.GetComponent<CircleCollider2D>().isTrigger = true;
        SetMove(temp_obj, bullet_move_);

        for (int i = 0; i < pooled_amount; i++)
        {
            GameObject obj = (GameObject)Instantiate(temp_obj, new Vector3(4000, 0, 0), Quaternion.identity);
            pooled_bullets.Add(obj);
        }
    }
Example #33
0
 void SetMove(GameObject bullet, BulletMove bullet_move_)
 {
     switch (bullet_move_)
     {
         case BulletMove.STRAIGHT:
             bullet.AddComponent<bullet_straight>();
             break;
         case BulletMove.HOMING:
             bullet.AddComponent<bullet_homing>();
             break;
         case BulletMove.ENEMY_STRAIGHT:
             bullet.AddComponent<bullet_enemy_straight>();
             break;
         case BulletMove.ENEMY_HOMING:
             bullet.AddComponent<bullet_enemy_homing>();
             break;
         case BulletMove.STRAIGHT_2:
             bullet.AddComponent<bullet_straingt_2>();
             break;
     }
 }
Example #34
0
    public bool SetData(int charIndex, int accountLevel, int level, int grade, int arrayIndexNum)
    {
        LevelData leveldata;
        CharacterData chardata;
        BulletData bulletdata;

        My_Level = level;//GameManager.charnum[arrayIndexNum] % 100;// (GetLevelDataIndex() / 100) % 100;
        My_Grade = grade;
        DataManager.Get().CharDatas.TryGetValue(index, out chardata);
        DataManager.Get().LevelDatas.TryGetValue(GetLevelDataIndex(), out leveldata);

        if (chardata == null)
        {
            Debug.Log("Char SetData in CharacterStatus Error : " + index);
        }
        if (leveldata == null)
        {
            Debug.Log("Level SetData in CharacterStatus Error : " + GetLevelDataIndex() );
        }
        DataManager.Get().BulletDatas.TryGetValue(GetLevelDataIndex() / 100, out bulletdata);
        if (bulletdata == null)
        {
            Debug.Log("BULLET SetData in CharacterStatus Error : " + chardata.BulletIndex);
        }

        num = arrayIndexNum;
        index = chardata.Index;
        charon = true;
        char_name = chardata.ResourceName + ((GetLevelDataIndex() / 100) % 100).ToString();
        char_hanname = chardata.Name;
        attribute = (Attribute)chardata.Attribute;
        char_MP = chardata.ManaPoint;
        char_HP = leveldata.HealthPoint * (1f + (accountLevel * 0.006f));
        char_ATK = leveldata.AttackPoint * (1f + (accountLevel * 0.003f)); 
        char_SPD = chardata.Speed;
        Askill_num = chardata.SkillIndex;
        Askill_name = chardata.SkillName;
        Askill_info = chardata.SkillDesc;
        Askill_MP = chardata.SkillManaCost;
        bullet_num = chardata.BulletIndex;

        bullet_move_type = (BulletMove)bulletdata.MoveType;
        bullet_hit_type = (HitType)bulletdata.HitType;
        bullet_SPD = bulletdata.Speed;
        bullet_size = bulletdata.Size;
        shooting_way = bulletdata.MuzzleCount;
        shooting_angle = bulletdata.MuzzleAngle;
        shooting_amount = bulletdata.Amount;
        shooting_repeat = bulletdata.Repeat;
        shooting_delay = bulletdata.Delay;
        shooting_period = bulletdata.Period;
        //Debug.Log(char_hanname + " : " + GetLevelDataIndex() + " >> " + leveldata.AttackPoint + " : " + char_ATK);
        return true;
    }