Example #1
0
        public Task transform()
        {
            //	return mesh_.transform (to_);
            int count = Mathf.Min (from_.Length, to_.Length);
            TaskSet tl = new TaskSet ();

            for (int i = 0; i< count; ++i) {
                VoxelHandler hander = mesh_.getVoxel(new VectorInt3(from_[i].x, from_[i].y, from_[i].z) );
                tl.push (oneTask (hander._vox, to_[i]));
            }
            TaskManager.PushFront(tl, delegate{
                mesh_.showVox();
            });
            if (to_.Length > count) {
                Debug.LogWarning(to_.Length);
                for(int i = count; i<to_.Length; ++i){

                    Debug.LogWarning(i);
                }
            }
            TaskManager.PushBack(tl, delegate{
                mesh_.clear();
            });
            return tl;
        }
Example #2
0
File: Test.cs Project: gdgeek/fly
        void Start()
        {
            _head.close ();
            _me.close ();
            _mePop.close ();
            _pop.close ();
            TaskList tl = new TaskList ();
            tl.push (new TaskWait (1.0f));
            TaskSet ts = new TaskSet ();

            tl.push (_me.openTask());
            tl.push (_head.openTask());
            Task pop = _mePop.openTask ("那边的是楚云帆老师吗?");

            tl.push (talk(pop));
            tl.push (new TaskWait(2.0f));

            tl.push (talk(_mePop.next("这次比赛能给高分么?")));
            tl.push (_mePop.closeTask());

            tl.push (talk2(_pop.openTask ("我有看过你的作品么?")));
            TaskWait tw = new TaskWait (0.5f);

            TaskManager.PushBack (tw, delegate {
                _me.emotion = VoxelHead.Emotions.Surprise;
                        });
            tl.push (tw);
            TaskManager.Run (tl);
            //TaskManag
        }
Example #3
0
    public Task moveTask(int number, Vector2 begin, Vector2 end)
    {
        TaskSet ts = new TaskSet ();
        Square s = (Square)GameObject.Instantiate (_phototype);
        Square b = this.getSquare((int)(begin.x), (int)(begin.y));
        Square e = this.getSquare((int)(end.x), (int)(end.y));

        s.transform.SetParent(b.transform.parent);
        s.transform.localScale = b.transform.localScale;
        s.transform.localPosition = b.transform.localPosition;
        s.show ();
        s.number = number;
        b.hide ();
        TweenTask tt = new TweenTask (delegate() {
            return TweenLocalPosition.Begin(s.gameObject, 0.5f, e.transform.localPosition);
        });

        TweenTask t2 = new TweenTask (delegate() {
            return TweenRotation.Begin(s.gameObject, 0.5f, Quaternion.AngleAxis((begin.x - end.x) * 90.0f, Vector3.up));
        });

        ts.push (tt);
        ts.push (t2);

        TaskManager.PushBack (ts, delegate {
            GameObject.DestroyObject(s.gameObject);
        });
        return ts;
    }
Example #4
0
        private Task refreshTask()
        {
            TaskSet ts = new TaskSet();

            if (_target.Value != _now.Value)
            {
                IRedio now = getRedio(_now.Value);
                if (now != null)
                {
                    ts.push(now.close);
                }


                IRedio target = getRedio(_target.Value);

                if (target != null)
                {
                    ts.push(target.open);
                }
            }


            TaskManager.PushFront(ts, delegate
            {
                _now = _target;
            });
            return(ts);
        }
Example #5
0
        public Task goOutTask()
        {
            TaskSet ts = new TaskSet();

            ts.push(_head.closeTask());
            ts.push(_pop.closeTask());
            return(ts);
        }
Example #6
0
 private Task oneTask(Voxel vox, VoxelData to)
 {
     TaskSet task = new TaskSet ();
     TweenTask tt1 = new TweenTask(delegate {
         return TweenVoxel.Begin(vox, 1.0f, to, new Vector3(-1, -4, -0.5f));
     });
     task.push (tt1);
     return task;
 }
Example #7
0
 public Task clearTask()
 {
     TaskSet ts = new TaskSet ();
     ts.push (_scoreText.setTextTask(""));
     ts.push (_score.setTextTask(""));
     ts.push (_bestText.setTextTask(""));
     ts.push (_best.setTextTask(""));
     return ts;
 }
