示例#1
1
 public Chunk(Vector3 chunkSize, Vector3 location, Island island)
 {
     this.mChunkSize = chunkSize;
     this.mChunkLocation = location;
     this.mVisible = new bool[16, 16, 16, 6];
     this.mIsland = island;
 }
示例#2
0
        public override void populate(Island curr, Random random)
        {
            int x = random.Next(2, (int)curr.getSize().x) * Cst.CHUNK_SIDE;
            int z = random.Next(2, (int)curr.getSize().z) * Cst.CHUNK_SIDE;
            int y = curr.getSurfaceHeight(x, z);

            while (y == -1)
            {
                x = random.Next(2, (int)curr.getSize().x) * Cst.CHUNK_SIDE;
                z = random.Next(2, (int)curr.getSize().z) * Cst.CHUNK_SIDE;
                y = curr.getSurfaceHeight(x, z);
            }

            int size = ((int)(curr.getSize().x + curr.getSize().z) / 2) / 5;

            for(int i = 0; i < size * Cst.CHUNK_SIDE; i += 5) {
                for (int j = 0, max = random.Next(4, 10); j < max; j++) {
                    double angle = 2.0 * Math.PI * random.NextDouble();

                    int treeX = (int)(x + i * Math.Cos(angle)) + (random.Next(-10, 11) / 5);
                    int treeZ = (int)(y + i * Math.Sin(angle)) + (random.Next(-10, 11) / 5);
                    int treeY = curr.getSurfaceHeight(treeX, treeZ, "Grass");

                    if(treeY != -1) { this.createTree(curr, random, treeX, treeY, treeZ); }
                }
            }
        }
示例#3
0
 public void makeCross(Island current, Vector3 loc)
 {
     current.setBlockAt((int)loc.x + 1, (int)loc.y, (int)loc.z, "TowerWoodBlock", true);
     current.setBlockAt((int)loc.x - 1, (int)loc.y, (int)loc.z, "TowerWoodBlock", true);
     current.setBlockAt((int)loc.x, (int)loc.y, (int)loc.z + 1, "TowerWoodBlock", true);
     current.setBlockAt((int)loc.x, (int)loc.y, (int)loc.z - 1, "TowerWoodBlock", true);
 }
示例#4
0
        public override void populate(Island curr, Random random)
        {
            Vector3 p = new Vector3(curr.getSize().x * 8, curr.getSize().y * 16 + 16, curr.getSize().z * 8);
            Vector3 center = p + (8) * Vector3.UNIT_X  + (8) * Vector3.UNIT_Y + (8) * Vector3.UNIT_Z;

            for(float x = p.x; x < p.x + 18; x++) {
                for(float y = p.y; y < p.y + 18; y++) {
                    for(float z = p.z; z < p.z + 16; z++) {
                        if(isInSphere(x, y, z, center.x, center.y, center.z, 9)) {
                            curr.setBlockAt((int)x, (int)y, (int)z, 2, true);
                        }
                        if(y == center.y) {
                            curr.setBlockAt((int)x, (int)y, (int)z, "Grass", true);
                        }

                    }
                }
            }

            createTree(curr, random, (int)center.x, (int)center.y + 1, (int)center.z);
            createTree(curr, random, (int)center.x + 7, (int)center.y + 1, (int)center.z - 3);
            createTree(curr, random, (int)center.x, (int)center.y + 1, (int)center.z + 7);
            createTree(curr, random, (int)center.x + 2, (int)center.y + 1, (int)center.z + 7);
            createTree(curr, random, (int)center.x + 5, (int)center.y + 1, (int)center.z - 7);
            createTree(curr, random, (int)center.x + 4, (int)center.y + 1, (int)center.z + 4);

            createTree(curr, random, (int)center.x - 2, (int)center.y + 1, (int)center.z + 3);
            createTree(curr, random, (int)center.x - 2, (int)center.y + 1, (int)center.z + 4);
            createTree(curr, random, (int)center.x - 6, (int)center.y + 1, (int)center.z - 7);
            createTree(curr, random, (int)center.x - 5, (int)center.y + 1, (int)center.z - 5);
            createTree(curr, random, (int)center.x - 8, (int)center.y + 1, (int)center.z - 3);
        }
示例#5
0
 public void reSpawnCurrentIsland(int verticeCount, float amplitude, float roughness)
 {
     // (currently not directly in use)
     Destroy (currentIsland.getGameObject (), 0f);
     currentIsland = spawnIsland (verticeCount, amplitude, roughness);
     spawnCamera ();
 }
示例#6
0
 public Zone(int index, int levelIndex, string name, Island island)
 {
     Index = index;
       LevelIndex = levelIndex;
       Name = name;
       Island = island;
 }
示例#7
0
        public void build(Island current, Random rd, Vector3 loc)
        {
            int towerHeight = rd.Next(15, 30);
            //body
            for(int x = 0; x < xMax; x++) {
                for(int z = 0; z < zMax; z++) {
                    for(int y = 0; y <= towerHeight; y++) {
                        if((x == 0 && z == 0) || (x == 0 && z == zMax - 1) || (x == xMax - 1 && z == 0) || (z == zMax - 1 && x == xMax - 1)) { //corners
                            current.setBlockAt((int)loc.x + x, (int)loc.y + y, (int)loc.z + z, "TowerWoodBlock", true);
                        } else if((x == 0 || z == 0 || x == xMax - 1 || z == zMax - 1) && y != towerHeight) { //borders
                            current.setBlockAt((int)loc.x + x, (int)loc.y + y, (int)loc.z + z, "DarkWood", true);
                        }

                        if(y == 0 || y == 1 || y == towerHeight - 1) {
                            if(x == 0 || z == 0 || x == xMax - 1 || z == zMax - 1) { //borders
                                current.setBlockAt((int)loc.x + x, (int)loc.y + y, (int)loc.z + z, "TowerWoodBlock", true);
                            } else {
                                current.setBlockAt((int)loc.x + x, (int)loc.y + y, (int)loc.z + z, "DarkWood", true);
                            }
                        }
                    }
                }
            }

            new DarkBeard().makeDarkBeard(current, towerHeight, loc, xMax, zMax);
            new RoofBuilder().build(current, loc + Vector3.UNIT_Y * towerHeight, new Vector2(xMax, zMax), rd);
            new Bridge(this.mSourceBuilding, this.getEntrance(this.mSourceBuilding, 1, loc), new NullTower()).build(current);
        }
