Example #1
0
    public TaskTree SlowMo(float duration, Vector3 location)
    {
        shaking = false;
        float startOrthographicSize = Camera.main.orthographicSize;

        ActionTask slow_down = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuadEaseOut,
                                                      t =>
            {
                transform.position           = new Vector3(Mathf.Lerp(basePos.x, location.x, t), Mathf.Lerp(basePos.y, location.y, t), -10f);
                Camera.main.orthographicSize = Mathf.Lerp(startOrthographicSize, 4, t);
            }));
        });

        Wait wait = new Wait(duration / 2);

        ActionTask speed_up = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseIn,
                                                      t =>
            {
                transform.position           = new Vector3(Mathf.Lerp(location.x, basePos.x, t), Mathf.Lerp(location.y, basePos.y, t), -10f);
                Camera.main.orthographicSize = Mathf.Lerp(4, startOrthographicSize, t);
            }));
        });

        Wait wait2 = new Wait(duration / 2);

        ActionTask reset = new ActionTask(() => { Camera.main.orthographicSize = startOrthographicSize; SetPosition(basePos); });

        TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset)))));

        return(to_return);
    }
Example #2
0
 public void Do(TaskTree taskTree)
 {
     Debug.Assert(taskTree.root != null);
     Debug.Assert(!taskTree.root.IsAttached);
     tasks.Add(taskTree.DistributedTree());
     taskTree.root.SetStatus(Task.TaskStatus.Pending);
 }
Example #3
0
    public TaskTree SlowMo(float duration)
    {
        silent = true;
        ActionTask slow_down = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.Linear,
                                                      t =>
            {
                Services.AudioManager.SetPitch(Mathf.Lerp(1, 0.1f, t));
            }));
        });

        Wait wait = new Wait(duration / 2);

        ActionTask speed_up = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.Linear,
                                                      t =>
            {
                Services.AudioManager.SetPitch(Mathf.Lerp(0.1f, 1, t));
            }));
        });

        Wait wait2 = new Wait(duration / 2);

        ActionTask reset = new ActionTask(() => { Services.AudioManager.SetPitch(1f); silent = false; });

        TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset)))));

        return(to_return);
    }
Example #4
0
    public void OnHomePressed()
    {
        Services.AudioManager.CreateTrackAndPlay(Clips.TAP);
        Services.AudioManager.FadeAudio();
        Services.EventManager.Fire(new RefreshGameBaord());

        Task fadeIndicatorIconTask = new LERPColor(_turnIndicatorIcon, _turnIndicatorIcon.color, _transparent, 0.5f);
        Task fadeIndicatorTextTask = new LERPColor(_turnIndicator, _turnIndicator.color, _transparent, 0.5f);
        Task fadeHomeButtonTask    = new LERPColor(_homeButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeReplayButtonTask  = new LERPColor(_replayButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeGradient          = new LERPColor(_gradient, _gradient.color, _transparent, 0.75f);

        // This is the smae idea found in the OnRestartPressed function above
        TaskTree returnHomeTasks = new TaskTree(new EmptyTask(),
                                                new TaskTree(fadeIndicatorIconTask),
                                                new TaskTree(fadeIndicatorTextTask),
                                                new TaskTree(fadeHomeButtonTask),
                                                new TaskTree(fadeReplayButtonTask),
                                                new TaskTree(fadeGradient),
                                                new TaskTree(new BoardEntryAnimation()),
                                                new TaskTree(new Wait(3),
                                                             new TaskTree(new ActionTask(ReturnHome))));

        _tm.Do(returnHomeTasks);
    }
Example #5
0
    public void OnRestartPressed()
    {
        Services.AudioManager.CreateTrackAndPlay(Clips.TAP);
        Services.AudioManager.FadeAudio();
        Services.EventManager.Fire(new RefreshGameBaord());

        Task fadeIndicatorIconTask = new LERPColor(_turnIndicatorIcon, _turnIndicatorIcon.color, _transparent, 0.5f);
        Task fadeIndicatorTextTask = new LERPColor(_turnIndicator, _turnIndicator.color, _transparent, 0.5f);
        Task fadeHomeButtonTask    = new LERPColor(_homeButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeReplayButtonTask  = new LERPColor(_replayButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeGradient          = new LERPColor(_gradient, _gradient.color, _transparent, 0.75f);

        //  Here we have a modification of the Task tree where we want to compelte the fading
        //  board animation and waiting tasks in parallel, than compete the ResetGameScene Task.
        //  To accomplish this, I made the ResetGameScene Task a child of the Wait task.
        TaskTree restartGameTasks = new TaskTree(new EmptyTask(),
                                                 new TaskTree(fadeIndicatorIconTask),
                                                 new TaskTree(fadeIndicatorTextTask),
                                                 new TaskTree(fadeHomeButtonTask),
                                                 new TaskTree(fadeReplayButtonTask),
                                                 new TaskTree(fadeGradient),
                                                 new TaskTree(new BoardEntryAnimation()),
                                                 new TaskTree(new Wait(3),
                                                              new TaskTree(new ActionTask(ResetGameScene))));

        _tm.Do(restartGameTasks);
    }
Example #6
0
    public TaskTree SlowTimeScale(float duration)
    {
        slow_mo = true;

        ActionTask slow_down = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseOut,
                                                      t =>
            {
                Time.timeScale = Mathf.Lerp(1f, 0.1f, t);
            }));
        });

        Wait wait = new Wait(duration / 2);

        ActionTask speed_up = new ActionTask(() =>
        {
            StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseIn,
                                                      t =>
            {
                Time.timeScale = Mathf.Lerp(0.1f, 1f, t);
            }));
        });

        Wait wait2 = new Wait(duration / 2);

        ActionTask reset = new ActionTask(() => { Time.timeScale = 1f; slow_mo = false; });

        TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset)))));

        return(to_return);
    }
