Inheritance: MonoBehaviour
    public override void OnInspectorGUI()
    {
        Explodable myTarget = (Explodable)target;

        myTarget.allowRuntimeFragmentation = EditorGUILayout.Toggle("Allow Runtime Fragmentation", myTarget.allowRuntimeFragmentation);
        myTarget.shatterType     = (Explodable.ShatterType)EditorGUILayout.EnumPopup("Shatter Type", myTarget.shatterType);
        myTarget.extraPoints     = EditorGUILayout.IntField("Extra Points", myTarget.extraPoints);
        myTarget.subshatterSteps = EditorGUILayout.IntField("Subshatter Steps", myTarget.subshatterSteps);
        if (myTarget.subshatterSteps > 1)
        {
            EditorGUILayout.HelpBox("Use subshatter steps with caution! Too many will break performance!!! Don't recommend more than 1", MessageType.Warning);
        }

        myTarget.fragmentLayer    = EditorGUILayout.TextField("Fragment Layer", myTarget.fragmentLayer);
        myTarget.sortingLayerName = EditorGUILayout.TextField("Sorting Layer", myTarget.sortingLayerName);
        myTarget.orderInLayer     = EditorGUILayout.IntField("Order In Layer", myTarget.orderInLayer);

        if (myTarget.GetComponent <PolygonCollider2D>() == null && myTarget.GetComponent <BoxCollider2D>() == null)
        {
            EditorGUILayout.HelpBox("You must add a BoxCollider2D or PolygonCollider2D to explode this sprite", MessageType.Warning);
        }
        else
        {
            if (GUILayout.Button("Generate Fragments"))
            {
                myTarget.fragmentInEditor();
                EditorUtility.SetDirty(myTarget);
            }
            if (GUILayout.Button("Destroy Fragments"))
            {
                myTarget.deleteFragments();
                EditorUtility.SetDirty(myTarget);
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        m_lineRenderer.SetPosition(0, transform.position);

        Vector3    direction = transform.rotation * Vector3.forward;
        RaycastHit hit;

        if (Physics.Raycast(transform.position, direction, out hit, 100, m_hitLayerMask))
        {
            m_lineRenderer.SetPosition(1, hit.point);

            GameObject      hitObject  = hit.collider.gameObject;
            LaserSelectable selectable = hitObject.GetComponent <LaserSelectable>();
            if (selectable != null)
            {
                // selectable.sethi
                if (Input.GetMouseButtonDown(0))
                {
                    Explodable explodable = hitObject.GetComponent <Explodable>();
                    if (explodable != null)
                    {
                        m_catHead.Attack(explodable);
                    }
                }
            }
        }
        else
        {
            m_lineRenderer.SetPosition(1, direction * 100);
        }
    }
    // Use this for initialization
    void Start()
    {
        explodable = GetComponent <Explodable>();

        time     = 0;
        breakflg = false;
    }
Beispiel #4
0
    private bool OnMove(int horizontalMovment, int verticalMovement)
    {
        Vector2    nextPlayerLocation      = PlayerGridLocation + new Vector2(horizontalMovment, verticalMovement);
        Explodable explodableInDestination = cells[(int)nextPlayerLocation.y, (int)nextPlayerLocation.x];

        TileBase tilebase = tilemap.GetTile(new
                                            Vector3Int((int)nextPlayerLocation.x - gridSize.x / 2, (int)nextPlayerLocation.y - gridSize.y / 2, 0));

        if (tilebase == tileBaseCompare)
        {
            Debug.Log("load new level");
            SceneManager.LoadScene(levelbase);
        }

        Tile.ColliderType colliderType = tilemap.GetColliderType(new
                                                                 Vector3Int((int)nextPlayerLocation.x - gridSize.x / 2, (int)nextPlayerLocation.y - gridSize.y / 2, 0));

        if ((explodableInDestination != null && !explodableInDestination.Destroyed) || colliderType == Tile.ColliderType.Sprite)
        {
            player.nextMove = Vector3.zero;
            return(false);
        }

        float deltaX = horizontalMovment * cellSize;
        float deltaY = verticalMovement * cellSize;

        player.nextMove = new Vector3(deltaX, deltaY, 0);

        return(true);
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        // Ensure some minumums for score and lifepoints
        if (ScoreValue < 1)
        {
            ScoreValue = 1;
        }
        if (LifePoints < 1)
        {
            LifePoints = 1;
        }

        explodable = GetComponent <Explodable>();

        // Set up some "wiggle" values; when not following a path, just wiggle a bit for
        //  a more organic look
        wiggleMagnitude = UnityEngine.Random.Range(0.0005f, 0.001f);
        wiggletime      = UnityEngine.Random.Range(2, 5);
        if (UnityEngine.Random.Range(0, 100) < 50)
        {
            wiggleMagnitude = -wiggleMagnitude;
        }

        startRotation      = transform.localRotation;
        startPosition      = transform.position;
        startLocalPosition = transform.localPosition;

        PathTraveller.SetPathMirror(MirrorX, false);
    }
    IEnumerator AttackCoroutine(Explodable explodable)
    {
        m_followTarget = false;
        m_lookAtTarget = false;

        m_floatingMovement.enabled = false;

        Quaternion startRotation  = transform.rotation;
        Quaternion targetRotation = Quaternion.LookRotation(explodable.laserTarget - transform.position);

        // rotate to the target
        float t = 0.0f;

        while (t < 1.0f)
        {
            transform.rotation = Quaternion.Slerp(startRotation, targetRotation, t);
            t += 0.1f;

            yield return(new WaitForSeconds(0.01f));
        }

        transform.rotation = targetRotation;

        // shoot lasers
        m_lasetShooting.ShootLasersAt(explodable);

        yield return(new WaitForSeconds(1.0f));

        m_floatingMovement.enabled = true;
        m_followTarget             = true;
        m_lookAtTarget             = true;
    }
Beispiel #7
0
 // Use this for initialization
 void Start()
 {
     _explodable  = GetComponent <Explodable>();
     rb           = GetComponent <Rigidbody2D>();
     soundManager = GameObject.Find("SoundManager").GetComponent <SoundManagerScript>();
     player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
 }
Beispiel #8
0
    // Start is called before the first frame update
    void Start()
    {
        isColumnBomb   = false;
        isRowBomb      = false;
        isColourBomb   = false;
        isAdjacentBomb = false;

        //board = FindObjectOfType<Board>();

        board = GameObject.FindWithTag("Board").GetComponent <Board>();

        findMatches    = FindObjectOfType <FindMatches>();
        hintManager    = FindObjectOfType <HintManager>();
        shake          = FindObjectOfType <ScreenShake>();
        endGameManager = FindObjectOfType <EndGameManager>();

        explodable = GetComponent <Explodable>();

        audioSource = gameObject.GetComponent <AudioSource>();

        childObj = transform.Find("FollowMouse");

        if (board.AllJuice == true)
        {
            childObj.gameObject.SetActive(true);
        }
    }
Beispiel #9
0
    public override void OnFragmentsGenerated(List <GameObject> fragments)
    {
        _explodable = GetComponent <Explodable> ();
        float mass;

        foreach (GameObject fragment in fragments)
        {
            Rigidbody2D fragRb = fragment.GetComponent <Rigidbody2D> ();
            fragRb.useAutoMass = true;
            mass = fragRb.mass * 100;
            fragRb.useAutoMass = false;
            fragRb.mass        = mass;
            fragRb.bodyType    = RigidbodyType2D.Static;

            Explodable fragExp = fragment.AddComponent <Explodable> ();
            fragExp.shatterType = Explodable.ShatterType.Voronoi;
            fragExp.allowRuntimeFragmentation = true;
            fragExp.extraPoints      = 1;
            fragExp.fragmentLayer    = _explodable.fragmentLayer;
            fragExp.sortingLayerName = _explodable.sortingLayerName;
            fragExp.orderInLayer     = _explodable.orderInLayer;

            fragment.AddComponent <EarthBlock> ();
            fragment.AddComponent <ExplodeOnClick> ();
            fragment.layer = _explodable.gameObject.layer;
        }
    }
    public void ShootLasersAt(Explodable explodable)
    {
        LaserBeam leftBeam  = CreateBeamAt(m_leftEye, explodable.laserTarget);
        LaserBeam rightBeam = CreateBeamAt(m_rightEye, explodable.laserTarget);

        StartCoroutine(FinishAttack(explodable, leftBeam, rightBeam));
    }
Beispiel #11
0
    public override void Ping(int turn)
    {
        if (turn == explodeOnTurn)
        {
            Col = Sprite.color;

            Explosion.SetBool("Explode", true);
            ExplosionSquare.GetComponent <SpriteRenderer>().color = Invisble;
            ExplosionSquare.SetActive(false);
            ExplosionSound.Play();

            Collider2D[] colliders = Physics2D.OverlapBoxAll(new Vector2(transform.position.x, transform.position.y), explosionSize, 0);

            Debug.Log("Colliders: " + colliders.Length);

            foreach (Collider2D collider in colliders)
            {
                Explodable explodable = collider.GetComponent <Explodable>();
                if (explodable != null && !Destroyed)
                {
                    explodable.DetectExplosion(turn);
                }
            }

            base.DetectExplosion(turn);
        }
    }
Beispiel #12
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (colliding)
        {
            return;
        }
        Destroy(gameObject);

        GameObject fragments = GameObject.Find("Meteor Fragments");

        Explodable[] explodables = fragments.GetComponentsInChildren <Explodable>();

        // randomly find an explodable from the pool
        Explodable explodable = explodables[Random.Range(0, explodables.Length)];

        while (explodable.exploding)
        {
            explodable = explodables[Random.Range(0, explodables.Length)];
        }

        GameObject meteorFragment = explodable.gameObject;

        meteorFragment.transform.position = collision.transform.position;

        Explodable _explodable = meteorFragment.GetComponent <Explodable>();

        _explodable.explode();
    }
Beispiel #13
0
    void Explode()
    {
        Debug.Log("boom!");

        //Cria uma esfera ao redor da granada usando a variável "raio"
        //Então guarda em um array todos os objetos com colliders que estiverem no raio da esfera
        Collider[] colliders = Physics.OverlapSphere(transform.position, raio);

        //Procura por objetos do tipo Explodable dentro daquela array
        foreach (Collider objetoProximo in colliders)
        {
            Explodable expl = objetoProximo.GetComponent <Explodable>();

            //Se encontrar um objeto do tipo Explodable com o mesmo TipoGranada executa o efeito deste TipoGranada
            if (expl != null && expl.tg == tg)
            {
                switch (tg)
                {
                case TipoGranada.DESTROY:
                    expl.Destroy();
                    break;

                case TipoGranada.GELO:
                    expl.Freeze();
                    break;
                }
            }
        }

        //Explode a granada
        Destroy(gameObject);
        explodiu = true;
    }
Beispiel #14
0
    void applyDamage(GameObject nearbyObject)
    {
        switch (nearbyObject.name)
        {
        case "Player(Clone)":
            //Debug.Log ("Player in Granade");
            //Move player by the explosion
//			Rigidbody2D rb = nearbyObject.GetComponent<Rigidbody2D> ();
//			if (rb != null) {
//				rb.AddForce (Vector2 (2f, 2f));
//			}
            PlayerController player = nearbyObject.GetComponent <PlayerController> ();
            player.decreaseHealth(damage);
            break;

        case "block":
            //Debug.Log ("Block in Granade");
            Explodable _explo = nearbyObject.GetComponent <Explodable> ();
            _explo.explode();
            break;

        default:
            //Debug.Log ("Default in Granade: " + gameObject.name);
            break;
        }
    }
    public override void OnFragmentsGenerated(List <GameObject> fragments)
    {
        Explodable _explodable = GetComponent <Explodable> ();

        foreach (GameObject fragment in fragments)
        {
            Collider2D col = fragment.GetComponent <Collider2D> ();
            col.attachedRigidbody.useAutoMass = true;
            col.density = 100;

            fragment.AddComponent <Gravity> ();

            Explodable fragExp = fragment.AddComponent <Explodable> ();
            fragExp.shatterType = Explodable.ShatterType.Voronoi;
            fragExp.allowRuntimeFragmentation = true;
            fragExp.extraPoints      = 0;
            fragExp.fragmentLayer    = _explodable.fragmentLayer;
            fragExp.sortingLayerName = _explodable.sortingLayerName;
            fragExp.orderInLayer     = _explodable.orderInLayer;

            fragment.AddComponent <EarthBlock> ();

            fragment.layer = _explodable.gameObject.layer;
        }
    }
Beispiel #16
0
    void Start()
    {
        exp = gameObject.GetComponent <Explodable>();
        SpriteRenderer tr = gameObject.GetComponent <SpriteRenderer>();

        height = tr.bounds.size.y * transform.localScale.x;
        y      = transform.position.y;
    }
Beispiel #17
0
 private void SpawnExploder()
 {
     exploderParent.DestroyChildren();
     exploder = Instantiate(exploderPrefab, exploderParent);
     exploder.transform.localPosition = Vector3.zero;
     exploder.transform.localRotation = Quaternion.identity;
     explosionForce = exploder.GetComponent <ExplosionForce>();
 }
Beispiel #18
0
 private void Awake()
 {
     explodable                  = GetComponent <Explodable>();
     inAcid                      = transform.GetChild(0).gameObject;
     inAcidStartScale            = inAcid.transform.localScale;
     increaseScale               = new Vector3(0, inAcidStartScale.y / _acidCollectMax, 0);
     inAcid.transform.localScale = new Vector3(1, 0, 1);
     PreCalcSpreadAngle();
 }
    IEnumerator FinishAttack(Explodable explodable, LaserBeam leftBeam, LaserBeam rightBeam)
    {
        yield return(new WaitForSeconds(m_attackDuration));

        Destroy(leftBeam.gameObject);
        Destroy(rightBeam.gameObject);

        explodable.Explode();
    }
    // Start is called before the first frame update
    void Start()
    {
        expl   = GetComponent <Explodable>();
        player = GameObject.FindObjectOfType <ControllerPersonaje>().gameObject;
        BoxCollider2D coll = GetComponent <BoxCollider2D>();

        coll.isTrigger = true;
        coll.size     *= 1.2f;
    }
Beispiel #21
0
 void Update()
 {
     if (m_controllerIndex != -1 && m_explodable != null && SteamVR_Controller.Input(m_controllerIndex).GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger))
     {
         CatHead catHead = FindObjectOfType <CatHead>();
         catHead.Attack(m_explodable);
         m_explodable = null;
     }
 }
