Example #1
0
    void OnTriggerEnter(Collider other)
    {
        if (enabled)
        {
            SpawnField field = other.GetComponent <SpawnField>();

            if (field != null && other.CompareTag(spawnAreaTag))
            {
                Vector3    position = field.AlignPosition(transform.position);
                Quaternion rotation = field.AlignRotation(transform.up);

#pragma warning disable CS0219
//#pragma warning disable CS1692
                GameObject newObject = Instantiate(
                    objPrefab.constValue,
                    position,
                    rotation,
                    null
                    ) as GameObject;
#pragma warning restore

                MortalityHandler.Kill(gameObject);
            }
        }
    }
Example #2
0
 void Update()
 {
     if (Time.time > startTime + timeOutDelay.constValue)
     {
         MortalityHandler.Kill(gameObject);
     }
 }
Example #3
0
    private void OnTriggerEnter(Collider other)
    {
        MortalityHandler.Kill(gameObject);

        countVariable.value--;

        if (countVariable.value == 0)
        {
            lastOneEvent.Invoke();
        }
    }
Example #4
0
    private void Update()
    {
        if (Time.time > startTime + delay.constValue)
        {
            if (!keepRetrying.constValue)
            {
                this.enabled = false;
            }

            MortalityHandler.Kill(gameObject);
        }
    }
Example #5
0
    /// <summary>
    /// Kill the specified object, using its MortalityHandler if it has one. If it doesn't have one, the object gets
    /// destroyed on the spot. Note that, under some circumstances, the object in question might be immortal, so then
    /// it won't die.
    /// </summary>
    /// <param name="other">Thing that needs to die.</param>
    public static void Kill(GameObject other)
    {
        MortalityHandler otherHandler = other.GetComponentInChildren <MortalityHandler>();

        if (otherHandler != null)
        {
            otherHandler.Die();
        }
        else
        {
            // When you're an expendable crew-member, you should be able to die even if you don't have any way of dying
            // that's on-script.
            Destroy(other);
        }
    }
Example #6
0
    public void RefreshStatus()
    {
        int  remainingCount = pickupCount.constValue;
        bool opened         = remainingCount == 0;

        // Toggle which door is opened
        openedObject.SetActive(opened);
        closedObject.SetActive(!opened);

        // Manage trails
        if (trails == null)
        {
            trails = new List <GameObject>();
        }

        while (remainingCount != trails.Count)
        {
            if (remainingCount < trails.Count)
            {
                // We have too many
                GameObject marked = trails[0];
                trails.RemoveAt(0);

                MortalityHandler.Kill(marked);
            }
            else
            {
                GameObject newTrail = Instantiate(
                    trailPrafab.constValue,
                    transform.position,
                    transform.rotation,
                    transform
                    ) as GameObject;

                trails.Add(newTrail);
            }
        }
    }