public Desk(int width, int depth, int drawers, MATERIALS material)
 {
     this.width    = width;
     this.depth    = depth;
     this.drawers  = drawers;
     this.material = (MATERIALS)material;
 }
Example #2
0
    public override void Execute()
    {
        blockIndex = ELevel.instance.objNum++;

        if (prefab != null)
        {
            Vector3 posicao = new Vector3(block.dados.x, block.dados.y, -5);
            block.gameObject = MonoBehaviour.Instantiate(prefab.gameObject, posicao, Quaternion.identity) as GameObject;
            MATERIALS mat = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), ((BlockData)block.dados).material);
            block.gameObject.GetComponent <ABBlock>().SetMaterial(mat);
            MonoBehaviour.Destroy(block.gameObject.GetComponent("ABBlock"));
            MonoBehaviour.Destroy(block.gameObject.GetComponent("ABParticleSystem"));
            block.gameObject.GetComponent <Rigidbody2D>().isKinematic = true;
            block.gameObject.name = "block_" + blockIndex;
            if (block.dados.type.Equals("TriangleHole"))
            {
                MonoBehaviour.Destroy(block.gameObject.GetComponent <PolygonCollider2D>());
                block.gameObject.AddComponent <BoxCollider2D>();
            }
            if (block.dados.rotation != 0)
            {
                block.rotated90Degree = true;
                block.gameObject.transform.Rotate(new Vector3(0, 0, 1), 90);
            }
            block.gameObject.AddComponent <InstantiateObject>();
            if (BlocksEditor != null)
            {
                block.gameObject.transform.SetParent(BlocksEditor.transform);
            }
        }

        ELevel.instance.blocksEditor.Add(blockIndex, block);
    }
Example #3
0
    public void SetMaterial(MATERIALS material)
    {
        _material = material;

        switch (material)
        {
        case MATERIALS.wood:
            _clips   = ABWorldAssets.WOOD_DAMAGE_CLIP;
            _sprites = _woodSprites;
            _destroyEffect._particleSprites = ABWorldAssets.WOOD_DESTRUCTION_EFFECT;
            _collider.sharedMaterial        = ABWorldAssets.WOOD_MATERIAL;
            _life *= 1f;
            break;

        case MATERIALS.stone:
            _clips   = ABWorldAssets.STONE_DAMAGE_CLIP;
            _sprites = _stoneSprites;
            _destroyEffect._particleSprites = ABWorldAssets.STONE_DESTRUCTION_EFFECT;
            _collider.sharedMaterial        = ABWorldAssets.STONE_MATERIAL;

            _life *= 2f;
            break;

        case MATERIALS.ice:
            _clips   = ABWorldAssets.ICE_DAMAGE_CLIP;
            _sprites = _iceSprites;
            _destroyEffect._particleSprites = ABWorldAssets.ICE_DESTRUCTION_EFFECT;
            _collider.sharedMaterial        = ABWorldAssets.ICE_MATERIAL;

            _life *= 0.5f;
            break;
        }

        _spriteRenderer.sprite = _sprites [0];
    }
 private void Start()
 {
     // Start as wood.
     eCurrentMaterial = MATERIALS.WOOD;
     bTransmute       = true;
     fTimer           = 2.0f;
     // Set Rigidbody and Renderer values to those of the attached GameObject.
     rMyRigidbody = GetComponent <Rigidbody>();
     rMyRenderer  = GetComponent <Renderer>();
     // Set kinematic to false so that movement works.
     rMyRigidbody.isKinematic = false;
     // Initialise timers.
     fDeathTimer   = 0.0f;
     fRespawnTimer = 0.0f;
     fLevelTime    = 0.0f;
     // Set the lighting conditions.
     RenderSettings.skybox.SetFloat("_Exposure", 1.5f);
     RenderSettings.ambientIntensity = 1.0f;
     // Set respawn location to start location.
     vRespawnPos = new Vector3(0.0f, 0.5f, 0.0f);
     // Disable all in-game menus.
     cPauseMenu.enabled     = false;
     cOptionsMenu.enabled   = false;
     cLevelComplete.enabled = false;
     // Set the timescale to the standard value.
     Time.timeScale = 1.0f;
 }
