public virtual IEnumerator Effect(HexagonMapEditor editor, Grid hexGrid, int x, int z, int size) // does the effect of the hazard on the tiles that are in its size
    {
        List <HexagonCell> frontier = new List <HexagonCell>();                                      // list of nodes that the hazard has effect over
        HexagonCell        curr     = hexGrid.Get_Cell_Index(new HexagonCoord(x, z));

        //Debug.Log(type_name  +" hazard epicenter at: " + curr.coords.x + "," + curr.coords.Y_coord + "," + curr.coords.z);
        for (int i = 0; i < hexGrid.cells.Length; i++)
        {
            int distance = curr.coords.FindDistanceTo(hexGrid.cells[i].coords);
            if (distance <= size)
            {
                frontier.Add(hexGrid.cells[i]);
            }
        }
        for (int j = 0; j < frontier.Count; j++)
        {
            if (frontier[j].occupied)
            {
                frontier[j].unitOnTile.current_health -= 10;
                Debug.Log("Hazard effected " + frontier[j].unitOnTile.unit_name + " for 10 damage");
            }
        }
        yield return(new WaitForSeconds(anim_time));

        Debug.Log("effect finishing");
    }
Пример #2
0
    //private

    // Use this for initialization
    void Start()
    {
        Debug.Log("Shit Bird-------------------------");
        Editor_Obj = GameObject.Find("Editor");
        Editor     = Editor_Obj.GetComponent <HexagonMapEditor>();
        //GameObject.Find("EventSystem").GetComponent<EventSystem>().SetSelectedGameObject(Conf_Button);
        currently_selected = "YES";
        gameObject.SetActive(false);
    }
    void Start()
    {
        Editor = Editor_Obj.GetComponent <HexagonMapEditor>();
        cursor = cursor_obj.GetComponent <Cursor>();
        _Grid  = Grid_obj.GetComponent <Grid>();
        // 1. Get the data to be displayed
        ListItems = new ArrayList()
        {
            new UI_List_Item(IconImages[0],
                             "Select Unit"),
            new UI_List_Item(IconImages[1],
                             "Deselect Unit"),
            new UI_List_Item(IconImages[2],
                             "Pause Game"),
            new UI_List_Item(IconImages[0],
                             "Move Unit"),
            new UI_List_Item(IconImages[3],
                             "Cycle Through Units")
        };

        // 2. Iterate through the data,
        //	  instantiate prefab,
        //	  set the data,
        //	  add it to panel
        float num_of_items        = ListItems.Count;
        float curr_num_counter    = 0;
        float desired_width_ratio = 0.1666f; //one eighth of the total size

        foreach (UI_List_Item list_item in ListItems)
        {
            GameObject newListItem = Instantiate(ListItemPrefab) as GameObject;
            UI_List    controller  = newListItem.GetComponent <UI_List>();
            controller.Icon_Obj.GetComponent <Image>().sprite  = list_item.Icon;
            controller.Con_Text_Obj.GetComponent <Text>().text = list_item.Con_Text;
            newListItem.transform.SetParent(UI_ListPanel.transform, false);
            newListItem.transform.localScale = Vector3.one;
            //max x and min x should always be 1 and 0 respectively, but min and max y should change
            float max_y_anchor = 1 - (curr_num_counter * desired_width_ratio);
            float min_y_anchor = 1 - ((curr_num_counter + 1) * desired_width_ratio);
            newListItem.GetComponent <RectTransform>().anchorMax = new Vector2(1, max_y_anchor);
            newListItem.GetComponent <RectTransform>().anchorMin = new Vector2(0, min_y_anchor);
            newListItem.GetComponent <RectTransform>().sizeDelta = UI_ListPanel.GetComponent <RectTransform>().rect.size;
            newListItem.GetComponent <RectTransform>().offsetMax = new Vector2(0, 0);
            newListItem.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0);
            curr_num_counter += 1;
        }
    }
Пример #4
0
    // Use this for initialization
    public void Start()
    {
        attackSound.playOnAwake = false;
        hitSound.playOnAwake    = false;
        moveSound.playOnAwake   = false;

        editor              = FindObjectOfType <HexagonMapEditor>();
        anim                = GetComponent <Animator>();
        current_health      = health;
        current_mobility    = mobility;
        currently_attacking = false;
        crit_buff           = false;
        attack_buff         = false;
        health_buff         = false;
        move_buff           = false;
        fortress_def_buff   = false;
        health_color        = health_bar.GetComponent <Image>().color;
        color_should_be     = Color.white;
    }
Пример #5
0
    public override IEnumerator Effect(HexagonMapEditor editor, Grid hexGrid, int x, int z, int size)
    {
        //Debug.Log("poison gas hurting people");
        List <HexagonCell> frontier = new List <HexagonCell>(); // list of nodes that the hazard has effect over
        HexagonCell        curr     = hexGrid.Get_Cell_Index(new HexagonCoord(x, z));

        //Debug.Log(type_name + " hazard epicenter at: " + curr.coords.x + "," + curr.coords.Y_coord + "," + curr.coords.z);
        for (int i = 0; i < hexGrid.cells.Length; i++)
        {
            int distance = curr.coords.FindDistanceTo(hexGrid.cells[i].coords);
            if (distance <= size)
            {
                frontier.Add(hexGrid.cells[i]);
            }
        }
        for (int j = 0; j < frontier.Count; j++)
        {
            if (frontier[j].occupied && frontier[j].unitOnTile.gameObject.tag != gameObject.tag)
            {
                //frontier[j].unitOnTile.current_health -= damageDealt;

                StartUnit  attacked_unit = frontier[j].unitOnTile;
                GameObject damagetext    = Instantiate(attacked_unit.FloatingTextPrefab, attacked_unit.transform.position, Quaternion.identity, attacked_unit.transform);
                damagetext.GetComponent <TextMesh>().color         = Color.yellow;
                damagetext.GetComponent <TextMesh>().characterSize = 0.03f + (0.06f * ((float)10 / 75f));
                damagetext.GetComponent <TextMesh>().text          = damageDealt.ToString();

                if (Mathf.Sign(damagetext.transform.parent.localScale.x) == -1 && Mathf.Sign(damagetext.transform.localScale.x) == 1)
                {
                    damagetext.gameObject.transform.localScale = new Vector3(damagetext.transform.localScale.x * -1, damagetext.transform.localScale.y,
                                                                             damagetext.transform.localScale.z);

                    //damagetext.GetComponent<TextMesh>().color = Color.green;
                    //Debug.Log("BackWards Text");
                }
                else
                {
                    if (Mathf.Sign(damagetext.transform.parent.localScale.x) == 1 && Mathf.Sign(damagetext.transform.localScale.x) == -1)
                    {
                        damagetext.gameObject.transform.localScale = new Vector3(damagetext.transform.localScale.x * -1, damagetext.transform.localScale.y,
                                                                                 damagetext.transform.localScale.z);
                    }
                }
                attacked_unit.TakeDamage(attacked_unit, damageDealt); // true damage so no need to incorporate
                attacked_unit.PlayHit();
                attacked_unit.PlayBlink(editor.Unit_Hurt_Color, attacked_unit, Time.time + 1f);

                if (attacked_unit.current_health <= 0)
                {
                    attacked_unit.dead = true;
                    editor.Units_To_Delete.Add(frontier[j]);
                    PoisonHero pHero;
                    if (gameObject.tag == "Player 1")
                    {
                        pHero = editor.P1Team[0].GetComponent <PoisonHero>();
                    }
                    else
                    {
                        pHero = editor.P2Team[0].GetComponent <PoisonHero>();
                    }
                    if (attacked_unit.tag == "TeamBuff") // was a buffmonster
                    {
                        GameObject buffItem = Instantiate(pHero.FloatingBuffPrefab, pHero.transform.position, Quaternion.identity, pHero.transform);
                        int        randBuff = Random.Range(0, 4);
                        //give correct buff accordingly
                        Debug.Log("acquiring buff");
                        if (randBuff == 0) // movement buff
                        {
                            buffItem.GetComponent <SpriteRenderer>().sprite = pHero.mobilityBuff;
                            Debug.Log(name + " got a movement buff");
                            pHero.current_mobility += 1;
                            pHero.move_buff         = true;
                            if (pHero.current_health != pHero.health)
                            {
                                pHero.current_health += 10;
                            }
                        }
                        else if (randBuff == 1) // crit buff
                        {
                            buffItem.GetComponent <SpriteRenderer>().sprite = pHero.critBuff;
                            Debug.Log(name + " got a crit buff");
                            pHero.crit     += 0.20f;
                            pHero.crit_buff = true;
                            if (pHero.current_health != pHero.health)
                            {
                                pHero.current_health += 10;
                            }
                        }
                        else if (randBuff == 2) // attack buff
                        {
                            Debug.Log(name + " got an attack buff");
                            buffItem.GetComponent <SpriteRenderer>().sprite = pHero.attackBuff;
                            pHero.attack         += 25;
                            pHero.current_attack += 25;
                            pHero.attack_buff     = true;
                            if (pHero.current_health != pHero.health)
                            {
                                pHero.current_health += 10;
                            }
                        }
                        else // health buff
                        {
                            Debug.Log(name + " got a health buff");
                            buffItem.GetComponent <SpriteRenderer>().sprite = pHero.healthBuff;
                            pHero.health         += 100;
                            pHero.current_health += 100;

                            pHero.health_buff = true;
                        }
                        if (pHero.current_health > (pHero.health * 0.4f))
                        {
                            pHero.anim.SetBool("Injured", false);
                            pHero.Injured = false;
                        }
                        float healthpercent = pHero.current_health / pHero.health; //    120/180 = .667

                        float attack_deduction = 1 - healthpercent;                //   1 - .667 = .333
                        float reduction        = attack_deduction / 2;
                        float new_attack       = pHero.attack * reduction;         //   72 * .333 = 23.76
                        pHero.current_attack = pHero.attack + new_attack;          // 72 - 23.76 = 48

                        gameObject.GetComponentInChildren <Buff_UI_Manager>().update_current_buffs(pHero);
                    }
                }
            }
        }
        GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>().fizzleSound.Play();
        yield return(new WaitForSeconds(anim_time));

        GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>().fizzleSound.Stop();
        Debug.Log("effect finishing");
    }
