Example #1
0
    protected virtual void UpdateGridState()
    {
        if (this.IsSelect())
        {
            this.CheckHitTerrainGrid();
            if (this.last_hit_grid != null)
            {
                this.select.SetActive(true);
                this.select.transform.position = this.last_hit_grid.transform.position;
                this.select.transform.rotation = this.last_hit_grid.transform.rotation;
                this.select.transform.Translate(new Vector3(0f, 0.001f, 0f), Space.Self);

                if (Input.GetMouseButton(0))
                {
                    ChangeGridCommand command = new ChangeGridCommand();
                    command.GridId    = this.last_hit_grid.GetComponent <TerrainGrid>().GetGridId();
                    command.Direction = this.select.transform.rotation.eulerAngles.y;
                    if (this.select.GetComponent <TerrainGrid>())
                    {
                        command.DataId = this.select.GetComponent <TerrainGrid>().GetDataId();
                        this.ChangeTerrainGrid(command);
                    }
                    else if (this.select.GetComponent <BuildGrid>())
                    {
                        command.DataId = this.select.GetComponent <BuildGrid>().GetDataId();
                        this.ChangeBuildGrid(command);
                    }
                }
            }
            else
            {
                this.select.SetActive(false);
            }

            if (Input.GetMouseButton(1))
            {
                this.UnSelect();
            }
        }
    }
Example #2
0
 protected override void ChangeBuildGrid(ChangeGridCommand command)
 {
 }
Example #3
0
 protected override void ChangeTerrainGrid(ChangeGridCommand command)
 {
 }
Example #4
0
 protected virtual void OnBuildGridChange(ChangeGridCommand command)
 {
     this.map.ChangeBuildGrid(command.GridId, command.DataId, command.Direction);
 }
Example #5
0
 // 通过保存命令可以做成引导回放等东西,先挖坑
 protected virtual void OnTerrainGridChange(ChangeGridCommand command)
 {
     this.map.ChangeTerrainGrid(command.GridId, command.DataId);
 }
Example #6
0
 protected virtual void ChangeBuildGrid(ChangeGridCommand command)
 {
     this.OnBuildGridChange(command);
 }
Example #7
0
 protected virtual void ChangeTerrainGrid(ChangeGridCommand command)
 {
     this.OnTerrainGridChange(command);
 }