Example #5
0
    public static void GenerateSubset(ABLevel subset, int tag, float x, float y)
    {
        float tempX = subset.triggerX;
        float tempY = subset.triggerY;

        subset.triggerX = x;
        subset.triggerY = y;
        foreach (OBjData gameObj in subset.pigs)
        {
            gameObj.x += x - tempX;
            gameObj.y += y - tempY;
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);
            GameObject temp     = ABWorldAssets.PIGS [gameObj.type];
            temp.tag = tag.ToString();
            ABGameWorld.Instance.AddPig(temp, pos, rotation);
        }

        foreach (BlockData gameObj in subset.blocks)
        {
            gameObj.x += x - tempX;
            gameObj.y += y - tempY;
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);
            GameObject temp     = ABWorldAssets.BLOCKS[gameObj.type];
            temp.tag = tag.ToString();
            GameObject block    = ABGameWorld.Instance.AddBlock(temp, pos, rotation);
            MATERIALS  material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), gameObj.material);
            block.GetComponent <ABBlock> ().SetMaterial(material);
        }

        foreach (PlatData gameObj in subset.platforms)
        {
            gameObj.x += x - tempX;
            gameObj.y += y - tempY;
            Vector2    pos  = new Vector2(gameObj.x, gameObj.y);
            GameObject temp = ABWorldAssets.PLATFORM;
            temp.tag = tag.ToString();
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);
            ABGameWorld.Instance.AddPlatform(temp, pos, rotation, gameObj.scaleX, gameObj.scaleY);
        }

        foreach (OBjData gameObj in subset.tnts)
        {
            gameObj.x += x - tempX;
            gameObj.y += y - tempY;
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);
            GameObject temp     = ABWorldAssets.TNT;
            temp.tag = tag.ToString();
            ABGameWorld.Instance.AddBlock(temp, pos, rotation);
        }
    }
Example #6
0
        public void AddMaterial(string name)
        {
            if (MATERIALS == null)
            {
                MATERIALS = new List <string>();
            }

            name = name.Replace('/', '\\');

            if (!MATERIALS.Contains(name))
            {
                MATERIALS.Add(name);
            }
        }
Example #7
0
    public void ShootVerticalTriggerPoint()
    {
        if (!_isSimulation || !IsLevelStable())
        {
            print("Return V");
            return;
        }

        if (!alreadyDrop)
        {
            print("DROP V");
            float      x        = CurrentLevel.triggerX + 2f;
            float      y        = CurrentLevel.triggerY + 4f;
            GameObject block    = AddBlock(ABWorldAssets.BLOCKS["CircleSmall"], new Vector2(x, y), Quaternion.Euler(0, 0, 0));
            MATERIALS  material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), "stone");
            block.GetComponent <ABBlock>().SetMaterial(material);
            block.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, -0.5f), ForceMode2D.Impulse);
            block.tag = "test";
            SubsetSimulationNumber = 1;
            verticalBulletPosition++;
            //if (verticalBulletPosition > verticalTimes)
            //{
            //    print("----- V");
            //    verticalBulletPosition = 0;
            //    HorizontalStart = false;
            //    isShootVerticalTriggerPoint = true;

            //    //isSaveLevel = true;
            //    //SavegenerateLevel();
            //    return;
            //}
            alreadyDrop = true;
        }
        else
        {
            print("initx V");

            initx();
            for (int i = 0; i < positionSubsets.Count; i++)
            {
                GenerateSubset(positionSubsets[i], levelSubsets[i]);
            }
            alreadyDrop = false;
        }
    }
