Esempio n. 1
0
    void FixedUpdate()
    {
        //if (!spawning)
        //    return;

        spawnTimer -= Time.fixedDeltaTime;
        if (spawnTimer <= 0)
        {
            Tile tile = GetRandomUnusedTile();
            if (tile != null)
            {
                SupplyCrate crate = Instantiate(scPrefab, tile.transform.position + Vector3.up * yOffset, Quaternion.identity);
                crate.SetParent(tile);
            }
            //else spawning = false;
            spawnTimer = spawnInterval;
        }
    }
Esempio n. 2
0
    public void Explode(Vector3 direction, float force, Player owner = null)
    {
        if (owner != null)
        {
            lastPlayerHitBy = owner;
        }

        if (type == InteractableType.GROUND)
        {
            return;
        }

        if (type == InteractableType.OBSTACLE)
        {
            SupplyCrate crate = GetComponent <SupplyCrate>();
            if (crate)
            {
                crate.OnExplode();
            }
        }

        force = Mathf.Max(force - weight, 0f);
        rb.AddForce(direction * force, ForceMode.VelocityChange);
    }
Esempio n. 3
0
        /// <summary>
        /// Checks if the object is a SupplyCrate
        /// </summary>
        /// <returns>Returns true if it is.</returns>
        public bool IsSupplyCrate()
        {
            SupplyCrate str = this.Object as SupplyCrate;

            return(str != null);
        }