示例#8
0
        public List<Node> getAdjacent(Island current, Vector3 destination)
        {
            Vector3[] adjacent = new Vector3[] {
                Vector3.UNIT_X, Vector3.UNIT_Z,
                Vector3.NEGATIVE_UNIT_X, Vector3.NEGATIVE_UNIT_Z,
                Vector3.UNIT_X + Vector3.UNIT_Z, Vector3.UNIT_X + Vector3.NEGATIVE_UNIT_Z,
                Vector3.NEGATIVE_UNIT_X + Vector3.UNIT_Z, Vector3.NEGATIVE_UNIT_X + Vector3.NEGATIVE_UNIT_Z,
            };

            List<Node> returnList = new List<Node>();

            Vector3 adj = Vector3.ZERO;

                for(int i = 0; i < adjacent.Length; i++) {
                    adj = adjacent[i] + this.pos;
                    if(current.getBlock(adj, false) is Air && !(current.getBlock(adj + Vector3.NEGATIVE_UNIT_Y, false) is Air)) {
                        returnList.Add(new Node(destination, adj, this));
                    } else if(current.getBlock(adj + Vector3.UNIT_Y, false) is Air && !(current.getBlock(adj, false) is Air)) {
                        returnList.Add(new Node(destination, adj + Vector3.UNIT_Y, this));
                    } else if(current.getBlock(adj - Vector3.UNIT_Y, false) is Air && !(current.getBlock(adj - 2 * Vector3.UNIT_Y, false) is Air)) {
                        returnList.Add(new Node(destination, adj - Vector3.UNIT_Y, this));
                    }
                }
            //}
            return returnList;
        }
示例#9
0
        public static void makePortal(int val, Island current, Vector3 position)
        {
            switch(val) {
                case 1:
                    for(int x = 0; x < 4; x++) {
                        for(int y = -1; y < 5; y++) {
                            if(x == 0 || x == 3 || y == -1 || y == 4) { current.setBlockAt((int)position.x + x, (int)position.y + y, (int)position.z, "Crystal", true); }
                            else { current.setBlockAt((int)position.x + x, (int)position.y + y, (int)position.z, "CrystalGate H", true); }
                        }
                    }
                break;
                case 2:
                for(int x = 0; x < 4; x++) {
                    for(int z = 0; z < 4; z++) {
                        if(x == 0 || z == 0 || x == 3 || z == 3) { current.setBlockAt((int)position.x + x, (int)position.y, (int)position.z + z, "Crystal", true); }
                        else {
                            current.setBlockAt((int)position.x + x, (int)position.y, (int)position.z + z, "CrystalGate H", true);
                        }
                    }
                }

                break;

            }
        }
示例#10
0
 public BuildingManager(StateManager stateMgr, Island island, RTSManager RTSMgr)
 {
     this.mStateMgr = stateMgr;
     this.mIsland = island;
     this.mRTSManager = RTSMgr;
     this.Buildings = new Dictionary<Vector3, Building>();
 }
示例#11
0
文件: Animal.cs 项目: kmichel/passeur
 public void Update(Island island, float movementProbability, float eatGrassProbability)
 {
     age += Time.deltaTime;
     Move(island, movementProbability);
     if (type == AnimalType.Sheep)
         EatGrass(island, eatGrassProbability);
 }
示例#12
0
        public override void populate(Island curr, Random random)
        {
            {
                for (int i = 0; i < (curr.getSize().x + curr.getSize().z) * 4; i++)
                {
                    Vector3 pos = this.findRandomPoint(curr, random, "Grass");

                    if ((curr.getBlock((int)pos.x, (int)pos.y, (int)pos.z, true) is AirBlock))
                    {
                        for (int p = 1; p < 6; p++)
                        {
                            int tmp = 0;
                            for (int y = 6 * p; y < 9 * p; y++)
                            {
                                for (int x = 0 + tmp; x < 7 - tmp; x++)
                                {
                                    for (int z = 0 + tmp; z < 7 - tmp; z++)
                                    {
                                        curr.setBlockAt((int)pos.x + x - 3, (int)pos.y + y, (int)pos.z + z - 3, "Leaves", true);
                                    }
                                }
                                tmp++;
                            }
                        }

                        for (int y = 0; y < 30; y++)
                        {
                            curr.setBlockAt((int)pos.x, (int)pos.y + y, (int)pos.z, "DarkWood", true);
                        }
                    }
                }
            }
        }
 public void AddIsland(Island island)
 {
     if (islands == null) {
         islands = new List<Island> ();
     }
     islands.Add (island);
 }
 public void GoToLevel(Island island)
 {
     //		Debug.Log(island.LevelName);
     //		string levelName = island.LevelName;
     //Todo goto level with this name
     Application.LoadLevel(island.LevelName);
 }
