Пример #1
0
    // Hurt the player character when colliding
    // Reflect the projectile back to the flier when colliding with the sword
    // Destroy the projectile with any other collisions
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.tag == "Sword" && coll.isTrigger && !respawning)
        {
            GameObject Drop;
            Drop = Instantiate(
                baby,
                transform.position,
                transform.rotation) as GameObject;

            Drop.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            Drop.GetComponent <H2OBoy>().pushBackForce = 100f;
            Drop.layer = 0;
            SpriteRenderer sr;
            sr = GetComponent <SpriteRenderer>();
            SpriteRenderer srb;
            Animator       sra;
            sra         = fake.GetComponent <Animator>();
            srb         = fake.GetComponent <SpriteRenderer>();
            sr.enabled  = false;
            sra.enabled = false;
            srb.enabled = false;
            respawning  = true;
            foreach (BoxCollider2D c in GetComponents <BoxCollider2D> ())
            {
                c.enabled = false;
            }
        }
    }
Пример #2
0
    private void SetColor(Drop drop, string color)
    {
        drop.color = color;

        Sprite newSprite = sprites[0];

        switch (drop.color)
        {
        case "red":
            newSprite = sprites[0];
            break;

        case "yellow":
            newSprite = sprites[1];
            break;

        case "green":
            newSprite = sprites[2];
            break;

        case "blue":
            newSprite = sprites[3];
            break;

        default:
            newSprite = null;
            break;
        }

        drop.GetComponent <SpriteRenderer>().sprite = newSprite;
    }
Пример #3
0
 public bool CheckTask()
 {
     if (Drop.GetComponent <Drop>().setUnit == true && !checkflag)
     {
         checkflag = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
    // Use this for initialization
    void Start()
    {
        ICONS = Icons;
        Use.onClick.AddListener(Us);
        Button Inventor = Inventory.GetComponent <Button>();

        Inventor.onClick.AddListener(Invento);
        Button Drp = Drop.GetComponent <Button>();

        Drp.onClick.AddListener(Dro);
        Button Clos = Close.GetComponent <Button>();

        Clos.onClick.AddListener(Clo);
        Button Cel1 = Cell[0].GetComponent <Button>();

        Cel1.onClick.AddListener(C1);
        Button Cel2 = Cell[1].GetComponent <Button>();

        Cel2.onClick.AddListener(C2);
        Button Cel3 = Cell[2].GetComponent <Button>();

        Cel3.onClick.AddListener(C3);
        Button Cel4 = Cell[3].GetComponent <Button>();

        Cel4.onClick.AddListener(C4);
        Button Cel5 = Cell[4].GetComponent <Button>();

        Cel5.onClick.AddListener(C5);
        Button Cel6 = Cell[5].GetComponent <Button>();

        Cel6.onClick.AddListener(C6);
        Button Cel7 = Cell[6].GetComponent <Button>();

        Cel7.onClick.AddListener(C7);
        Button Cel8 = Cell[7].GetComponent <Button>();

        Cel8.onClick.AddListener(C8);
        Button Cel9 = Cell[8].GetComponent <Button>();

        Cel9.onClick.AddListener(C9);
        Button Cel10 = Cell[9].GetComponent <Button>();

        Cel10.onClick.AddListener(C10);
        Button Cel11 = Cell[10].GetComponent <Button>();

        Cel11.onClick.AddListener(C11);
        Button Cel12 = Cell[11].GetComponent <Button>();

        Cel12.onClick.AddListener(C12);
    }
Пример #5
0
    public void WaveSpawner()
    {
        // Spawn a drop
        CurrentDropTime += Time.deltaTime;
        if (CurrentDropTime > DropTime && Wave.DropsSpawnAmount != Wave.DropsAmount)
        {
            EnemyManager.AddObserver(Drop.GetComponent <JuiceDrop>());
            CurrentDropTime = 0f;
            DropTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn a spike
        CurrentSpikeTime += Time.deltaTime;
        if (CurrentSpikeTime > SpikeTime && Wave.SpikesSpawnAmount != Wave.SpikesAmount)
        {
            EnemyManager.AddObserver(Spike.GetComponent <Spike>());
            CurrentSpikeTime = 0;
            SpikeTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn a fire
        CurrentFireTime += Time.deltaTime;
        if (CurrentFireTime > FireTime && Wave.FiresSpawnAmount != Wave.FireAmount)
        {
            EnemyManager.AddObserver(Fire.GetComponent <Fire>());
            CurrentFireTime = 0f;
            FireTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn the boss
        if (Wave.DropsSpawnAmount == Wave.DropsAmount && Wave.SpikesSpawnAmount == Wave.SpikesAmount && Wave.FiresSpawnAmount == Wave.FireAmount && Wave.WaveLevel == Wave.FinalWaveLevel)
        {
            LevelState = LevelState.Boss;
            // Or Spawn another wave
        }
        else if (Wave.DropsSpawnAmount == Wave.DropsAmount && Wave.SpikesSpawnAmount == Wave.SpikesAmount && Wave.FiresSpawnAmount == Wave.FireAmount)
        {
            GameObject.FindWithTag("GameController").GetComponent <GameController>().Restart();
        }

        // Notify all enemies
        //EnemyManager.Notify(Player);
    }