コード例 #1
0
    public void Init(BattleWarrior warrior)
    {
        this.warrior    = warrior;
        value           = startValue;
        parentTransform = transform.parent.GetComponent <RectTransform> ();
        InvokeRepeating("MoveForward", 0, 0.01f);

        switch (warrior.type)
        {
        case BattleWarrior.WarriorType.Default:
            line.GetComponent <Image>().color = neutralColor;
            circle.color = neutralColor;
            break;

        case BattleWarrior.WarriorType.Player:
            line.GetComponent <Image>().color = playerColor;
            circle.color = playerColor;
            break;

        case BattleWarrior.WarriorType.Enemy:
            line.GetComponent <Image>().color = enemyColor;
            circle.color = enemyColor;
            break;
        }

        portrait.sprite             = warrior.smallPortrait;
        randomInitiativeModificator = Random.Range(-0.5f, 0.5f);
        visualValue = (value - 0.5f) * parentTransform.rect.height;

        transform.localPosition = new Vector3(transform.localPosition.x, visualValue, transform.localPosition.z);
    }
コード例 #2
0
 private void Depointed(BattleWarrior warrior)
 {
     if (warrior)
     {
         warrior.GetComponent <WarriorSelector> ().DeHighlight();
     }
 }
コード例 #3
0
ファイル: HexField.cs プロジェクト: makaronnik13/HexFight
        public void SelectWarrior(BattleWarrior warrior)
        {
            GameController.Instance.Warrior = warrior;
            Vector2 p = WarriorCell(warrior).coord;

            Highlighter.HighlightArea(WarriorCell(warrior), GetComponent <HexPathFinder>().GetAwaliableCells(WarriorCell(warrior), warrior.Ap), CellsHighlighter.HighlightLayer.Selection, 0);
        }
コード例 #4
0
 private void DepointWarrior(BattleWarrior warrior)
 {
     if (GameController.Instance.Mode == GameController.GameMode.Battle)
     {
         ShowWarrior(lastWarrior);
     }
 }
コード例 #5
0
 private void SelectWarrior(BattleWarrior warrior)
 {
     if (GameController.Instance.Mode == GameController.GameMode.Battle)
     {
         lastWarrior = warrior;
         ShowWarrior(lastWarrior);
     }
 }
コード例 #6
0
 public void SelectWarrior(BattleWarrior warrior)
 {
     FindObjectOfType <HexField> ().OnHexClicked -= HexClicked;
     this.warrior = warrior;
     if (warrior)
     {
         FindObjectOfType <HexField> ().OnHexClicked += HexClicked;
         SelectPointToAtack();
     }
 }
コード例 #7
0
 public BattleWarrior(BattleWarrior item)
 {
     /*    this.atk = item.atk;
      *  this.atk = item.characterId;
      *  this.atk = item.dataEquipmentUserId;
      *  this.atk = item.def;
      *  this.atk = item.exp;
      *  this.atk = item.hp;
      *  this.atk = item.level;
      *  this.atk = item.luck;
      *  this.atk = item.lvPlus;
      *  this.atk = item.;*/
 }
コード例 #8
0
    void SetWarriorToBattleList()
    {
        for (int i = 0; i < team.Count; i++)
        {
            BattleWarrior temp  = null;
            BattleWarrior temp2 = null;
            temp = new BattleWarrior();
            temp.setDataWarrior(team[i], readData.languageId);
            allWar.Add(temp);

            temp2 = new BattleWarrior();
            temp2.setDataWarrior(team[i], readData.languageId);
            allWarOrigin.Add(temp2);
        }
    }
コード例 #9
0
ファイル: Npc.cs プロジェクト: makaronnik13/HexFight
    private void Update()
    {
        if (interractionEnable)
        {
            Vector3    aimPoint = transform.position + transform.forward * 1.5f;
            NavMeshHit hit;
            NavMesh.SamplePosition(aimPoint, out hit, 2, NavMesh.AllAreas);

            BattleWarrior w = GameController.Instance.Warrior;
            if (w && w.GetComponent <NavMeshAgent>().destination == hit.position && Vector3.Distance(hit.position, w.transform.position) <= w.GetComponent <NavMeshAgent>().stoppingDistance)
            {
                Talk();
            }
        }
    }
コード例 #10
0
 private void ShowWarrior(BattleWarrior warrior)
 {
     Hide();
     if (GameController.Instance.Mode == GameController.GameMode.Battle)
     {
         if (warrior)
         {
             foreach (Transform t in transform)
             {
                 t.gameObject.SetActive(true);
             }
             WarriorPortrait.sprite = warrior.portrait;
             ApSlider.Init(warrior);
         }
     }
 }
