コード例 #1
0
 // Use this for initialization
 void Start()
 {
     bossCannon = GameObject.Find("BossCannon");
     player = GameObject.Find("Player_ship");
     is_firing = false;
     healthBar = GameObject.Find("BossShip").GetComponent<HealthbarScript>();
 }
コード例 #2
0
    void SetStageForReplay(int waveNo)
    {
        foreach (BattleWarrior war in allWarOrigin)
        {
            string nameobject = "";
            if (war.typeOfChar == 1)
            {
                nameobject = "Canvas/Warrior" + war.position + "/Healthbar";

                Animator animator = GameObject.Find("Canvas/Warrior" + war.position + "/entity_01(Clone)").GetComponent <Animator>();
                animator.Play("Idle");


                if (waveNo == 1)
                {
                    HealthbarScript health = GameObject.Find(nameobject).GetComponent <HealthbarScript>();
                    GameObject.Find(nameobject).GetComponent <Image>().fillAmount = 1;
                    health.hp    = war.hp;
                    health.maxHp = war.hp;
                }
            }
            else
            {
                nameobject = "Canvas/Enemy" + war.position + "/Healthbar";

                Animator animator = GameObject.Find("Canvas/Enemy" + war.position + "/entity_01(Clone)").GetComponent <Animator>();
                animator.Play("Idle");

                HealthbarScript health = GameObject.Find(nameobject).GetComponent <HealthbarScript>();
                GameObject.Find(nameobject).GetComponent <Image>().fillAmount = 1;
                health.hp    = war.hp;
                health.maxHp = war.hp;
            }
        }
    }
コード例 #3
0
    public void UpdateHealth(int newhp)
    {
        health += newhp;
        GameObject      hbar    = GameObject.Find("Healthbar");
        HealthbarScript hscript = hbar.GetComponent <HealthbarScript>();

        hscript.UpdateHealthbar(health);
        if (health <= 0)
        {
            NaturalDeathTrigger();
        }
    }
コード例 #4
0
 public virtual void Initialize(float health, float speed, float range, float damage)
 {
     isDead           = false;
     _health          = health;
     _initialhealth   = health;
     _speed           = speed;
     _range           = range;
     _damage          = damage;
     _canMove         = true;
     _beingPushedBack = false;
     if (!healthbar)
     {
         healthbar = GetComponentInChildren <HealthbarScript>();
     }
     //if (!floatingCombatText)
     //{
     //    floatingCombatText = GetComponentInChildren<FloatingCombatText>();
     //}
     healthbar.Init(_health);
 }
コード例 #5
0
 // Start is called before the first frame update
 void Start()
 {
     playerHealth = FindObjectOfType <HealthbarScript>();
     StartCoroutine("WaveSpawner");
 }
コード例 #6
0
 public static void SetHealthBarScript(HealthbarScript hp)
 {
     hpScript = hp;
     SynchronizePlayerAndHealthbar();
 }
コード例 #7
0
 // Use this for initialization
 void Start()
 {
     bossHealthBar = GameObject.Find("BossShip").GetComponent<HealthbarScript>();
 }
コード例 #8
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;
    }