Ejemplo n.º 1
0
    public IEnumerator SummonBlocked(Vector3 originalLanding, RaycastHit blocker)
    {
        if (summonToStrikeDelay > 0)
        {
            OnSummonEvent.Invoke();
        }
        yield return(new WaitForSeconds(summonToStrikeDelay));

        Debug.DrawLine(originalLanding, originalLanding + Vector3.up * _originHeight, Color.blue, 3);

        OnBlockedEvent.Invoke();
        OnBlockedEventPos.Invoke(originalLanding + Vector3.up * _originHeight, blocker.collider.gameObject.transform.position);

        ThunderReactor impactReactor =
            blocker.transform.GetComponent <ThunderReactor>();

        // Activate any thunder specific reactions the hit object might have
        if (impactReactor != null)
        {
            print("Invoking reactors on blocker");
            impactReactor.OnHitByThunder.Invoke();
            impactReactor.OnSpotHitByThunder.Invoke(blocker.point);
        }

        yield return(null);
    }
Ejemplo n.º 2
0
    public IEnumerator SummonThunder(Vector3 landingSpot)
    {
        //DEBUG///////////////////////////
        Debug.DrawLine(new Vector3(landingSpot.x + 1, landingSpot.y + 1, landingSpot.z), new Vector3(landingSpot.x - 1, landingSpot.y - 1, landingSpot.z), Color.red, 3);
        Debug.DrawLine(new Vector3(landingSpot.x + 1, landingSpot.y - 1, landingSpot.z), new Vector3(landingSpot.x - 1, landingSpot.y + 1, landingSpot.z), Color.red, 3);
        //////////////////////////////////////////

        Vector3 origin = landingSpot;

        //print("Landing place " +  origin);
        origin.y += _originHeight;
        //print("Origin" +  origin);

        RaycastHit strikeInfo;

        Physics.Raycast(origin, Vector3.down, out strikeInfo, _originHeight * 5, impactLayer);

        OnSummonEventPos.Invoke(strikeInfo.point);

        if (summonToStrikeDelay > 0)
        {
            OnSummonEvent.Invoke();
        }
        yield return(new WaitForSeconds(summonToStrikeDelay));



        //print("StrikePoint " +  strikeInfo.point);

        OnStrikeEvent.Invoke(strikeInfo.point);

        ThunderReactor impactReactor =
            strikeInfo.transform.GetComponent <ThunderReactor>();

        // Activate any thunder specific reactions the hit object might have
        if (impactReactor)
        {
            impactReactor.OnHitByThunder.Invoke();
            impactReactor.OnSpotHitByThunder.Invoke(strikeInfo.point);
        }

        ///DEBUG///////////////////////////////////////
        Debug.DrawLine(origin, strikeInfo.point, Color.yellow, 2);

        Debug.DrawLine(new Vector3(strikeInfo.point.x + 1, strikeInfo.point.y + 1, strikeInfo.point.z), new Vector3(strikeInfo.point.x - 1, strikeInfo.point.y - 1, strikeInfo.point.z), Color.yellow, 3);
        Debug.DrawLine(new Vector3(strikeInfo.point.x + 1, strikeInfo.point.y - 1, strikeInfo.point.z), new Vector3(strikeInfo.point.x - 1, strikeInfo.point.y + 1, strikeInfo.point.z), Color.yellow, 3);
        //////////////////////////////////////////

        yield return(null);
    }
Ejemplo n.º 3
0
    public void SpawnCover()
    {
        if (ThunderCover)
        {
            _spawnedCover = Instantiate(ThunderCover.gameObject, transform.position + transform.up * coverHeight, Quaternion.identity);
            _spawnedCover.GetComponent <SphereCollider>().isTrigger = true;
            _spawnedCover.GetComponent <SphereCollider>().radius    = coverRadius;

            ThunderReactor _tReact =
                _spawnedCover.GetComponent <ThunderReactor>();
            if (_tReact)
            {
                _tReact.OnHitByThunder += SpawnAmmo;
                print("Found Reactor in Cover");
            }
        }
    }