示例#1
0
 public void OnPointerEnter(PointerEventData eventData) //get mouse enter and see move left or right
 {
     move.move(left);
 }
示例#2
0
    IEnumerator createlevel()
    {
        moveCam movecam = GetComponent <moveCam>();

        movecam.move();
        yield return(new WaitForSeconds(3f));

        enemies.Insert(0, mainEnemy);



        level++;
        enemies[0].SetActive(true);
        attack.setAttackSpeed(level / 10);

        if ((live.getHP() + 10) >= 100)
        {
            live.changeHP(100 - live.getHP());
        }
        else
        {
            live.changeHP(10);
        }
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 19; j++)
            {
                if (enemies.Count < Random.Range(1, 4))
                {
                    sprEnemy.sprite = getSpEnemy();
                    var en = Instantiate(prefabEnemy, new Vector2(Random.Range(-5f, 4.5f), Random.Range(-2f, 2f)), Quaternion.identity);
                    enemies.Add((en as Transform).gameObject);
                }
                if (Random.Range(1, (int)(80 - (level * 0.7))) == 3)
                {
                    sprEnemy.sprite = getSpEnemy();
                    var en = Instantiate(prefabEnemy, new Vector2(Random.Range(-5f, 4.5f), Random.Range(-2f, 2f)), Quaternion.identity);
                    enemies.Add((en as Transform).gameObject);
                }

                if ((i == 3 && j == 0) || (i == 4 && j == 0) || (i == 5 && j == 0) || (i == 6 && j == 0))
                {
                    var d = Instantiate(prefabDoor, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                    clones.Add((d as Transform).gameObject);
                }
                else if ((i == 3 && j == 18) || (i == 4 && j == 18) || (i == 5 && j == 18) || (i == 6 && j == 18))
                {
                    var d = Instantiate(prefabDoor, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                    clones.Add((d as Transform).gameObject);
                }
                else if ((i == 0 && j == 7) || (i == 0 && j == 8) || (i == 0 && j == 9) || (i == 0 && j == 10) || (i == 0 && j == 11))
                {
                    var d = Instantiate(prefabDoor, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                    clones.Add((d as Transform).gameObject);
                }
                else if ((i == 9 && j == 7) || (i == 9 && j == 8) || (i == 9 && j == 9) || (i == 9 && j == 10) || (i == 9 && j == 11))
                {
                    var d = Instantiate(prefabDoor, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                    clones.Add((d as Transform).gameObject);
                }
                else
                {
                    if (i == 0 || j == 0 || i == 9 || j == 18)
                    {
                        yield return(new WaitForSeconds(0.0001f));

                        //wall = Instantiate(wall, new Vector3(-6f + j * 0.64f, -3f + i * 0.64f, 0f), Quaternion.identity);
                        var w = Instantiate(prefabWall, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                        clones.Add((w as Transform).gameObject);
                        sprWall.sprite = getSpW();
                    }
                    else
                    {
                        yield return(new WaitForSeconds(0.0001f));

                        if (Random.Range(1, 30) == 5)
                        {
                            sprSpike.sprite = getSpSp();
                            var sp = Instantiate(prefabSpike, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);

                            clones.Add((sp as Transform).gameObject);
                        }

                        // floor = Instantiate(floor, new Vector3(-6f + j * 0.64f, -3f + i * 0.64f,0f), Quaternion.identity);
                        var f = Instantiate(prefabFloor, new Vector2(-6f + j * 0.64f, -3f + i * 0.64f), Quaternion.identity);
                        clones.Add((f as Transform).gameObject);
                        sprFloor.sprite = getSpF();
                    }
                }
            }
        }
        moveCharacter.setMove(true);
        enemies[0].SetActive(false);
        bar.SetActive(true);
        state.SetActive(true);
    }