コード例 #1
0
        public void initBoard(UIPlane plane)
        {
            // create a new table with the given plane
            WARControlBoard.CreateTable(plane);

            // we're done with the setup mode so move to the deployment mode
            WARGame.SetMode(GAME_MODE.deployment);
        }
コード例 #2
0
        public void initBoard(UIPlane plane)
        {
            // remove an existing table if there is one
            if (table != null)
            {
                GameObject.Destroy(table);
            }

            // create a new object
            table = createTable(plane);
        }
コード例 #3
0
        public void AStarCostMap()
        {
            var go = new GameObject();
            // TODO make a mock grid class to test with
            // hex grid instantiates our WARGrid abstact logic
            var   grid        = go.AddComponent <WARHexGrid>();
            float globalScale = 0.01f;

            float outterRadius = 1f * globalScale;
            float innerRadius  = outterRadius * Mathf.Sqrt(3) / 2f;

            float numberOfColumns = 3f;
            float numberOfRows    = 9f;

            // create a plane on the origin with an extent of 0.25f
            var plane = new UIPlane {
                center = Vector3.zero,
                extent = new Vector3(3f * numberOfColumns * outterRadius, 0f, numberOfRows * innerRadius)
            };
            var hex = new GameObject("hex cell");

            hex.AddComponent <WARActorCell>();
            hex.AddComponent <MeshRenderer>();
            var child = new GameObject();

            child.transform.SetParent(hex.transform);
            child.AddComponent <TextMesh>();

            // an astar pathfinder to test
            var finder = new WARPathAStar();


            // initialize our grid with this plane and an empty hex cell 'prefab'
            grid.initialize(plane, hex, finder);
            // create the grid to populate cell metadata
            grid.createGrid();

            // the source of the source map
            int cellId = 3;

            // compute the map relative to our source
            var map = finder.getCostMap(cellId, grid);

            // make sure the source has no cost
            Assert.AreEqual(0, map[cellId]);
            // check a few known values at each weight
            Assert.AreEqual(1, map[2]);
            Assert.AreEqual(2, map[10]);
            Assert.AreEqual(3, map[11]);
            Assert.AreEqual(3, map[9]);
            Assert.AreEqual(4, map[19]);
            Assert.AreEqual(5, map[20]);
        }
コード例 #4
0
        // return the a new table with cool stuffs
        private GameObject createTable(UIPlane plane)
        {
            // create an empty game object to attach things to
            GameObject go = new GameObject("table");

            // make an instance of the singleton table actor
            WARActorTable table = go.AddComponent <WARActorTable>() as WARActorTable;

            table.initialize(plane, GRID_TYPE.hex);

            // return the table tree
            return(go);
        }
コード例 #5
0
        public void AStarStraightPath()
        {
            var go = new GameObject();
            // TODO make a mock grid class to test with
            // hex grid instantiates our WARGrid abstact logic
            var   grid        = go.AddComponent <WARHexGrid>();
            float globalScale = 0.01f;

            float outterRadius = 1f * globalScale;
            float innerRadius  = outterRadius * Mathf.Sqrt(3) / 2f;

            float numberOfColumns = 3f;
            float numberOfRows    = 9f;

            // create a plane on the origin with an extent of 0.25f
            var plane = new UIPlane {
                center = Vector3.zero,
                extent = new Vector3(3f * numberOfColumns * outterRadius, 0f, numberOfRows * innerRadius)
            };
            var hex = new GameObject("hex cell");

            hex.AddComponent <WARActorCell>();
            hex.AddComponent <MeshRenderer>();
            var child = new GameObject();

            child.transform.SetParent(hex.transform);
            child.AddComponent <TextMesh>();

            // an astar pathfinder to test
            var finder = new WARPathAStar();


            // initialize our grid with this plane and an empty hex cell 'prefab'
            grid.initialize(plane, hex, finder);
            // create the grid to populate cell metadata
            grid.createGrid();

            // compute the path from 3 to 9
            var path = finder.findPath(3, 9, grid);
            // the path we expect back
            var target = new List <int> {
                3, 2, 10, 9
            };

            // make sure we got what we want
            Assert.AreEqual(target, path);
        }
コード例 #6
0
ファイル: Test.cs プロジェクト: MrCuijc/cFramework
    private void OnGUI()
    {
        if (GUILayout.Button("CreateUIMessage"))
        {
            control        = ControlResources.CreateControl <UIPlane>();
            control.Parent = _2dRoot;

            UIMessageBox box = ControlResources.CreateControl <UIMessageBox>();
            box.DefaultEnable = false;

            UIBagControl bag = ControlResources.CreateControl <UIBagControl>();

            if (control is UIPlane)
            {
                UIPlane plane = control as UIPlane;
                plane.AddControl(box);
                plane.AddControl(bag);
            }

            //control.Show();
        }

        if (GUILayout.Button("Show"))
        {
            if (control != null)
            {
                control.Show();
            }
        }
        if (GUILayout.Button("Hide"))
        {
            if (control != null)
            {
                control.Hide();
            }
        }
        if (GUILayout.Button("Dispose"))
        {
            ControlResources.Destroy(control);
            control = null;
        }
    }
コード例 #7
0
        // return the a new table with cool stuffs
        public static void CreateTable(UIPlane plane)
        {
            // remove an existing table if there is one
            if (Instance.table != null)
            {
                GameObject.Destroy(Instance.table);
                // clear the selection
                WARControlSelection.ClearSelection();
            }
            var tableObject = new GameObject();

            // instantiate the appropriate pathfinder
            switch (Instance.pathfinderType)
            {
            // if we are making an astar
            case PATHFINDER_TYPE.astar:
                Instance.pathfinder = new WARPathAStar();
                break;
            }

            // spawn the appropriate grid for the
            switch (Instance.gridType)
            {
            // if we are building a hex grid
            case GRID_TYPE.hex:
                // fill our plane extent with hex slots
                WARHexGrid hexGrid = tableObject.AddComponent <WARHexGrid>() as WARHexGrid;
                hexGrid.initialize(plane, Instance.hexSlot, Instance.pathfinder);
                Instance.grid = hexGrid;
                break;

            default:
                print("could not instantiate cell with type " + Instance.gridType);
                return;
            }

            // draw the grid
            Instance.grid.createGrid();

            // we're done here
            Instance.table = tableObject;
        }
コード例 #8
0
 public void initialize(UIPlane plane, GRID_TYPE cellType)
 {
 }
コード例 #9
0
 public void initialize(UIPlane plane, GameObject hexPrefab, IWARPathfinder pathfinder)
 {
     base.initialize(pathfinder);
     this.plane     = plane;
     this.hexPrefab = hexPrefab;
 }