コード例 #1
0
ファイル: TokenSpawnPoint.cs プロジェクト: szhangGT/Rangers
 /// <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());
     }
 }
コード例 #2
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;
 }
コード例 #3
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;
     }
 }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: TokenSpawnPoint.cs プロジェクト: Dattebane/Rangers
 /// <summary>
 /// Initializes the spawn point
 /// </summary>
 public void Init()
 {
     if (TokenSpawner.instance.Tokens.Count > 0)
     {
         // Add a repeating timer to keep spawning tokens
         RepetitionTimer t = gameObject.AddComponent <RepetitionTimer>();
         t.Initialize(10f, "Token Spawn Timer");
         t.TimeOut += new RepetitionTimer.TimerEvent(SpawnTokenHelper);
     }
 }
コード例 #6
0
ファイル: TokenSpawnPoint.cs プロジェクト: Dattebane/Rangers
 /// <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);
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 // Target for the timer's final timeout
 private void FinalHit(RepetitionTimer t)
 {
     Destroy(this);
 }
コード例 #9
0
 // Target for the repeating timer
 private void DamagePlayer(RepetitionTimer t)
 {
     controller.LifeComponent.ModifyHealth(-damage, fromPlayer);
 }