private void SpawnFish(RepetitionTimer t)
 {
     Bounds b = GameManager.instance.field.GetComponent<Collider2D>().bounds;
     Vector2 pos = new Vector2(Random.Range(b.min.x, b.max.x), Random.Range(b.min.y, b.max.y));
     GameObject fish = (GameObject)Instantiate(fishPrefab, pos, Quaternion.identity);
     fish.GetComponent<Fish>().Game = this;
 }
Пример #2
0
 void Start()
 {
     // Get all AcidAttacks already on the player (this component should have at least been added)
     AcidAttack[] currentAttacks = gameObject.GetComponents<AcidAttack>();
     // If this component is not the only AcidAttack on the player
     if(currentAttacks.Length > 1)
     {
         for(int i  = 0; i < currentAttacks.Length; i++)
         {
             // Reset the timer if it is the original timer and not this timer
             if(currentAttacks[i] != this) currentAttacks[i].Timer.Reset();
         }
         // Destroy this AcidAttack because it is not the original
         Destroy(this);
     }
     // This is the only AcidAttack on the player
     else
     {
         // Initialize the acid attack
         controller = GetComponent<Controller>();
         t = gameObject.AddComponent<RepetitionTimer>();
         t.Initialize(damageInterval, "Acid Attack", numHits);
         t.TimeOut += new RepetitionTimer.TimerEvent(DamagePlayer);
         t.FinalTick += FinalHit;
     }
 }
Пример #3
0
        /// <summary>
        /// Creates a repetition timer on a GameObject.
        /// </summary>
        /// <param name="gameObject">The game object to add the timer to.</param>
        /// <param name="interval">How long the timer will run for.</param>
        /// <param name="id">ID of the timer.</param>
        /// <param name="timerEvent">The function to call when the timer runs out.</param>
        public static void CreateTimer(GameObject gameObject, float interval, string id, TimerEvent timerEvent)
        {
            RepetitionTimer timer = gameObject.AddComponent <RepetitionTimer>();

            timer.Initialize(interval, id);
            timer.TimeOut += new RepetitionTimer.TimerEvent(timerEvent);
        }
        public override void Init()
        {

            inGameBaskets = new List<Basket>();
            finished = false;
            spawnTimer = gameObject.AddComponent<RepetitionTimer>();
            spawnTimer.Initialize(0.5f, "Fish Spawner");
            spawnTimer.TimeOut += new RepetitionTimer.TimerEvent(SpawnFish);
            spawnTimer.FinalTick += new RepetitionTimer.TimerEvent(SpawnFish);
            fishCaught = new int[4];
            Winners = new System.Collections.Generic.List<PlayerID>();

			for(int i = 0; i < GameManager.instance.AllPlayers.Count; i++)
			{
				GameManager.instance.AllPlayers[i].LifeComponent.Health = 100;
				GameManager.instance.AllPlayers[i].Anim.SetBool("Stay Dead", false);
				GameManager.instance.AllPlayers[i].Active = true;
			}

            if (GameManager.instance.CharacterToPlayer.ContainsKey(Util.Enums.Characters.Opochtli))
            {
                Basket b = ((GameObject)Instantiate(baskets[0], new Vector2(-5, 1), Quaternion.identity)).GetComponent<Basket>();
				b.RespawnAt(new Vector2(-5,1));
                b.Character = Util.Enums.Characters.Opochtli;
                inGameBaskets.Add(b);
            }
            if (GameManager.instance.CharacterToPlayer.ContainsKey(Util.Enums.Characters.Zolin))
            {
                Basket b = ((GameObject)Instantiate(baskets[1], new Vector2(-5, -3), Quaternion.identity)).GetComponent<Basket>();
				b.RespawnAt(new Vector2(-5,-3));
                b.Character = Util.Enums.Characters.Zolin;
                inGameBaskets.Add(b);
            }
            if (GameManager.instance.CharacterToPlayer.ContainsKey(Util.Enums.Characters.Yaotl))
            {
                Basket b = ((GameObject)Instantiate(baskets[2], new Vector2(5, 1), Quaternion.identity)).GetComponent<Basket>();
				b.RespawnAt(new Vector2(5,1));
                b.Character = Util.Enums.Characters.Yaotl;
                inGameBaskets.Add(b);
            }
            if (GameManager.instance.CharacterToPlayer.ContainsKey(Util.Enums.Characters.Coatl))
            {
                Basket b = ((GameObject)Instantiate(baskets[3], new Vector2(5, -3), Quaternion.identity)).GetComponent<Basket>();
				b.RespawnAt(new Vector2(5,-3));
                b.Character = Util.Enums.Characters.Coatl;
                inGameBaskets.Add(b);
            }
        }
Пример #5
0
 /// <summary>
 /// Spawns a token when timer times out
 /// </summary>
 /// <param name="t">Timer that is spawning tokens</param>
 private void SpawnTokenHelper(RepetitionTimer t)
 {
     if (!HasToken()) SpawnToken(TokenSpawner.instance.GetToken());
 }
Пример #6
0
 // Target for the timer's final timeout
 private void FinalHit(RepetitionTimer t)
 {
     Destroy(this);
 }
Пример #7
0
 // Target for the repeating timer
 private void DamagePlayer(RepetitionTimer t)
 {
     controller.LifeComponent.ModifyHealth(-damage, fromPlayer);
 }
 /// <summary>
 /// Spawns a token when timer times out
 /// </summary>
 /// <param name="t">Timer that is spawning tokens</param>
 private void SpawnTokenHelper(RepetitionTimer t)
 {
     if (!HasToken()) SpawnToken(TokenSpawner.instance.GetToken());
     else spawnItem.gameObject.SetActive(false);
     
 }
Пример #9
0
		/// <summary>
		/// Initializes the acid timer.
		/// </summary>
		private void InitializeTimer() {
			t = gameObject.AddComponent<RepetitionTimer>();
			t.Initialize(damageInterval, "Acid Attack", numHits);
			t.TimeOut += new RepetitionTimer.TimerEvent(DamagePlayer);
			t.FinalTick += FinalHit;
		}