Пример #1
0
        private Voxel AddClick(WorldMaster master, Maker maker, PacketAddVoxel packet)
        {
            int dstHeight = packet.DestinationHeight;
            var voxelType = packet.VoxelType;
            var vert      = new Vert()
            {
                angle  = packet.VertAngle,
                hexPos = packet.HexPos
            };

            if (!vert.full)
            {
                vert = master.grid.GetVertOrIterate(packet.HexPos, null);
            }

            if (!vert.full || !master.graph.IsCoordinateAllowed(vert.hexPos))
            {
                return(null);
            }

            maker.BeginNewAction();
            if (dstHeight == 0)
            {
                voxelType = VoxelType.Ground;
            }

            var result = master.graph.AddVoxel(vert.hexPos, (byte)dstHeight, voxelType, true);

            maker.AddAction(vert.hexPos, (byte)dstHeight, VoxelType.Empty, voxelType);
            maker.EndAction();
            return(result);
        }
Пример #2
0
        private Voxel RemoveClick(WorldMaster master, Maker maker, PacketRemoveVoxel packet)
        {
            maker.BeginNewAction();
            Voxel result = null;

            foreach (var voxel in UnityEngine.Object.FindObjectsOfType <Voxel>())
            {
                if (voxel.transform.position.Equals(packet.VoxelPosition))
                {
                    result = voxel;
                    break;
                }
            }
            maker.AddAction(packet.HexPos, result.height, result.type, VoxelType.Empty);
            master.graph.RemoveVoxel(result);
            maker.EndAction();
            return(result);
        }
    public void LoadXMLData()
    {
        Debug.Log("Loading XML data...");

        using (FileStream fs = new FileStream(dataFileName + ".xml", FileMode.Open)) {
            XmlSerializer xs = new XmlSerializer(typeof(WorldMaster));
            world = (WorldMaster)xs.Deserialize(fs);
        }

        // Debug
        for (int i = 0; i < world.mountains.Length; i++)
        {
            if (world.mountains[i] == null)
            {
                break;
            }
            Debug.Log("Mountain " + i + ". X = " + world.mountains[i].mapPos.x + ". Y = " + world.mountains[i].mapPos.y);
        }

        Debug.Log("XML data has loaded.");
    }
Пример #4
0
 void Start()
 {
     master = GameObject.FindObjectOfType <WorldMaster> ();
 }