Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        State = PlayerState.Default;
        float hInput = _playerInput.HorizontalInput;
        float vInput = _playerInput.VerticalInput;

        float horizontalMove = hInput * Speed;
        float VerticalMove   = vInput * Speed;

        //Debug.LogFormat("{0} {1}", hInput, vInput);
        if (vInput * hInput != 0)
        {
            horizontalMove /= 1.414f; // Sqrt(2)
            VerticalMove   /= 1.414f;
        }
        if (_playerInput.SlowButton)
        {
            horizontalMove /= 2.5f;
            VerticalMove   /= 3.0f;
            State           = PlayerState.SlowMove;
        }
        Vector2 playerPos = (Vector2)transform.position;
        Vector2 tempPos   = (Vector2)transform.position +
                            new Vector2(horizontalMove, VerticalMove) * Time.deltaTime;

        if (!(tempPos.x < -GameSetting.Instance.WidthF || tempPos.x > GameSetting.Instance.WidthF))
        {
            playerPos.x += horizontalMove * Time.deltaTime;
        }
        if (!(tempPos.y < -GameSetting.Instance.HeightF || tempPos.y > GameSetting.Instance.HeightF))
        {
            playerPos.y += VerticalMove * Time.deltaTime;
        }
        transform.position = new Vector3(playerPos.x, playerPos.y, transform.position.z);


        if (_playerInput.ShotButton)
        {
            //Debug.Log("Shot");
            if (frame % 2 == 0)
            {
                _bulletPool.AddBullet(true, 0, 0, playerPos.x - 0.25f, playerPos.y, Mathf.PI / 8, 0.15f);
                _bulletPool.AddBullet(true, 0, 0, playerPos.x - 0.1f, playerPos.y, 0, 0.3f);
                _bulletPool.AddBullet(true, 0, 0, playerPos.x + 0.1f, playerPos.y, 0, 0.3f);
                _bulletPool.AddBullet(true, 0, 0, playerPos.x + 0.25f, playerPos.y, -Mathf.PI / 8, 0.15f);
            }
        }
        frame++;
    }
Exemple #2
0
    public void Danmaku01(Emitter emitter)
    {
        const int TM000 = 120;
        int       i, t = emitter.frame % TM000;

        int   bullet_id = 0;
        float angle;

        if (t < 60 && t % 10 == 0)
        {
            angle = emitterAtan2(emitter.x, emitter.y);
            for (i = 0; i < 30; i++)
            {
                bullet_id = _bulletPool.AddBullet(false, 1, 0,
                                                  emitter.x, emitter.y,
                                                  angle + PI2 / 30 * i,
                                                  3 / 100f, emitter.emitterId);
                emitter.bulletFlag[bullet_id] = true;
            }
        }
    }
 public virtual void Shoot()
 {
     if (OnFireDistance())
     {
         var bullet = bp.Get();
         if (bullet == null)
         {
             return;
         }
         bullet.Spawn(firePosition.position, firePosition.forward, damage, false);
         bp.AddBullet(bullet);
         canShoot = false;
         fireTime = Random.Range(minFireTime, maxFireTime);
         enem.audioSource.clip = shootAudio;
         enem.audioSource.Play();
     }
 }
 public void OnPoolEnter()
 {
     bulletPool.AddBullet(this);
     this.gameObject.SetActive(false);
 }