Example #8
0
File: Logo.cs Project: gdgeek/fly
        public Task closeTask()
        {
            TaskSet ts = new TaskSet ();

            for (int i =0; i<_curtain.Length; ++i) {
                ts.push (closeCurtainTask(i));
            }

            return ts;
        }
Example #9
0
        private Task closeCharTask()
        {
            TaskSet ts = new TaskSet();

            for (int i = 0; i < _fonts.Length; ++i)
            {
                ts.push(new TaskPack(_fonts[i].closeTask));
            }
            return(ts);
        }
Example #10
0
        public Task next(string text)
        {
            TaskSet ts = new TaskSet ();
            TaskList tl = new TaskList ();

            tl.push (closeCharTask ());
            tl.push (openCharTask (text));
            ts.push (tl);
            ts.push (shake());
            return ts;
        }
Example #11
0
        public Task next(string text)
        {
            TaskSet  ts = new TaskSet();
            TaskList tl = new TaskList();

            tl.push(closeCharTask());
            tl.push(openCharTask(text));
            ts.push(tl);
            ts.push(shake());
            return(ts);
        }
Example #12
0
        public static TaskList AddParallelAnimations(this TaskList list, TweenTask.Maker[] tweenTaskMethods)
        {
            TaskSet ts = new TaskSet();

            foreach (var tweenTaskMethod in tweenTaskMethods)
            {
                ts.push(new TweenTask(tweenTaskMethod));
            }
            list.push(ts);
            return(list);
        }
Example #13
0
    // Use this for initialization
    void Start()
    {
        TaskList tl = new TaskList ();
        Task task1 = new Task ();
        task1.init = delegate() {
            Debug.Log("this is firs task!!!");
        };
        task1.isOver = delegate() {
            return true;
        };
        tl.push (task1);
        TaskWait wait = new TaskWait ();
        wait.setAllTime (2f);
        tl.push (wait);
        Task task2 = new Task ();
        task2.init = delegate() {
            Debug.Log("this is second task!!!");
        };

        tl.push (task2);

        TaskSet mt = new TaskSet ();
        Task task3 = new Task ();
        task3.init = delegate() {
            Debug.Log("this is third task!!!");
        };
        task3.update = delegate(float d)
        {

        };

        mt.push (task3);

        Task task4 = new Task ();
        task4.init = delegate() {
            Debug.Log("this is four task!!!");
        };
        mt.push (task4);
        TaskWait wait2 = new TaskWait ();
        wait2.setAllTime (5f);
        mt.push (wait2);

        Task task5 = new Task ();
        task5.init = delegate() {
            Debug.Log("this is five task!!!");
        };
        mt.push (task5);

        tl.push (mt);

        TaskManager.Run (tl);
    }
Example #14
0
    public Task blow()
    {
        TaskSet ts = new TaskSet ();

        TaskManager.PushFront(ts, delegate{
            mesh_.showVox();
        });
        for (int i = 0; i< mesh_._datas.Length; ++i) {
            VoxelHandler handler = mesh_._datas[i];
            ts.push (oneTask (handler._vox));
        }

        return ts;
    }
Example #15
0
    private Task oneTask(Voxel vox)
    {
        TaskSet task = new TaskSet ();
        TweenTask tt1 = new TweenTask(delegate {
            return TweenLocalPosition.Begin(vox.gameObject, Random.Range(0.3f, 0.5f), new Vector3(Random.Range(-100f, 100f),Random.Range(-100f, 100f),Random.Range(-100f, 100f)));

        });

        TaskManager.PushBack (tt1, delegate {
            vox.gameObject.SetActive(false);
        });
        task.push (tt1);
        return task;
    }
Example #16
0
    public Task outFire()
    {
        TaskSet ts = new TaskSet ();
        TweenTask left = new TweenTask (delegate() {
            return TweenLocalPosition.Begin(_fireLeft, 1.0f, new Vector3(0, 0, 10));
        });
        ts.push (left);

        TweenTask right = new TweenTask (delegate() {
            return TweenLocalPosition.Begin(_fireRight, 1.0f, new Vector3(0, 0, 10));
        });

        ts.push (right);
        return ts;
    }
Example #17
0
    public Task outCap()
    {
        TaskSet ts = new TaskSet ();
        TweenTask left = new TweenTask (delegate() {
            return TweenRotation.Begin(_capLeft, 1.0f, Quaternion.Euler(0, 0 , 179.999f));
        });
        ts.push (left);

        TweenTask right = new TweenTask (delegate() {
            return TweenRotation.Begin(_capRight, 1.0f, Quaternion.Euler(0, 0 , -179.999f));
        });

        ts.push (right);
        return ts;
    }
