Пример #1
0
    public void UpdateGodTouch()
    {
        GameObject thunder     = null;
        bool       hitOnGround = true;

        var hits = TestGodTouch();

        if (hits == null)
        {
            return;
        }
        bool isThunder = true;

        foreach (var hit in hits)
        {
            if (!dungeon.currentFloor.fogOfWar.IsVisibleByGod(Coord.Round(hit.transform.position)))
            {
                return;
            }
            if (isThunder)
            {
                thunder = Instantiate(thunderPrefab);
                thunder.transform.position = new Vector3(hit.transform.position.x, thunder.transform.position.y, hit.transform.position.z);
                var clip = audioManager.SFXs[5];
                AudioManager.playSFX(thunder.transform.position, clip, 0);
                isThunder      = false;
                god.powerLeft -= 20;
            }
            var hitGO    = hit.collider.gameObject;
            var godTouch = hitGO.GetComponent <GodTouchAction>();
            if (godTouch != null)
            {
                hitOnGround = false;
                godTouch.Act();
            }
        }

        if (hitOnGround && thunder != null)
        {
            var thunderCoord = Coord.Round(thunder.transform.position);
            if (Coord.distance(hero.coord, thunderCoord) <= hero.visibleDistance)
            {
                heroController.ForceRunAway(thunderCoord, Random.Range(2, 5));
            }
        }
    }