예제 #1
0
    public void LoadGame()
    {
        BinaryFormatter bf      = new BinaryFormatter();
        FileStream      fStream = new FileStream("GameMap.dat", FileMode.Open, FileAccess.Read, FileShare.None);

        try
        {
            GameMap = (Map_01)bf.Deserialize(fStream);
        }
        catch
        {
            Debug.Log("couldnt load game");
        }
    }
예제 #2
0
    public void Begin()
    {
        foreach (GameObject G in GameObject.FindGameObjectsWithTag("Unit"))
        {
            Destroy(G);
        }

        foreach (GameObject G in GameObject.FindGameObjectsWithTag("Building"))
        {
            Destroy(G);
        }

        GameMap = new Map_01();
        GameMap.NewBattlefield();
        TheGame = new GameEngine();

        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 20; y++)
            {
                Map_01 UnitPos = new Map_01();

                foreach (MeleeUnit u in GameMap.MeleeList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueS, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowS, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                }

                foreach (RangedUnit u in GameMap.RangedList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);

                                Instantiate(BlueA, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowA, pos, Quaternion.Euler(90, 180, 0));
                                break;
                            }
                        }
                    }
                }

                for (int i = 0; i < 4; i++)
                {
                    if (i == 0 || i == 1)
                    {
                        RecourceBuilding u = (RecourceBuilding)GameMap.buildingList[i];

                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.Team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueRec, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowRec, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                    else
                    {
                        Factory u = (Factory)GameMap.buildingList[i];

                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.Team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueFac, pos, Quaternion.Euler(90, 180, 0));
                                Debug.Log("factory");
                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowFac, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                }

                foreach (Wizard u in GameMap.WizardList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;

                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueW, pos, Quaternion.Euler(90, 180, 0));
                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowW, pos, Quaternion.Euler(90, 180, 0));
                                break;
                            }
                        }
                    }
                }
            }
        } //Update
    }
예제 #3
0
    private void updatebuttons()
    {
        foreach (GameObject G in GameObject.FindGameObjectsWithTag("Unit"))
        {
            Destroy(G);
        }

        Vector3 posP = new Vector3(9, -2, 0);

        Instantiate(parent, posP, Quaternion.identity);

        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 20; y++)
            {
                Map_01 UnitPos = new Map_01();

                foreach (MeleeUnit u in GameMap.MeleeList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueS, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowS, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                }

                foreach (RangedUnit u in GameMap.RangedList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);

                                Instantiate(BlueA, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowA, pos, Quaternion.Euler(90, 180, 0));
                                break;
                            }
                        }
                    }
                }

                for (int i = 0; i < 4; i++)
                {
                    if (i == 0 || i == 1)
                    {
                        RecourceBuilding u = (RecourceBuilding)GameMap.buildingList[i];

                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.Team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueRec, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowRec, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                    else
                    {
                        Factory u = (Factory)GameMap.buildingList[i];

                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;
                            switch (u.Team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueFac, pos, Quaternion.Euler(90, 180, 0));

                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowFac, pos, Quaternion.Euler(90, 180, 0));

                                break;
                            }
                        }
                    }
                }

                foreach (Wizard u in GameMap.WizardList)
                {
                    if (u != null)
                    {
                        if (x == u.X && y == u.Y)
                        {
                            Vector3 pos;

                            switch (u.team)
                            {
                            case "Blue":
                                pos = new Vector3(x, y, -2);
                                Instantiate(BlueW, pos, Quaternion.Euler(90, 180, 0));
                                break;

                            case "Yellow":
                                pos = new Vector3(x, y, -2);
                                Instantiate(YellowW, pos, Quaternion.Euler(90, 180, 0));
                                break;
                            }
                        }
                    }
                }
            }
        } //Update
    }     // displays positions of units and buildings
예제 #4
0
 void Start()
 {
     health = (Text)GameObject.Find("Canvas").GetComponentInChildren <Text>();
     form1  = (Map_01)GameObject.Find("Main Camera").GetComponent <Map_01>();
 }