示例#1
0
    public virtual void Die()
    {
        UnityEngine.Object.Destroy(this.gameObject);
        Transform deadModel = UnityEngine.Object.Instantiate(this.deadModelPrefab, this.transform.position, this.transform.rotation);

        EnemyDamage.CopyTransformsRecurse(this.transform, deadModel);
        Transform effect = UnityEngine.Object.Instantiate(this.explosionPrefab, this.transform.position, this.transform.rotation);

        effect.parent = deadModel;
        Rigidbody deadModelRigidbody     = deadModel.GetComponent <Rigidbody>();
        Vector3   relativePlayerPosition = this.transform.InverseTransformPoint(Camera.main.transform.position);

        deadModelRigidbody.AddTorque(Vector3.up * 7);
        if (relativePlayerPosition.z > 0)
        {
            deadModelRigidbody.AddForceAtPosition(-this.transform.forward * 2, this.transform.position + (this.transform.up * 5), ForceMode.Impulse);
        }
        else
        {
            deadModelRigidbody.AddForceAtPosition(this.transform.forward * 2, this.transform.position + (this.transform.up * 2), ForceMode.Impulse);
        }
        int toDrop = Random.Range(this.dropMin, this.dropMax + 1);
        int i      = 0;

        while (i < toDrop)
        {
            var direction = Random.onUnitSphere;
            if (direction.y < 0)
            {
                direction.y = -direction.y;
            }
            Vector3        dropPosition = this.transform.TransformPoint(Vector3.up * 1.5f) + (direction / 2);
            DroppableMover dropped      = null;
            if (Random.value > 0.5f)
            {
                dropped = UnityEngine.Object.Instantiate(this.healthPrefab, dropPosition, Quaternion.identity);
            }
            else
            {
                dropped = UnityEngine.Object.Instantiate(this.fuelPrefab, dropPosition, Quaternion.identity);
            }
            dropped.Bounce((direction * 4) * (Random.value + 0.2f));
            i++;
        }
    }
示例#2
0
 public virtual void Start()
 {
     this.mover = (DroppableMover)this.GetComponent(typeof(DroppableMover));
 }