示例#15
0
        public void createTree(Island curr, Random random, int x, int y, int z)
        {
            for(int i = 0, height = random.Next(6, 12); i < height; i++) {
                if(i != height - 1) { curr.setBlockAt(x, y + i, z, "Wood", true); } else { curr.setBlockAt(x, y + i, z, "Leaves", true); }
                if(i >= height - 5 && i < height - 3) {
                    for(int j = -2; j < 3; j++) {
                        for(int k = -2; k < 3; k++) {
                            if(j == 0 && k == 0) { continue; }
                            if((j == -2 && (k == -2 || k == 2)) || (j == 2 && (k == -2 || k == 2))) {
                                if(random.Next(0, 100) > 15) { curr.setBlockAt(x + j, y + i, z + k, "Leaves", true); }
                            } else {
                                curr.setBlockAt(x + j, y + i, z + k, "Leaves", true);
                            }
                        }
                    }
                } else if(i >= height - 3) {
                    for(int j = -1; j < 2; j++) {
                        for(int k = -1; k < 2; k++) {
                            if(j == 0 && k == 0) { continue; }
                            if(i == height - 3 && (j == -1 && (k == -1 || k == 1)) || (j == 1 && (k == -1 || k == 1))) {
                                if(random.Next(0, 100) > 75) { curr.setBlockAt(x + j, y + i, z + k, "Leaves", true); }
                            } else {
                                curr.setBlockAt(x + j, y + i, z + k, "Leaves", true);
                            }
                        }
                    }
                }

            }
        }
示例#16
0
 public Player(PlayerIndex playerIndex, IShip ship, Island homeIsland, Map map)
 {
     this.playerIndex = playerIndex;
     this.ship = ship;
     this.homeIsland = homeIsland;
     this.map = map;
 }
示例#17
0
 public Sloop CreateSloop(Color color, Vector2 shipLocation, Island playerIsland, float shipAngle)
 {
     Sloop ship = new Sloop(base.Game, shipLocation, CannonBallManager, shipAngle);
     SloopView shipView = new SloopView(base.Game, color, Color.White, SpriteBatch, ship);
     base.Game.Components.Add(ship);
     base.Game.Components.Add(shipView);
     return ship;
 }
示例#18
0
 public Cutter CreateCutter(Color color, Vector2 shipLocation, Island playerIsland, float shipAngle)
 {
     Cutter ship = new Cutter(base.Game, shipLocation, CannonBallManager, shipAngle);
     CutterView shipView = new CutterView(base.Game, color, Color.White, SpriteBatch, ship);
     base.Game.Components.Add(ship);
     base.Game.Components.Add(shipView);
     return ship;
 }
示例#19
0
 public void display(Island currentIsland, API.Geo.World currentWorld)
 {
     if (this.faceNumber > 0) {
         block.End();
         this.node = this.mIsland.Node.CreateChildSceneNode("MultiBlockNode-" + this.mName);
         this.node.AttachObject(block);
     }
 }
示例#20
0
 public Island CreateIsland(Vector2 position, int goldAmount)
 {
     Island island = new Island(base.Game, position, goldAmount);
     GameObjectView islandView = new GameObjectView(base.Game, Content.Island, Color.White, SpriteBatch, island, ZIndexManager.getZIndex(ZIndexManager.drawnItemOrders.island));
     base.Game.Components.Add(island);
     base.Game.Components.Add(islandView);
     return island;
 }
示例#21
0
 public Island spawnIsland(int verticeCount, float amplitude, float roughness)
 {
     // Spawn a new island and return a reference
     Island theIsland = new Island (GameObject.Find ("Root"), "Island 01");
     theIsland.spawnTerrain (10.0f, 4, amplitude, roughness);
     theIsland.spawnDelauney (verticeCount, 10f);
     return theIsland;
 }
示例#22
0
 public void addNewIsland(int verticeCount, float amplitude, float roughness)
 {
     // Add a new island to the buffer, switch the view, drop cam
     currentIsland.setVisible (false);
     currentIsland = spawnIsland (verticeCount, amplitude, roughness);
     theIslands.Add (currentIsland);
     spawnCamera ();
 }
示例#23
0
文件: Boat.cs 项目: Lattyware/lgj2.0
	public void InitializeVals(int nVikings, int nSheep, Island source, GameObject island){
		numVikings = nVikings;
		numSheep = nSheep;
		sourceIsland = source.gameObject;
		targettedIsland = island;
		rotAngle = this.transform.rotation.y;
		//this.transform.Rotate(new Vector3(0, 90, 0));
	}
示例#24
0
 /// <summary>
 /// An AIController should have access to all information a user of the system has.
 /// </summary>
 /// <param name="game">The game</param>
 /// <param name="controlledShip">The ship that the AI is controlling</param>
 /// <param name="homeIsland">The ship's home island</param>
 /// <param name="islands">All islands in the game(excluding the ships home island)</param>
 public AIController(Game game, IShip controlledShip, Island homeIsland, List<Island> otherIslands, IShip targetShip)
     : base(game)
 {
     this.ControlledShip = controlledShip;
     this.HomeIsland = homeIsland;
     this.OtherIslands = otherIslands;
     this.ProximityRadius = 50.0f;
     this.TargetShip = targetShip;
 }
