当前位置: 首页>>代码示例>>C#>>正文


C# Enemy.addAction方法代码示例

本文整理汇总了C#中Enemy.addAction方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.addAction方法的具体用法?C# Enemy.addAction怎么用?C# Enemy.addAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Enemy的用法示例。


在下文中一共展示了Enemy.addAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadLevel

    public void loadLevel()
    {
        Stream stream = File.Open(Application.dataPath + "/Levels/" + panelUILoad.transform.FindChild("LabelFile").GetComponent<UILabel>().text, FileMode.Open);
        BinaryFormatter bformatter = new BinaryFormatter();
        bformatter.Binder = new VersionDeserializationBinder();
        Level l = (Level)bformatter.Deserialize(stream);
        stream.Close();

        //purge
        actualLevel.purge(maxWidth, maxHeight, maxVolume);
        for(int i=0; i<listUIEnemy.Count; i++)
        {
            for(int j=0; j<listUIEnemy.ElementAt(i).Value.Count; j++)
            {
                Destroy(listUIEnemy.ElementAt(i).Value.ElementAt(j));
            }
        }
        listUIEnemy.Clear();

        //load
        actualLevel.loadLevel(l);

        //Recreate the world
        var theLevelState = actualLevel.getEntireBlocState();
        for(int i=0; i<maxWidth; i++)
        {
            for(int j=0; j<maxHeight; j++)
            {
                for(int h=0; h<maxVolume; h++)
                {
                    if(theLevelState[i,j,h] == BLOCSTATE.CUBE)
                    {
                        var go = (GameObject)Instantiate(h == 0 ? cubeBase : cubeBloc, new Vector3(j*2, h*2, i*2), cubeBase.transform.rotation);
                        actualLevel.setCube(i, j, h, go);
                        go.SetActive(true);
                    }

                    if(theLevelState[i,j,h] == BLOCSTATE.SPECIAL)
                    {
                        var go = (GameObject)Instantiate(special, new Vector3(j*2, h*2, i*2), special.transform.rotation);
                        actualLevel.setSpecial(i, j, h, go);
                        go.SetActive(true);
                    }
                }
            }
        }
        actualLevel.setStartPlayerPosition((int)l.getPlayerSpawn().x, (int)l.getPlayerSpawn().y);
        actualLevel.setFinishPlayerPosition((int)l.getPlayerFinish().x, (int)l.getPlayerFinish().y);
        playerSpawnValid.SetActive(true);
        playerSpawn.transform.position = new Vector3(l.getPlayerSpawn().y*2f, 2f, l.getPlayerSpawn().x*2f);
        playerFinishValid.SetActive(true);
        playerFinish.transform.position = new Vector3(l.getPlayerFinish().y*2f, 2f, l.getPlayerFinish().x*2f);

        //Recréation de la liste d'ennemy
        listUIEnemy = new Dictionary<Enemy, List<GameObject>>();
        for(int i=0; i<l.getEnemies().Count; i++)
        {
            var enemy = l.getEnemies().ElementAt(i);
            var go = (GameObject)Instantiate(enemy.isHelicopter ? enemyHelicoModel : enemyModel, new Vector3(enemy.startY*2, enemy.isHelicopter ? 6f : 2f, enemy.startX*2), enemyModel.transform.rotation);
            if(enemy.isHelicopter){
                actualLevel.setStartEnemyPosition(enemy.startX, enemy.startY, go);
            }else{
                actualLevel.setStartEnemyHelicoPosition(enemy.startX, enemy.startY, go);
            }
            go.SetActive(true);
            go.transform.GetComponent<Enemy>().loadEnemy(enemy);
            listUIEnemy.Add(go.transform.GetComponent<Enemy>(), new List<GameObject>());
            actualEnemyEdit = go.transform.GetComponent<Enemy>();
            for(int j=0; j<enemy.ea.Count; j++)
            {
                bool isDeplacement = ((int)actualEnemyEdit.getLastAction() <= 3);
                actualEnemyEdit.addAction(enemy.ea.ElementAt(j).state, enemy.ea.ElementAt(j).timeWait);
                if((int)enemy.ea.ElementAt(j).state <= 3)
                {
                    actualNumberAction = actualEnemyEdit.getNumberOfAction();
                    placeUIWay(enemy.ea.ElementAt(j).state, actualEnemyEdit.isHelico());
                }else{
                    if(isDeplacement)
                    {
                        placeUIAction(actualEnemyEdit.getLastPosition(), actualEnemyEdit.isHelico());
                    }
                }
                listUIEnemy[actualEnemyEdit].Last().SetActive(false);
            }
        }

        for(int i=0; i<l.getObjects().Count; i++)
        {
            var theObj = l.getObjects().ElementAt(i);
            if(theObj.isCanon)
            {
                var go = (GameObject)Instantiate(canonModel, new Vector3(theObj.positionY*2f, 2.2f, theObj.positionX*2f), canonModel.transform.rotation);
                actualLevel.setCanon((int)theObj.positionX, (int)theObj.positionY, go);
                go.SetActive(true);
                go.GetComponent<Canon>().setLook((LOOK)theObj.theLook);
                switch(theObj.theLook)
                {
                case LOOK.DOWN:
                    go.transform.eulerAngles = new Vector3(0f, 0f, 0f);
                    break;
//.........这里部分代码省略.........
开发者ID:BenouKat,项目名称:Unity-HiddenFox,代码行数:101,代码来源:EditorLevelManager.cs


注:本文中的Enemy.addAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。