Example #1
0
 // Use this for initialization
 void Start()
 {
     //取得
     _accelerator      = GetComponent <BulletAccelerator>();
     nemuno_Controller = transform.parent.GetComponent <NemunoController>();
     //オブジェクトプール
     ObjectPoolManager.Instance.Create_New_Pool(yellow_Rice_Bullet, 48);
 }
 // Update is called once per frame
 void Update()
 {
     if (Time.time > nextFire)
     {
         nextFire = Time.time + fireRate;
         GameObject        bulletClone       = Instantiate(shot, shotSpawn.position, shotSpawn.rotation) as GameObject;
         BulletAccelerator bulletAccelerator = bulletClone.gameObject.GetComponent <BulletAccelerator> ();
         bulletAccelerator.initialize(shotSpeed, shotLifetime, shotDamage);
     }
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     //オブジェクトプール
     pool_Manager = ObjectPoolManager.Instance;
     pool_Manager.Create_New_Pool(scales_Bullet, 10);
     pool_Manager.Create_New_Pool(green_Rice_Bullet, 40);
     pool_Manager.Create_New_Pool(red_Bullet, 2);
     //取得
     player      = GameObject.FindWithTag("PlayerTag");
     _shoot      = GetComponent <ShootFunction>();
     _bullet_Acc = GetComponent <BulletAccelerator>();
 }
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "EBullet")
     {
         BulletAccelerator bulletAccelerator = col.gameObject.GetComponent <BulletAccelerator> ();
         health -= bulletAccelerator.getDamage();
         Destroy(col.gameObject);
     }
     if (health <= 0)
     {
         //YOU LOSE
     }
 }
    // Update is called once per frame
    void Update()
    {
        //Detects fire button
        if (Input.GetButton("Fire1") && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            GameObject        bulletClone       = Instantiate(shot, shotSpawn.position, shotSpawn.rotation) as GameObject;
            BulletAccelerator bulletAccelerator = bulletClone.gameObject.GetComponent <BulletAccelerator> ();
            bulletAccelerator.initialize(shotSpeed, shotLifetime, shotDamage);
        }

        //Moves controller
        if (charController.isGrounded)
        {
            moveDirection = new Vector3(Input.GetAxis("Vertical"), 0, Input.GetAxis("Horizontal"));
            //moveDirection = transform.TransformDirection(moveDirection);
            moveDirection *= speed;
        }
        moveDirection.y -= gravity * Time.deltaTime;
        charController.Move(moveDirection * Time.deltaTime);

        //Jump
        if (Input.GetButton("Jump"))
        {
            moveDirection.y = jumpSpeed;
        }

        //Rotates player
        if (Input.GetButton("RotateHorizontal") || Input.GetButton("RotateVertical"))
        {
            float y     = Input.GetAxis("RotateHorizontal");
            float x     = Input.GetAxis("RotateVertical");
            float angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg;
            float temp  = Mathf.LerpAngle(transform.eulerAngles.y, angle, 0.05f);
            transform.rotation = Quaternion.Euler(new Vector3(0, temp, 0));
        }
    }