コード例 #11
0
    private BattleWarrior PickTarget(BattleWarrior character, List <BattleWarrior> listAll)
    {
        BattleWarrior        temp = null;
        List <BattleWarrior> listAllTemp;

        int[] setOfposition;

        if (character.typeOfChar == 1)
        {
            listAllTemp = listAll.FindAll(x => (x.hp > 0) && (x.typeOfChar == 2));
        }
        else
        {
            listAllTemp = listAll.FindAll(x => (x.hp > 0) && (x.typeOfChar == 1));
        }


        if (character.position == 1 || character.position == 2)
        {
            setOfposition = new int[] { 1, 2, 3, 4, 5, 6 };
            for (int i = 0; (i < setOfposition.Length) && (temp == null); i++)
            {
                temp = listAllTemp.Find(x => x.position == setOfposition[i]);
            }
        }
        else if (character.position == 5 || character.position == 6)
        {
            setOfposition = new int[] { 5, 6, 3, 4, 1, 2 };

            for (int i = 0; (i < setOfposition.Length) && (temp == null); i++)
            {
                temp = listAllTemp.Find(x => x.position == setOfposition[i]);
            }
        }
        else
        {
            setOfposition = new int[] { 3, 4, 1, 2, 5, 6 };

            for (int i = 0; (i < setOfposition.Length) && (temp == null); i++)
            {
                temp = listAllTemp.Find(x => x.position == setOfposition[i]);
            }
        }

        return(temp);
    }
コード例 #12
0
 public void Init(BattleWarrior warrior)
 {
     if (currentWarrior)
     {
         switch (type)
         {
         case SliderType.Ap:
             currentWarrior.OnApChanged -= ValueChanged;
             break;
         }
     }
     currentWarrior = warrior;
     switch (type)
     {
     case SliderType.Ap:
         currentWarrior.OnApChanged += ValueChanged;
         SetValues(currentWarrior.Ap, currentWarrior.MaxAp);
         break;
     }
 }
コード例 #13
0
    void SetEnemyToBattleList(List <string> enemyList)
    {
        BattleWarrior temp  = null;
        BattleWarrior temp2 = null;

        for (int i = 0; i < enemyList.Count; i++)
        {
            temp  = new BattleWarrior();
            temp2 = new BattleWarrior();
            if (enemyIdWave1[i] != "0")
            {
                temp.setDataEnemy(enemyList[i], readData.jsonEnemyData, readData.jsonEnemySkillData, readData.languageId);
                temp2.setDataEnemy(enemyList[i], readData.jsonEnemyData, readData.jsonEnemySkillData, readData.languageId);



                allWar.Add(temp);
                allWarOrigin.Add(temp2);
            }
        }
    }
コード例 #14
0
    private void Pointed(BattleWarrior warrior)
    {
        if (warrior)
        {
            Color color = Color.white;
            switch (warrior.type)
            {
            case BattleWarrior.WarriorType.Default:
                color = Color.white;
                break;

            case BattleWarrior.WarriorType.Player:
                color = Color.green;
                break;

            case BattleWarrior.WarriorType.Enemy:
                color = Color.red;
                break;
            }

            warrior.GetComponent <WarriorSelector> ().Highlight(color);
        }
    }
コード例 #15
0
    private void SelectWarrior(BattleWarrior warrior)
    {
        if (this.warrior)
        {
            RemoveRaycasters();
            foreach (PlayerFollower pf in FindObjectsOfType <PlayerFollower>())
            {
                Destroy(pf);
            }
        }

        if (warrior)
        {
            this.warrior = warrior.GetComponent <FakeController> ();
        }
        else
        {
            this.warrior = null;
        }


        if (this.warrior)
        {
            AddRaycasters();
            int i = 0;

            foreach (BattleWarrior bw in FindObjectsOfType <BattleWarrior>())
            {
                if (bw != this.warrior.GetComponent <BattleWarrior>() && bw.type == BattleWarrior.WarriorType.Player)
                {
                    bw.gameObject.AddComponent <PlayerFollower> ().Init(i, FindObjectsOfType <BattleWarrior>().Length, formationType, formationScale);
                    i++;
                }
            }
        }
    }
コード例 #16
0
 public void SelectWarrior(BattleWarrior bw)
 {
     HexBattleStateMachine.Instance.SelectWarrior(bw);
 }
