/// <summary>
        /// Unity Method
        /// </summary>
        private void Awake()
        {
            CommandDataEntity entity = new CommandDataEntity();

            this.DataEntity = entity;
            Watch(this);
        }
示例#2
0
 /// <summary>
 /// 注入命令系统
 /// </summary>
 private void Start()
 {
     goUndo    = GameObject.Find("/Canvas/BtnUndo");
     goRedo    = GameObject.Find("/Canvas/BtnRedo");
     CmdEntity = (CommandDataEntity)FindObjectOfType <CommandDataModel>().DataEntity;
     InjectService.InjectInto(this);
     StartCoroutine(UpdateCommandUIState());
 }
示例#3
0
        /// <summary>
        /// 创建Cube操作
        /// </summary>
        public void OnCreate()
        {
            CommandDataEntity cmdEntity = (CommandDataEntity)FindObjectOfType <CommandDataModel>().DataEntity;
            CreateCommandStr  str       = new CreateCommandStr();

            //随机坐标
            str.Position = new Vector3(Random.Range(-7, 11), Random.Range(-4, 6), Random.Range(0, 50));
            cmdEntity.CreatePartMessage = str;
        }
示例#4
0
 /// <summary>
 /// 删除Cube操作
 /// </summary>
 public void OnDelete()
 {
     if (IsClickedPart)
     {
         CommandDataEntity cmdEntity = (CommandDataEntity)FindObjectOfType <CommandDataModel>().DataEntity;
         DeleteCommandStr  str       = new DeleteCommandStr();
         str.ObjectID = cubeDataEntity.objectID;
         cmdEntity.DeletePartMessage = str;
         IsClickedPart = false;
     }
 }
示例#5
0
 /// <summary>
 ///  改变Cube颜色
 /// </summary>
 public void OnChangeColor()
 {
     if (IsClickedPart)
     {
         CommandDataEntity cmdEntity = (CommandDataEntity)FindObjectOfType <CommandDataModel>().DataEntity;
         ColorCommandStr   str       = new ColorCommandStr();
         str.ObjectID = cubeDataEntity.objectID;
         //记录开始的颜色
         str.OldColor = cubeDataModdel.gameObject.GetComponent <MeshRenderer>().material.color;
         //随机新的颜色
         str.NewColor = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
         cmdEntity.ColorParMessage = str;
         IsClickedPart             = false;
     }
 }
        /// <summary>
        /// Execute操作
        /// </summary>
        public override void Execute()
        {
            CommandDataEntity entity = (CommandDataEntity)GameObject.FindObjectOfType <CommandDataModel>().DataEntity;

            CubeDataModel[] cubes = GameObject.FindObjectsOfType <CubeDataModel>();
            foreach (CubeDataModel cube in cubes)
            {
                if (((BaseDataModelEntity)cube.DataEntity).objectID.Equals(ObjectId))
                {
                    Deleteobj = cube.gameObject;
                    Deleteobj.SetActive(false);
                    return;
                }
            }
        }
示例#7
0
        /// <summary>
        /// Execute操作
        /// </summary>
        public override void Execute()
        {
            //物体UUID从数据实体(CommanDataEntity)中获得
            CommandDataEntity entity = (CommandDataEntity)GameObject.FindObjectOfType <CommandDataModel>().DataEntity;

            CubeDataModel[] cubes = GameObject.FindObjectsOfType <CubeDataModel>();
            foreach (CubeDataModel cube in cubes)
            {
                if (((BaseDataModelEntity)cube.DataEntity).objectID.Equals(ColorObjectID))
                {
                    Colorobj = cube.gameObject;
                    Colorobj.GetComponent <Renderer>().material.color = NewColor;
                    return;
                }
            }
        }