예제 #1
0
 public void nextEffect() //Changes the selected projectile to the next. Used by UI
 {
     if (currentProjectile < projectiles.Length - 1)
     {
         currentProjectile++;
     }
     else
     {
         currentProjectile = 0;
     }
     selectedProjectileButton.getProjectileNames();
 }
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                nextEffect();
                selectedProjectileButton.getProjectileNames();         // Run the getProjectileNames() function in SciFiButtonScript
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                nextEffect();
                selectedProjectileButton.getProjectileNames();
            }

            if (Input.GetKeyDown(KeyCode.A))
            {
                previousEffect();
                selectedProjectileButton.getProjectileNames();
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                previousEffect();
                selectedProjectileButton.getProjectileNames();
            }

            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                if (!selectedProjectileButton.overButton())
                {
                    if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100f))
                    {
                        GameObject projectile = Instantiate(projectiles[currentProjectile], spawnPosition.position, Quaternion.identity) as GameObject;
                        projectile.transform.LookAt(hit.point);
                        projectile.GetComponent <Rigidbody>().AddForce(projectile.transform.forward * speed);
                        projectile.GetComponent <SciFiProjectileScript>().impactNormal = hit.normal;
                    }
                }
            }
            Debug.DrawRay(Camera.main.ScreenPointToRay(Input.mousePosition).origin, Camera.main.ScreenPointToRay(Input.mousePosition).direction *100, Color.yellow);
        }