Esempio n. 1
0
    public void ClearOtherSelection()
    {
        Totems = GameObject.FindGameObjectsWithTag("Totem");

        foreach (GameObject Totem in Totems)
        {
            if (Totem != ActiveTotem || EnemyTotem)
            {
                Totem.GetComponentInChildren <Renderer>().material = Totem.GetComponentInChildren <Totem>().TotemMat;
            }
        }
    }
Esempio n. 2
0
        void OnCollisionEnter2D(Collision2D collision)
        {
            if (collision.transform.gameObject == this.Player)
            {
                Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider);
            }

            string tag = collision.collider.tag;

            if (tag == "TerrainObject")
            {
                Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider);
                Terrain2 t   = collision.gameObject.GetComponent <Terrain2>();
                float    tmp = destructionCircle.radius;
                destructionCircle.radius = radius;
                t.DestroyGround(destructionCircle);
                destructionCircle.radius = tmp;
            }
            else if (tag.Contains("Player"))
            {
                int          id     = collision.collider.gameObject.GetInstanceID();
                GameObject[] totems = GameObject.FindGameObjectsWithTag(tag.Replace("Module", ""));
                foreach (GameObject g in totems)
                {
                    Totem totem = g.GetComponent <Totem>();
                    foreach (GameObject mod in totem.Modulos)
                    {
                        if (mod.GetInstanceID() == id)
                        {
                            if (totem.IgluActivado() && (mod.GetInstanceID() == totem.GetIDModuloProtegidoIglu()))
                            {
                                Iglu ig = totem.GetComponentInChildren <Iglu>();
                                ig.IncNumeroUsos();
                                Destroy(this.gameObject);
                            }
                            else
                            {
                                totem.SendMessage("Damage", new HealthEvent(gameObject, damage));
                                totem.DecreaseVida();
                            }
                        }
                    }
                }
            }

            GameObject executeDeathExplosion = Instantiate(this.explosion, this.gameObject.transform.position, this.explosion.transform.rotation);

            Destroy(executeDeathExplosion, executeDeathExplosion.GetComponent <AudioSource>().clip.length);

            Destroy(this.gameObject);
        }
Esempio n. 3
0
    public void ClearSelection()
    {
        Totems = GameObject.FindGameObjectsWithTag("Totem");

        foreach (GameObject Totem in Totems)
        {
            Totem.GetComponentInChildren <Renderer>().material = Totem.GetComponentInChildren <Totem>().TotemMat;
        }
        EnebattleHUD.ResetHUD(EnemyTotem);
        CurrbattleHUD.ResetHUD(ActiveTotem);
        EnemyTotem    = null;
        ActiveTotem   = null;
        Selectedtotem = null;

        ClearOtherSelection();
    }
Esempio n. 4
0
        void OnCollisionEnter2D(Collision2D collision)
        {
            if (collision.transform.gameObject == this.Player)
            {
                Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider);
            }

            string tag = collision.collider.tag;

            if (tag == "TerrainObject")
            {
                if (!ignore)
                {
                    Invoke("Explosion", 2);
                }
                ignore = true;
            }
            else if (tag.Contains("Player"))
            {
                int          id     = collision.collider.gameObject.GetInstanceID();
                GameObject[] totems = GameObject.FindGameObjectsWithTag(tag.Replace("Module", ""));
                foreach (GameObject g in totems)
                {
                    Totem totem = g.GetComponent <Totem>();
                    foreach (GameObject mod in totem.Modulos)
                    {
                        if (mod.GetInstanceID() == id)
                        {
                            if (totem.IgluActivado() && (mod.GetInstanceID() == totem.GetIDModuloProtegidoIglu()))
                            {
                                Iglu ig = totem.GetComponentInChildren <Iglu>();
                                ig.IncNumeroUsos();
                                Destroy(this.gameObject);
                            }
                            else
                            {
                                totem.SendMessage("Damage", new HealthEvent(gameObject, damage));
                                totem.DecreaseVida();
                            }
                        }
                    }
                }
            }

            this.collision = collision;
        }
Esempio n. 5
0
    public void Selection()

    {
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            Ray        toMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit rhInfo;
            //bool didHit = Physics.Raycast(toMouse, out rhInfo, 500.0f);
            if (Physics.Raycast(toMouse, out rhInfo, rayLength, layermask))
            {
                Selectedtotem = rhInfo.collider.gameObject.GetComponent <Totem>();
                Debug.Log(rhInfo.collider.name);
                FindObjectOfType <SoundManager>().Play("SelectAudio");
                switch (BattleGameState)
                {
                case GameState.PLAYER_1_TURN:
                    switch (Selectedtotem.totemIs)
                    {
                    case WhatisTotem.O:
                        ActiveTotem = Selectedtotem;

                        ActiveTotem.GetComponentInChildren <Renderer>().material = HighlightedMat;
                        CurrbattleHUD.SetHUD(ActiveTotem);

                        break;

                    case WhatisTotem.X:
                        EnemyTotem = Selectedtotem;

                        EnemyTotem.GetComponentInChildren <Renderer>().material = EneMat;
                        EnebattleHUD.SetHUD(EnemyTotem);
                        break;


                    default:
                        break;
                    }


                    break;

                case GameState.PLAYER_2_TURN:
                    switch (Selectedtotem.totemIs)
                    {
                    case WhatisTotem.X:
                        ActiveTotem = Selectedtotem;

                        ActiveTotem.GetComponentInChildren <Renderer>().material = HighlightedMat;
                        CurrbattleHUD.SetHUD(ActiveTotem);
                        break;

                    case WhatisTotem.O:
                        EnemyTotem = Selectedtotem;
                        EnemyTotem.GetComponentInChildren <Renderer>().material = EneMat;
                        EnebattleHUD.SetHUD(EnemyTotem);
                        break;

                    default:
                        break;
                    }



                    break;
                }
            }


            else
            {
                ClearOtherSelection();
                ClearSelection();
                Debug.Log("Nothing");
            }
        }
    }