Inheritance: MonoBehaviour
Example #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, null, null, null, transformMatrix: camera.Transfrom);

            for (int z = 0; z < SquaresDepth; z++)
            {
                int layer = z;
                for (int y = 0; y < 50; y++)
                {
                    int row = y;
                    for (int x = 0; x < 100; x++)
                    {
                        int column = x;

                        spriteBatch.Draw(
                            TileSet.TileSetTexture,
                            new Rectangle((x * Scale), (y * Scale), Scale, Scale),
                            TileSet.GetSourceRectangle(MapLoad.Maps(map, layer, row, column)), //need to make variable fro map
                            Color.White,
                            0f,
                            Vector2.Zero,
                            SpriteEffects.None,
                            0f);
                    }
                }
            }

            hero.Draw(spriteBatch);
            base.Draw(gameTime);
            spriteBatch.End();
        }
Example #2
0
        public void CheckCollision(Vector2 new_position)
        {
            // check if new position is valid
            int Scale = 48;
            int map   = 0;

            bool HasCollided = false;

            for (int x = (int)(new_position.X / Scale); x <= (int)((new_position.X + texture.Width * 3) / Scale); x++)
            {
                for (int y = (int)(new_position.Y / Scale); y <= (int)((new_position.Y + texture.Height * 3) / Scale); y++)
                {
                    int tileNum = MapLoad.Maps(map, 1, y, x);

                    if (tileNum != 0 && tileNum != 4)
                    {
                        HasCollided = true;
                    }
                }
            }

            if (HasCollided == false)
            {
                position = new_position;
            }
        }
    public void Start()
    {
        transform.localScale = Vector3.one;
        //transform.rotation = Quaternion.identity;
        ml = Util.GetMapload ();
        BC2Array planeArray = Util.GetArray ("Planes", transform.GetComponent<BC2Instance> ().instance);
        BC2Array pointArray = Util.GetArray ("Points", transform.GetComponent<BC2Instance> ().instance);

        foreach (Item item in pointArray.item) {
            if (item.reference != "" && item.reference != "null" && item.reference != null) {
                points.Add (Util.GetGOByString (item.reference));
            }
        }

        foreach (Item item in planeArray.item) {
            if (item.reference != "" && item.reference != "null" && item.reference != null) {
                GameObject plane = Util.GetGOByString (item.reference);
                planes.Add (plane);
                plane.transform.parent = transform;
                plane.GetComponent<TerrainSplinePlaneData> ().positionPoints = points;
                plane.GetComponent<TerrainSplinePlaneData> ().AssignValues ();
            }
        }

        DrawLines ();
    }
    public void Start()
    {
        transform.localScale = Vector3.one;
        //transform.rotation = Quaternion.identity;
        ml = Util.GetMapload();
        BC2Array planeArray = Util.GetArray("Planes", transform.GetComponent <BC2Instance> ().instance);
        BC2Array pointArray = Util.GetArray("Points", transform.GetComponent <BC2Instance> ().instance);

        foreach (Item item in pointArray.item)
        {
            if (item.reference != "" && item.reference != "null" && item.reference != null)
            {
                points.Add(Util.GetGOByString(item.reference));
            }
        }

        foreach (Item item in planeArray.item)
        {
            if (item.reference != "" && item.reference != "null" && item.reference != null)
            {
                GameObject plane = Util.GetGOByString(item.reference);
                planes.Add(plane);
                plane.transform.parent = transform;
                plane.GetComponent <TerrainSplinePlaneData> ().positionPoints = points;
                plane.GetComponent <TerrainSplinePlaneData> ().AssignValues();
            }
        }


        DrawLines();
    }
    public static GameObject GetGOByString(string GUID)
    {
        MapLoad    ml       = GetMapload();
        GameObject returnGO = null;

        ml.instantiatedDictionary.TryGetValue(GUID.ToUpper(), out returnGO);
        return(returnGO);
    }
        public Material GetMaterial(string meshPath, string shaderPath, string subsetName)
        {
            Material mat;
            MapLoad  mapLoad = Util.GetMapload();

            string materialPath = meshPath + "/" + shaderPath;

            // We have already processed this material.
            if (materials.TryGetValue(materialPath, out mat))
            {
                return(mat);
            }
            Dictionary <string, List <string> > shader;

            // We don't have that shader registered.
            if (!shaders.TryGetValue(meshPath, out shader))
            {
                return(mapLoad.materialwhite);
            }

            // Loop through the shader names of the shader, figure out if any of them fits inside the subset name.
            foreach (string shaderName in shader.Keys)
            {
                if (subsetName.Contains(shaderName))
                {
                    //The current shader fits within the subset name.
                    List <string> textures = new List <string>();
                    if (!shader.TryGetValue(shaderName, out textures))
                    {
                        Debug.Log(shaderName);
                    }

                    mat      = new Material(mapLoad.materialwhite);
                    mat.name = shaderName;
                    if (textures == null)
                    {
                        return(mapLoad.materialwhite);
                    }
                    //Loop through all the textures registered to that shader, and apply them to a new material.
                    foreach (string textureName in textures)
                    {
                        //Figure out what type of texture this is and try to load it.
                        string    textureType = Util.GetTextureType(textureName);
                        Texture2D texture     = Util.LoadiTexture(textureName + ".itexture");

                        if (textureType != "" && texture != null)
                        {
                            mat.SetTexture(textureType, texture);
                        }
                    }
                    //Cache this material for later recovery.
                    this.materials.Add(materialPath, mat);
                    return(mat);
                }
            }
            return(mapLoad.materialwhite);
        }