Example #8
0
    public void ShootHorizontalTriggerPoint()
    {
        if (!_isSimulation || !IsLevelStable())
        {
            return;
        }

        if (!alreadyDropHorizontal)
        {
            print("DROP H");
            float y = (CurrentLevel.triggerY + 2f);             // + currentLevel.triggerY
            float x = (CurrentLevel.triggerY - 2f);             //+ currentLevel.triggerX
            //			Debug.Log("X "+CurrentLevel.platformStartPoint.x+",Y "+CurrentLevel.platformStartPoint.y);
            GameObject block    = AddBlock(ABWorldAssets.BLOCKS["CircleSmall"], new Vector2(x, y), Quaternion.Euler(0, 0, 0));
            MATERIALS  material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), "stone");
            block.GetComponent <ABBlock>().SetMaterial(material);
            block.GetComponent <Rigidbody2D>().AddForce(new Vector2(0.7f, 0.7f), ForceMode2D.Impulse);
            block.tag = "test";
            SubsetSimulationNumber = 0;
            horizontalBulletPosition++;
            //isShootHorizontalTriggerPoint = true;
            if (horizontalBulletPosition > horizontalTimes)
            {
                print("----- H");
                //ABTNT.ResetCountExplode();
                //isShootHorizontalTriggerPoint = true;
                //horizontalBulletPosition = 0;
                //HorizontalStart = true;
                //return;
                //isSaveLevel = true;
                //SavegenerateLevel();
            }
            alreadyDropHorizontal = true;
        }
        else
        {
            print("initx H");
            initx();
            for (int i = 0; i < positionSubsets.Count; i++)
            {
                GenerateSubset(positionSubsets[i], levelSubsets[i]);
            }
            alreadyDropHorizontal = false;
        }
    }
    public void DecodeLevel(ABLevel level)
    {
        foreach (OBjData gameObj in level.pigs)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            GameObject pig = InstantiateGameObject(ABWorldAssets.PIGS[gameObj.type]);
            pig.transform.parent   = GameObject.Find("Blocks").transform;
            pig.transform.position = pos;
            pig.transform.rotation = rotation;
        }

        _birdsAdded = 0;
        foreach (BirdData gameObj in level.birds)
        {
            CreateBird(gameObj.type);
            _birdsAdded++;
        }

        foreach (BlockData gameObj in level.blocks)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            GameObject block = InstantiateGameObject(ABWorldAssets.BLOCKS[gameObj.type]);
            block.transform.parent   = GameObject.Find("Blocks").transform;
            block.transform.position = pos;
            block.transform.rotation = rotation;

            MATERIALS material = (MATERIALS)Enum.Parse(typeof(MATERIALS), gameObj.material);
            BlockEditor.UpdateBlockMaterial(block.GetComponent <ABBlock>(), material);
        }

        foreach (OBjData gameObj in level.platforms)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            GameObject platform = InstantiateGameObject(ABWorldAssets.PLATFORM);
            platform.transform.parent   = GameObject.Find("Platforms").transform;
            platform.transform.position = pos;
            platform.transform.rotation = rotation;
        }
    }
