コード例 #1
0
        /// <summary>
        /// Uses this GameObject's relevant position as well as its faction to return a list of enemy Transforms that excludes this GameObject
        /// </summary>
        /// <param name="myTransform">Transform of GameObject to exclude</param>
        /// <param name="myFaction">Faction of GameObject to exclude</param>
        /// <returns></returns>
        public List <Transform> GetAllEnemyTransforms(Transform myTransform, Faction.Faction_ID myFaction)
        {
            List <Transform> enemyTransforms = new List <Transform>();

            try
            {
                foreach (GameObject m in GameObject.FindGameObjectsWithTag("Melee"))
                {
                    if (m != null && m.transform != myTransform && m.GetComponent <MeleeBehviour>().MeleeFaction != myFaction)
                    {
                        enemyTransforms.Add(m.transform);
                    }
                }

                foreach (GameObject r in GameObject.FindGameObjectsWithTag("Ranged"))
                {
                    if (r != null && r.transform != myTransform && r.GetComponent <RangedBehaviour>().RangedFaction != myFaction)
                    {
                        enemyTransforms.Add(r.transform);
                    }
                }

                foreach (GameObject w in GameObject.FindGameObjectsWithTag("Wizard"))
                {
                    if (w != null && w.transform != myTransform && w.GetComponent <WizardBehaviour>().WizardFaction != myFaction)
                    {
                        enemyTransforms.Add(w.transform);
                    }
                }

                foreach (GameObject rb in GameObject.FindGameObjectsWithTag("Resource"))
                {
                    if (rb != null && rb.transform != myTransform && rb.GetComponent <ResourceBehaviour>().ResourceFaction != myFaction)
                    {
                        enemyTransforms.Add(rb.transform);
                    }
                }

                foreach (GameObject fb in GameObject.FindGameObjectsWithTag("Factory"))
                {
                    if (fb != null && fb.transform != myTransform && fb.GetComponent <FactoryBehaviour>().FactoryFaction != myFaction)
                    {
                        enemyTransforms.Add(fb.transform);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }

            //Add other enemy types Transforms

            return(enemyTransforms);
        }
コード例 #2
0
        private IEnumerator DealDamageMelee(Collider other)
        {
            int enemyHealth = other.GetComponent <MeleeBehviour>().Health;

            Faction.Faction_ID targetFaction = other.GetComponent <MeleeBehviour>().MeleeFaction;

            GameObject target = other.gameObject;

            for (int i = 0; i < enemyHealth; i++)
            {
                if (target != null)
                {
                    other.gameObject.GetComponent <MeleeBehviour>().Health -= this.attack;
                }
                yield return(new WaitForSeconds(attackOverTime));
            }
        }
コード例 #3
0
 public WizardSerializer(int health, float[] position, Faction.Faction_ID faction)
 {
     this.health   = health;
     this.position = position;
     this.faction  = faction;
 }