Ejemplo n.º 1
0
    public void FileAddWrite(string text, string url, TaskEvent finished = null, ErrorEvent error = null)
    {
        try
        {
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(accessUrlBase + url));
            request.Method = WebRequestMethods.Ftp.AppendFile;

            byte[] fileContents = Encoding.UTF8.GetBytes(text);

            request.ContentLength = fileContents.Length;
            request.Credentials   = icr;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(fileContents, 0, fileContents.Length);
            requestStream.Close();
            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
            response.Close();
            requestStream.Dispose();
            response.Dispose();
            finished?.Invoke();
        }
        catch (WebException e)
        {
            error?.Invoke(((FtpWebResponse)e.Response).StatusDescription);
        }
    }
Ejemplo n.º 2
0
    private void createTasks()
    {
        SkillEnum[] skillList = new SkillEnum[] {};

        for (int ti = 0; ti < 3; ti++)
        {
            Task task = new Task();
            tasks.Add(task);

            for (int si = 0; si < Task.numSkills; si++)
            {
                if (skillList.Length == 0)
                {
                    skillList = getAllSkills();
                }

                SkillEnum skill = skillList.Rnd();
                task.skills.Add(skill);
            }
            task.skills.Sort();

            task.gold = Random.Range(Task.minGold, Task.maxGold + 1);
            float v = Random.value;
            task.crew = v < 0.5 ? 1 : (v < 0.9 ? 2 : 3);

            onTaskCreated.Invoke(task);
        }
    }
Ejemplo n.º 3
0
    private void Update()
    {
        ScoreText.text = Score.ToString();
        DnaText.text   = Dna.ToString();

        if (CurrentTask != null && State == StateType.Task)
        {
            CurrentTask.TimeLeft -= Time.deltaTime;

            float percentComplete = 100 / CurrentTask.TimeAmount * CurrentTask.TimeLeft;
            TaskTimeLeftBar.fillAmount = percentComplete / 100;
            if (CurrentTask.TimeLeft <= 0)
            {
                TaskDoneEvent.Invoke(CurrentTask);
            }
        }
    }
Ejemplo n.º 4
0
 public void FileUpload(string local, string url, TaskEvent finished = null, ErrorEvent error = null)
 {
     try
     {
         ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
         webClient.UploadFile(accessUrlBase + url, local);
         finished?.Invoke();
     }
     catch (WebException e)
     {
         error?.Invoke(((FtpWebResponse)e.Response).StatusDescription);
     }
     catch (Exception e)
     {
         error?.Invoke(e.Message);
     }
 }
Ejemplo n.º 5
0
 public void MakeDirectory(string url, TaskEvent finished = null, ErrorEvent error = null)
 {
     try
     {
         FtpWebRequest ftpReq = (FtpWebRequest)WebRequest.Create(accessUrlBase + url);
         ftpReq.Credentials = icr;
         ftpReq.Method      = WebRequestMethods.Ftp.MakeDirectory;
         FtpWebResponse ftpRes = (FtpWebResponse)ftpReq.GetResponse();
         ftpRes.Close();
         finished?.Invoke();
     }
     catch (WebException e)
     {
         error?.Invoke(((FtpWebResponse)e.Response).StatusDescription);
     }
     catch (Exception e)
     {
         error?.Invoke(e.Message);
     }
 }
Ejemplo n.º 6
0
    public void Run()
    {
        Task task = TaskGenerator.Generate(10);

        TaskStartEvent.Invoke(task);
    }
Ejemplo n.º 7
0
 protected void OnFinishTask(Task task)
 {
     FinishTaskEvent?.Invoke(this, task);
 }
Ejemplo n.º 8
0
 protected void OnStartTask(Task task)
 {
     StartTaskEvent?.Invoke(this, task);
 }