Example #18
0
File: Logo.cs Project: gdgeek/fly
        public Task nextTask()
        {
            TaskSet ts = new TaskSet ();
            TweenTask tt = new TweenTask (delegate() {
                Tween tween =  TweenLocalPosition.Begin(this.gameObject, 1.0f, new Vector3(0, -50, 30));
                tween.method = _curtainMethod;
                return tween;
            });
            ts.push (tt);
            /*for (int i =0; i<_curtain.Length; ++i) {
                ts.push (curtainTask(i));
            }*/

            return ts;
        }
Example #19
0
	public State getFollowState(){

		StateWithEventMap state = TaskState.Create (delegate {

			TaskSet ts = new TaskSet();
			TweenTask turn  = new TweenTask(delegate() {
				Vector3 v = this._position - this._child.transform.position;
				if(Mathf.Abs(v.x)>  Mathf.Abs(v.z)){
					if(v.x > 0){		
						return TweenRotation.Begin(this._child.gameObject, 0.1f, Quaternion.AngleAxis(-90, Vector3.up));
						
					}else{
						return TweenRotation.Begin(this._child.gameObject, 0.1f, Quaternion.AngleAxis(90, Vector3.up));
					}

				}else{
					if(v.z > 0){		
						return TweenRotation.Begin(this._child.gameObject, 0.1f, Quaternion.AngleAxis(180, Vector3.up));

					}else{
						return TweenRotation.Begin(this._child.gameObject, 0.1f, Quaternion.AngleAxis(0, Vector3.up));
					}

				}
				return TweenRotation.Begin(this._child.gameObject, 0.1f, Quaternion.AngleAxis(-90, Vector3.up));
			});

			TweenTask walk = new TweenTask(delegate() {
				return TweenWorldPosition.Begin(this._child.gameObject, 0.3f, _position);
			});


			ts.push(walk);
			ts.push(turn);
			return ts;
		}, this._fsm, delegate {
			return "wait";
		});






		return state;

	}
Example #20
0
        public Task openCharTask(string text)
        {
            TaskSet ts = new TaskSet ();

            for (int i =0; i<_fonts.Length; ++i) {

                TaskList tl = new TaskList();
                if(i < text.Length){
                    tl.push (new TaskWait(0.1f * i));
                }
                tl.push (new TaskPack(_fonts[i].openTask));
                ts.push(tl);
            }
            TaskManager.PushFront (ts, delegate{
                this.write(text);
            });
            return ts;
        }
Example #21
0
        public Task openCharTask(string text)
        {
            TaskSet ts = new TaskSet();

            for (int i = 0; i < _fonts.Length; ++i)
            {
                TaskList tl = new TaskList();
                if (i < text.Length)
                {
                    tl.push(new TaskWait(0.1f * i));
                }
                tl.push(new TaskPack(_fonts[i].openTask));
                ts.push(tl);
            }
            TaskManager.PushFront(ts, delegate {
                this.write(text);
            });
            return(ts);
        }
Example #22
0
        public static TaskSet AddAnimation(this TaskSet set, TweenTask.Maker maker, TaskInit init = null, TaskShutdown shutdown = null)
        {
            var tt = new TweenTask(
                maker
                );

            if (init != null)
            {
                tt.init = init;
            }

            if (shutdown != null)
            {
                tt.shutdown = shutdown;
            }

            set.push(tt);
            return(set);
        }
Example #23
0
        private Task setTextTask_(string text)
        {
            TaskSet ts   = new TaskSet();
            string  comp = compress(text);
            int     n    = Mathf.Min(chars_.Count, comp.Length);

            for (int i = 0; i < n; ++i)
            {
                if (chars_[i].ch != comp[i])
                {
                    ts.push(changeTask(i, comp[i], comp.Length));
                }
            }
            if (chars_.Count > comp.Length)
            {
                for (int i = n; i < chars_.Count; i++)
                {
                    Task remove = removeTask(i);
                    TaskManager.PushBack(ts, delegate {
                        chars_.RemoveRange(n, chars_.Count - n);
                    });
                    ts.push(remove);
                }
            }


            if (comp.Length > chars_.Count)
            {
                for (int i = n; i < comp.Length; ++i)
                {
                    ts.push(addTask(comp[i], comp.Length));
                }
            }



            return(ts);
        }