示例#25
0
        public override void populate(Island curr, Random random)
        {
            Vector3 pos = this.findRandomPoint(curr, random);
            int tmp = 0;

            string brick = "Sand";

            curr.setBlockAt((int)pos.x, (int)pos.y, (int)pos.z, brick, true);
            for (int y = 0; y < 18; y++)
            {
                for (int x = 0 + tmp; x < _width - tmp; x++)
                {
                    for (int z = 0 + tmp; z < _width - tmp; z++) {

                        if (y == 0 || y == 7)
                            curr.setBlockAt((int)pos.x + x, (int)pos.y + y - 7, (int)pos.z + z, brick, true);
                        else if ((x == 0 || z == 0 || x == _width - 1 || z == _width - 1) && y <= 6)
                            curr.setBlockAt((int)pos.x + x, (int)pos.y + y - 7, (int)pos.z + z, brick, true);
                        else if (y > 7)
                            curr.setBlockAt((int)pos.x + x, (int)pos.y + y - 7, (int)pos.z + z, brick, true);
                        else
                            curr.setBlockAt((int)pos.x + x, (int)pos.y + y - 7, (int)pos.z + z, "Air", true);
                    }
                }
                if (y >= 7)
                    tmp++;
            }

            CharacterInfo iaInfo = new CharacterInfo("Robot-" + Guid.NewGuid().ToString(), Faction.Red);

            iaInfo.SpawnPoint = new Vector3(pos.x + _width / 2 - 4, (int)pos.y - 5, (int)pos.z + _width / 2) * Cst.CUBE_SIDE;
            curr.mWorld.getStateMgr().MainState.CharacMgr.AddCharacter(iaInfo);

            iaInfo = new CharacterInfo("Robot-" + Guid.NewGuid().ToString(), Faction.Red);
            iaInfo.SpawnPoint = new Vector3(pos.x + _width / 2 + 4, (int)pos.y - 5, (int)pos.z + _width / 2) * Cst.CUBE_SIDE;
            curr.mWorld.getStateMgr().MainState.CharacMgr.AddCharacter(iaInfo);

            Portals.makePortal(1, curr, new Vector3((int)pos.x + _width / 2 - 2, (int)pos.y - 7, (int)pos.z + _width / 2 - 3));

            int tmp2 = 0;
            for (int y = 1; y < 6; y++)
            {
                for (int x = 0; x < 2; x++)
                {
                    for (int z = tmp2; z < tmp2 + 2; z++)
                    {
                        curr.setBlockAt((int)pos.x + _width / 2 - 1 + x, (int)pos.y + y - 8, (int)pos.z + _width - 1 + z, brick, true);
                        curr.setBlockAt((int)pos.x + _width / 2 - 1 + x, (int)pos.y + y - 7, (int)pos.z + _width - 1 + z, "Air", true);
                        curr.setBlockAt((int)pos.x + _width / 2 - 1 + x, (int)pos.y + y - 5, (int)pos.z + _width - 1 + z, "Air", true);
                        curr.setBlockAt((int)pos.x + _width / 2 - 1 + x, (int)pos.y + y - 6, (int)pos.z + _width - 1 + z, "Air", true);

                    }
                }
                tmp2++;
            }
        }
示例#26
0
文件: Animal.cs 项目: kmichel/passeur
 public void EatGrass(Island island, float eatGrassProbability)
 {
     if (island.RandFloat(0f, 1f) < eatGrassProbability) {
         foreach (var grass in island.grasses) {
             if (grass.row == row && grass.column == column) {
                 island.grasses.Remove(grass);
                 break;
             }
         }
     }
 }
示例#27
0
        public MultiBlock(string mat, Island current, World mainWorld, int meshType)
        {
            this.mMaterial = mat;
            this.mName = this.mMaterial + Guid.NewGuid().ToString();

            this.mIsland = current;
            this.mWorld = mainWorld;

            block = new ManualObject("MultiBlock-" + this.mName);
            block.Begin(this.mMaterial, RenderOperation.OperationTypes.OT_TRIANGLE_LIST);
            this.meshType = meshType;
        }
示例#28
0
        public void build(Island current, Vector3 location, Vector2 size, Random rd)
        {
            for(int x = 0; x < size.x; x++) {
                for(int z = 0; z < size.y; z++) {
                    if(x == 0 || x == size.x - 1 || z == 0 || z == size.y - 1) {
                        //build fences
                    }

                    if(x == size.x / 2 && z == size.y / 2) { this.buildStructure(current, rd.Next(0, 100) % 3, new Vector3(location.x + x, location.y, location.z + z)); }
                }
            }
        }
        public ActionResult Index()
        {
            var islandTileList = db.IslandTile.ToList();

            var playerList = db.Player.ToList();


            var    islandFactory = new IslandFactory();
            Island island        = islandFactory.Create(islandTileList);

            return(View(island));
        }
示例#30
0
        public override void populate(Island curr, Random random)
        {
            for(int x = 0; x < curr.getSize().x * Cst.CHUNK_SIDE; x++) {
                for(int z = 0; z < curr.getSize().z * Cst.CHUNK_SIDE; z++) {
                    int y = curr.getSurfaceHeight(x, z);

                    if(y >= 200) {
                        curr.setBlockAt(x, y, z, 23, true);
                    }
                }
            }
        }
示例#31
0
 public VanillaChunk(Vector3 chunkSize, Vector3 location, Island island)
     : base(chunkSize, location, island)
 {
     this.mBlockList = new Block[16, 16, 16];
     for(int x = 0; x < mChunkSize.x; x++) {
         for(int y = 0; y < mChunkSize.y; y++) {
             for(int z = 0; z < mChunkSize.z; z++) {
                 this.mBlockList[x, y, z] = staticBlock["Air"];
             }
         }
     }
 }