Example #7
0
 public void Then(TaskTree taskTree)
 {
     Debug.Assert(!taskTree.root.IsAttached);
     nextTasks = new List <Task>()
     {
         taskTree.DistributedTree()
     };
 }
Example #8
0
    public TribeFacts(string clanColor, TaskTree taskTree)
    {
        this.clanColor = clanColor;
        this.taskTree  = taskTree;
        knownFacts     = new Dictionary <string, List <WorkingMemoryValue> >();

        colorsInClan  = new List <string> ();
        populationCap = 5;
        agentsInClan  = 0;       // ((UnitCommander)GameObject.Find(clanColor + " Clan").transform.FindChild("Commanders").FindChild("UnitCommander(Clone)")).GetAgents().Count;
    }
Example #9
0
    public TribeFacts(string clanColor, TaskTree taskTree)
    {
        this.clanColor = clanColor;
        this.taskTree = taskTree;
        knownFacts = new Dictionary<string, List<WorkingMemoryValue>>();

        colorsInClan = new List<string> ();
        populationCap = 5;
        agentsInClan = 0;// ((UnitCommander)GameObject.Find(clanColor + " Clan").transform.FindChild("Commanders").FindChild("UnitCommander(Clone)")).GetAgents().Count;
    }
Example #10
0
    public TribeFacts(string clanColor, TaskTree taskTree)
    {
        this.clanColor = clanColor;
        this.taskTree = taskTree;
        knownFacts = new Dictionary<string, List<WorkingMemoryValue>>();

        colorsInClan = new List<string> ();
        populationCap = 5;
        agentsInClan = 0;
    }
Example #11
0
    private List <string> colorsInClan;    //available colors in the clan

    public TribeFacts(string clanColor, TaskTree taskTree)
    {
        this.clanColor = clanColor;
        this.taskTree  = taskTree;
        knownFacts     = new Dictionary <string, List <WorkingMemoryValue> >();

        colorsInClan  = new List <string> ();
        populationCap = 5;
        agentsInClan  = 0;
    }