コード例 #17
0
ファイル: HexField.cs プロジェクト: makaronnik13/HexFight
 public Cell WarriorCell(BattleWarrior warrior)
 {
     return(cells.Where(c => c.cellWarrior == warrior).ToList()[0]);
 }
コード例 #18
0
    private IEnumerator WaitForS()
    {
        //foreach (BattleLog log in battleLog)
        for (int i = 0; i < battleLog.Count; i++)
        {
            yield return(new WaitForSeconds(2));

            string   tempname = "";
            int      position = 0;
            Vector3  position2;
            Animator animator;

            float[] animatetimeAtk = new float[] { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
            float[] animatetime1   = new float[] { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
            float[] animatetime2   = new float[] { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
            float[] animatetime3   = new float[] { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };

            List <float[]> animateSkillTime = new List <float[]>();
            animateSkillTime.Add(animatetimeAtk);
            animateSkillTime.Add(animatetime1);
            animateSkillTime.Add(animatetime2);
            animateSkillTime.Add(animatetime3);

            int countCombo = 0;

            GameObject    monsterBody     = null;
            GameObject    monsterFile     = null;
            BattleWarrior attacker        = null;
            Skill         skillTemp       = null;
            float[]       tempAnimateTime = animatetimeAtk;
            int           hitAmount       = 1;
            string        skillName       = "Attack!";

            if (battleLog[i].skillId != 0)
            {
                if (battleLog[i].typeOfCharAtk == 1)
                {
                    attacker = allWarOrigin.Find(x => battleLog[i].attackerUserId == x.warriorUserId);
                }
                else
                {
                    attacker = allWarOrigin.Find(x => (battleLog[i].attackerId == x.characterId) && (battleLog[i].positionAtk == x.position));
                }

                skillTemp = attacker.skillList.Find(x => x.skillId == battleLog[i].skillId);

                tempAnimateTime = animateSkillTime[battleLog[i].ordinal];
                skillName       = skillTemp.name[0].ToString() + "!";
                hitAmount       = skillTemp.hitAmount;
            }
            else
            {
            }

            if (battleLog[i].typeOfCharAtk == 1)
            {
                tempname = "Enemy" + battleLog[i].positionDef;

                position2 = new Vector3(enemyLocation[battleLog[i].positionDef - 1].position.x, enemyLocation[battleLog[i].positionDef - 1].position.y, enemyLocation[battleLog[i].positionDef - 1].position.z);
                Vector3 attackerPosition = new Vector3(warriorLocation[battleLog[i].positionAtk - 1].position.x, warriorLocation[battleLog[i].positionAtk - 1].position.y + 200, warriorLocation[battleLog[i].positionAtk - 1].position.z);

                animator = GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk + "/entity_01(Clone)").GetComponent <Animator>();
                GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().endPosition   = GameObject.Find("Canvas/Enemy" + battleLog[i].positionDef).transform;
                GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().charType      = 1;
                GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().mode          = 1;
                GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().startCastTime = 0;
                monsterBody = GameObject.Find("Canvas");


                GameObject skillNamePrefab = (GameObject)Resources.Load("Prefab/SkillName", typeof(GameObject));
                GameObject tempSkillName   = Instantiate(skillNamePrefab, attackerPosition, Quaternion.identity) as GameObject;
                tempSkillName.GetComponent <Text>().text = skillName;
                tempSkillName.transform.parent           = monsterBody.transform;
                tempSkillName.transform.localScale       = new Vector3(1, 1, 1);
                tempSkillName.transform.localPosition    = attackerPosition;
                tempSkillName.GetComponent <DamagePopupScript>().FadeOut();

                yield return(new WaitForSeconds(0.25f));

                if (battleLog[i].skillId == 0)
                {
                    animator.Play("Atk");
                }
                else
                {
                    animator.Play("Skill" + battleLog[i].ordinal);
                }

                yield return(new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length));



                if ((i + 1) == battleLog.Count || battleLog[i + 1].attackerUserId != battleLog[i].attackerUserId)
                {
                    //GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent<WarriorStageScript>().startCastTime = 0;
                    GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().charType      = 1;
                    GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().mode          = 2;
                    GameObject.Find("Canvas/Warrior" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().startCastTime = 0;
                    //yield return new WaitForSeconds(0.25f);
                }
                animator = GameObject.Find("Canvas/" + tempname + "/entity_01(Clone)").GetComponent <Animator>();
                animator.Play("Hit");
            }
            else
            {
                tempname = "Warrior" + battleLog[i].positionDef;

                position2 = new Vector3(warriorLocation[battleLog[i].positionDef - 1].position.x, warriorLocation[battleLog[i].positionDef - 1].position.y, warriorLocation[battleLog[i].positionDef - 1].position.z);
                Vector3 attackerPosition = new Vector3(enemyLocation[battleLog[i].positionAtk - 1].position.x, enemyLocation[battleLog[i].positionAtk - 1].position.y + 200, enemyLocation[battleLog[i].positionAtk - 1].position.z);
                //animator = GameObject.Find("Canvas/" + tempname + "/entity_01(Clone)").GetComponent<Animator>();
                //animator.Play("Hit");
                //***********
                animator = GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk + "/entity_01(Clone)").GetComponent <Animator>();
                GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().endPosition   = GameObject.Find("Canvas/Warrior" + battleLog[i].positionDef).transform;
                GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().charType      = 2;
                GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().mode          = 1;
                GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().startCastTime = 0;

                monsterBody = GameObject.Find("Canvas");
                GameObject skillNamePrefab = (GameObject)Resources.Load("Prefab/SkillName", typeof(GameObject));
                GameObject tempSkillName   = Instantiate(skillNamePrefab, attackerPosition, Quaternion.identity) as GameObject;
                tempSkillName.GetComponent <Text>().text = skillName;
                tempSkillName.transform.parent           = monsterBody.transform;
                tempSkillName.transform.localScale       = new Vector3(1, 1, 1);
                tempSkillName.transform.localPosition    = attackerPosition;
                tempSkillName.GetComponent <DamagePopupScript>().FadeOut();

                yield return(new WaitForSeconds(0.25f));

                if (battleLog[i].skillId == 0)
                {
                    animator.Play("Atk");
                }
                else
                {
                    animator.Play("Skill" + battleLog[i].ordinal);
                    if (battleLog[i].ordinal == 3)
                    {
                        Animator animatorEffect = GameObject.Find("Canvas/Warrior1/entity_01(Clone)").GetComponent <Animator>();
                        animatorEffect.SetFloat("light", 1f);
                    }
                }

                yield return(new WaitForSeconds(0.25f));

                animator = GameObject.Find("Canvas/" + tempname + "/entity_01(Clone)").GetComponent <Animator>();
                animator.Play("Hit");

                if ((i + 1) == battleLog.Count || battleLog[i + 1].positionAtk != battleLog[i].positionAtk)
                {
                    //GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent<WarriorStageScript>().startCastTime = 0;
                    GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().charType      = 2;
                    GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().mode          = 2;
                    GameObject.Find("Canvas/Enemy" + battleLog[i].positionAtk).GetComponent <WarriorStageScript>().startCastTime = 0;

                    //yield return new WaitForSeconds(0.25f);
                }


                //yield return new WaitForSeconds(0.25f);
            }


            //
            //   float length = animator.GetCurrentAnimatorStateInfo(0).length;


            monsterFile = (GameObject)Resources.Load("Prefab/Damage", typeof(GameObject));



            for (int j = 0; j < hitAmount; j++)
            {
                GameObject tempDmg    = Instantiate(monsterFile, position2, Quaternion.identity) as GameObject;
                int        realDamage = 0;
                if (battleLog[i].skillId != 0)
                {
                    realDamage = battleLog[i].dmg * Convert.ToInt32(skillTemp.hitDmg[j]) / 100;
                }
                else
                {
                    realDamage = battleLog[i].dmg;
                }

                tempDmg.GetComponent <Text>().text = realDamage.ToString();
                tempDmg.transform.parent           = monsterBody.transform;

                tempDmg.transform.localScale = new Vector3(1, 1, 1);
                //if (animation["x"].enabled && animation["x"].time == 0)
                //audio.clip = xsound;
                soundManager.GetComponent <SoundManagerScript>().PlayEffect();
                //atk1.Play();
                //tempDmg.transform.localPosition = new Vector3(1, 1, 1);
                tempDmg.GetComponent <DamagePopupScript>().FadeOut();

                HealthbarScript health = GameObject.Find(tempname + "/Healthbar").GetComponent <HealthbarScript>();
                health.hp -= battleLog[i].dmg;
                animator.SetFloat("hp", health.hp);

                yield return(new WaitForSeconds(tempAnimateTime[j]));

                //GameObject.Find("Canvas/" + tempname).GetComponent<WarriorStageScript>().mode = 0;
                //Destroy(tempDmg);
                Debug.Log("wait");
            }

            if ((i + 1) == battleLog.Count || battleLog[i + 1].positionAtk != battleLog[i].positionAtk)
            {
                animator.Play("Dead");
            }
        }

        endofreplay = 1;
    }
コード例 #19
0
    public int ActionSkill(BattleWarrior target, List <BattleLog> battleLog)
    {
        //normal atk
        int dmg = atk;

        dmg        = atk / 1;
        target.hp -= dmg;
        BattleLog log = new BattleLog();

        log.attackerId     = this.characterId;
        log.defenderId     = target.characterId;
        log.attackerUserId = this.warriorUserId;
        log.defenderUserId = target.warriorUserId;
        log.typeOfCharAtk  = this.typeOfChar;
        log.dmg            = dmg;
        log.skillId        = 0;
        log.positionAtk    = this.position;
        log.positionDef    = target.position;
        battleLog.Add(log);

        //skill
        foreach (Skill skill in skillList)
        {
            if (skill.useWhen != 4)
            {
                if (UnityEngine.Random.Range(1, 1) <= skill.percentUse)
                {
                    //dmg = skill.dmg * atk;
                    dmg                = atk / 1;
                    target.hp         -= dmg;
                    log                = new BattleLog();
                    log.attackerId     = this.characterId;
                    log.defenderId     = target.characterId;
                    log.attackerUserId = this.warriorUserId;
                    log.defenderUserId = target.warriorUserId;
                    log.typeOfCharAtk  = this.typeOfChar;
                    log.dmg            = dmg;
                    log.hitAmount      = skill.hitAmount;
                    log.skillId        = skill.skillId;
                    log.ordinal        = skill.ordinal;
                    log.positionAtk    = this.position;
                    log.positionDef    = target.position;
                    battleLog.Add(log);
                }
                else
                {
                    break;
                }
            }
        }

        if (target.hp <= 0 && this.hp <= 0)
        {
            return(3);
        }
        else if (target.hp > 0 && this.hp > 0)
        {
            return(4);
        }
        else if (target.hp <= 0)
        {
            return(1);
        }
        else
        {
            return(2);
        }
    }
コード例 #20
0
 public void AddWarrior(BattleWarrior bw)
 {
     //Lean.Pool.LeanPool.Spawn(token, transform.GetChild(1).position, Quaternion.identity, transform.GetChild(1)).GetComponent<InitiativeToken>().Init(bw);
     Instantiate(token, transform.GetChild(1).position, Quaternion.identity, transform.GetChild(1)).GetComponent <InitiativeToken>().Init(bw);
 }
コード例 #21
0
    void CalculatePhase()
    {
        List <BattleWarrior> tempDie = new List <BattleWarrior>();

        battleStatus = 0;

        int round = 0;

        for (int i = 1; i <= 1; i++)
        {
            allWar = allWar.OrderByDescending(x => x.spd).ToList();

            while (result)
            {
                //start calulate result
                battleStatus = 1;
                round++;
                Debug.Log("start round " + round);

                foreach (BattleWarrior character in allWar)
                {
                    if (character.hp > 0)
                    {
                        BattleWarrior target       = PickTarget(character, allWar);
                        int           resultBattle = character.ActionSkill(target, battleLog);

                        if (resultBattle == 1)
                        {
                            tempDie.Add(target);
                        }
                        else if (resultBattle == 2)
                        {
                            tempDie.Add(character);
                        }
                        else if (resultBattle == 4)
                        {
                        }
                        else
                        {
                            tempDie.Add(target);
                            tempDie.Add(character);
                        }

                        //check result
                        if (allWar.FindAll(x => (x.typeOfChar == 1) && (x.hp > 0)).Count == 0)
                        {
                            //lose
                            result       = false;
                            battleStatus = 3;
                            break;
                        }
                        else if (allWar.FindAll(x => (x.typeOfChar == 2) && (x.hp > 0)).Count == 0)
                        {
                            //win
                            result       = false;
                            battleStatus = 2;
                            break;
                        }
                        else
                        {
                            //continute
                            result = true;
                        }
                    }
                }

                //remove all character for next round
                foreach (BattleWarrior temp3 in tempDie)
                {
                    allWar.Remove(temp3);
                }



                //Limit round
                if (round >= 30)
                {
                    //draw
                    result = false;
                    Debug.Log("draw");
                    battleStatus = 4;
                }
                else if (battleStatus == 1)
                {
                    Debug.Log("continute");
                    Debug.Log("end round " + round);
                }
                else if (battleStatus == 2)
                {
                    Debug.Log("win");
                }
                else if (battleStatus == 3)
                {
                    Debug.Log("lose");
                }
            }

            //clear origin enemy for next wave
            //allWarOrigin.RemoveAll(x => x.typeOfChar == 2);
        }
    }