Example #10
0
    public static void UpdateBlockMaterial(ABBlock block, MATERIALS material)
    {
        block._material = material;

        if (material == MATERIALS.wood)
        {
            block.GetComponent <SpriteRenderer> ().sprite = block.GetComponent <ABBlock> ()._woodSprites [0];
        }

        else if (material == MATERIALS.stone)
        {
            block.GetComponent <SpriteRenderer> ().sprite = block.GetComponent <ABBlock> ()._stoneSprites [0];
        }

        else if (material == MATERIALS.ice)
        {
            block.GetComponent <SpriteRenderer> ().sprite = block.GetComponent <ABBlock> ()._iceSprites [0];
        }
    }
    //start Vertical test
    public void SubsetSimulationVertical()
    {
        if (!_isSimulation || !IsLevelStable())
        {
            return;
        }

        if (!AlreadyDropVertical)
        {
            VerticalTimes = CurrentLevel.platforms.Count + 1;
            float   x   = VerticalBulletPosition * 0.62f + ABGameWorld.platformStartPointX - 0.32f;
            float   y   = ABGameWorld.platformStartPointY + 5f;
            Vector2 pos = new Vector2(x, y);
//            Vector2 force = new Vector2(0, -2f);
            Quaternion rotation = Quaternion.Euler(0, 0, 0);
            GameObject block    = AddBlock(ABWorldAssets.BLOCKS["CircleSmall"], pos, rotation);
            block.tag = "test";
//            block.GetComponent<Rigidbody2D>().AddForce(force, ForceMode2D.Impulse);
            block.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, -4f);
            MATERIALS material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), "stone");
            block.GetComponent <ABBlock>().SetMaterial(material);
            VerticalBulletPosition++;
            if (VerticalBulletPosition > VerticalTimes)
            {
                VerticalBulletPosition    = 0;
                HorizontalEvaluationStart = false;
                print("Useless Subset");
                NextLevel();
                return;
            }

            AlreadyDropVertical = true;
        }
        else
        {
            initx();
            AlreadyDropVertical = false;
        }
        //		if (IsLevelStable ()&&block.transform.position.y<5) {
        //			initx ();
        //		}
    }
    public void ShootInitiator()
    {
//		if (CurrentLevel.triggerX == 0) {
//			return;
//		}

        for (int i = 1; i < subsetList.Count; i++)
        {         // generate old subset
            GenerateSubset(subsetList[i].triggerPoint, i, subsetList[i].id);
            print("id : " + subsetList [i].id.ToString() + ", trigger : " + subsetList [i].triggerPoint.ToString());
        }
        if (GetLevelStability() > 0.5f)
        {
            subsetList.RemoveAt(subsetList.Count - 1);
            initx();
            print("Subset is unstable!");
            return;
        }
        Destroy(GameObject.FindGameObjectWithTag("test"));
        Vector2    shootPos;
        GameObject block;
        MATERIALS  material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), "stone");

        if (CurrentLevel.horizontal)
        {
            shootPos = new Vector2(CurrentLevel.triggerX - 0.4f, CurrentLevel.triggerY + 0.1f);
            block    = AddBlock(ABWorldAssets.BLOCKS ["CircleSmall"], shootPos, Quaternion.Euler(0, 0, 0));
            block.GetComponent <Rigidbody2D> ().velocity = new Vector2(4f, 0);
        }
        else
        {
            shootPos = new Vector2(CurrentLevel.triggerX, CurrentLevel.triggerY + 0.4f);
            block    = AddBlock(ABWorldAssets.BLOCKS ["CircleSmall"], shootPos, Quaternion.Euler(0, 0, 0));
            block.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, -4f);
        }
        block.GetComponent <ABBlock>().SetMaterial(material);
        block.tag = "test";
        initiate  = false;
//		block2.GetComponent<ABBlock>().SetMaterial(material);
//		block2.GetComponent<Rigidbody2D> ().velocity = new Vector2 (2f, -2f);
//		block2.tag = "test";
    }
    /// <summary>
    /// ABLG!!
    /// Functions for evaluating Subsets
    /// </summary>

    //start Horizontal test
    public void SubsetSimulationHorizontal()
    {
        if (!_isSimulation || !IsLevelStable())
        {
            return;
        }

        if (!AlreadyDropHorizontal)
        {
            float y = HorizonalBulletPosition * 0.31f + ABGameWorld.platformStartPointY + 0.6f;
            float x = ABGameWorld.platformStartPointX - 0.62f;

            Vector2 pos = new Vector2(x, y);
//            Vector2 force = new Vector2(2, 0);
            Quaternion rotation = Quaternion.Euler(0, 0, 0);

            GameObject block = AddBlock(ABWorldAssets.BLOCKS["CircleSmall"], pos, rotation);
            block.tag = "test";
            MATERIALS material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), "stone");
            block.GetComponent <ABBlock>().SetMaterial(material);
            block.GetComponent <Rigidbody2D> ().velocity = new Vector2(4f, 0);
