コード例 #1
0
    private IEnumerator AcyncDamage()
    {
        permission = false;
        if (furnitures.Count > 0)
        {
            foreach (var furniture in furnitures)
            {
                Vector3    vectorFurniture    = furniture.transform.position;
                Vector3    thisVector         = transform.position;
                var        forward            = vectorFurniture - thisVector;
                float      distance           = Vector2.Distance(vectorFurniture, thisVector);
                IFurniture furnitureComponent = furniture.GetComponent <IFurniture>();
                furnitureComponent.Damage(damage);
                furnitureComponent.Jerk(forward.normalized, strongJerk);
            }
        }

        yield return(new WaitForSeconds(frequency));

        permission = true;
    }
コード例 #2
0
    private IEnumerator AcyncDamage()
    {
        permission = false;
        Debug.Log(furnitures.Count);
        if (furnitures.Count > 0)
        {
            foreach (var furniture in furnitures)
            {
                Vector3    vectorFurniture    = furniture.transform.position;
                Vector3    thisVector         = transform.position;
                var        forward            = vectorFurniture - thisVector;
                float      distance           = Vector2.Distance(vectorFurniture, thisVector);
                IFurniture furnitureComponent = furniture.GetComponent <IFurniture>();
                furnitureComponent.Jerk(forward.normalized, powerGarbageFurniture - (distance * weakeningGarbageFurniture));
            }
        }

        if (mobs.Count > 0)
        {
            foreach (var mob in mobs)
            {
                Vector3 vectorFurniture = mob.transform.position;
                Vector3 thisVector      = transform.position;
                var     forward         = vectorFurniture - thisVector;
                float   distance        = Vector2.Distance(vectorFurniture, thisVector);
                IMob    mobComponent    = mob.GetComponent <IMob>();
                mobComponent.SetFreeze(1.5f);
                mobComponent.NoCollision(1.5f);
                mobComponent.SetDamage(damage);
                mobComponent.Jerk(forward.normalized, powerGarbage - (distance * weakeningGarbage));
            }
        }
        yield return(new WaitForSeconds(0f));

        readyDestroy = true;
    }