Example #12
0
    private void GenerateResource()
    {
        //  Sends message to player to add one resource
        TaskTree genResourcesTaskTree = new TaskTree(new WaitTask(resourceGenPeriod));

        Services.GameManager.players [Owner.owner - 1].numResources++;
        genResourcesTaskTree.Then(new ActionTask(GenerateResource));
        //  To do additional things just add more thens
        //  Add child to make other things happen as a result of a task
        _tm.AddTask(genResourcesTaskTree);
    }
Example #13
0
    public void FadeOutFlockAgents()
    {
        TaskTree fadeAgents = new TaskTree(new EmptyTask());

        foreach (FlockAgent agent in _agents)
        {
            Task fadeOut = new LERPColor(agent.sr, agent.sr.color, _transparent, 0.3f);
            fadeAgents.AddChild(fadeOut);
        }
        _tm.Do(fadeAgents);
    }
Example #14
0
        public void InitTaskTree(ref TaskTree _taskTree)
        {
            MyTask   myTask   = MyTaskFactory.CreateMyTask();
            TaskTree taskTree = MyTaskFactory.CreateMyTaskTree(MyTaskFactory.CreateListTaskTree(10));

            for (int i = 0; i < 10; i++)
            {
                taskTree[i] = MyTaskFactory.CreateMyTaskTree(MyTaskFactory.CreateListTaskTree(10));
            }
            _taskTree = taskTree;
        }
Example #15
0
 public TaskTree Then(TaskTree nextTree)
 {
     if (children.Count > 0)
     {
         return(children[0].Then(nextTree));
     }
     else
     {
         return(AddChild(nextTree));
     }
 }
 public MyTaskItem(TaskTree taskTree) : this()
 {
     this.InitializeComponent();
     _thisTaskTree = taskTree;
     TitleTask     = null;
     //CounItem = null;
     ShortDescription  = null;
     ProcessValue      = null;
     MaxProcessValue   = null;
     ProccentComplited = null;
     Color             = null;
 }
Example #17
0
 private void DeleteTaskBtn_Click(object sender, EventArgs e)
 {
     subject.Tasks.Remove(runtime);
     if (subject.Tasks.Count > 0)
     {
         runtime = subject.Tasks[0];
     }
     else
     {
         runtime = new TaskClass();
         subject.Tasks.Add(runtime);
     }
     UpdateTaskList();
     TaskTree.SelectedNode = TaskTree.Nodes[0].Nodes[0];
     TaskTree.Select();
     changeState();
 }
        private void CreateAndShow_Click(object sender, RoutedEventArgs e)
        {
            TaskTree taskTree = new TaskTree(
                new MyTask(
                    AddMyTask.NumberValue,
                    AddMyTask.NameValue,
                    AddMyTask.ShortDescriptionValue,
                    AddMyTask.DescriptionValue,
                    AddMyTask.StartDateTimeValue,
                    AddMyTask.EndDateTimeValue
                    ), null);


            ShowTask.TitleTask = taskTree.Value.NameTask;
            //ShowTask.CounItem = taskTree.CountTask;
            ShowTask.ShortDescription = taskTree.Value.ShortDescription;
            ShowTask.ProcessValue     = 1;
            ShowTask.MaxProcessValue  = 10;
        }
