コード例 #1
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            LeagueDetails leagueDetails = (LeagueDetails)entity;

            switch (xmlNode.Name) {
                case Tags.LeagueID:
                    leagueDetails.leagueIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                    break;
                case Tags.LeagueName:
                    leagueDetails.leagueNameField = xmlNode.InnerText;
                    break;
                case Tags.LeagueLevel:
                    leagueDetails.leagueLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                    break;
                case Tags.MaxLevel:
                    leagueDetails.maxLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                    break;
                case Tags.LeagueLevelUnitID:
                    leagueDetails.leagueLevelUnitIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                    break;
                case Tags.LeagueLevelUnitName:
                    leagueDetails.leagueLevelUnitNameField = xmlNode.InnerText;
                    break;
                case Tags.CurrentMatchRound:
                    leagueDetails.currentMatchRound = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                    break;
                case Tags.Team:
                    Team newTeam = ParseTeamNode(xmlNode);
                    leagueDetails.teamField[newTeam.positionField - 1] = newTeam;
                    break;
                default:
                    throw new Exception(string.Format("Invalid XML: LeagueDetails.xml", Tags.Team));
            }
        }
コード例 #2
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            try
            {
                WorldDetails worldDetails = (WorldDetails)entity;

                switch (xmlNode.Name)
                {
                    case Tags.LeagueList:
                        {
                            if (xmlNode.ChildNodes != null)
                            {
                                worldDetails.leagueListField = ParseLeagueListNode(xmlNode);
                            }
                            break;
                        }
                    default:
                        throw new Exception(string.Format("Invalid XML: WorldDetails.xml"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public List <List <TimeView> > getScheduleList(double width, string days, string schedule)
        {
            List <List <TimeView> > result = new List <List <TimeView> >();

            string[] scheduleArray = schedule.Split('&');
            string[] daysArray     = days.Split(',');
            int      last_hour     = -1;
            string   minutes       = "";

            for (int i = 0; i < daysArray.Length; i++)
            {
                List <TimeView> tempList = new List <TimeView>();
                last_hour = -1;
                minutes   = "";
                if (daysArray[i] != "" && int.Parse(daysArray[i]) != -1)
                {
                    string[] scheduleDayArray = scheduleArray[Int32.Parse(daysArray[i])].Split(',');
                    for (int j = 0; j < scheduleDayArray.Length; j++)
                    {
                        HM hm = getHourMinute(scheduleDayArray[j]);
                        if (last_hour == -1)
                        {
                            last_hour = hm.hour;
                        }

                        if (hm.hour != last_hour || j == (scheduleDayArray.Length))
                        {
                            tempList.Add(new TimeView()
                            {
                                color  = i == getCurrentDaySchedule(schedule, days) && (last_hour - (last_hour / 24) * 24) == DateTime.Now.Hour ? "Gray" : "Transparent",
                                hour   = last_hour - (last_hour / 24) * 24,
                                width  = width,
                                minute = minutes.Substring(0, minutes.Length - 1),
                            });
                            last_hour = hm.hour;
                            minutes   = (hm.minute.ToString().Length == 1 ? "0" + hm.minute.ToString() : hm.minute.ToString()) + ",";
                        }
                        else
                        {
                            minutes += (hm.minute.ToString().Length == 1 ? "0" + hm.minute.ToString() : hm.minute.ToString()) + ",";
                        }
                    }
                }
                if (last_hour != -1)
                {
                    tempList.Add(new TimeView()
                    {
                        color  = i == getCurrentDaySchedule(schedule, days) && (last_hour - (last_hour / 24) * 24) == DateTime.Now.Hour ? "Gray" : "Transparent",
                        hour   = last_hour - (last_hour / 24) * 24,
                        width  = width,
                        minute = minutes.Substring(0, minutes.Length - 1),
                    });
                }
                result.Add(tempList);
            }

            return(result);
        }
コード例 #4
0
        public HM getHourMinute(string time)
        {
            HM  hm      = new HM();
            int timeInt = int.Parse(time);

            hm.hour   = timeInt / 60;
            hm.minute = timeInt - hm.hour * 60;
            return(hm);
        }
コード例 #5
0
        public double GetPositionWeight(HM.Resources.PlayerSkillTypes skill)
        {
            double weight = 0;

            if (this.positionWeights.ContainsKey(skill)) {
                weight = this.positionWeights[skill];
            }

            return (weight);
        }
コード例 #6
0
        public string GetLastFileName(HM.Resources.FileType fileType)
        {
            string filename = string.Empty;

            //Try and update an exisiting field
            for (int i = 0; i < lastFileListField.Count; i++) {
                LastFiles file = lastFileListField[i];

                if (file.fileTypeField == fileType) {
                    filename = file.fileNameField;
                    break;
                }
            }

            return (filename);
        }
コード例 #7
0
        public string getNextBusTime(string schedule, string days)
        {
            int current_time     = getUnixTime();
            int current_week_day = getWeekDay();
            int last_week_day    = getLastWeekDay();

            int currentHour  = DateTime.Now.Hour >= 0 && DateTime.Now.Hour <= 3 ? 24 + DateTime.Now.Hour : DateTime.Now.Hour;
            int currenMinute = DateTime.Now.Minute;

            string[] scheduleArray = schedule.Split('&');
            string[] daysArray     = days.Split(',');
            string   current_day   = daysArray[getWeekDay()];

            if (int.Parse(daysArray[last_week_day]) != -1 && currentHour >= 24)
            {
                string[] scheduleDayArray = scheduleArray[Int32.Parse(daysArray[last_week_day])].Split(',');
                if (scheduleDayArray[scheduleDayArray.Length - 1] != "" && int.Parse(scheduleDayArray[scheduleDayArray.Length - 1]) > currentHour * 60 + currenMinute)
                {
                    current_week_day = last_week_day;
                }
            }

            if (current_week_day == getWeekDay())
            {
                currentHour = DateTime.Now.Hour;
            }

            if (daysArray[current_week_day] != "" && int.Parse(daysArray[current_week_day]) != -1)
            {
                string[] scheduleDayArray = scheduleArray[Int32.Parse(daysArray[current_week_day])].Split(',');
                for (int j = 0; j < scheduleDayArray.Length; j++)
                {
                    if (scheduleDayArray[j] != "")
                    {
                        HM hm = getHourMinute(scheduleDayArray[j]);

                        if (hm.hour * 60 + hm.minute >= currentHour * 60 + currenMinute)
                        {
                            HM current = getHourMinute(((hm.hour * 60 + hm.minute) - (currentHour * 60 + currenMinute)).ToString());
                            return((current.hour == 0 ? "" : current.hour.ToString() + " " + this.resourceLoader.GetString("String_H") + " ") + "" + current.minute + " " + this.resourceLoader.GetString("String_M"));
                        }
                    }
                }
            }
            return(this.resourceLoader.GetString("ScheduleFinished"));
        }
コード例 #8
0
        public RimHelperProxy(ModContentPack content) : base(content)
        {
            IPC.Create();
            Log.Warning($"[RimHelperProxy] Shared memory with size: {IPC.MemorySize / (1024 * 1024)} Mb allocated!");

            HM.Init();

            new Thread(() => // Exception not handling from another threads!
            {
                while (true)
                {
                    HandleMessagesTick();
                    ResetTick();
                    Thread.Sleep(100);
                }
            }).Start();
        }
コード例 #9
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            try {
                Servers servers = (Servers)entity;

                switch (xmlNode.Name) {
                    case Tags.RecommendedURL:
                        servers.recommendedUrlField = xmlNode.InnerText;
                        break;
                    case Tags.Servers:
                        if (xmlNode.ChildNodes != null) {
                            servers.serversField = ParseServersNode(xmlNode);
                        }
                        break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
コード例 #10
0
        private void MeasurementTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Single   PTSA, HM, temp;
                ushort[] data = master.ReadInputRegisters(byte.Parse(ModbusAddrTextBox.Text), 46001 - 1, 8);

                UInt32 tData      = ((UInt32)data[1] << 16) + data[0];
                byte[] temp_bytes = BitConverter.GetBytes(tData);
                PTSA = BitConverter.ToSingle(temp_bytes, 0);

                tData      = ((UInt32)data[5] << 16) + data[4];
                temp_bytes = BitConverter.GetBytes(tData);
                temp       = BitConverter.ToSingle(temp_bytes, 0);

                tData      = ((UInt32)data[7] << 16) + data[6];
                temp_bytes = BitConverter.GetBytes(tData);
                HM         = BitConverter.ToSingle(temp_bytes, 0);

                DateTime CrtTime = new DateTime();
                CrtTime = DateTime.Now;

                if (senortype == SenorType.ST_510 || senortype == SenorType.Unknow)
                {
                    ValueLabel1.Text = "PTSA: " + PTSA.ToString() + "ppb";
                    ValueLabel2.Text = "HM: " + HM.ToString() + "%";
                    ValueLabel3.Text = "temp: " + temp.ToString() + " ";
                }


                File.AppendAllText(SnTextBox.Text + ".csv", CrtTime.ToString() + "," + PTSA.ToString("F2") + "," + HM.ToString("F1") + "," + temp.ToString("F1") + "\r\n");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
コード例 #11
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            LeagueFixtures leagueFixtures = (LeagueFixtures)entity;

            switch (xmlNode.Name)
            {
                case Tags.LeagueLevelUnitID:
                    leagueFixtures.leagueLevelUnitIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                    break;
                case Tags.LeagueLevelUnitName:
                    leagueFixtures.leagueLevelUnitNameField = xmlNode.InnerText;
                    break;
                case Tags.Season:
                    leagueFixtures.seasonField = Convert.ToInt32(xmlNode.InnerText);
                    break;
                case Tags.Match:
                    leagueFixtures.matchListField.Add(ParseMatchNode(xmlNode));
                    break;
                default:
                    throw new Exception(string.Format("Invalid XML: LeagueFixtures.xml", Tags.Match));
            }
        }
コード例 #12
0
        public Image GetPlayerValueImage(HTEntities.Players.Player player, HM.Resources.TableColumns columnID)
        {
            switch (columnID) {
                case TableColumns.Player_Category:
                    HTEntities.Players.Internal.PlayerCategories playerCategory = player.internalDataField.playerCategories.Find(pc => pc.PlayerIDField == player.playerIdField);

                    if (playerCategory != null) {
                        return (HM.Resources.GenericFunctions.GetCategoryImage(this.user.applicationSettingsField.playerCategoryListField.Find(cat => cat.categoryIdField == playerCategory.PlayerCategoryField).categoryColourField));
                    } else {
                        return (HM.Resources.GenericFunctions.GetCategoryImage(0));
                    }
                case TableColumns.Player_Health:
                    return (HM.Resources.GenericFunctions.GetInjuriesImage(player.injuryLevelField));
                case TableColumns.Player_LastPosition:
                    return (HM.Resources.GenericFunctions.GetPositionImage(player.lastMatchField.roleField));
                case TableColumns.Player_Nationality:
                    return (HM.Resources.GenericFunctions.GetFlagByLeagueId(player.leagueIdField));
                case TableColumns.Player_Warnings:
                    return (HM.Resources.GenericFunctions.GetCardImage(player.cardsField));
            }

            return (null);
        }
コード例 #13
0
        public Dictionary<HM.Resources.PlayerSkillTypes, double> GetPositionWeights(HM.Resources.FieldPositionCode selectedPosition)
        {
            for (int i = 0; i < playerPositionsListField.Count; i++) {
                Position position = playerPositionsListField[i];

                if (position.positionID == selectedPosition) {
                    return (position.positionWeights);
                }
            }

            return (new Dictionary<HM.Resources.PlayerSkillTypes, double>());
        }
コード例 #14
0
        /// <summary>
        /// Reads the UserSettings file and return it's content
        /// </summary>
        /// <returns>HattrickSettings for the selected user</returns>
        public HMEntities.Settings.HattrickSettings ReadUserSettingsFile(HM.Entities.HattrickManager.UserProfiles.User selectedUser)
        {
            try {
                HMEntities.Settings.HattrickSettings settings = new HMEntities.Settings.HattrickSettings();
                string path = System.IO.Path.Combine(selectedUser.dataFolderField, selectedUser.teamIdField.ToString());
                path = System.IO.Path.Combine(path, FolderNames.UserSettings);

                string fileName = Path.Combine(path, FileNames.UserSettings);

                if (File.Exists(fileName)) {
                    settings = dataManager.ReadUserSettingsFile(GetFileStream(fileName));
                } else {
                    settings = dataManager.ReadUserSettingsFile(HM.Resources.GenericFunctions.GetDefaultSettings(HM.Resources.SettingTypes.All));
                }

                return (settings);
            } catch (Exception ex) {
                throw ex;
            }
        }
コード例 #15
0
 public void SetPositionWeight(HM.Resources.PlayerSkillTypes skill, double weight)
 {
     this.positionWeights[skill] = weight;
 }
コード例 #16
0
ファイル: DownObject.cs プロジェクト: ys333/job-hunting
    // Update is called once per frame
    void Update()
    {
        if (GameStart)
        {
            if (Time.timeScale == 1)
            {
                m_time += Time.deltaTime;
                DebugArray();

                if (is_humberger_appear)
                {
                    return;
                }

                downtime += Time.deltaTime;
                movetime += Time.deltaTime;

                // 次の場所の配列のやつ
                int nrx = (int)r_num.x;
                int nlx = (int)l_num.x;
                int nry = (int)r_num.y + 1;
                int nly = (int)l_num.y + 1;

                if (Material_food)
                {
                    // ランダムで数字を生成
                    int num = Random.Range(1, 100);

                    // 数字をGameNumRetentionに渡して、どの種類の素材なのかを確認する
                    hum_material = GameNumRetention.Instance.GetHumberMaterial(num);

                    // 上の素材情報をもとに、ロードするパスデータを取得する
                    prefab_name = GameNumRetention.Instance.GetHumberString(hum_material);

                    Image Next_image = GameObject.Find("Canvas/NextMaterial").GetComponent <Image>();

                    Next_image.sprite = Resources.Load("Sprite/HumburgerMaterial/" + prefab_name, typeof(Sprite)) as Sprite;

                    Material_food = false;
                }
                #region 生成/完成関係
                // 生成のやつ
                if (array[0, 7] == (int)HM.NONE && array[0, 8] == (int)HM.NONE && seisei == true)
                {
                    // ハンバーガー完成確認
                    for (int tate = array.GetLength(0) - 1; tate >= 0; tate--)
                    {
                        for (int yoko = 0; yoko < array.GetLength(1); yoko++)
                        {
                            //Debug.Log("YOKO:" + yoko + " TATE:" + tate);
                            // 下のパン以外だったらcontinue
                            if (array[tate, yoko] != (int)HM.PAN_BTM)
                            {
                                continue;
                            }

                            // ハンバーガーの種類分チェック
                            for (int HM_type = 0; HM_type < (int)HT.NUM; HM_type++)
                            {
                                HM[] hum = GameNumRetention.Instance.GetHumburgerInfo((HT)HM_type);

                                // エラーチェック
                                if (hum == null)
                                {
                                    continue;
                                }

                                int tate_check_end = tate - hum.Length;
                                if (tate_check_end < 0)
                                {
                                    tate_check_end = 0;
                                }
                                bool is_created  = false;
                                int  check_count = 0;

                                // ここから上にチェック
                                for (int tate_check = tate; tate_check > tate_check_end; tate_check--)
                                {
                                    // マップ配列とハンバーガー種類配列が同じだったら
                                    if (array[tate_check, yoko] == (int)hum[hum.Length - 1 - (tate - tate_check)] &&
                                        array[tate_check, yoko + 1] == (int)hum[hum.Length - 1 - (tate - tate_check)])
                                    {
                                        check_count++;
                                        // ハンバーガーの素材数分 確認できたら
                                        if (check_count == hum.Length)
                                        {
                                            // 処理
                                            Debug.Log("完成");
                                            is_created = true;
                                        }
                                    }
                                }

                                // 完成していたら
                                if (is_created)
                                {
                                    // 上にチェックしながら消していく
                                    for (int tate_check = tate; tate_check > tate_check_end; tate_check--)
                                    {
                                        // 配列の中の情報を消す
                                        array[tate_check, yoko]     = (int)HM.NONE;
                                        array[tate_check, yoko + 1] = (int)HM.NONE;

                                        // keyをさくせいしてゲームオブジェクトをDictionaryから検索
                                        string     key = tate_check.ToString() + yoko.ToString();
                                        GameObject ret = null;
                                        obj_list.TryGetValue(key, out ret);


                                        // retにゲームオブジェクトが帰ってきたら削除
                                        if (ret != null)
                                        {
                                            obj_list.Remove(key);
                                            Destroy(ret);
                                        }
                                    }

                                    // スコア取得
                                    int create_score = GameNumRetention.Instance.GetHumbergerScore((HT)HM_type);
                                    // スコアを加算
                                    GameNumRetention.Instance.AddScore(create_score);
                                    // 使用したハンバーガーを加算
                                    GameNumRetention.Instance.AddHumbergerCount((HT)HM_type, 1);
                                    Debug.Log(GameNumRetention.Instance.GetScore());

                                    Vector2 point = new Vector2(stpx - mvPos.x * 7, 4);

                                    is_humberger_appear = true;
                                    appear_set.CallFunc first = () =>
                                    {
                                        Sound_Efect = comp_Efect;
                                        SoundEfect  = true; SoundEfelctPlay();
                                    };
                                    appear_set.CallFunc call = () => { is_humberger_appear = false; };
                                    m_appear.SetAppearHumberger((HT)HM_type, new Vector2(point.x + yoko * mvPos.x, point.y - (tate - ((tate - tate_check_end) / 2.0f)) * mvPos.y), first, call);

                                    // スコアを取得して表示
                                    GameScore.text = "" + GameNumRetention.Instance.GetScore();
                                }
                            }
                        }
                    }
                    #endregion


                    // ブロック作る(instanciate)
                    meat = Instantiate(Resources.Load("Prefab/" + prefab_name, typeof(GameObject)),
                                       new Vector2(stpx, stpy), Quaternion.identity) as GameObject;

                    Material_food = true;

                    //ブロックやつ
                    DW_object = meat;
                    DW_object.transform.position = new Vector2(stpx, stpy);

                    hum_num = (int)hum_material; // meat とかバンズとか番号

                    // 座標を計算
                    array[0, 7] = hum_num; // l_num
                    array[0, 8] = hum_num; // r_num
                    l_num.x     = 7; l_num.y = 0;
                    r_num.x     = 8; r_num.y = 0;

                    nrx = (int)r_num.x;
                    nlx = (int)l_num.x;
                    nry = (int)r_num.y + 1;
                    nly = (int)l_num.y + 1;

                    seisei = false;

                    // もしタッチがされているなら、連続で物体移動を有効にしないようにnext_touchを無効にする
                    if (!first_touch)
                    {
                        next_touch = false;
                    }

                    nowPos = DW_object.transform.position;
                }
                // 配列の移動やつとブロックの移動やつ
                else if (downtime > 2)
                {
                    // 移動できた場合
                    if (array[nly, nlx] == (int)HM.NONE && array[nry, nrx] == (int)HM.NONE)
                    {
                        SetNextPoint(nrx, nry, nlx, nly);
                        nry = (int)r_num.y + 1;
                        nly = (int)l_num.y + 1;

                        Sound_Efect = Move_Efect;
                        SoundEfect  = true;
                    }

                    // どちらかにオブジェクトがあるので、移動できない場合
                    if (array[nly, nlx] != (int)HM.NONE || array[nry, nrx] != (int)HM.NONE)
                    {
                        AddStaticObjectList(l_num);

                        l_num = new Vector2(-1, -1);
                        r_num = new Vector2(-1, -1);

                        Sound_Efect = Stop_Efect;
                        SoundEfect  = true;

                        seisei = true;
                    }
                }

                // 生成地点にブロックがあったら ゲームオーバー
                if (array[0, 7] != (int)HM.NONE && array[0, 8] != (int)HM.NONE && seisei == true)
                {
                    SceneManager.LoadScene("Result");
                    GameNumRetention.Instance.SetTimeNum(m_time);
                }

                #region 移動系
                // とりまマウスで操作
                if (Input.GetMouseButton(0) && next_touch && !seisei)
                {
                    touch_time += Time.deltaTime;

                    touchPos = camera.ScreenToWorldPoint(Input.mousePosition);
                    if (first_touch == true)
                    {
                        firstPos    = touchPos;
                        first_touch = false;
                        is_move     = false;
                    }

                    // とりま左移動
                    if (nlx - 1 >= 0 && firstPos.x > touchPos.x + 1 && movetime > 0.1f && array[(int)l_num.y, nlx - 1] == (int)HM.NONE)
                    {
                        array[(int)l_num.y, (int)l_num.x - 1] = hum_num;
                        array[(int)r_num.y, (int)r_num.x]     = (int)HM.NONE;

                        l_num.x -= 1;
                        r_num.x -= 1;

                        nowPos.x -= mvPos.x;
                        movetime  = 0f;

                        Sound_Efect = Move_Efect;
                        SoundEfect  = true;

                        is_move = true;
                    }
                    // 逆に右移動
                    else if (nrx + 1 < array.GetLength(1) && firstPos.x < touchPos.x - 1 && movetime > 0.1f && array[(int)r_num.y, nrx + 1] == (int)HM.NONE)
                    {
                        array[(int)r_num.y, (int)r_num.x + 1] = hum_num;
                        array[(int)l_num.y, (int)l_num.x]     = (int)HM.NONE;

                        l_num.x += 1;
                        r_num.x += 1;

                        nowPos.x += mvPos.x;
                        movetime  = 0f;

                        Sound_Efect = Move_Efect;
                        SoundEfect  = true;

                        is_move = true;
                    }

                    // 下に落ちる系
                    else if (firstPos.y > touchPos.y + 1 && array[nly, nlx] == (int)HM.NONE && array[nry, nrx] == (int)HM.NONE)
                    {
                        SetNextPoint(nrx, nry, nlx, nly);
                        nry = (int)r_num.y + 1;
                        nly = (int)l_num.y + 1;

                        is_move = true;

                        // 次の位置をチェックしてあげて、何かしらのオブジェクトがあるなら生成モードへ
                        if (array[nly, nlx] != (int)HM.NONE || array[nry, nrx] != (int)HM.NONE)
                        {
                            AddStaticObjectList(l_num);

                            l_num = new Vector2(-1, -1);
                            r_num = new Vector2(-1, -1);

                            Sound_Efect = Stop_Efect;
                            SoundEfect  = true;

                            seisei = true;
                        }
                    }

                    DW_object.transform.position = nowPos;
                }

                if (Input.GetMouseButtonUp(0))
                {
                    // 0.5秒以下
                    if (touch_time < 0.3f && next_touch && !is_move)
                    {
                        ChangePanType();
                    }

                    first_touch = true;
                    next_touch  = true;
                    touch_time  = 0.0f;
                }

                SoundEfelctPlay();
                #endregion
            }
        }
    }
コード例 #17
0
ファイル: GameNumRetention.cs プロジェクト: ys333/job-hunting
    public string GetHumberString(HM num)
    {
        string Material_name = m_HUM_PASS_list[(int)num];

        return(Material_name);
    }
コード例 #18
0
        public void Update(KeyboardState keyboardState, GameTime gameTime, IEnumerable <ICollidable> collidables)
        {
            MouseState mouseState = Mouse.GetState();

            Hitbox    = new Rectangle((int)Position.X - 16, (int)Position.Y - 16, 32, 32);
            rectangle = new Rectangle((int)Position.X, (int)Position.Y, Texture.Width, Texture.Height);
            // W
            // Move up
            if (keyboardState.IsKeyDown(Keys.W))
            {
                Vector2   newPosiiton      = new Vector2(Position.X, Position.Y - playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
                Rectangle newRectangle     = new Rectangle((int)newPosiiton.X - 16, (int)newPosiiton.Y - 16, 32, 32);
                bool      movementPossible = true;
                foreach (var item in collidables)
                {
                    if (item.Hitbox.Intersects(newRectangle) && item.IsSolid)
                    {
                        movementPossible = false;
                        return;
                    }
                }

                if (movementPossible)
                {
                    Position.Y -= playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    isMoving    = true;
                }
            }

            // S
            // Move down
            if (keyboardState.IsKeyDown(Keys.S))
            {
                Vector2   newPosiiton      = new Vector2(Position.X, Position.Y + playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
                Rectangle newRectangle     = new Rectangle((int)newPosiiton.X - 16, (int)newPosiiton.Y - 16, 32, 32);
                bool      movementPossible = true;
                foreach (var item in collidables)
                {
                    if (item.Hitbox.Intersects(newRectangle) && item.IsSolid)
                    {
                        movementPossible = false;
                        return;
                    }
                }

                if (movementPossible)
                {
                    Position.Y += playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    isMoving    = true;
                }
            }

            // A
            // Move left
            if (keyboardState.IsKeyDown(Keys.A))
            {
                Vector2   newPosiiton      = new Vector2(Position.X - playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds, Position.Y);
                Rectangle newRectangle     = new Rectangle((int)newPosiiton.X - 16, (int)newPosiiton.Y - 16, 32, 32);
                bool      movementPossible = true;
                foreach (var item in collidables)
                {
                    if (item.Hitbox.Intersects(newRectangle) && item.IsSolid)
                    {
                        movementPossible = false;
                        return;
                    }
                }

                if (movementPossible)
                {
                    Position.X -= playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    isMoving    = true;
                }
            }

            // D
            // Move right
            if (keyboardState.IsKeyDown(Keys.D))
            {
                Vector2   newPosiiton      = new Vector2(Position.X + playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds, Position.Y);
                Rectangle newRectangle     = new Rectangle((int)newPosiiton.X - 16, (int)newPosiiton.Y - 16, 32, 32);
                bool      movementPossible = true;
                foreach (var item in collidables)
                {
                    if (item.Hitbox.Intersects(newRectangle) && item.IsSolid)
                    {
                        movementPossible = false;
                        return;
                    }
                }

                if (movementPossible)
                {
                    Position.X += playerSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    isMoving    = true;
                }
            }

            // LMB
            // Shoot
            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                Shoot(Position, mouseState.Position.ToVector2(), GameState.mapObjects, GameState.entities);
            }

            // 1
            // Change gun to 0
            if (keyboardState.IsKeyDown(Keys.D1))
            {
                CurrentGun = 0;
            }

            // 2
            // Change gun to 1
            if (keyboardState.IsKeyDown(Keys.D2))
            {
                CurrentGun = 1;
            }

            // 3
            // Change gun to 2
            if (keyboardState.IsKeyDown(Keys.D3))
            {
                CurrentGun = 2;
            }

            // 4
            // Change gun to 3
            if (keyboardState.IsKeyDown(Keys.D4))
            {
                CurrentGun = 3;
            }

            // No keys
            // Reset movement
            if (keyboardState.GetPressedKeyCount() == 0)
            {
                isMoving = false;
            }

            //Hitmarks remove
            if (HM.Count > 15)
            {
                HM.Dequeue();
            }


            currentFrame++;
            if (currentFrame == totalFrames)
            {
                currentFrame = 0;
            }
            GunCooldown++;
        }
コード例 #19
0
        public string GetPlayerValueName(HTEntities.Players.Player player, HM.Resources.TableColumns columnID)
        {
            switch (columnID) {
                case TableColumns.Player_AgeFull:
                    return (player.getFullAge());
                case TableColumns.Player_FirstName:
                    return (player.firstNameField);
                case TableColumns.Player_FullName:
                    return (player.getFullName());
                case TableColumns.Player_LastName:
                    return (player.lastNameField);
            }

            return (string.Empty);
        }
コード例 #20
0
        public int GetPlayerValueNumber(HTEntities.Players.Player player, HM.Resources.TableColumns columnID)
        {
            switch (columnID) {
                case TableColumns.Player_AgeDays:
                    return (Convert.ToInt32(player.ageDaysField));
                case TableColumns.Player_AgeYears:
                    return (Convert.ToInt32(player.ageField));
                case TableColumns.Player_Defending:
                    return (Convert.ToInt32(player.defenderSkillField));
                case TableColumns.Player_Form:
                    return (Convert.ToInt32(player.playerFormField));
                case TableColumns.Player_Health:
                    return (Convert.ToInt32(player.injuryLevelField));
                case TableColumns.Player_ID:
                    return (Convert.ToInt32(player.playerIdField));
                case TableColumns.Player_Keeping:
                    return (Convert.ToInt32(player.keeperSkillField));
                case TableColumns.Player_LastPosition:
                    return (Convert.ToInt32(player.lastMatchField.roleField));
                case TableColumns.Player_Nationality:
                    return (Convert.ToInt32(player.countryIdField));
                case TableColumns.Player_Number:
                    return (Convert.ToInt32(player.playerNumberField));
                case TableColumns.Player_Passing:
                    return (Convert.ToInt32(player.passingSkillField));
                case TableColumns.Player_Playmaking:
                    return (Convert.ToInt32(player.playmakerSkillField));
                case TableColumns.Player_Scoring:
                    return (Convert.ToInt32(player.scorerSkillField));
                case TableColumns.Player_SetPieces:
                    return (Convert.ToInt32(player.setPiecesSkillField));
                case TableColumns.Player_Stamina:
                    return (Convert.ToInt32(player.staminaSkillField));
                case TableColumns.Player_TSI:
                    return (Convert.ToInt32(player.tsiField));
                case TableColumns.Player_Warnings:
                    return (Convert.ToInt32(player.cardsField));
                case TableColumns.Player_Wing:
                    return (Convert.ToInt32(player.wingerSkillField));
            }

            return (0);
        }
コード例 #21
0
        public void Shoot(Vector2 sourcePosition, Vector2 destinationPosition, List <ICollidable> mapObjects, List <IEntity> entities)
        {
            var rnd = new Random();                     // generator liczb losowych

            // Sprawdz czy jest amunicja i czy można strzelić
            if (!(GunInventory[CurrentGun].AmmoCount > 0) | !(GunCooldown > GunInventory[CurrentGun].RateOfFire))
            {
                return;
            }

            GunInventory[CurrentGun].AmmoCount -= 1;
            GunCooldown = 0;

            for (int i = 0; i < GunInventory[CurrentGun].PelletCount; i++)       // dla każdego pocisku
            {
                //soundeffect.

                GameState.soundEffects[0].Play();

                float rndOffset    = (float)rnd.Next(-GunInventory[CurrentGun].Spread, GunInventory[CurrentGun].Spread);  // Oblicz losowe odchylenie zgodne z Spread
                float radRndOffset = (float)(rndOffset * (Math.PI / 180));

                float baseAngle = (float)Math.Atan2(destinationPosition.Y - sourcePosition.Y, destinationPosition.X - sourcePosition.X); // Oblicz startowy kąt między pozycją gracza i myszki

                double shootAngle = baseAngle + radRndOffset;                                                                            // Oblicz kąt strzału z odchyleniem


                // Sprawdzanie kolizji
                bool   colided           = false;
                bool   outOfRange        = false;
                int    distanceTravelled = 0;
                double xToCheck          = sourcePosition.X;
                double yToCheck          = sourcePosition.Y;

                while (!colided & !outOfRange)
                {
                    foreach (var entity in entities)
                    {
                        if (entity.Hitbox.Contains((int)xToCheck, (int)yToCheck) && entity.IsSolid)
                        {
                            entity.Hurt(GunInventory[CurrentGun].Damage);        // Dodać metode do przeciwników która odejmuje zdrowie
                            colided = true;
                        }
                    }

                    foreach (var mapObj in mapObjects)
                    {
                        // Kolizja ze scianą, oknem, drzwiami
                        if (mapObj.Hitbox.Contains((int)xToCheck, (int)yToCheck) && mapObj.IsSolid)
                        {
                            colided = true;
                        }
                    }
                    // Przesuń sprawdzany punkt
                    if (!colided)
                    {
                        xToCheck = xToCheck + Math.Cos(shootAngle) * 1.02;
                        yToCheck = yToCheck + Math.Sin(shootAngle) * 1.02;
                    }

                    // Sprawdz czy nie jest za ekranem
                    if (xToCheck > 2000 | yToCheck > 2000 | xToCheck < 0 | yToCheck < 0)
                    {
                        outOfRange = true;
                    }

                    if (colided)
                    {
                        HM.Enqueue(new Vector2((float)xToCheck - 16, (float)yToCheck - 16));
                    }
                }
            }
        }
コード例 #22
0
        public void UpdateLastFile(HM.Resources.FileType fileType, string fileName)
        {
            bool FileExists = false;
            string currentDate = DateTime.Now.ToString(HM.Resources.Constants.Chpp.HMDateFormat);

            //Try and update an exisiting field
            for (int i = 0; i < lastFileListField.Count; i++) {
                LastFiles file = lastFileListField[i];

                if (file.fileTypeField == fileType) {
                    file.fileNameField = fileName;
                    file.dateField = currentDate;
                    FileExists = true;
                    break;
                }
            }

            // Create New Last File Field
            if (!FileExists) {
                LastFiles newFile = new LastFiles();
                newFile.fileTypeField = fileType;
                newFile.fileNameField = fileName;
                newFile.dateField = currentDate;

                lastFileListField.Add(newFile);
            }
        }