示例#1
0
    // Update is called once per frame
    void Update()
    {
        float fireTimeInterval = Mathf.Lerp(minFireInterval, maxFireInterval, Mathf.Lerp(1.0f, 0.0f, rate * 2f));

        if (Time.time - lastFireTime > fireTimeInterval)
        {
            fireReadyIndicator.SetActive(true);
            countdownIndicator.SetText("");
            if (isFiring)
            {
                //Firing
                lastFireTime = Time.time;

                Debug.Log("Fire!");
                for (int i = 0; i < multi; i++)
                {
                    var p = Instantiate(projectileSource, projectileEmit.position, projectileEmit.rotation);
                    p.GetComponent <Projectile> ().SetAttributes(Mathf.Lerp(minScale, maxScale, size), aim, guide);

                    //Keep first shot straight
                    if (i > 0)
                    {
                        p.GetComponent <Rigidbody> ().velocity = Spread(p.GetComponent <Rigidbody> ().velocity, Mathf.Lerp(20f, 12f, size), (float)multi / 2);
                    }

                    ScorchAudio.PlayFire();
                }
            }
        }
        else
        {
            int interval = (int)fireTimeInterval - (int)(Time.time - lastFireTime);
            countdownIndicator.SetText(interval.ToString("00"));
            if (fireReadyIndicator != null)
            {
                fireReadyIndicator.SetActive(false);
            }
        }


        //Aim shake

        /*var randCircle = Random.insideUnitCircle;
         * randCircle = Vector2.Scale (randCircle, new Vector2 (Mathf.Lerp(shakeAmplitude, 0, aim), Mathf.Lerp(shakeAmplitude, 0, aim)));
         * transform.localEulerAngles = new Vector3 (transform.localEulerAngles.x + randCircle.x, transform.localEulerAngles.y + randCircle.y, transform.localEulerAngles.z);
         */
        wiggleIndex += wiggleSpeed * Time.deltaTime;
        float angle = 0.0f;

        for (int i = 1; i < octaves; i++)
        {
            angle += (wiggleIndex * i) / i;
        }
        transform.RotateAround(Vector3.up, Mathf.Sin(angle) * wiggleAmplitude * (1f - aim));
        transform.RotateAround(Vector3.left, Mathf.Cos(angle * 1.3f) * wiggleAmplitude * (1f - aim));
    }
 void OnCollisionEnter(Collision col)
 {
     if (col.collider.tag != "Floor")
     {
         // we were hit
         hit.Dispatch(this);
         Debug.Log("tower hit!");
         ScorchAudio.PlayImpact();
         releaseCard();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            cardSelectedIndex--;
            cardSelectedIndex = Mathf.Clamp(cardSelectedIndex, 0, cards.Count);
            SelectCard(cardSelectedIndex);
            ScorchAudio.PlayMenuMove();
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            cardSelectedIndex++;
            cardSelectedIndex = Mathf.Clamp(cardSelectedIndex, 0, cards.Count);
            SelectCard(cardSelectedIndex);
            ScorchAudio.PlayMenuMove();
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            CardSelected.Dispatch(cards[cardSelectedIndex].cardData);
            ScorchAudio.PlayMenuSelect();
        }
    }
示例#4
0
 public void MenuSelect()
 {
     ScorchAudio.PlayMenuSelect();
 }
示例#5
0
 public void MenuMove()
 {
     ScorchAudio.PlayMenuMove();
 }
示例#6
0
 public void Impact()
 {
     ScorchAudio.PlayImpact();
 }
示例#7
0
 public void Fire()
 {
     ScorchAudio.PlayFire();
 }
示例#8
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }