public void Initialize(ActData act, Button BackButton = null)
    {
        this.act = act;

        print("Selected Act[" + act.ActNumber + "] " + act.Name);
        ActNumber.text = "Act " + act.ActNumber;
        ActName.text   = act.Name;
        container.DOAnchorPosX(0f, 0f);

        MoveZoneInformation(PrefType.LAST_SELECTED_ZONE.GetInt(0), true);
        PopulateZones();
        ClearPartyList();

        for (int h = 0; h < 5; h++)
        {
            HeroDisplay hd = _partyList.GetOrCreate(HeroPrefab, partyArea.transform);
            hd.isClearable  = true;
            hd.isUsingFades = true;
            hd.Btn_ClearSlot();
            hd.Initialize(null, HeroListFilterType.Level, OnPartySlotSelected);
            hd.btnClear.onClick.AddListener(() => OnPartySlotClear(hd));
        }

        this.BackButton = BackButton;

        if (PlayerPrefs.GetInt("tutorial_step") == 7)
        {
            StoryManager.Instance.DisplayStory("story_tutorial_explore_choose_zone");

            PlayerPrefs.SetInt("tutorial_step", 8);
        }
    }
    void EnemySetUp()
    {
        GameObject  go      = Instantiate(heroPrefab, new Vector3(enemyPortraitSpawn.position.x, enemyPortraitSpawn.position.y, enemyPortraitSpawn.position.z), Quaternion.identity);
        HeroDisplay display = go.GetComponent <HeroDisplay>();

        display.HeroSetUp(enemyHero);
    }
    public void OnPartySlotSelected(HeroDisplay member)
    {
        DeselectAllParty();
        _currentPartyMemberSelector = member;

        member.Selected();
    }
Example #4
0
    public void dealDamage(int p)
    {
        GameObject  p2HeroDef = GameObject.Find("Player2");
        HeroDisplay a2        = p2HeroDef.GetComponent <HeroDisplay>();

        int P2hpc0 = Convert.ToInt32(a2.healthText.text);

        GameObject  p1C0Atk = GameObject.Find("P1Card " + p);
        CardDisplay a       = p1C0Atk.GetComponent <CardDisplay>();
        int         magic   = a.Amount;

        P2hpc0 = P2hpc0 - magic;

        // โช ผล
        string z = "-" + a.Amount.ToString();;

        a2.hDamage(z, 1.5f);

        a2.healthText.text = P2hpc0.ToString();

        if (P2hpc0 <= 0)
        {
            GameLevelManager.instance.endGame(2f, 1);
        }
    }
Example #5
0
    public void Attacks(int value)
    {
        //Loads the hero's in for easy finding of targets
        HeroDisplay pos1  = GameObject.FindWithTag("Hero1").GetComponent <HeroDisplay>();
        HeroDisplay pos2  = GameObject.FindWithTag("Hero2").GetComponent <HeroDisplay>();
        HeroDisplay pos3  = GameObject.FindWithTag("Hero3").GetComponent <HeroDisplay>();
        Hero        hero1 = pos1.getHero();
        Hero        hero2 = pos2.getHero();
        Hero        hero3 = pos3.getHero();

        switch (value)
        {
        //Add attacks by adding cases
        case 1:

            StartCoroutine(Attack1());
            break;

        case 2:
            StartCoroutine(Attack2());
            break;

        case 3:
            StartCoroutine(Attack3());
            break;
        }
    }
    public void ShowHeroSelect()
    {
        AudioManager.Instance.Play(SFX_UI.WooshIn);

        _heroesList.SetActiveForAll(false);

        List <Hero> heroes = PlayerManager.Instance.GetFilteredHeroes(filter);

        trace("Should be showing heroes: " + heroes.Count + " / " + _heroesList.Count);

        foreach (Hero hero in heroes)
        {
            if (selectedPartyMembers.Contains(hero))
            {
                continue;
            }

            HeroDisplay hd = _heroesList.GetOrCreate(HeroPrefab, HeroSelectContainer);

            hd.Initialize(hero, filter, OnHeroSelected);
        }

        HeroSelectPanel.DOAnchorPosX(0f, 0.5f)
        .SetEase(Ease.OutSine);
    }
Example #7
0
    private void PlayerSetup()
    {
        GameObject  go      = Instantiate(avatarPrefab, new Vector3(playerAvatarSpawn.position.x, playerAvatarSpawn.position.y, -1.5f), Quaternion.identity);
        HeroDisplay display = go.GetComponent <HeroDisplay>();

        display.HeroSetup(playerHero);
    }
Example #8
0
    public void PopulateHeroList()
    {
        List <Hero> heroes = PlayerManager.Instance.GetFilteredHeroes(filter, true);

        if (heroes.Count < 1)
        {
            noHeroesText.gameObject.SetActive(true);
            noHeroesText.text = "No Heroes To Display";
            return;
        }
        else
        {
            noHeroesText.gameObject.SetActive(false);
        }

        heroGOList.SetActiveForAll(false);

        txtFilter.text = "<color=#ddd>SORT BY:</color> " + filter; //.ToString()

        // Load Heroes
        for (int c = 0; c < heroes.Count; c++)
        {
            SpawnHero(heroes[c]);
        }

        HeroDisplay firstAvailableHero = heroGOList.Find(hd => hd.hero.ExploringActZone < 1);

        HeroSelected(firstAvailableHero);
    }
Example #9
0
    IEnumerator Attack3()
    {
        GameObject    scene  = GameObject.FindWithTag("ActionCam");
        BattleManager battle = GameObject.FindWithTag("BattleManager").GetComponent <BattleManager>();
        HeroDisplay   pos1   = GameObject.FindWithTag("Enemy1").GetComponent <HeroDisplay>();
        HeroDisplay   pos2   = GameObject.FindWithTag("Enemy2").GetComponent <HeroDisplay>();
        HeroDisplay   pos3   = GameObject.FindWithTag("Enemy3").GetComponent <HeroDisplay>();
        Enemy         enemy1 = pos1.GetEnemy();
        Enemy         enemy2 = pos2.GetEnemy();
        Enemy         enemy3 = pos3.GetEnemy();

        List <Damagable> enemies = new List <Damagable>();
        List <Vector3>   pos     = new List <Vector3>();
        List <string>    buff    = new List <string>();

        if (enemy1.isAlive())
        {
            enemies.Add(enemy1);
            pos.Add(new Vector3(0, 100, 0));
            buff.Add("+25% Damage");
        }
        if (enemy2.isAlive())
        {
            enemies.Add(enemy2);
            pos.Add(new Vector3(400, 100, 0));
            buff.Add("+25% Damage");
        }
        if (enemy3.isAlive())
        {
            enemies.Add(enemy3);
            pos.Add(new Vector3(800, 100, 0));
            buff.Add("+25% Damage");
        }


        battle.DisplayAbilityName("Rally to the Light");
        pos1.SelectTarget();
        pos2.SelectTarget();
        pos3.SelectTarget();


        yield return(new WaitForSeconds(1));

        enemy1.AddMod("attack", Mathf.RoundToInt(enemy1.getAttackDamage() * 0.25f), 2);
        enemy2.AddMod("attack", Mathf.RoundToInt(enemy2.getAttackDamage() * 0.25f), 2);
        enemy3.AddMod("attack", Mathf.RoundToInt(enemy3.getAttackDamage() * 0.25f), 2);

        List <int> pose = new List <int>();

        pose.Add(1);
        pose.Add(1);
        pose.Add(1);



        scene.GetComponent <DisplayScene>().BattleDisplayBase(enemies, pos, buff, pose);

        battle.ViewBattle(0);
    }
Example #10
0
    void SpawnHero(Hero hero)
    {
        tempHeroPanel = heroGOList.GetOrCreate(heroPrefab, container, isAnchoredZero: true);

        // Init the UI
        tempHeroPanel.isDisabledIfExploring = true;
        tempHeroPanel.Initialize(hero, filter, HeroSelected);
    }
    // playersetup
    private void Player2Setup()
    {
        GameObject go = Instantiate(avatarPrefab, new Vector3(enemyAvatarSpawn.position.x,
                                                              enemyAvatarSpawn.position.y, -1.5f), Quaternion.identity);
        HeroDisplay display = go.GetComponent <HeroDisplay>();

        display.HeroSetup(enemyHero);
        //ตั้งชื่อ obj
        go.name = "Player2";
    }
Example #12
0
    void HeroSelected(HeroDisplay heroDisplay)
    {
        if (heroDisplay == null)
        {
            return;
        }

        selectedHero = heroDisplay.hero;
        int index = 0;

        foreach (Hero h in heroes)
        {
            if (h == selectedHero)
            {
                SelectedHeroID = index;
            }

            index++;
        }

        foreach (HeroDisplay hd in heroGOList)
        {
            if (hd.gameObject.activeSelf)
            {
                hd.Deselect();
            }
        }

        heroDisplay.Selected();

        // Populate the selected data here
        selectedHeroName.text        = selectedHero.Name;
        selectedHeroDescription.text = "LVL " + selectedHero.Level + " " + selectedHero.data.Class + "\n" + selectedHero.GetPrimaryStat(PrimaryStats.Strength) + " STR - " + selectedHero.GetPrimaryStat(PrimaryStats.Vitality) + " VIT - " + selectedHero.GetPrimaryStat(PrimaryStats.Intelligence) + " INT - " + selectedHero.GetPrimaryStat(PrimaryStats.Speed) + " SPD";
        selectedHeroPortrait.sprite  = selectedHero.LoadPortraitSprite();

        Destroy(selectedHeroAnimations);
        selectedHeroAnimations = Instantiate(selectedHero.LoadUIAnimationReference());

        RectTransform rect = selectedHeroAnimations.GetRect();

        rect.SetParent(uiHeroContainer);
        rect.anchoredPosition = new Vector2(0, 925f + rect.anchoredPosition.y);
        rect.localScale       = rect.localScale;

        var animHandler = selectedHeroAnimations == null ? null : selectedHeroAnimations.GetComponent <HeroUIAnimationHandler>();

        if (animHandler != null)
        {
            animHandler.Initialize(selectedHero);
        }
        else
        {
            traceError("Cannot find <HeroUIAnimationHandler> component on Hero '{0}'".Format2(selectedHero.data.FullIdentity));
        }
    }
    public void OnHeroSelected(HeroDisplay heroDisplay)
    {
        _currentHeroSelector = heroDisplay;

        if (_currentPartyMemberSelector == null)
        {
            print("Missing _currentPartyMemberSelector!");
            return;
        }

        SwapHeroes(heroDisplay.hero);
    }
Example #14
0
    public void cardAction(GameObject position)
    {
        BattleManager battle   = GameObject.FindWithTag("BattleManager").GetComponent <BattleManager>();
        HeroDisplay   display1 = position.GetComponent <HeroDisplay>();
        HeroDisplay   display2 = battle.currentChar().GetComponent <HeroDisplay>();
        Hero          hero1    = display1.getHero();
        Hero          hero2    = display2.getHero();

        battle.PosSwap(hero1, hero2);
        display1.updateChar(hero2);
        display2.updateChar(hero1);
        battle.MinusAction();
    }
Example #15
0
    IEnumerator Attack1()
    {
        GameObject    scene  = GameObject.FindWithTag("ActionCam");
        BattleManager battle = GameObject.FindWithTag("BattleManager").GetComponent <BattleManager>();
        HeroDisplay   pos1   = GameObject.FindWithTag("Hero1").GetComponent <HeroDisplay>();
        HeroDisplay   pos2   = GameObject.FindWithTag("Hero2").GetComponent <HeroDisplay>();
        HeroDisplay   pos3   = GameObject.FindWithTag("Hero3").GetComponent <HeroDisplay>();
        Hero          hero1  = pos1.getHero();
        Hero          hero2  = pos2.getHero();
        Hero          hero3  = pos3.getHero();

        List <Hero>    heroes  = new List <Hero>();
        List <Vector3> heroPos = new List <Vector3>();
        List <string>  damages = new List <string>();

        if (hero1.isAlive())
        {
            heroes.Add(hero1);
            heroPos.Add(new Vector3(900, 100, 0));
        }
        if (hero2.isAlive())
        {
            heroes.Add(hero2);
            heroPos.Add(new Vector3(700, 100, 0));
        }
        if (hero3.isAlive())
        {
            heroes.Add(hero3);
            heroPos.Add(new Vector3(500, 100, 0));
        }


        battle.DisplayAbilityName("Daunting \n Flames");
        pos1.SelectTarget();
        pos2.SelectTarget();
        pos3.SelectTarget();


        yield return(new WaitForSeconds(1));

        damages.Add(hero1.decreaseHealth(getAttackDamage() / 2, getBaseCrit()));
        damages.Add(hero2.decreaseHealth(getAttackDamage() / 2, getBaseCrit()));
        damages.Add(hero3.decreaseHealth(getAttackDamage() / 2, getBaseCrit()));


        scene.GetComponent <DisplayScene>().BattleDispayEnemyAttack(heroes, this.GetComponent <Enemy>(), heroPos, new Vector3(0, 100, 0), damages);



        battle.ViewBattle(0);
    }
Example #16
0
    public void cardAction(GameObject position)
    {
        HeroDisplay display = position.GetComponent <HeroDisplay>();
        Hero        hero    = display.getHero();


        BattleManager battle  = GameObject.FindWithTag("BattleManager").GetComponent <BattleManager>();
        GameObject    Display = GameObject.FindWithTag("ActionCam");

        Display.GetComponent <DisplayScene>().BattleDisplaySelf(hero, new Vector3(600, 50, 0), "Heal: " + hero.increaseHealth(.25f));
        battle.ViewBattle(0);

        battle.MinusAction();
    }
    public void OnPartySlotClear(HeroDisplay member)
    {
        if (_currentPartyMemberSelector == null)
        {
            return;
        }

        AudioManager.Instance.Play(SFX_UI.PageFlip);

        //PopulateHeroList(member.hero);
        selectedPartyMembers.Remove(member.hero);
        member.hero = null;

        ShowHeroSelect();
    }
Example #18
0
    public void healHero(int p)
    {
        GameObject  p2HeroDef = GameObject.Find("Player1");
        HeroDisplay a2        = p2HeroDef.GetComponent <HeroDisplay>();

        int P2hpc0 = Convert.ToInt32(a2.healthText.text);

        GameObject  p1C0Atk = GameObject.Find("P1Card " + p);
        CardDisplay a       = p1C0Atk.GetComponent <CardDisplay>();
        int         magic   = a.Amount;

        P2hpc0 = P2hpc0 + magic;

        // โช ผล
        string z = "+" + a.Amount.ToString();;

        a2.hDamage(z, 1.5f);

        a2.healthText.text = P2hpc0.ToString();
    }
Example #19
0
    public void cardAction(GameObject position)
    {
        HeroDisplay display = position.GetComponent <HeroDisplay>();
        Enemy       enemy   = display.GetEnemy();

        List <Enemy>   enemies  = new List <Enemy>();
        List <Vector3> EnemyPos = new List <Vector3>();
        List <string>  damage   = new List <string>();

        enemies.Add(enemy);
        EnemyPos.Add(new Vector3(0, 100, 0));
        damage.Add(enemy.decreaseHealth(hero.getAttackDamage(), hero.getBaseCrit()));

        GameObject Display = GameObject.FindWithTag("ActionCam");


        Display.GetComponent <DisplayScene>().BattleDispayAllyAttack(hero, enemies, EnemyPos, new Vector3(700, 100, 0), damage);
        battle.ViewBattle(0);

        battle.MinusAction();
    }
Example #20
0
    public void cardAction(GameObject pos)
    {
        hero = battle.getCurrent().GetComponent <Hero>();
        List <GameObject> hand = new List <GameObject>();

        hand = hero.GetComponent <DeckManager>().getInPlay();
        int count = 0;

        foreach (GameObject card in hand)
        {
            if (card.GetComponent <Treasure>() != null)
            {
                count++;
                hero.GetComponent <DeckManager>().Discard(card);
            }
        }

        HeroDisplay display = pos.GetComponent <HeroDisplay>();
        Enemy       enemy   = display.GetEnemy();

        List <Enemy>   enemies  = new List <Enemy>();
        List <Vector3> EnemyPos = new List <Vector3>();
        List <string>  damage   = new List <string>();

        enemies.Add(enemy);
        EnemyPos.Add(new Vector3(0, 100, 0));
        damage.Add(enemy.decreaseHealth(hero.getAttackDamage() * (1 + count), hero.getBaseCrit()));

        GameObject Display = GameObject.FindWithTag("ActionCam");


        Display.GetComponent <DisplayScene>().BattleDispayAllyAttack(hero, enemies, EnemyPos, new Vector3(700, 100, 0), damage);
        battle.ViewBattle(0);

        battle.MinusAction();
    }
Example #21
0
    private void OnMouseDown()
    {
        Debug.Log(gameObject.name);
        GameObject     p1C0Atk = GameObject.Find(gameObject.name);
        CretureDisplay a       = p1C0Atk.GetComponent <CretureDisplay>();

        for (int y = 0; y < 5; y++)
        {
            if (gameObject.name == "P2Creatre " + y)
            {
                i = y;
            }
        }

        if (Temp.instance.spawnPointBoard2[i] == true)
        {
            // ฝ่ายP2


            if (a.ischarge)
            {
                int atkc0 = Convert.ToInt32(a.attackValueText.text);
                int hpc0  = Convert.ToInt32(a.healthValueText.text);

                //ค้นหาเป้าหมาบบนboard
                if (Temp.instance.spawnPointBoard1[i] == true)
                {
                    GameObject     p2C0Def = GameObject.Find("P1Creatre " + i);
                    CretureDisplay a2      = p2C0Def.GetComponent <CretureDisplay>();
                    int            P2atkc0 = Convert.ToInt32(a2.attackValueText.text);
                    int            P2hpc0  = Convert.ToInt32(a2.healthValueText.text);

                    Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.nameText.text + " attack = " + P2atkc0 + " hp= " + P2hpc0);

                    // ฝ่ายโจมตี P2c0 ตี P1c0
                    P2hpc0 = P2hpc0 - atkc0;



                    // โช damage
                    string z = "-" + P2atkc0.ToString();;
                    a.ShowDamage(z, 1.5f);

                    a2.healthValueText.text = P2hpc0.ToString();
                    if (P2hpc0 <= 0)
                    {
                        Destroy(p2C0Def, 2);
                        Temp.instance.spawnPointBoard1[i] = false;
                    }

                    // ฝ่ายป้องกัน P1c0 ตี P2c0
                    hpc0 = hpc0 - P2atkc0;

                    // โช damage
                    string zz = "-" + atkc0.ToString();;
                    a2.ShowDamage(zz, 1.5f);

                    a.healthValueText.text = hpc0.ToString();

                    if (hpc0 <= 0)
                    {
                        Destroy(p1C0Atk, 2);
                        Temp.instance.spawnPointBoard2[i] = false;
                    }
                }
                else //ไม่เจอCreture ตี hero
                {
                    GameObject  p2HeroDef = GameObject.Find("Player1");
                    HeroDisplay a2        = p2HeroDef.GetComponent <HeroDisplay>();

                    int P2hpc0 = Convert.ToInt32(a2.healthText.text);
                    Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.gameObject.name + " hp= " + P2hpc0);

                    P2hpc0 = P2hpc0 - atkc0;

                    //countAtkHero = countAtkHero + atkc0;

                    // โช damage
                    string zz = "-" + atkc0.ToString();;

                    a2.hDamage(zz, 1.5f);

                    a2.healthText.text = P2hpc0.ToString();
                    if (P2hpc0 <= 0)
                    {
                        // endgame
                        GameLevelManager.instance.endGame(2f, 2);
                    }
                }
            }
            // set ว่าตีไปแล้ว

            a.ischarge = false;
        }
    }
Example #22
0
    IEnumerator Attack2()
    {
        GameObject    scene  = GameObject.FindWithTag("ActionCam");
        BattleManager battle = GameObject.FindWithTag("BattleManager").GetComponent <BattleManager>();
        HeroDisplay   pos1   = GameObject.FindWithTag("Hero1").GetComponent <HeroDisplay>();
        HeroDisplay   pos2   = GameObject.FindWithTag("Hero2").GetComponent <HeroDisplay>();
        HeroDisplay   pos3   = GameObject.FindWithTag("Hero3").GetComponent <HeroDisplay>();
        Hero          hero1  = pos1.getHero();
        Hero          hero2  = pos2.getHero();
        Hero          hero3  = pos3.getHero();

        List <Hero>    heroes  = new List <Hero>();
        List <Vector3> heroPos = new List <Vector3>();
        List <string>  damages = new List <string>();

        int choice = Random.Range(0, 3);

        heroPos.Add(new Vector3(700, 100, 0));

        if (choice == 0)
        {
            pos1.SelectTarget();
        }
        else if (choice == 1)
        {
            pos2.SelectTarget();
        }
        else
        {
            pos3.SelectTarget();
        }

        battle.DisplayAbilityName("Blinding Light");
        yield return(new WaitForSeconds(1));



        if (choice == 0)
        {
            heroes.Add(hero1);
            damages.Add(hero1.decreaseHealth(getAttackDamage(), getBaseCrit()));
            if (damages[0] != "Dodge")
            {
                hero1.AddMod("stun", 0, 1);
            }
        }
        else if (choice == 1)
        {
            heroes.Add(hero2);
            damages.Add(hero2.decreaseHealth(getAttackDamage(), getBaseCrit()));
            if (damages[0] != "Dodge")
            {
                hero2.AddMod("stun", 0, 1);
            }
        }
        else
        {
            heroes.Add(hero3);
            damages.Add(hero3.decreaseHealth(getAttackDamage(), getBaseCrit()));
            if (damages[0] != "Dodge")
            {
                hero3.AddMod("stun", 0, 1);
            }
        }


        scene.GetComponent <DisplayScene>().BattleDispayEnemyAttack(heroes, this.GetComponent <Enemy>(), heroPos, new Vector3(0, 100, 0), damages);

        battle.ViewBattle(0);
    }
Example #23
0
 private void Awake()
 {
     instance = this;
 }
Example #24
0
    public void P1attack()
    {
        for (int i = 0; i < spawnPointBoard1.Length; i++)
        {
            if (spawnPointBoard1[i] == true)
            {
                // ฝ่ายP1
                GameObject     p1C0Atk = GameObject.Find("P1Creatre " + i);
                CretureDisplay a       = p1C0Atk.GetComponent <CretureDisplay>();

                if (a.ischarge)
                {
                    int atkc0 = Convert.ToInt32(a.attackValueText.text);
                    int hpc0  = Convert.ToInt32(a.healthValueText.text);



                    //ค้นหาเป้าหมาบบนboard
                    if (spawnPointBoard2[i] == true)
                    {
                        GameObject     p2C0Def = GameObject.Find("P2Creatre " + i);
                        CretureDisplay a2      = p2C0Def.GetComponent <CretureDisplay>();
                        int            P2atkc0 = Convert.ToInt32(a2.attackValueText.text);
                        int            P2hpc0  = Convert.ToInt32(a2.healthValueText.text);

                        Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.nameText.text + " attack = " + P2atkc0 + " hp= " + P2hpc0);
                        // ฝ่ายโจมตี P1c0 ตี P2c0
                        P2hpc0 = P2hpc0 - atkc0;

                        // โช damage
                        string z = "-" + P2atkc0.ToString();;
                        a.ShowDamage(z, 1.5f);


                        a2.healthValueText.text = P2hpc0.ToString();

                        if (P2hpc0 <= 0)
                        {
                            Destroy(p2C0Def, 2);
                            spawnPointBoard2[i] = false;
                        }

                        // ฝ่ายป้องกัน P2c0 ตี P1c0
                        hpc0 = hpc0 - P2atkc0;

                        // โช damage
                        string zz = "-" + atkc0.ToString();;
                        a2.ShowDamage(zz, 1.5f);

                        a.healthValueText.text = hpc0.ToString();

                        if (hpc0 <= 0)
                        {
                            Destroy(p1C0Atk, 2);
                            spawnPointBoard1[i] = false;
                        }
                    }
                    else //ไม่เจอCreture ตี hero
                    {
                        GameObject  p2HeroDef = GameObject.Find("Player2");
                        HeroDisplay a2        = p2HeroDef.GetComponent <HeroDisplay>();

                        int P2hpc0 = Convert.ToInt32(a2.healthText.text);
                        Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.gameObject.name + " hp= " + P2hpc0);

                        P2hpc0       = P2hpc0 - atkc0;
                        countAtkHero = countAtkHero + atkc0;

                        // โช damage
                        string zz = "-" + countAtkHero.ToString();;
                        a2.hDamage(zz, 1.5f);

                        a2.healthText.text = P2hpc0.ToString();

                        if (P2hpc0 <= 0)
                        {
                            GameLevelManager.instance.endGame(2f, 1);
                        }
                    }
                }
                // set ว่าตีไปแล้ว

                a.ischarge = false;
            }
        }
        countAtkHero = 0;
        attackP1Button.gameObject.SetActive(false);
    }