Пример #6
0
    public override IEnumerator Effect(HexagonMapEditor editor, Grid hexGrid, int x, int z, int size)
    {
        List <HexagonCell> frontier = new List <HexagonCell>(); // list of nodes that the hazard has effect over
        HexagonCell        curr     = hexGrid.Get_Cell_Index(new HexagonCoord(x, z));

        Debug.Log(type_name + " hazard epicenter at: " + curr.coords.x + "," + curr.coords.Y_coord + "," + curr.coords.z);
        curr.CreateMissile();
        GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>().launchSound.Play(); // play launch sound instead
        for (int i = 0; i < hexGrid.cells.Length; i++)
        {
            int distance = curr.coords.FindDistanceTo(hexGrid.cells[i].coords);
            if (distance <= size)
            {
                frontier.Add(hexGrid.cells[i]);
                hexGrid.cells[i].Create_Caution_Sign();
            }
        }
        yield return(new WaitForSeconds(anim_time - 1));

        GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>().explosionSound.Play(); // play explosion sound instead

        for (int j = 0; j < frontier.Count; j++)
        {
            Destroy(frontier[j].Caution_Sign_Obj);

            if (frontier[j].occupied)
            {
                //frontier[j].unitOnTile.current_health -= damage - frontier[j].unitOnTile.defense; // this should be changeed when we are trying to implement the fortress hero's defense

                StartUnit  attacked_unit = frontier[j].unitOnTile;
                GameObject damagetext    = Instantiate(attacked_unit.FloatingTextPrefab, attacked_unit.transform.position, Quaternion.identity, attacked_unit.transform);
                damagetext.GetComponent <TextMesh>().color         = Color.yellow;
                damagetext.GetComponent <TextMesh>().characterSize = 0.03f + (0.06f * ((float)10 / 75f));
                damagetext.GetComponent <TextMesh>().text          = (damage - frontier[j].unitOnTile.defense).ToString();

                if (Mathf.Sign(damagetext.transform.parent.localScale.x) == -1 && Mathf.Sign(damagetext.transform.localScale.x) == 1)
                {
                    damagetext.gameObject.transform.localScale = new Vector3(damagetext.transform.localScale.x * -1, damagetext.transform.localScale.y,
                                                                             damagetext.transform.localScale.z);

                    //damagetext.GetComponent<TextMesh>().color = Color.green;
                    //Debug.Log("BackWards Text");
                }
                else
                {
                    if (Mathf.Sign(damagetext.transform.parent.localScale.x) == 1 && Mathf.Sign(damagetext.transform.localScale.x) == -1)
                    {
                        damagetext.gameObject.transform.localScale = new Vector3(damagetext.transform.localScale.x * -1, damagetext.transform.localScale.y,
                                                                                 damagetext.transform.localScale.z);
                    }
                }

                attacked_unit.TakeDamage(attacked_unit, (damage - frontier[j].unitOnTile.defense));
                attacked_unit.PlayHit();
                attacked_unit.PlayBlink(editor.Unit_Hurt_Color, attacked_unit, Time.time + 1f);

                if (attacked_unit.current_health <= 0)
                {
                    attacked_unit.dead = true;
                    editor.Units_To_Delete.Add(frontier[j]);
                }
            }
        }
        yield return(new WaitForSeconds(1f));

        Debug.Log("effect finishing");
        Destroy(curr.Missile_Obj);
    }