Example #24
0
    /// <summary>
    /// 下落,从下往上检查,当检查到有方块显示时,开始让他从上往下下落到底部
    /// 将下落过程做为一个任务来执行
    /// </summary>
    private Task DoFall()
    {
        TaskSet ts = new TaskSet();
        Cube end = null;
        int endY = 0;
        for (int i = 0; i < _model.width; i++)
        {
            for (int j = _model.height - 1; j >= 0; --j)
            {
                Cube c = _model.GetCube(i, j);
                if (c.isEnable)
                {
                    for (int k = j + 1; k < _model.height; ++k)
                    {
                        Cube f = _model.GetCube(i, k);
                        if (f == null || f.isEnable)
                        {
                            break;
                        }
                        else
                        {
                            end = f;
                            endY = k;

                        }
                    }
                    if (end != null)
                    {
                        end.number = c.number;
                        end.isEnable = true;
                        c.isEnable = false;
                        ts.push(_view.play.MoveTask(c.number,new Vector2(i,j),new Vector2(i,endY)));
                    }
                }
            }
        }

        //在任务集全部执行完毕后在刷新界面
        TaskManager.PushBack(ts, delegate
        {
            RefreshModelToView();
        });
        return ts;
    }
Example #25
0
        private Task setTextTask_(string text)
        {
            TaskSet ts = new TaskSet ();
            string comp = compress (text);
            int n = Mathf.Min (chars_.Count, comp.Length);
            for(int i = 0; i < n; ++i){
                if(chars_[i].ch != comp[i])
                {
                    ts.push (changeTask(i, comp[i], comp.Length));

                }
            }
            if (chars_.Count > comp.Length) {

                for(int i=n; i<chars_.Count; i++){

                    Task remove = removeTask(i);
                    TaskManager.PushBack(ts, delegate{
                        chars_.RemoveRange(n, chars_.Count - n);
                    });
                    ts.push (remove);
                }

            }

            if (comp.Length > chars_.Count) {
                for (int i = n; i<comp.Length; ++i) {
                    ts.push (addTask(comp[i], comp.Length));
                }
            }

            return ts;
        }
Example #26
0
 private Task inHeadAndEnd()
 {
     TaskSet ts = new TaskSet ();
     ts.push (inHead ());
     ts.push (inEnd ());
     return ts;
 }
Example #27
0
    public Task removeTask(List<Cube> remove)
    {
        TaskSet ts = new TaskSet ();
        if (remove.Count > 0) {
            TaskManager.PushFront(ts, delegate {
                _sound.remove.Play();
            });
            foreach (Cube c in remove) {
                c.isEnabled = false;
                Square s = _view.play.getSquare((int)(c.position.x), (int)(c.position.y));
                ts.push(s.removeTask());
                this._model.score++;
                float a = ((float)(this._model.score))/500.0f;
                _speed = 1.0f*(1-a) + 10.0f*a;
                Time.timeScale = _speed;
                Debug.Log ("speed" + _speed);
            }

        }
        TaskManager.PushBack (ts, delegate {

            refreshModel2View ();
                });
        return ts;
    }
Example #28
0
    public Task overTask()
    {
        TaskSet tl = new TaskSet ();
        for(int y = 0; y<_model.height; ++y){
            for (int x =0; x < _model.width; ++x) {

                Cube c = _model.getCube(x, y);
                if(c.isEnabled){
                    Square s = _view.play.getSquare(x, y);
                    tl.push (s.overTask());
                }

            }
        }
        TaskWait tw = new TaskWait ();
        tw.setAllTime (0.5f);
        tl.push (tw);
        return tl;
    }
Example #29
0
    public Task doFallTask()
    {
        TaskSet ts = new TaskSet ();

        for (int x =0; x < _model.width; ++x) {
            for(int y = _model.height - 1; y >= 0; --y){

                Cube c = _model.getCube(x, y);
                Cube end = null;
                int endY = 0;
                if(c.isEnabled){
                    for(int n = y+1; n < _model.height; ++n){
                        Cube fall = _model.getCube(x, n);
                        if(fall == null || fall.isEnabled == true){
                            break;
                        }else{
                            end = fall;
                            endY = n;
                        }
                    }
                    if(end != null)
                    {
                        end.number = c.number;
                        end.isEnabled = true;
                        c.isEnabled = false;
                        ts.push (_view.play.moveTask(c.number, new Vector2(x, y), new Vector2(x, endY)));
                        TaskManager.PushBack(ts, delegate {
                            _sound.fall.Play();
                        });
                    }
                }

            }
        }
        TaskManager.PushBack (ts, delegate() {
            refreshModel2View ();
        });
        return ts;
    }