示例#32
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter name of plenet");
            string nameOfPlanet = Console.ReadLine();
            Planet planet       = new Planet(nameOfPlanet);

            Console.WriteLine("Enter number of continents");
            int numberOfContinents = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < numberOfContinents; i++)
            {
                Console.WriteLine("Enter name of continent");
                string nameOfContinent = Console.ReadLine();
                Console.WriteLine("Enter area of continent");
                double    areaOfContinent = Convert.ToDouble(Console.ReadLine());
                Continent continent       = new Continent(nameOfContinent, areaOfContinent);
                planet.AddContinent(continent);
            }

            Console.WriteLine("Enter number of oceans");
            int numberOfOceans = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < numberOfOceans; i++)
            {
                Console.WriteLine("Enter name of ocean");
                string nameOfOcean = Console.ReadLine();
                Console.WriteLine("Enter temperature of ocean");
                double temperatureOfOcean = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Enter depth of ocean");
                double depthOfOcean = Convert.ToDouble(Console.ReadLine());
                Ocean  ocean        = new Ocean(nameOfOcean, temperatureOfOcean, depthOfOcean);
                planet.AddOcean(ocean);
            }

            Console.WriteLine("Enter number of islands");
            int numberOfIslands = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < numberOfIslands; i++)
            {
                Console.WriteLine("Enter name of island");
                string nameOfIsland = Console.ReadLine();
                Console.WriteLine("Enter population of island");
                double populationOfIsland = Convert.ToDouble(Console.ReadLine());
                Island island             = new Island(nameOfIsland, populationOfIsland);
                planet.AddIsland(island);
            }

            Console.WriteLine("Name of planet: " + planet.ReturnName() + "\n");
            Console.WriteLine(planet.ReturnInformationOfContinents() + "\n");
            Console.WriteLine(planet.ReturnInformationOfOceans() + "\n");
            Console.WriteLine(planet.ReturnInformationOfIslands() + "\n");
        }
示例#33
0
    public void Init()
    {
        island        = transform.parent.GetComponent <Island>();
        gridSize      = GameManager.Instance.GridSize;
        gridDivisions = GameManager.Instance.GridDivisions;

        GenerateBoard();

        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;

        initReady = true;
    }
示例#34
0
        public char GuessNumber(ref Island orig)
        {
            Island island = new Island(orig);
            char   g      = makeGuess(ref island);

            if (g == ' ')
            {
                island = new Island(orig);
                island.Grow();
                return(makeGuess(ref island));
            }
            return(g);
        }
示例#35
0
 public void AddIsland(Island island)
 {
     if (_islands.TryGetValue(island, out int refCount))
     {
         refCount++;
     }
     else
     {
         refCount = 1;
     }
     _islands[island] = refCount;
     UpdateScore();
 }
示例#36
0
    void createStartingIsland()
    {
        Island         island         = world.createNewIsland(new Coordinate(0, 0, 0));
        GameObject     startingIsland = Instantiate(islandObject, island.location.vec3 * World.WORLD_NEXUS_LENGTH * World.BLOCK_SIZE, new Quaternion(), transform);
        IslandRenderer islandRenderer = startingIsland.GetComponent <IslandRenderer>();

        islandRenderer.initialize(island);
        playerObject.GetComponent <PlayerController>().currentRenderer = islandRenderer;
        Player player1 = world.players[0];

        player1.updateLevel(island);
        islandRenderer.renderAroundPlayer(player1);
    }
示例#37
0
    public Island getNextIsland(Island currentIsland)
    {
        int indexOld = route.IndexOf(currentIsland);

        if (route.Count < indexOld)
        {
            return(route[indexOld + 1]);
        }
        else
        {
            return(route[0]);
        }
    }
示例#38
0
    public override void Paint(Island island)
    {
        int count = 0;

        foreach (var section in m_sections)
        {
#if UNITY_EDITOR
            UnityEditor.EditorUtility.DisplayProgressBar("Painting Forest", "Painting Sections...", (float)count / (float)m_sections.Length);
#endif
            section.Paint();
            count++;
        }
    }
示例#39
0
        public PathFinder(Vector3 destination, Vector3 start, Island current)   // dest in abs value, start rel
        {
            this.mOpen           = new NodeList <Node>();
            this.mClosed         = new NodeList <Node>();
            this.mPossibleNodes  = new List <Node>();
            this.mSolutionSize   = 0;
            this.mNbTotIter      = 0;
            this.mAbsDestination = destination;
            this.mRelDestination = MainWorld.getRelativeFromAbsolute(this.mAbsDestination);
            this.mCurrent        = current;

            this.mOpen.Add(new Node(this.mRelDestination, start));
        }
        public IEnumerator AdjustDockTransform(Island island)
        {
            CartographicIsland islandStructure = island.CartographicIsland;
            var         dependencyGraph        = islandStructure.Bundle.OSGiProject.DependencyGraph;
            GraphVertex vertex = islandStructure.DependencyVertex;

            GameObject importDock = island.ImportDock;
            GameObject exportDock = island.ExportDock;

            yield return(FindSuitablePosition2D(island, importDock, exportDock));

            if (vertex == null)
            {
                yield break;
            }

            float importSize = 0.04f * 25f; // Don't hardcode.
            float exportSize = 0.04f * 25f; // Don't hardcode.

            IEnumerable <GraphEdge> outEdges;

            dependencyGraph.TryGetOutEdges(vertex, out outEdges);
            List <GraphEdge> edgeList = outEdges.ToList();

            importDock.transform.localScale = new Vector3(importSize, importSize, importSize);
            DependencyDock dockComponent = importDock.GetComponent <DependencyDock>();

            dockComponent.setDockType(DockType.Import);

            foreach (GraphEdge e in edgeList)
            {
                GameObject ed = e.Target.Island.IslandGameObject.GetComponent <Island>().ExportDock;
                dockComponent.addDockConnection(ed.GetComponent <DependencyDock>(), e.Weight);
            }

            dependencyGraph.TryGetInEdges(vertex, out outEdges);
            edgeList = outEdges.ToList();

            float eDockWidth = exportDock.GetComponent <MeshFilter>().sharedMesh.bounds.size.x *exportSize;
            float iDockWidth = importDock.GetComponent <MeshFilter>().sharedMesh.bounds.size.x *importSize;

            exportDock.transform.localScale = new Vector3(exportSize, exportSize, exportSize);
            dockComponent = exportDock.GetComponent <DependencyDock>();
            dockComponent.setDockType(DockType.Export);

            foreach (GraphEdge e in edgeList)
            {
                GameObject id = e.Source.Island.IslandGameObject.GetComponent <Island>().ImportDock;
                dockComponent.addDockConnection(id.GetComponent <DependencyDock>(), e.Weight);
            }
        }
