public IEnumerator HandleInput()
    {
        if (inputManager.CheckInputUp())
        {
            ConfirmMove();
        }
        else if (inputManager.CheckInputDown())
        {
            currentMonster = GetMonsterAtPosition();
        }
        else if (inputManager.CheckInput() && currentMonster != null)
        {
            DragSelectedBlocks();
        }

        yield return(new WaitForSeconds(0.1f));
    }
    public void PopulateBoard(MonsterBlock prefab, Transform parent)
    {
        for (int x = 0; x < Board.Tiles.GetLength(0); x++)
        {
            float xPos = (x * boardStep) + boardRoot.x;

            for (int y = 0; y < Board.Tiles.GetLength(1); y++)
            {
                float   yPos   = (y * boardStep) + boardRoot.y;
                Vector2 coords = new Vector2(xPos, yPos);

                Board.Tiles[x, y]         = new Tile(coords);
                Board.Tiles[x, y].Monster = Object.Instantiate(prefab, parent);
                Board.Tiles[x, y].Monster.SetPosition(coords);
            }
        }
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy      enemy = hitInfo.GetComponent <Enemy>();
        GameObject sound = GameObject.Find("Sound");
        PlaySound  play  = sound.GetComponent <PlaySound>();

        if (enemy != null)
        {
            play.PlayHitEnemy();
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        PowerUpBlimp blimp = hitInfo.GetComponent <PowerUpBlimp>();

        if (blimp != null)
        {
            play.PlayHitBox();
            blimp.TakeDamage(damage);
            Destroy(gameObject);
        }
        Box box = hitInfo.GetComponent <Box>();

        if (box != null)
        {
            play.PlayHitBox();
            box.TakeDamage(damage);
            Destroy(gameObject);
        }
        MonsterBlock mBlock = hitInfo.GetComponent <MonsterBlock>();

        if (mBlock != null)
        {
            play.PlayHitBox();
            mBlock.TakeDamage(damage);
            Destroy(gameObject);
        }

        Monster monster = hitInfo.GetComponent <Monster>();

        if (monster != null)
        {
            play.PlayHitEnemy();
            monster.TakeDamage(damage);
            Destroy(gameObject);
        }

        Turret turret = hitInfo.GetComponent <Turret>();

        if (turret != null)
        {
            play.PlayHitEnemy();
            turret.TakeDamage(damage);
            Destroy(gameObject);
        }


        if (hitInfo.gameObject.tag == "Destructable")
        {
            hitInfo.gameObject.GetComponent <DamageDestructable>().TakeDamage(damage);
            Destroy(gameObject);
        }
    }
    void loadKnowedBlock(string stageId)
    {
        //從MapContentList取得地圖資訊
        XmlNode itemNodeRoot = m_xmlKnowedBlockList.SelectSingleNode("/KnowedBlock/Map[@sceneName='" + stageId + "']");
        XmlNodeList itemNodes = itemNodeRoot.SelectNodes("Block");//取得所有item的node
        for (int i = 0; i < itemNodes.Count; i++)
        {
            int PosX = int.Parse(itemNodes[i].SelectSingleNode("PosX").InnerText);
            int PosY = int.Parse(itemNodes[i].SelectSingleNode("PosY").InnerText);
            Debug.Log("PosX :" + PosX);
            Debug.Log("PosY :" + PosY);

            BlockContent.Type BlockType = (BlockContent.Type)int.Parse(itemNodes[i].SelectSingleNode("BlockType").InnerText);
            Debug.Log("BlockType :" + BlockType);
            switch (BlockType)
            {
                case BlockContent.Type.TERRAIN:
                    int TextureID = int.Parse(itemNodes[i].SelectSingleNode("TextureID").InnerText);
                    TerrainBlock terrainBlock = new TerrainBlock(PosX, PosY, TextureID);
                    KnowedBlockList.Add(terrainBlock);

                    break;
                case BlockContent.Type.MONSTER:
                    int MonsterID = int.Parse(itemNodes[i].SelectSingleNode("MonsterID").InnerText);
                    MonsterBlock monsterBlock = new MonsterBlock(PosX, PosY, MonsterID);
                    KnowedBlockList.Add(monsterBlock);
                    break;
            }
        }
    }
 public mapContent(MonsterBlock myMonsterBlock, int myNum)
 {
     content = myMonsterBlock;
     num = myNum;
 }
 public mapContent(int ID, int myNum)
 {
     content = new MonsterBlock(0,0,ID);
     num = myNum;
 }