Example #30
0
 private Task outHeadAndEnd()
 {
     TaskSet ts = new TaskSet ();
     ts.push (outHead ());
     ts.push (outEnd ());
     return ts;
 }
Example #31
0
        private Task closeCharTask()
        {
            TaskSet ts = new TaskSet ();

            for (int i =0; i<_fonts.Length; ++i) {

                ts.push (new TaskPack(_fonts[i].closeTask));

            }
            return ts;
        }
Example #32
0
    private Task outWing()
    {
        TaskSet ts = new TaskSet ();
        TweenTask left = new TweenTask (delegate() {
            return TweenLocalPosition.Begin(_wingLeft, 1.0f, new Vector3(-5, 0, 0));
        });
        ts.push (left);

        TweenTask right = new TweenTask (delegate() {
            return TweenLocalPosition.Begin(_wingRight, 1.0f, new Vector3(5, 0, 0));
        });

        ts.push (right);
        return ts;
    }
Example #33
0
    public Task outRocket()
    {
        TaskSet ts = new TaskSet ();
        TweenTask left = new TweenTask (delegate() {

            return TweenRotation.Begin(_rocketLeft, 1.0f,  Quaternion.Euler(-30, 0 , 0));
        });
        ts.push (left);

        TweenTask right = new TweenTask (delegate() {
            return TweenRotation.Begin(_rocketRight, 1.0f,  Quaternion.Euler(-30, 0 , 0));
        });

        ts.push (right);

        TweenTask end =  new TweenTask (delegate() {
            return TweenLocalPosition.Begin (_end, 1.0f, new Vector3 (0, 0, 3));
        });

        ts.push (end);
        return ts;
    }
Example #34
0
        public Task goOutTask()
        {
            TaskSet ts = new TaskSet ();

            ts.push(_head.closeTask ());
            ts.push (_pop.closeTask());
            return ts;
        }
Example #35
0
 public static TaskSet AddTask(this TaskSet set, Task task)
 {
     set.push(task);
     return(set);
 }
Example #36
0
        private State showState()
        {
            StateWithEventMap state = TaskState.Create(delegate() {
                //TaskList tl = new TaskList();
                health_ = 5;
                alive_ = true;
                TaskSet ts = new TaskSet();
                TweenTask tt = new TweenTask(delegate {
                    return TweenLocalPosition.Begin(_talk._head.gameObject, 0.5f, new Vector3(0,40,0));

                });

                TweenTask tt2 = new TweenTask(delegate {
                    return TweenRotation.Begin(_talk._head.gameObject, 0.5f, Quaternion.Euler(new Vector3(-45,0,0)));

                });
                ts.push (tt);
                ts.push (tt2);
                return ts;
            }, fsm_, "move");
            return state;
        }
Example #37
0
	public State getWalkState(){
		StateWithEventMap state = TaskState.Create(delegate{
			TaskSet ts = new TaskSet();
			ts.push(turnTask());
			ts.push(walkTask());
			return ts;
		}, this.fsm_, delegate(FSMEvent evt) {
			return "stop";
		});
		state.onStart += delegate {
			//_oldPosList.Insert(0, this._cop.transform.position);

			//for(int i = 0; i< this._childList.Count && i<_oldPosList.Count; ++i){
			//	this._childList[i].mustGo(_oldPosList[i]);
			//}

		};
		state.onOver += delegate {

			MapCtrl map = this.getMap();
			VectorInt2 cell = map.position2cell(new Vector2(_alien.gameObject.transform.position.x, _alien.gameObject.transform.position.z));
			IMapData data = map.ask(cell);
			data.trample();

			_director = _arrow;
		};




		return state;

	}
Example #38
0
        private State moveState()
        {
            Tween tween = null;
            StateWithEventMap state = TaskState.Create(delegate() {
                TaskSet ts = new TaskSet();
                TweenTask tt = new TweenTask(delegate {
                    tween = TweenWorldPosition.Begin(_talk._head.gameObject, 0.5f, nextPosition(Random.Range(0.0f, 1.0f), Random.Range(0.5f, 1.0f)));
                    return tween;
                });

                ts.push (tt);
                return ts;
            }, fsm_, "move");
            state.onOver += delegate {

                tween.enabled = false;
            };
            return state;
        }