Example #7
0
    void TopMenu()
    {
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("New", EditorStyles.miniButton, GUILayout.Width(50)))
        {
            dataPath         = string.Empty;
            defaultDirectory = string.Empty;
            defaultName      = "defaultMaps";

            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

            GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/Prefab/Main Camera.prefab"));
            GameObject go = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/Prefab/Map.prefab"));
            m_MapLoad = go.GetComponent <MapLoad>();
        }

        if (GUILayout.Button("Load", EditorStyles.miniButton, GUILayout.Width(50)))
        {
            string path = EditorUtility.OpenFilePanel("Open", defaultDirectory, "json");

            if (!string.IsNullOrEmpty(path))
            {
                dataPath         = path;
                defaultDirectory = Path.GetDirectoryName(path);
                defaultName      = Path.GetFileName(path);

                EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);

                GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/Prefab/Main Camera.prefab"));
                GameObject go = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/Prefab/Map.prefab"));
                m_MapLoad = go.GetComponent <MapLoad>();
                Load(path);
            }
        }

        if (GUILayout.Button("Save", EditorStyles.miniButton, GUILayout.Width(50)))
        {
            string path = EditorUtility.SaveFilePanel("Save", defaultDirectory, defaultName, "json");

            if (!string.IsNullOrEmpty(path))
            {
                Save(path);
            }
        }


        GUILayout.Label(dataPath, EditorStyles.miniLabel);
        GUILayout.EndHorizontal();
    }
 // Use this for initialization
 void Start()
 {
     Goal.clearObj = GameObject.Find("GameClear_Canvas");
     Goal.clearObj.SetActive(false);
     player = FindObjectOfType <Player>();
     // 現在のシーンの名前を取得
     mapLoad         = GameObject.Find("StageInit").GetComponent <MapLoad>();
     pc              = GameObject.FindObjectOfType <PageChange>(); // ページ遷移のコンポーネント取得
     sketchBookValue = BOOK_MAX_SIZE;
     tempSketchValue = sketchBookValue;                            // 差分用変数の値を設定
     for (int i = 0; i > bookValueObj.Length; i++)                 // 残機UIの初期設定
     {
         bookValueObj[i].GetComponent <GameObject>();
     }
 }