示例#41
0
        public ActionResult ChangeName(int id)
        {
            Island island = islandRepository.GetIsland(id);

            if (island.Property.Player.Id != User.Identity.GetUserId())
            {
                return(RedirectToAction("Map"));
            }
            ChangeNameViewModel viewModel = new ChangeNameViewModel {
                NameUsed = false, Id = id
            };

            return(View(viewModel));
        }
示例#42
0
 public VanillaChunk(Vector3 chunkSize, Vector3 location, Island island) : base(chunkSize, location, island)
 {
     this.mBlockList = new Block[16, 16, 16];
     for (int x = 0; x < mChunkSize.x; x++)
     {
         for (int y = 0; y < mChunkSize.y; y++)
         {
             for (int z = 0; z < mChunkSize.z; z++)
             {
                 this.mBlockList[x, y, z] = staticBlock["Air"];
             }
         }
     }
 }
示例#43
0
    private void RevealIsland(Island island)
    {
        currentIsland = island;

        // See if new sector needs to be generated
        int   offSize     = size - 1;
        Point sectorPoint = new Point(island.point.x % offSize, island.point.y % offSize);

        // Negative space offset
        int negativeX = 0;
        int negativeY = 0;

        // Negative sectors
        if (sectorPoint.x < 0)
        {
            sectorPoint.x = offSize + sectorPoint.x;
            negativeX    -= 1;
        }
        if (sectorPoint.y < 0)
        {
            sectorPoint.y = offSize + sectorPoint.y;
            negativeY    -= 1;
        }

        int range = 7;

        // Horizontal
        if (sectorPoint.x <= range)
        {
            Point sector = new Point(island.point.x / offSize - 1 + negativeX, island.point.y / offSize + negativeY);
            GenerateMap(sector);
        }
        else if (sectorPoint.x >= offSize - range)
        {
            Point sector = new Point(island.point.x / offSize + 1 + negativeX, island.point.y / offSize + negativeY);
            GenerateMap(sector);
        }

        // Vertical
        if (sectorPoint.y <= range)
        {
            Point sector = new Point(island.point.x / offSize + negativeX, island.point.y / offSize - 1 + negativeY);
            GenerateMap(sector);
        }
        else if (sectorPoint.y >= offSize - range)
        {
            Point sector = new Point(island.point.x / offSize + negativeX, island.point.y / offSize + 1 + negativeY);
            GenerateMap(sector);
        }
    }
示例#44
0
        public IActionResult OnGet(int?islandId)
        {
            this.Climates = htmlHelper.GetEnumSelectList <ClimateType>();
            if (islandId.HasValue)
            {
                Island = islandData.GetById(islandId.Value);
            }
            else
            {
                Island = new Island();
            }

            return(Page());
        }
示例#45
0
    public LookMenu(int width, int height, Island world, string hint = null, Func <Entity, bool> select = null, Action <XYZ> selectAt = null) : base(width, height)
    {
        UseKeyboard = true;

        this.world    = world;
        this.hint     = hint ?? "Select an entity to examine";
        this.select   = select ?? (e => false);
        this.selectAt = selectAt ?? (xyz => { });
        cursorVisible = true;
        cursorBlink   = new Timer(0.4, () => {
            cursorVisible = !cursorVisible;
        });
        UpdateExamine();
    }
示例#46
0
        public void DoTurn(IPirateGame state)
        {
            // Initing stuff
            List <Island> islands     = state.NotMyIslands();
            List <Pirate> myPirates   = state.MyPirates();
            List <Pirate> copyPirates = new List <Pirate>(myPirates);
            Dictionary <Pirate, Island> pirateToIsland = new Dictionary <Pirate, Island>();

            for (int i = 0; i < islands.Count; i++)
            {
                Pirate closestPirate = GetClosestPirate(state, islands[i], myPirates);

                //state.Debug($"closest: {closestPirate.Id.ToString()} to island: {islands[i]}");
                if (closestPirate != null)
                {
                    myPirates.Remove(closestPirate);
                    pirateToIsland.Add(closestPirate, islands[i]);
                }
            }

            copyPirates.ForEach(pirate =>
            {
                if (pirateToIsland.ContainsKey(pirate) && pirateToIsland[pirate] != null)
                {
                    Island island = pirateToIsland[pirate];
                    state.Debug($"Pirate {pirate.Id.ToString()} to island {island.Id.ToString()}");
                    List <Direction> movingDirections = state.GetDirections(pirate, island);

                    if (movingDirections.Count > 0 && !pirate.IsLost)
                    {
                        state.Debug($"Pirate: {pirate.Id.ToString()}");
                        movingDirections.ForEach(direc =>
                        {
                            state.Debug($"{direc}");
                        });
                        state.SetSail(pirate, movingDirections[0]);
                    }
                }
                else // Bot that has no island
                {
                    state.Debug($"Nothing {pirate.Id.ToString()}");
                    Island closestIsland = GetClosestIsland(state, pirate, state.NotMyIslands());
                    if (closestIsland != null)
                    {
                        List <Direction> movingDirections = state.GetDirections(pirate, closestIsland);
                        state.SetSail(pirate, movingDirections[0]);
                    }
                }
            });
        }
