示例#1
0
    private void OnCollisionEnter(Collision collision)
    {
        ItBurnsAhhhhhhh ahhhh = collision.gameObject.GetComponentInChildren <ItBurnsAhhhhhhh>();

        if (ahhhh != null && this.IsFireMaster && !this.IsCombining && !ahhhh.IsCombining)
        {
            ahhhh.IsFireMaster = false;

            GameObject newFire = (GameObject)Instantiate(
                this.transform.root.gameObject,
                (this.transform.root.position + ahhhh.transform.root.position) * 0.5f,
                Quaternion.identity);

            newFire.transform.localScale = this.transform.root.localScale + ahhhh.transform.root.localScale;

            this.IsCombining  = true;
            ahhhh.IsCombining = true;

            Destroy(this.transform.root.gameObject);
            Destroy(ahhhh.transform.root.gameObject);
        }
        else if (!this.hitGround && ahhhh == null && collision.gameObject.name != "Player")
        {
            this.hitGround = true;
            Rigidbody rigidbody = this.GetComponent <Rigidbody>();
            if (rigidbody != null)
            {
                rigidbody.velocity = Vector3.zero;
            }
        }
    }
    void Update()
    {
        this.timeTilNextFlame = this.timeTilNextFlame <= 0.0f ? 0.0f : this.timeTilNextFlame - Time.deltaTime;

        if (this.isFiring && this.timeTilNextFlame <= 0.0f)
        {
            this.timeTilNextFlame = 1.0f / this.fireRate;

            GameObject fire = (GameObject)Instantiate(
                this.firePrefab,
                this.firePoint.transform.position,
                Quaternion.LookRotation(-this.transform.forward, this.transform.up));

            Rigidbody fireRigid = fire.GetComponentInChildren <Rigidbody>();

            if (fireRigid != null)
            {
                fireRigid.AddForce(this.transform.forward * this.firingForce);
            }

            ItBurnsAhhhhhhh fireComp = fire.GetComponentInChildren <ItBurnsAhhhhhhh>();

            if (fireComp != null)
            {
                fireComp.Target = this.transform.root.gameObject;
            }
        }
    }