Beispiel #22
0
    void OnTriggerExit(Collider other)
    {
        Explodable explodable = other.GetComponent <Explodable> ();

        if (explodable != null)
        {
            _explodables.Remove(explodable);
        }
    }
Beispiel #23
0
    void OnTriggerEnter(Collider other)
    {
        Explodable explodable = other.GetComponent <Explodable> ();

        if (explodable != null)
        {
            _explodables.Add(explodable);
        }
    }
Beispiel #24
0
    void OnTriggerEnter(Collider other)
    {
        Explodable explodable = other.gameObject.GetComponent <Explodable>();

        if (explodable)
        {
            explodable.Explode();
            Destroy(gameObject);
        }
    }
Beispiel #25
0
    void Awake()
    {
        m_Explodable = GameObject.Instantiate(Resources.Load("Prefabs/HuLuBroken") as GameObject).GetComponent <Explodable>();
        m_Explodable.m_ObjParents = m_ObjParent;

        m_Explodable.fragmentInEditor();
        m_Explodable.transform.SetParent(this.transform);
        m_Explodable.transform.localPosition = Vector3.zero;
        m_Explodable.transform.eulerAngles   = Vector3.zero;
        m_Explodable.transform.localScale    = Vector3.one;
    }
    public IEnumerator ShowExplosion(Vector3 pos, Quaternion rotation, Explodable expl, float delay)
    {
        yield return(new WaitForSeconds(delay));

        if (expl.DoShowIndirectExplosions())
        {
            Instantiate(explosion, pos, rotation);
        }
        // explode it for real
        expl.Explode(this, BarrelExplosionPwr);
    }
Beispiel #27
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("bullet"))
     {
         Explodable exploder = GetComponent <Explodable>();
         exploder.explode();
         foreach (GameObject fragment in exploder.fragments)
         {
             Destroy(fragment, 3.0f);
         }
     }
 }
 protected override void Awake()
 {
     base.Awake();
     curHealth = maxHealth;
     coll      = GetComponent <Collider2D>();
     expl      = GetComponent <Explodable>();
     if (expl != null)
     {
         expl.deleteFragments();
         addon = GetComponent <MyFragmentsAddon>();
     }
 }
 void Execute()
 {
     GameObject[] selection = Selection.gameObjects;
     foreach (GameObject obj in selection)
     {
         Explodable explodable = obj.GetComponent <Explodable>();
         if (explodable != null)
         {
             explodable.Explode();
         }
     }
 }
Beispiel #30
0
 void Awake()
 {
             #if UNITY_EDITOR
     if (EditorApplication.isPlaying)
     {
                     #endif
     Debug.Log("Generate cave");
     _explodable = GetComponent <Explodable> ();
     _explodable.explode();
                     #if UNITY_EDITOR
 }
             #endif
 }
	// Use this for initialization
	void Start () {
        explodable = GetComponent<Explodable>();
	}