示例#47
0
        public void Board_cannot_find_land_from_invalid_coordinate()
        {
            // arrange
            var board = new Island();
            var posX  = _faker.Random.Number(int.MinValue, -1);
            var posY  = _faker.Random.Number(5, int.MaxValue);

            // act
            var success = board.TryGetLand(posX, posY, out var land);

            // assert
            success.Should().BeFalse();
            land.Should().BeNull();
        }
    void SpawnIsland()
    {
        if (currentIsland != null)
        {
            Destroy(currentIsland);
        }

        currentIsland = (GameObject)GameObject.Instantiate(islandPrefab, Vector3.zero, Quaternion.identity);

        Island isl = currentIsland.GetComponent <Island>();

        isl.islandPosition = new Vector3(Random.Range(0, 10000), Random.Range(0, 10000), Random.Range(0, 10000));
        isl.Regenerate(true);
    }
示例#49
0
        public static void Feather(Island island)
        {
            for (var i = island.Pixels.Count - 1; i >= 0; i--)
            {
                var pixel = island.Pixels[i];
                var x     = pixel.X;
                var y     = pixel.Y;

                TryFeather(island, x - 1, y);
                TryFeather(island, x + 1, y);
                TryFeather(island, x, y - 1);
                TryFeather(island, x, y + 1);
            }
        }
示例#50
0
        public IEnumerator CanPlaceBlockAtMaximumHeight()
        {
            Island        testCandidate = new Island(64);
            Block         testBlock     = EarthBlock.GetInstance();
            BlockPosition blockPosition = new BlockPosition(63, 255, 63);

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            Block blockAt = testCandidate.GetBlockAt(blockPosition);

            yield return(null);

            Assert.That(blockAt, Is.SameAs(testBlock));
        }
示例#51
0
    public Player(Island World, XYZ Position)
    {
        this.World    = World;
        this.Position = Position;
        this.Velocity = new XYZ(0, 0, 0);
        Actions       = new HashSet <EntityAction>();
        Equipment     = new Equipment();
        Inventory     = new HashSet <IItem>();
        Watch         = new HashSet <Effect>();

        HistoryLog    = new List <HistoryEntry>();
        HistoryRecent = new List <HistoryEntry>();
        health        = new Health();
    }
示例#52
0
        public IEnumerator RetrievesPreviouslyPlacedBlock()
        {
            Island        testCandidate = new Island(64);
            Block         testBlock     = GrassyEarthBlock.GetInstance();
            BlockPosition blockPosition = new BlockPosition(63, 0, 63);

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            Block blockAt = testCandidate.GetBlockAt(blockPosition);

            yield return(null);

            Assert.That(blockAt, Is.SameAs(testBlock));
        }
示例#53
0
        public IEnumerator BuildIslandHightlight(Island island)
        {
            GameObject highlight = new GameObject("Island Highlight");

            yield return(BuildHighlight(island.gameObject, highlight));

            MeshRenderer renderer     = highlight.GetComponent <MeshRenderer>();
            Interactable interactable = island.GetComponent <Interactable>();

            foreach (Region region in island.Regions)
            {
                yield return(BuildRegionHighlight(region));
            }

            if (true)
            {
                interactable.FocusBehaviour = new Action(() => {
                    if (StateManager.Instance.CurrentState.Name == "main" && interactable.Type == InteractableType.Bundle)
                    {
                        UIManager.Instance.SetPanelHeaderTop("Bundle");
                        UIManager.Instance.SetPanelHeaderBottom(island.name);
                        UIManager.Instance.Tooltip.Show(island.gameObject);
                    }

                    UIManager.Instance.Tooltip.Show(island.gameObject);
                    interactable.Highlight.gameObject.SetActive(true);
                });

                interactable.DefocusBehaviour = new Action(() => {
                    if (StateManager.Instance.CurrentState.Name == "main" && interactable.Type == InteractableType.Bundle)
                    {
                        UIManager.Instance.SetPanelHeaderTop("");
                        UIManager.Instance.SetPanelHeaderBottom("");
                    }

                    UIManager.Instance.Tooltip.Hide();
                    interactable.Highlight.gameObject.SetActive(false);
                });

                interactable.SelectBehaviour = new Action(() => {
                    UIManager.Instance.SetPanelHeaderTop("Bundle");
                    UIManager.Instance.SetPanelHeaderBottom(island.name);
                    UIManager.Instance.Tooltip.Hide();
                });

                interactable.DeselectBehaviour = new Action(() => {
                    UIManager.Instance.Tooltip.Hide();
                });
            }
        }