//            block.GetComponent<Rigidbody2D>().AddForce(force, ForceMode2D.Impulse);
            HorizonalBulletPosition++;


            if (HorizonalBulletPosition > HorizontalTimes)
            {
                HorizonalBulletPosition   = 0;
                HorizontalEvaluationStart = true;
                initx();
                return;
            }
            AlreadyDropHorizontal = true;
        }
        else
        {
            initx();
            AlreadyDropHorizontal = false;
        }
    }
Example #14
0
        private void BImport_Click(object sender, EventArgs e)
        {
            XmlSerialization <MATERIALS> xmlSerialization = new XmlSerialization <MATERIALS>();

            MATERIALS cl = new MATERIALS(); // путь к файлу

            string filePath = @"xml\import.xml";

            cl = (MATERIALS)xmlSerialization.ReadData(filePath, cl); //дерсериализация

            for (int i = 0; i < cl.MATERIAL.Count; i++)
            {
                string materialname = cl.MATERIAL[i].Name;
                string materialgram = cl.MATERIAL[i].GramPrice;
                int    matergram    = Convert.ToInt32(materialgram);

                using (var context = new MyDbContext())
                {
                    var query = context.Materials.Where(x => x.Name == materialname && matergram == x.GramPrice);

                    var materials = new Material()
                    {
                        Name      = materialname,
                        GramPrice = Convert.ToInt32(materialgram)
                    };

                    if (query.ToList().Count < 1)
                    {
                        context.Materials.Add(materials);
                        context.SaveChanges();
                    }
                }

                for (int j = 0; j < cl.MATERIAL[i].TITLE.Count; j++)
                {
                    string titlename = cl.MATERIAL[i].TITLE[j].Name;
                    string titletype = cl.MATERIAL[i].TITLE[j].Type;

                    using (var context = new MyDbContext())
                    {
                        var query = context.Titles.Where(x => x.Name == titlename && x.Type == titletype);

                        var titles = new Title()
                        {
                            Name = titlename,
                            Type = titletype
                        };

                        if (query.ToList().Count < 1)
                        {
                            context.Titles.Add(titles);
                            context.SaveChanges();
                        }
                    }

                    for (int y = 0; y < cl.MATERIAL[i].TITLE[j].PRODUCT.Count; y++)
                    {
                        string productmname  = cl.MATERIAL[i].TITLE[j].PRODUCT[y].materialname;
                        string producttname  = cl.MATERIAL[i].TITLE[j].PRODUCT[y].titlename;
                        string producttype   = cl.MATERIAL[i].TITLE[j].PRODUCT[y].titletype;
                        string productweight = cl.MATERIAL[i].TITLE[j].PRODUCT[y].Weight;
                        string productprice  = cl.MATERIAL[i].TITLE[j].PRODUCT[y].Price;

                        int weightint = Convert.ToInt32(productweight);
                        int priceint  = Convert.ToInt32(productprice);



                        using (var context = new MyDbContext())
                        {
                            var getTitleid    = context.Titles.Where(x => x.Name == producttname && x.Type == producttype).Select(x => x.TitleId).First();
                            var getMaterialid = context.Materials.Where(x => x.Name == productmname).Select(x => x.MaterialID).First();

                            var query = context.Products.Where(x => x.MaterialId == getMaterialid && x.TitleId == getTitleid && x.Weight == weightint && x.Price == priceint);

                            var product = new Product()
                            {
                                MaterialId = getMaterialid,
                                TitleId    = getTitleid,
                                Weight     = Convert.ToInt32(productweight),
                                Price      = Convert.ToInt32(productprice)
                            };

                            if (query.ToList().Count < 1)
                            {
                                context.Products.Add(product);
                                context.SaveChanges();
                            }
                        }
                    }

                    for (int y = 0; y < cl.MATERIAL[i].TITLE[j].SALE.Count; y++)
                    {
                        string salename      = cl.MATERIAL[i].TITLE[j].SALE[y].Name;
                        string salesurname   = cl.MATERIAL[i].TITLE[j].SALE[y].SName;
                        string salefname     = cl.MATERIAL[i].TITLE[j].SALE[y].FName;
                        string saletitlename = cl.MATERIAL[i].TITLE[j].SALE[y].TitleName;
                        string saletitletype = cl.MATERIAL[i].TITLE[j].SALE[y].TitleType;
                        string saledate      = cl.MATERIAL[i].TITLE[j].SALE[y].SaleDate;

                        DateTime saledates = DateTime.Parse(saledate);

                        using (var context = new MyDbContext())
                        {
                            var getTitleid = context.Titles.Where(x => x.Name == saletitlename && x.Type == saletitletype).Select(x => x.TitleId).First();

                            var query = context.Sales.Where(x => x.TitleId == getTitleid && x.Name == salename && x.SName == salesurname && x.FName == salefname && x.SaleDate == saledates);

                            var sale = new Sale()
                            {
                                Name     = salename,
                                SName    = salesurname,
                                FName    = salefname,
                                TitleId  = getTitleid,
                                SaleDate = saledates
                            };

                            if (query.ToList().Count < 1)
                            {
                                context.Sales.Add(sale);
                                context.SaveChanges();
                            }
                        }
                    }
                }
            }
            MessageBox.Show("Импорт завершён");
        }
