Exemplo n.º 1
0
		public virtual void createMinion (Assets.Scripts.Engine.Minions.Minion minion)
		{
			this.minion = minion;
			minion.tag = this;
			minionObject = (GameObject)GameObject.Instantiate(childStaticMinionObject);
			minionObject.name = "m_" + minion.instanceId;
			
            healthBar = minionObject.transform.FindChild("HealthBar").gameObject.GetComponent<HealthBarDrawer>();
		    if (healthBar != null)
		    {
		        healthBar.health = (int) minion.stats.health;
		        healthBar.maxHealth = (int) minion.stats.healthTotal;
		    }


		    animations = (Animation[]) minionObject.GetComponentsInChildren<Animation>();
            foreach (Animation animation in animations)
                if(animation["walk"] != null)
			        animation["walk"].speed = minion.stats.baseMovementSpeed * walkAnimationSpeedMultiplier();

			rangeProjector = (Projector)GameObject.Instantiate(childStaticRangeProjector);
			rangeProjector.transform.parent = minionObject.transform;
			rangeProjector.transform.localPosition = new Vector3(0, 0.2f, 0);
			rangeProjector.orthographicSize = 0.2f;
			rangeProjector.enabled = false;

		    soundPlayer = minionObject.AddComponent<AudioSource>();
		    soundPlayer.volume = 2;
            soundPlayer.rolloffMode = AudioRolloffMode.Linear;
		    if (spawnSound == null)
		        spawnSound = Resources.Load<AudioClip>("Sound/minion_spawn");
		    soundPlayer.clip = spawnSound;
            soundPlayer.Play();
		}
Exemplo n.º 2
0
        public virtual void createMinion(Assets.Scripts.Engine.Minions.Minion minion)
        {
            this.minion       = minion;
            minion.tag        = this;
            minionObject      = (GameObject)GameObject.Instantiate(childStaticMinionObject);
            minionObject.name = "m_" + minion.instanceId;

            healthBar = minionObject.transform.FindChild("HealthBar").gameObject.GetComponent <HealthBarDrawer>();
            if (healthBar != null)
            {
                healthBar.health    = (int)minion.stats.health;
                healthBar.maxHealth = (int)minion.stats.healthTotal;
            }


            animations = (Animation[])minionObject.GetComponentsInChildren <Animation>();
            foreach (Animation animation in animations)
            {
                if (animation["walk"] != null)
                {
                    animation["walk"].speed = minion.stats.baseMovementSpeed * walkAnimationSpeedMultiplier();
                }
            }

            rangeProjector = (Projector)GameObject.Instantiate(childStaticRangeProjector);
            rangeProjector.transform.parent        = minionObject.transform;
            rangeProjector.transform.localPosition = new Vector3(0, 0.2f, 0);
            rangeProjector.orthographicSize        = 0.2f;
            rangeProjector.enabled = false;

            soundPlayer             = minionObject.AddComponent <AudioSource>();
            soundPlayer.volume      = 2;
            soundPlayer.rolloffMode = AudioRolloffMode.Linear;
            if (spawnSound == null)
            {
                spawnSound = Resources.Load <AudioClip>("Sound/minion_spawn");
            }
            soundPlayer.clip = spawnSound;
            soundPlayer.Play();
        }