示例#54
0
        /// <summary>
        /// This method calculates a list of islands from a list of polygons
        /// </summary>
        /// <param name="polygons">The list of polygons to calculate the islands from</param>
        /// <returns>The calculated list of islands</returns>
        private static List <Island> calculateIslandFromPolygons(Polygons polygons)
        {
            List <Island> islandList = new List <Island>();

            //We now need to put the polygons through clipper sothat it can detect holes for us
            //and then make proper islands with the returned data
            PolyTree resultTree = new PolyTree();

            Clipper clipper = new Clipper();

            clipper.AddPaths(polygons, PolyType.ptClip, true);
            clipper.Execute(ClipType.ctUnion, resultTree, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);

            List <PolyNode> polyNodeList = moveNodesToSameLevel(resultTree);

            foreach (PolyNode polyNode in polyNodeList)
            {
                if (!polyNode.IsHole)
                {
                    Island temp = new Island();
                    temp.outlinePolygons.Add(polyNode.Contour);
                    islandList.Add(temp);
                }
                else //IsHole
                {
                    bool shouldBreak = false;

                    foreach (Island island in islandList)
                    {
                        if (shouldBreak)
                        {
                            break;
                        }

                        foreach (Polygon islandPolygon in island.outlinePolygons)
                        {
                            if (polyNode.Parent.Contour.Equals(islandPolygon))
                            {
                                island.outlinePolygons.Add(polyNode.Contour);
                                shouldBreak = true;
                                break;
                            }
                        }
                    }
                }
            }

            //Lastly we return our list of islands
            return(islandList);
        }
示例#55
0
        public void TestBridgeConnecting()
        {
            var level = setupRendering();

            var isl = level.CreateNewIsland(new Vector3(5, 3, 5));

            cameraIsland = isl;

            var isl2 = level.CreateNewIsland(new Vector3(15, 3, 5));

            addBridge(isl, Vector3.UnitX, new Vector3(3, 0, 0));
            addBridge(isl, Vector3.UnitZ, new Vector3(0, 0, 3));
            addBridge(isl2, -Vector3.UnitX, new Vector3(-3, 0, 0));
        }
示例#56
0
    public void Test_Environment()
    {
        Terrain terrain = Object.FindObjectOfType <Terrain>();

        Assert.NotNull(terrain, "Terrain is missing");

        AreaDamageOverTime lava = Object.FindObjectOfType <AreaDamageOverTime>();

        Assert.NotNull(lava, "Lava is missing");

        Island island = Object.FindObjectOfType <Island>();

        Assert.NotNull(island, "Island is missing");
    }
示例#57
0
        private string GetDefenderSquadInfo(Island island, int squadCountCount, UnitNames unitNames, int pad)
        {
            List <long>   sc = new List <long>();
            StringBuilder sb = new StringBuilder();

            // Sort the islands with squads so that they display nicely.
            List <long> squadPlans = new List <long>();

            for (int c = 0; c < island.SquadPlans.Count; c++)
            {
                squadPlans.Add(island.SquadPlans[c][0]);
            }
            squadPlans.Sort();

            sb.AppendLine("<pre>");
            // Add in all tiles with squads on them
            for (int j = 0; j < squadCountCount; j++)
            {
                sc = island.SquadCounts[j];
                int tileNumber = Convert.ToInt32(squadPlans[j]);    // Convert.ToInt32(island.SquadPlans[j][0]);
                // List blockers & bunkers & features (terrain)
                string defenses = island.Defenses;
                string features = island.Features;
                char   defense  = defenses[tileNumber];
                char   feature  = features[tileNumber];
                string blocker  = GetBlockerFromChar(defense);
                string bunkers  = GetBunkersFromChar(defense);
                string terrain  = GetTerrainFromChar(feature);

                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;Squad #" + (j + 1).ToString() + " on tile " + tileNumber.ToString() + "  ==> " + terrain + " with " + blocker + " and " + bunkers);

                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.Riflemen.PadRight(pad) + " = " + sc[0].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.MachineGunners.PadRight(pad) + " = " + sc[1].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.Bazookamen.PadRight(pad) + " = " + sc[2].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.LightTanks.PadRight(pad) + " = " + sc[3].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.MediumTanks.PadRight(pad) + " = " + sc[4].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.HeavyTanks.PadRight(pad) + " = " + sc[5].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.LightFighters.PadRight(pad) + " = " + sc[6].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.MediumFighters.PadRight(pad) + " = " + sc[7].ToString().PadLeft(12, ' '));
                sb.AppendLine("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + unitNames.Bombers.PadRight(pad) + " = " + sc[8].ToString().PadLeft(12, ' '));
            }

            // Add in all the tiles with no squad on them
            sb.AppendLine(GetDefenderNoSquadInfo(island));

            sb.AppendLine("</pre>");

            return(sb.ToString());
        }
示例#58
0
    /// <summary>
    /// Generate columns of blocks at the chunk x, z
    /// </summary>
    /// <param name="chunk"></param>
    static void generateChunkColumn(Chunk chunk)
    {
        for (int x = 0; x < Chunk.CHUNK_DIAMETER; x++)
        {
            for (int z = 0; z < Chunk.CHUNK_DIAMETER; z++)
            {
                int islandX = chunk.location.x * Chunk.CHUNK_DIAMETER + x;
                int islandZ = chunk.location.z * Chunk.CHUNK_DIAMETER + z;
                generateColumn(chunk, islandX, islandZ);
            }
        }
        Island island = chunk.level as Island;

        island.setColumnGenerated(chunk.location);
    }
示例#59
0
        public void Refuse_move_worker_to_invalid_coordinate()
        {
            // arrange
            var board  = new Island();
            var player = new Player(_faker.Name.FirstName());
            var worker = player.Workers.First();

            board.TryAddPiece(worker, 0, 0);

            // act
            var success = worker.TryMoveTo(-1, 5);

            // assert
            success.Should().BeFalse();
        }
示例#60
0
        public void Worker_cannot_build_at_invalid_coordinate()
        {
            // arrange
            var board  = new Island();
            var player = new Player(_faker.Name.FirstName());
            var worker = player.Workers.First();

            board.TryAddPiece(worker, 0, 0);

            // act
            var success = worker.TryBuildAt(5, -1);

            // assert
            success.Should().BeFalse();
        }