Example #15
0
 public string[] GetMaterials()
 {
     return(MATERIALS.ToArray());
 }
Example #16
0
    public void DecodeLevel(ABLevel currentLevel)
    {
        ClearWorld();

        LevelHeight = ABConstants.LEVEL_ORIGINAL_SIZE.y;
        LevelWidth  = (float)currentLevel.width * ABConstants.LEVEL_ORIGINAL_SIZE.x;

        Vector3 cameraPos = GameplayCam.transform.position;

        cameraPos.x = currentLevel.camera.x;
        cameraPos.y = currentLevel.camera.y;
        GameplayCam.transform.position = cameraPos;

        GameplayCam._minWidth = currentLevel.camera.minWidth;
        GameplayCam._maxWidth = currentLevel.camera.maxWidth;

        Vector3 landscapePos  = ABWorldAssets.LANDSCAPE.transform.position;
        Vector3 backgroundPos = ABWorldAssets.BACKGROUND.transform.position;

        if (currentLevel.width > 1)
        {
            landscapePos.x  -= LevelWidth / 4f;
            backgroundPos.x -= LevelWidth / 4f;
        }

        for (int i = 0; i < currentLevel.width; i++)
        {
            GameObject landscape = (GameObject)Instantiate(ABWorldAssets.LANDSCAPE, landscapePos, Quaternion.identity);
            landscape.transform.parent = transform;

            float screenRate = currentLevel.camera.maxWidth / LevelHeight;
            if (screenRate > 2f)
            {
                for (int j = 0; j < (int)screenRate; j++)
                {
                    Vector3 deltaPos = Vector3.down * (LevelHeight / 1.5f + (j * 2f));
                    Instantiate(ABWorldAssets.GROUND_EXTENSION, landscapePos + deltaPos, Quaternion.identity);
                }
            }

            landscapePos.x += ABConstants.LEVEL_ORIGINAL_SIZE.x - 0.01f;

            if (!RatingSystem.IsGenerating)
            {
                GameObject background = (GameObject)Instantiate(ABWorldAssets.BACKGROUND, backgroundPos, Quaternion.identity);
                background.transform.parent = GameplayCam.transform;
                backgroundPos.x            += ABConstants.LEVEL_ORIGINAL_SIZE.x - 0.01f;
            }
        }

        Vector2 slingshotPos = new Vector2(currentLevel.slingshot.x, currentLevel.slingshot.y);

        _slingshot                  = (GameObject)Instantiate(ABWorldAssets.SLINGSHOT, slingshotPos, Quaternion.identity);
        _slingshot.name             = "Slingshot";
        _slingshot.transform.parent = transform;

        foreach (BirdData gameObj in currentLevel.birds)
        {
            AddBird(ABWorldAssets.BIRDS[gameObj.type], ABWorldAssets.BIRDS[gameObj.type].transform.rotation);
        }

        foreach (OBjData gameObj in currentLevel.pigs)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);
            AddPig(ABWorldAssets.PIGS[gameObj.type], pos, rotation);
        }

        foreach (BlockData gameObj in currentLevel.blocks)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            GameObject block = AddBlock(ABWorldAssets.BLOCKS[gameObj.type], pos, rotation);

            MATERIALS material = (MATERIALS)System.Enum.Parse(typeof(MATERIALS), gameObj.material);
            block.GetComponent <ABBlock> ().SetMaterial(material);
        }

        foreach (PlatData gameObj in currentLevel.platforms)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            AddPlatform(ABWorldAssets.PLATFORM, pos, rotation, gameObj.scaleX, gameObj.scaleY);
        }

        foreach (OBjData gameObj in currentLevel.tnts)
        {
            Vector2    pos      = new Vector2(gameObj.x, gameObj.y);
            Quaternion rotation = Quaternion.Euler(0, 0, gameObj.rotation);

            AddBlock(ABWorldAssets.TNT, pos, rotation);
        }

        StartWorld();
    }
