Exemple #1
0
        public IEnumerable <BlockPlacement> GetBlocks()
        {
            for (int x = 0; x < width; x++)
            {
                for (int z = 0; z < height; z++)
                {
                    float a = x / smoothing;
                    float b = z / smoothing;
                    int   h = (int)(Mathf.PerlinNoise(a, b) * amplitude);

                    for (int y = -5; y <= h; y++)
                    {
                        var place = new BlockPlacement
                        {
                            Position = new BlockPosition(x, y, z),
                            BlockID  = (ushort)(y == h ? 2 : 3),
                        };

                        yield return(place);
                    }

                    for (int y = h + 1; y <= (int)amplitude + 5; y++)
                    {
                        var place = new BlockPlacement
                        {
                            Position = new BlockPosition(x, y, z),
                            BlockID  = BlockType.AIR,
                        };

                        yield return(place);
                    }
                }
            }
        }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        this.UIChatText             = GameObject.Find("UIChatText");
        this.UIChatInput            = GameObject.Find("UIChatInput");
        this.chatText               = GameObject.Find("ChatText").GetComponent <UnityEngine.UI.Text>();
        this.inputField             = GameObject.Find("InputField").GetComponent <UnityEngine.UI.InputField>();
        this.blockPlacementInstance = ownPlayer.GetComponent <BlockPlacement>();
        this.lastPosition           = ownPlayer.transform.position;
        this.pingTimer              = System.Environment.TickCount;

        b.AppendLine(chatText.text);
    }
 private void Awake()
 {
     instance    = this;
     cubeCast    = GetComponent <CubeCast>();
     previewCast = GetComponent <PreviewCast>();
 }