Example #19
0
    public void FadeInFlockAgents()
    {
        TaskTree fadeAgents = new TaskTree(new EmptyTask());

        Color targetColor;

        if (_icon == FlockIcon.X)
        {
            targetColor = Services.GameManager.Player1Color[1];
        }
        else
        {
            targetColor = Services.GameManager.Player2Color[1];
        }

        foreach (FlockAgent agent in _agents)
        {
            Task fadeOut = new LERPColor(agent.sr, _transparent, targetColor, 0.3f);
            fadeAgents.AddChild(fadeOut);
        }
        _tm.Do(fadeAgents);
    }
    public void OnHomePressed()
    {
        Services.EventManager.Fire(new RefreshGameBaord());

        Task fadeIndicatorIconTask = new LERPColor(_turnIndicatorIcon, _turnIndicatorIcon.color, _transparent, 0.5f);
        Task fadeIndicatorTextTask = new LERPColor(_turnIndicator, _turnIndicator.color, _transparent, 0.5f);
        Task fadeHomeButtonTask    = new LERPColor(_homeButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeReplayButtonTask  = new LERPColor(_replayButtonIcon, _iconGray, _transparent, 0.5f);
        Task fadeGradient          = new LERPColor(_gradient, _gradient.color, _transparent, 0.75f);

        TaskTree returnHomeTasks = new TaskTree(new EmptyTask(),
                                                new TaskTree(fadeIndicatorIconTask),
                                                new TaskTree(fadeIndicatorTextTask),
                                                new TaskTree(fadeHomeButtonTask),
                                                new TaskTree(fadeReplayButtonTask),
                                                new TaskTree(fadeGradient),
                                                new TaskTree(new BoardEntryAnimation()),
                                                new TaskTree(new Wait(3),
                                                             new TaskTree(new ActionTask(ReturnHome))));

        _tm.Do(returnHomeTasks);
    }
Example #21
0
        /// <summary>
        /// 获取任务树和任务执行状态
        /// </summary>
        /// <returns></returns>
        public List <TaskTree> getTaskTree()
        {
            List <TaskTree> tasks = new List <TaskTree>();
            TaskTree        task  = new TaskTree();

            task.ID    = 1;
            task.Type  = "J";
            task.Name  = "华研PDM";
            task.State = "执行中";
            tasks.Add(task);
            TaskTree task1 = new TaskTree();

            task1.ID         = 1;
            task1.Type       = "D";
            task1.Name       = "XXX-华研PDM";
            task1.ParentName = "华研PDM";
            task1.State      = "执行中";
            tasks.Add(task1);
            TaskTree task2 = new TaskTree();

            task2.ID         = 1;
            task2.Type       = "A";
            task2.Name       = "文档管理";
            task2.ParentName = "XXX-华研PDM";
            task2.State      = "实例化未就绪";
            tasks.Add(task2);
            TaskTree task3 = new TaskTree();

            task3.ID         = 2;
            task3.Type       = "T";
            task3.Name       = "零部件管理";
            task3.ParentName = "XXX-华研PDM";
            task3.State      = "实例化未就绪";
            tasks.Add(task3);
            return(tasks);
        }
Example #22
0
    internal override void OnEnter(TransitionData data)
    {
        Services.AudioManager.StopClip();
        if (!Services.AudioManager.muted)
        {
            Services.AudioManager.SetVolume(0.5f);
        }
        Services.AudioManager.PlayClip(Clips.MATCH_SONG);
        Services.GameManager.UpdateMutIcon(audioStatusIcon);

        Services.GameScene = this;
        players            = new Player[Services.GameManager.TotalPlayers];
        for (int i = 0; i < Services.GameManager.TotalPlayers; i++)
        {
            players[i] = Instantiate(Services.Prefabs.Player, Vector3.zero, Quaternion.identity, transform);
            int playerNum = i + 1;
            players[i].name = "Player " + playerNum;
            Color[] colors;
            switch (i)
            {
            case 0: colors = Services.GameManager.Player1Color; break;

            case 1: colors = Services.GameManager.Player2Color; break;

            default: colors = Services.GameManager.Player1Color; break;
            }
            players[i].Init(playerNum, Services.GameManager.AvailableIcons[i], colors);
        }

        board = GetComponent <GameBoard>();
        BoardInfo info;

        info.row = 3;
        info.col = 3;


        board.Init(info);

        currentPlayerIndex = UnityEngine.Random.Range(0, 2);
        currentPlayer      = players[currentPlayerIndex];

        if (currentPlayerIndex == 0)
        {
            currentPlayerIndex        = (int)PlayerNum.PLAYER1;
            _turnIndicatorIcon.sprite = players[(int)PlayerNum.PLAYER1].PlayerIcon;
        }
        else
        {
            currentPlayerIndex        = (int)PlayerNum.PLAYER2;
            _turnIndicatorIcon.sprite = players[(int)PlayerNum.PLAYER2].PlayerIcon;
        }

        // These are independent tasks I want to complete when entering the game scene
        Task fadeIndicatorIconTask = new LERPColor(_turnIndicatorIcon, _transparent, currentPlayer.playerColor[0], 3f);
        Task fadeIndicatorTextTask = new LERPColor(_turnIndicator, _transparent, currentPlayer.playerColor[0], 3f);
        Task fadeHomeButtonTask    = new LERPColor(_homeButtonIcon, _transparent, _iconGray, 1f);
        Task fadeReplayButtonTask  = new LERPColor(_replayButtonIcon, _transparent, _iconGray, 1f);

        // I want to compelte these tasks in parallel so I use a TaskTree.
        // How it works:
        //              A Task tree will complete the Task at its root first, then move on to complete
        //              the tasks in in child nodes in parallel.
        TaskTree uiEntryTask = new TaskTree(new EmptyTask(),
                                            new TaskTree(fadeIndicatorIconTask),
                                            new TaskTree(fadeIndicatorTextTask),
                                            new TaskTree(fadeHomeButtonTask),
                                            new TaskTree(fadeReplayButtonTask));

        _tm.Do(uiEntryTask);

        Services.EventManager.Register <PlayMadeEvent>(OnPlayMade);
        Services.EventManager.Register <GameEndEvent>(OnGameEnd);
    }
Example #23
0
 public TaskTree AddChild(TaskTree child)
 {
     children.Add(child);
     return(this);
 }
Example #24
0
 private void Form1_Load(object sender, EventArgs e)
 {
     TaskTree.ExpandAll();
 }
Example #25
0
 public TaskTreeQueue Add(TaskTree task)
 {
     tasksTrees.Add(task);
     return(this);
 }
    internal override void OnEnter(TransitionData data)
    {
        Services.GameScene = this;
        players            = new Player[Services.GameManager.TotalPlayers];
        for (int i = 0; i < Services.GameManager.TotalPlayers; i++)
        {
            players[i] = Instantiate(Services.Prefabs.Player, Vector3.zero, Quaternion.identity, transform);
            int playerNum = i + 1;
            players[i].name = "Player " + playerNum;
            Color[] colors;
            switch (i)
            {
            case 0: colors = Services.GameManager.Player1Color; break;

            case 1: colors = Services.GameManager.Player2Color; break;

            default: colors = Services.GameManager.Player1Color; break;
            }
            players[i].Init(playerNum, Services.GameManager.AvailableIcons[i], colors);
        }

        board = GetComponent <GameBoard>();
        BoardInfo info;

        info.row = 3;
        info.col = 3;


        board.Init(info);

        currentPlayerIndex = UnityEngine.Random.Range(0, 2);
        currentPlayer      = players[currentPlayerIndex];

        if (currentPlayerIndex == 0)
        {
            currentPlayerIndex        = (int)PlayerNum.PLAYER1;
            _turnIndicatorIcon.sprite = players[(int)PlayerNum.PLAYER1].PlayerIcon;
        }
        else
        {
            currentPlayerIndex        = (int)PlayerNum.PLAYER2;
            _turnIndicatorIcon.sprite = players[(int)PlayerNum.PLAYER2].PlayerIcon;
        }

        Task fadeIndicatorIconTask = new LERPColor(_turnIndicatorIcon, _transparent, currentPlayer.playerColor[0], 3f);
        Task fadeIndicatorTextTask = new LERPColor(_turnIndicator, _transparent, currentPlayer.playerColor[0], 3f);
        Task fadeHomeButtonTask    = new LERPColor(_homeButtonIcon, _transparent, _iconGray, 1f);
        Task fadeReplayButtonTask  = new LERPColor(_replayButtonIcon, _transparent, _iconGray, 1f);


        TaskTree uiEntryTask = new TaskTree(new EmptyTask(),
                                            new TaskTree(fadeIndicatorIconTask),
                                            new TaskTree(fadeIndicatorTextTask),
                                            new TaskTree(fadeHomeButtonTask),
                                            new TaskTree(fadeReplayButtonTask));

        _tm.Do(uiEntryTask);

        Services.EventManager.Register <PlayMadeEvent>(OnPlayMade);
        Services.EventManager.Register <GameEndEvent>(OnGameEnd);
    }