Example #17
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();

        _birdsOps = (BIRDS)EditorGUILayout.EnumPopup("", _birdsOps);
        if (GUILayout.Button("Create Bird", GUILayout.Width(80), GUILayout.Height(20)))
        {
            CreateBird(_birdsOps.ToString());
        }

        EditorGUILayout.EndVertical();

        // Pigs section
        EditorGUILayout.BeginHorizontal();

        _pigsOps = (PIGS)EditorGUILayout.EnumPopup("", _pigsOps);

        if (GUILayout.Button("Create Pig", GUILayout.Width(80), GUILayout.Height(20)))
        {
            GameObject pig = InstantiateGameObject(_pigs[_pigsOps.ToString()]);
            pig.transform.parent = GameObject.Find("Blocks").transform;
        }

        EditorGUILayout.EndVertical();

        // Blocks section
        EditorGUILayout.BeginHorizontal();

        _blocksOps = (BLOCKS)EditorGUILayout.EnumPopup("", _blocksOps);
        _material  = (MATERIALS)EditorGUILayout.EnumPopup("", _material);

        if (GUILayout.Button("Create Block", GUILayout.Width(80), GUILayout.Height(20)))
        {
            GameObject block = InstantiateGameObject(_blocks[_blocksOps.ToString()]);
            block.transform.parent = GameObject.Find("Blocks").transform;

            BlockEditor.UpdateBlockMaterial(block.GetComponent <ABBlock>(), _material);
        }

        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("Create Platform"))
        {
            GameObject platform = InstantiateGameObject(_platform);
            platform.transform.parent = GameObject.Find("Platforms").transform;
        }

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Load Level"))
        {
            LoadLevel();
        }

        if (GUILayout.Button("New Level"))
        {
            if (EditorUtility.DisplayDialog("Create New Level",
                                            "Are you sure you want to create a new level? This operation will " +
                                            "not save the current level in the scene", "Yes", "Cancel"))
            {
                CleanLevel();
            }
        }

        if (GUILayout.Button("Save Level"))
        {
            SaveLevel();
        }

        EditorGUILayout.EndHorizontal();
    }