コード例 #1
0
    public void HulkSmash()
    {
        GameObject[] blobbies = GameObject.FindGameObjectsWithTag("Blobby");
        if (blobbies.Length <= 1)
        {
            return;
        }

        GameObject victim = blobbies[Random.Range(0, blobbies.Length)];

        while (victim == gameObject)
        {
            victim = blobbies[Random.Range(0, blobbies.Length)];
        }

        Blobby b = victim.GetComponent <Blobby>();

        log.AddEvent($"{blobbyName} gets mad at {b.blobbyName} and attacks!");

        wanderLocation = victim.transform.position;
        attackTime     = 0;
        isWandering    = true;
        speed          = Random.Range(maxMovementSpeed / 2, maxMovementSpeed);
        wanderingTime  = wanderCooldown;
    }
コード例 #2
0
ファイル: BlobbyTrap.cs プロジェクト: jbasinger/LudumDare46
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Blobby b = collision.gameObject.GetComponent <Blobby>();

        if (b == null)
        {
            return;
        }

        TrappedBlobby trapped = Instantiate(trappedPrefab);

        trapped.color = b.color;
        trapped.worth = b.chonk;

        trapped.gameObject.transform.position = transform.position;

        shop.MakeMoney((int)b.GetBlobWorth());
        data.blobbiesSacrificed += 1;

        sound.PlayTrapClip();

        Destroy(gameObject);
        Destroy(b.gameObject);
        Destroy(trapped.gameObject, 10);
    }
コード例 #3
0
 void CompleteGame()
 {
     GameObject[] blobs = GameObject.FindGameObjectsWithTag("Blobby");
     gameData.blobbiesKeptAlive = blobs.Length;
     foreach (GameObject go in blobs)
     {
         Blobby blob = go.GetComponent <Blobby>();
         gameData.finalScore += (int)(blob.GetBlobWorth() * 2) + shop.coins;
     }
     SceneManager.LoadScene("GameComplete");
 }
コード例 #4
0
    void Update()
    {
        foreach (QueuedBlobby b in queuedBlobbies)
        {
            float progress = b.PercentComplete();

            if (b.Label != null)
            {
                b.Label.UpdateProgress(progress);
            }

            if (progress >= 1)
            {
                doneBlobbys.Add(b);
            }

            b.CurrentTime += Time.deltaTime;
        }

        bool didOne = false;

        foreach (QueuedBlobby b in doneBlobbys)
        {
            GameObject objBlobby   = Instantiate(blobbyPrefab);
            Blobby     freshBlobby = objBlobby.GetComponent <Blobby>();
            freshBlobby.transform.position = new Vector2(transform.position.x, transform.position.y) + Random.insideUnitCircle.normalized * 3;
            freshBlobby.color      = b.Color;
            freshBlobby.blobbyName = b.Name;
            log.AddEvent($"{b.Name} is born!");
            queuedBlobbies.Remove(b);
            didOne = true;
            sound.PlayNameClip(b.NameIndex);
        }

        doneBlobbys.Clear();

        if (didOne && hud.currentMenu == Menu.Spawner)
        {
            hud.ToggleMenu(Menu.None, new List <GameObject>());
            CleanGameObjectRefs();
            UpdateMenu();
        }

        if (queuedBlobbies.Count > 0)
        {
            StartSpawner();
        }
        else
        {
            StopSpawner();
        }
    }
コード例 #5
0
ファイル: Level.cs プロジェクト: TimWatsonNZ/SpaceShooter
 public void Update(Transform parent)
 {
     foreach (EnemySpawner currentSpawner in spawners)
     {
         if (currentSpawner.spawned == false && Time.time > currentSpawner.SpawnTime)
         {
             var child = Blobby.Instantiate(currentSpawner.EnemyPrefab, currentSpawner.position, Quaternion.identity);
             child.transform.parent = parent;
             EnemyCount++;
             child.OnDeath         += OnChildDeath;
             child.behaviour        = currentSpawner.behaviour;
             currentSpawner.spawned = true;
         }
     }
     spawners.RemoveAll(spawner => spawner.spawned);
 }
コード例 #6
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Food   f = collision.gameObject.GetComponent <Food>();
        Blobby b = collision.gameObject.GetComponent <Blobby>();

        if (f != null)
        {
            float foodValue = Random.Range(f.replenish * .75f, f.replenish * 1.25f);

            if (f.type == FoodType.Heal)
            {
                currentHP += foodValue;
                if (currentHP > maxHP)
                {
                    currentHP = maxHP;
                }
                sound.PlayRandomHealClip();
            }
            else
            {
                currentHunger += foodValue;
                if (currentHunger > maxHunger)
                {
                    chonk += foodValue / 200;
                }
                sound.PlayRandomFoodClip();
            }

            isWandering = false;
            Destroy(f.gameObject);
        }

        if (b != null && Random.value > blobbyBumpChance && attackTime <= 0)
        {
            b.currentHP -= Random.Range(blobbyAttack * 0.5f, blobbyAttack * 1.5f) * chonk;
            attackTime  += Random.Range(attackCooldown * 0.5f, attackCooldown * 1.5f);
            log.AddEvent($"{blobbyName} attacks {b.blobbyName}!");
            sound.PlayRandomHitClip();
        }
    }