Example #9
0
 // Use this for initialization
 void Start()
 {
     mapLoad      = FindObjectOfType <MapLoad>();                // マップ読み込みクラスのコンポーネント取得
     player       = FindObjectOfType <Player>();                 // プレイヤークラスのコンポーネント取得
     playerTrans  = player.transform;                            // プレイヤーの座標取得
     topLeft      = GetTopLeft();                                // カメラの左端を取得
     buttomRight  = GetButtomRight();                            // カメラの右端を取得
     mapStartX    = 0;                                           // マップの左端は必ず0になっている
     height       = mapLoad.height;                              // マップ読み込みクラスよりマップの高さを取得する
     heightOffset = 5.5f;                                        // 高さの補正値を設定
     mapEndX      = Mathf.Max(mapLoad.width);                    //マップの右端を取得
     edgeStartX   = Mathf.Abs(mapStartX - buttomRight.x + 0.5f); // マップ左端と自キャラの差分を求める
     edgeEndX     = Mathf.Abs(mapEndX - edgeStartX);             // マップ右端と自キャラの差分を求める
     // カメラ初期座標の設定
     this.transform.position = new Vector3(edgeStartX, playerTrans.position.y + offset.y, playerTrans.position.z + offset.z);
 }
Example #10
0
        public void Initialize()
        {
            IsEndFlag        = false;
            clearFlag        = false;
            characterManager = new CharacterManager();
            spP.Clear();

            mapLoad = new MapLoad();                    //マップクラスの作成
            mapLoad.LoadMap(1);                         //マップの1番目をロード

            List <TurnPoint> mpts = mapLoad.CreateTP(); //エネミーの通り道

            spP = new Dictionary <string, List <Vector2> >(mapLoad.CreateSpawnP());
            foreach (var mpl in mpts)
            {
                characterManager.AddTurnPoint(mpl);
            }
            Tower tower = new Tower(3, mapLoad.CreateTower()); //タワーを生成

            characterManager.AddTower(tower);                  //
            life = new Life(characterManager.tower.life, new Vector2(50, 800));

            MouseCol mouseCol = new MouseCol("clickUI", Input.MousePosition);

            characterManager.AddMouseCol(mouseCol);

            stage = Stage.S1; //現在のステージ

            waveCnt = 1;      //現在のウェーブ

            pillarCnt = 0;    //ピラーを置いた数(0で初期化)

            maxPillarCnt = 3;
            maxBulletCnt = 2; //弾を発射できる最大数

            timeCounter = 0;

            i             = 0;
            j             = 0;
            maxI          = 0;
            maxJ          = 0;
            waveClearFlag = false;

            SetPointMaxNum(stage);

            enemyCnt = 0;
        }
    public void Start()
    {
        inst = this.gameObject.GetComponent<BC2Instance>().instance;
        BC2Array array = Util.GetArray("Points", inst);
        foreach (Item Item in array.item)
        {
            ml = Util.GetMapload();
            Inst refPoint = Util.GetInst(Item.reference, ml.partition);
            points.Add(refPoint);
        }
        foreach(Inst point in points)
        {
            Complex posString = Util.GetComplex("Position", point);
            Vector3 pos = Util.CalculatePositionFromString(posString.value);
            pointPos.Add(pos);
        }

        LineRenderer LR = gameObject.AddComponent<LineRenderer>();
        LR.SetVertexCount(pointPos.Count);
        for(int i = 0; i < pointPos.Count; i++)
        {
            LR.SetPosition(i, pointPos[i]);
        }

        BC2Array planes = Util.GetArray("Planes", inst);
        Inst plane = Util.GetInst(planes.item[0].reference, ml.partition);
        if(Util.GetField("PlaneType", plane).value == "Lake")
        {
            GeneratePlane gp = transform.gameObject.AddComponent<GeneratePlane>();
            foreach(Vector3 v3 in pointPos)
            {
                gp.points.Add(v3);
            }
            Vector3 startpos = new Vector3();
            startpos.y = pointPos[0].y;
            transform.position = startpos;
            transform.rotation = new Quaternion(0, 0, 0, 0);

            gp.Generate();
            transform.GetComponent<MeshRenderer>().material = ml.waterMaterial;
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        MapLoad mapLoad = (MapLoad)target;


        if (GUILayout.Button("Save as " + mapLoad.saveAs))
        {
            mapLoad.Save();
        }
        string path = "Levels/" + mapLoad.mapName;
        string minimapPath;

        if (lastMapName != mapLoad.mapName)
        {
            if (Util.FileExist("Resources/" + path + ".xml"))
            {
                partition = Util.LoadPartition(path);
                foreach (Field field in Util.GetComplex("LevelDescription", partition.instance [0]).field)
                {
                    if (field.name == "MinimapTexture")
                    {
                        minimapPath  = Util.ClearGUIDString(field.reference);
                        minimapPath += ".itexture";
                        texture      = Util.LoadiTexture(minimapPath);
                    }
                }
            }
            lastMapName = mapLoad.mapName;
        }
        if (texture != null && !Application.isPlaying)
        {
            GUILayout.Label(texture, GUILayout.Width(EditorGUIUtility.currentViewWidth - 40), GUILayout.Height(EditorGUIUtility.currentViewWidth - 40));
        }
    }
Example #13
0
 void Start()
 {
     instance = this;
 }
Example #14
0
 // Use this for initialization
 void Awake()
 {
     mapload = this;
 }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            switch (CurrentGameState)
            {
            case GameState.Game1:
                spriteBatch.Begin();
                spriteBatch.Draw(Content.Load <Texture2D>("MainMenu"), new Rectangle(0, 0, WindowWidth, WindowHeight), Color.White);
                btnPlay.Draw(spriteBatch);
                break;

            case GameState.Playing:
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, null, null, null, transformMatrix: Camera.Transfrom);

                for (int z = 0; z < MapDepth; z++)
                {
                    int layer = z;
                    for (int y = 0; y < MapHeight; y++)
                    {
                        int row = y;
                        for (int x = 0; x < MapWidth; x++)
                        {
                            int column = x;

                            spriteBatch.Draw(
                                TileSet.TileSetTexture,
                                new Rectangle((x * Scale), (y * Scale), Scale, Scale),
                                TileSet.GetSourceRectangle(MapLoad.Maps(map, layer, row, column)),     //need to make variable fro map
                                Color.White,
                                0f,
                                Vector2.Zero,
                                SpriteEffects.None,
                                0f);
                        }
                    }
                }

                hero.Draw(spriteBatch);
                archer.Draw(spriteBatch);
                foreach (Sprite projectile in numProjectiles)     //drawing on all projectiles
                {
                    projectile.Draw(spriteBatch);
                }

                int tileNumNW = MapLoad.Maps(map, 1, (int)(hero.position.Y / Scale), (int)(hero.position.X / Scale));
                int tileNumSW = MapLoad.Maps(map, 1, (int)((hero.position.Y + hero.texture.Height * 3) / Scale), (int)(hero.position.X / Scale));
                int tileNumNE = MapLoad.Maps(map, 1, (int)(hero.position.Y / Scale), (int)((hero.position.X + hero.texture.Width * 3) / Scale));
                int tileNumSE = MapLoad.Maps(map, 1, (int)((hero.position.Y + hero.texture.Height * 3) / Scale), (int)((hero.position.X + hero.texture.Width * 3) / Scale));

                //((int)(hero.position.X/Scale)).ToString() + "," + ((int)(hero.position.Y / Scale)).ToString()

                spriteBatch.DrawString(font, tileNumNW.ToString(), hero.position, Color.Black);
                spriteBatch.DrawString(font, tileNumSW.ToString(), new Vector2(hero.position.X, hero.position.Y + hero.texture.Height * 3), Color.Black);
                spriteBatch.DrawString(font, tileNumNE.ToString(), new Vector2(hero.position.X + hero.texture.Width * 3, hero.position.Y), Color.Black);
                spriteBatch.DrawString(font, tileNumSE.ToString(), new Vector2(hero.position.X + hero.texture.Width * 3, hero.position.Y + hero.texture.Height * 3), Color.Black);


                break;

            case GameState.Inventory:
                spriteBatch.Begin();
                break;
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Example #16
0
 public void Awake()
 {
     gameObject.AddComponent<BoxCollider2D>().isTrigger = true;
     Debug.Log("asd");
     m = GameObject.Find("_Controll").GetComponent<MapLoad>();
 }