Ejemplo n.º 1
0
    public void TrapBreaker(ManageDungeon dun, BaseCharacter target)
    {
        //サウンドを鳴らす
        SoundInformation.Sound.Play(SoundInformation.SoundType.AttackHit);

        //自オブジェクトとの距離を取得
        int dist = CurrentPoint.DistanceAbs(target.CurrentPoint);

        MapPoint vector     = CommonFunction.CharacterDirectionVector[target.Direction];
        MapPoint checkpoint = target.CurrentPoint;

        dun.SetUpTrapMap();
        //対象位置までのトラップをすべて破壊
        for (int i = 0; i <= dist; i++)
        {
            BaseTrap tr = dun.TrapMap.Get(checkpoint);
            if (CommonFunction.IsNull(tr) == false)
            {
                EffectSmoke.CreateObject(tr, false).Play();
                dun.RemoveTrap(tr);
                ManageDungeon.KillObjectNow(tr);

                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapBreak, tr.DisplayNameInMessage,
                                  CommonFunction.StateNames[StateAbnormal.Slow]));
            }
            //1マス先を取得
            checkpoint = checkpoint.Add(vector);
        }
    }
Ejemplo n.º 2
0
        public override void Calculate(TrackPoint nextPoint)
        {
            base.Calculate(nextPoint);
            var timeSpanSeconds = (nextPoint.DateTime - CurrentPoint.DateTime).TotalSeconds;

            if (timeSpanSeconds > TimeFilter || timeSpanSeconds == 0)
            {
                return;
            }
            var deltaS = CurrentPoint.GetGeoCoordinate().GetDistanceTo(nextPoint.GetGeoCoordinate());
            var deltaT = (nextPoint.DateTime - CurrentPoint.DateTime).TotalSeconds;
            var speed  = deltaS / deltaT;

            speeds.Add(speed);
            switch (CurrentDirection)
            {
            case AltitudeDirection.Climbing:
                climbingSpeeds.Add(speed);
                break;

            case AltitudeDirection.Descent:
                descentSpeeds.Add(speed);
                break;

            case AltitudeDirection.Flat:
                flatSpeeds.Add(speed);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            CurrentPoint = nextPoint;
        }
Ejemplo n.º 3
0
 public void updateBoardByDirections(int i_pointX, int i_pointY, List <Utilities.Point> i_listOfChanges, string i_shape)
 {
     foreach (Utilities.Point CurrentPoint in i_listOfChanges)
     {
         updateBoardByDirection(i_pointX, i_pointY, CurrentPoint.X(), CurrentPoint.Y(), i_shape);
     }
 }
        public override void Calculate(TrackPoint nextPoint)
        {
            base.Calculate(nextPoint);

            var timeSpanSeconds = (nextPoint.DateTime - CurrentPoint.DateTime).TotalSeconds;

            if (timeSpanSeconds > TimeFilter || timeSpanSeconds == 0)
            {
                return;
            }
            var distance = CurrentPoint.GetGeoCoordinate().GetDistanceTo(nextPoint.GetGeoCoordinate());

            _totalDistance += distance;
            switch (CurrentDirection)
            {
            case AltitudeDirection.Climbing:
                _climbDistance += distance;
                break;

            case AltitudeDirection.Descent:
                _descentDistance += distance;
                break;

            case AltitudeDirection.Flat:
                _flatDistance += distance;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            CurrentPoint = nextPoint;
        }
Ejemplo n.º 5
0
        void OnTriggerEnter(Collider other)
        {
            if (other.tag == "Player")
            {
                CharacterScore playerScore = other.transform.GetComponent <CharacterScore>();
                playerScore.addScore();
            }



            switch (currentPoint)
            {
            case CurrentPoint.POINT_ONE:
                currentPoint       = CurrentPoint.POINT_TWO;
                transform.position = point2;
                break;

            case CurrentPoint.POINT_TWO:
                currentPoint       = CurrentPoint.POINT_ONE;
                transform.position = point1;
                break;

            default:
                //do nothing
                break;
            }
        }
Ejemplo n.º 6
0
 public DrawObjectMouseDown OnMouseDown(UnitPoint point)
 {
     this.OnMouseMove(point);
     if (CurrentMousePoint == CurrentPoint.FirstPoint)
     {
         CurrentMousePoint = CurrentPoint.EndPoint;
         return(DrawObjectMouseDown.Continue);
     }
     return(DrawObjectMouseDown.Done);
 }
Ejemplo n.º 7
0
        /// <summary> 连线绘制图案(以设定颜色绘制)  将选中的圆形以color颜色链接起来
        /// </summary>
        /// <param name="rect">图形上下文</param>
        /// <param name="color">连线颜色</param>
        public void ConnectCirclesInRect(CGRect rect, UIColor color)
        {
            //获取上下文
            CGContext ctx = UIGraphics.GetCurrentContext();

            // 添加路径
            ctx.AddRect(rect);
            //是否剪裁
            ClipSubviewsWhenConnectInContext(ctx, Clip);
            //剪裁上下文
            ctx.EOClip();
            // 遍历数组中的circle
            for (int index = 0; index < CircleSet.Count; index++)
            {
                // 取出选中按钮
                PCCircle circle = CircleSet[index];
                // 起点按钮
                if (index == 0)
                {
                    ctx.MoveTo(circle.Center.X, circle.Center.Y);
                }
                else
                {
                    // 全部是连线
                    ctx.AddLineToPoint(circle.Center.X, circle.Center.Y);
                }
            }

            // 连接最后一个按钮到手指当前触摸得点
            if (!CurrentPoint.Equals(new CGPoint(0, 0)))
            {
                foreach (var item in Subviews)
                {
                    if (GetCircleState() == CircleState.CircleStateError || GetCircleState() == CircleState.CircleStateLastOneError)
                    {
                        // 如果是错误的状态下不连接到当前点
                    }
                    else
                    {
                        ctx.AddLineToPoint(CurrentPoint.X, CurrentPoint.Y);
                    }
                }
            }

            //线条转角样式
            ctx.SetLineCap(CGLineCap.Round);
            ctx.SetLineJoin(CGLineJoin.Round);
            // 设置绘图的属性
            ctx.SetLineWidth(PCCircleViewConst.CircleConnectLineWidth);
            // 线条颜色
            color.SetColor();
            //渲染路径
            ctx.StrokePath();
        }
Ejemplo n.º 8
0
 public void OnMouseMove(ICanvas canvas, UnitPoint unitPoint)
 {
     if (this.current == CurrentPoint.P1)
     {
         this.MultiLinePoints.Add(unitPoint);
         this.current = CurrentPoint.EndPoint;
         return;
     }
     else
     {
         this.currentPoint = unitPoint;
     }
 }
Ejemplo n.º 9
0
        public static bool ReachedPoint(Vector2 point)
        {
            const int compareDistance = 80 * 80;

            for (var i = 0; i < Index; i++)
            {
                if (Path[i].Distance(point, true) <= compareDistance)
                {
                    return(true);
                }
            }

            return(CurrentPoint.Distance(point, true) < compareDistance);
        }
Ejemplo n.º 10
0
        public static bool IsMovingTowards(Vector2 point)
        {
            if (!IsPathing)
            {
                return(false);
            }

            if (Index > Path.Length - 1)
            {
                return(false);
            }

            return(CurrentPoint.Distance(point, true) <= SwitchDistance);
        }
Ejemplo n.º 11
0
    void Start()
    {
        rb       = GetComponent <Rigidbody2D>();
        sr       = GetComponent <SpriteRenderer>();
        refEnemy = GetComponent <Enemy>();

        // find a reference point
        referencePoint = GameObject.Find("Camera").transform;

        // initialize the origin
        origin = new Vector2(referencePoint.position.x, referencePoint.position.y);

        // only randomize starting position and create clones if we're the original
        if (isOriginal == true)
        {
            // randomly set the starting point to either the top left or top right
            if (Random.Range(0, 2) == 1)
            {
                transform.position = origin + (topRightOffset * 2);
                currentPoint       = CurrentPoint.topRight;
                justWasTopRight    = true;
                defaultTopRight    = true;
            }
            else
            {
                transform.position = origin + (topLeftOffset * 2);
                currentPoint       = CurrentPoint.topLeft;
                justWasTopRight    = false;
                defaultTopRight    = false;
            }

            // save the default position for clones
            defaultPosition = transform.position;

            // save the default current position for clones
            defaultCurrentPoint = currentPoint;

            // spawn clones
            if (numOfClones > 0)
            {
                for (int i = 1; i < numOfClones + 1; ++i)
                {
                    Invoke("SpawnClone", i * spawnInterval);
                }
            }
        }
    }
Ejemplo n.º 12
0
 public DrawObjectMouseDown OnMouseDown(ICanvas canvas, UnitPoint point, ISnapPoint snapPoint, MouseEventArgs e)
 {
     OnMouseMove(canvas, point);
     if (this.currentPoint == CurrentPoint.CenterPoint)
     {
         this.currentPoint = CurrentPoint.StartPoint;
         return(DrawObjectMouseDown.Continue);
     }
     if (this.currentPoint == CurrentPoint.StartPoint)
     {
         //OnMouseMove(canvas, point);
         this.IsSelected     = false;
         this.startMovePoint = this.hexagonPoints[0];
         this.drawStatus     = DrawObjectMouseDown.Done;
         this.SN             = ++GlobalModel.TotalDrawObjectCount;
         return(DrawObjectMouseDown.Done);
     }
     return(DrawObjectMouseDown.Done);
 }
Ejemplo n.º 13
0
        private static void OnTick(EventArgs args)
        {
            if (Path == null || Index > Path.Length - 1 || Player.Instance.IsDead)
            {
                StopPath();
            }

            if (!IsPathing || !Player.Instance.CanMove)
            {
                return;
            }

            if (Player.Instance.ServerPosition.To2D().Distance(CurrentPoint, true) <= SwitchDistance.Pow())
            {
                Index += 1;
            }

            if (Index <= Path.Length - 1 &&
                (Player.Instance.Path.Last().Distance(CurrentPoint, true) > SwitchDistance.Pow()))
            {
                Player.IssueOrder(GameObjectOrder.MoveTo, CurrentPoint.To3DWorld(), false);
            }
        }
Ejemplo n.º 14
0
            public void Back(Attacker person, ref CurrentPoint CharacterPoint, ref CurrentPoint EnemyPoint)
            {
                if (person == Attacker.Enemy)
                {
                    EnemyPoint.attack  = BuffAttack;
                    EnemyPoint.defence = BuffDefence;
                    EnemyPoint.speed   = BuffSpeed;

                    CharacterPoint.attack  = DebuffAttack;
                    CharacterPoint.defence = DebuffDefence;
                    CharacterPoint.speed   = DebuffSpeed;
                }
                else
                {
                    CharacterPoint.attack  = BuffAttack;
                    CharacterPoint.defence = BuffDefence;
                    CharacterPoint.speed   = BuffSpeed;

                    EnemyPoint.attack  = DebuffAttack;
                    EnemyPoint.defence = DebuffDefence;
                    EnemyPoint.speed   = DebuffSpeed;
                }
            }
Ejemplo n.º 15
0
            public Characteristic(Attacker person, ref CurrentPoint CharacterPoint, ref CurrentPoint EnemyPoint)
            {
                if (person == Attacker.Enemy)
                {
                    BuffAttack  = EnemyPoint.attack;
                    BuffDefence = EnemyPoint.defence;
                    BuffSpeed   = EnemyPoint.speed;

                    DebuffAttack  = CharacterPoint.attack;
                    DebuffDefence = CharacterPoint.defence;
                    DebuffSpeed   = CharacterPoint.speed;
                }
                else
                {
                    BuffAttack  = CharacterPoint.attack;
                    BuffDefence = CharacterPoint.defence;
                    BuffSpeed   = CharacterPoint.speed;

                    DebuffAttack  = EnemyPoint.attack;
                    DebuffDefence = EnemyPoint.defence;
                    DebuffSpeed   = EnemyPoint.speed;
                }
            }
Ejemplo n.º 16
0
    private void CheckDistance()
    {
        // if we're in range of our current point
        if (Vector2.Distance(transform.position, GetCurrentPointVec()) < checkDistance)
        {
            // update the current point
            switch (currentPoint)
            {
            case CurrentPoint.topRight:
            {
                currentPoint = CurrentPoint.bottom;
                break;
            }

            case CurrentPoint.topLeft:
            {
                currentPoint = CurrentPoint.bottom;
                break;
            }

            case CurrentPoint.bottom:
            {
                if (justWasTopRight)
                {
                    currentPoint    = CurrentPoint.topLeft;
                    justWasTopRight = false;
                }
                else
                {
                    currentPoint    = CurrentPoint.topRight;
                    justWasTopRight = true;
                }
                break;
            }
            }
        }
    }
Ejemplo n.º 17
0
        //Person - тот кто атакует
        //метод использует ссылки на структуры CurrentPoint
        //чтобы сохранить значения структур в методе
        //затем изменить их на время действия метода
        //и, после, вернуть им изначальные значения
        public bool Do(Attacker creature, ref CurrentPoint CharacterPoint, ref CurrentPoint EnemyPoint)
        {
            Random rand = new Random();

            if (creature == Attacker.Enemy)
            {
                temp = new Characteristic(Attacker.Enemy, ref CharacterPoint, ref EnemyPoint);

                EnemyPoint.attack  = EnemyPoint.attack * (uint)current.BuffAttack / 100;
                EnemyPoint.defence = EnemyPoint.defence * (uint)current.BuffDefence / 100;
                EnemyPoint.speed   = EnemyPoint.speed * (uint)current.BuffSpeed / 100;

                CharacterPoint.attack  = CharacterPoint.attack * (uint)current.DebuffAttack / 100;
                CharacterPoint.defence = CharacterPoint.defence * (uint)current.DebuffDefence / 100;
                CharacterPoint.speed   = CharacterPoint.speed * (uint)current.DebuffSpeed / 100;

                if (GetAttackProbability(creature) == 100 || rand.Next(100) <= GetAttackProbability(creature))
                {
                    if (CharacterPoint.defence < EnemyPoint.attack)
                    {
                        if (CharacterPoint.HP <= -CharacterPoint.defence + EnemyPoint.attack)
                        {
                            CharacterPoint.HP = 0;
                        }
                        else
                        {
                            CharacterPoint.HP += CharacterPoint.defence - EnemyPoint.attack;
                        }
                    }
                    temp.Back(Attacker.Enemy, ref CharacterPoint, ref EnemyPoint);
                    return(true);
                }
                temp.Back(Attacker.Enemy, ref CharacterPoint, ref EnemyPoint);
                return(false);
            }
            else
            {
                temp = new Characteristic(Attacker.Player, ref CharacterPoint, ref EnemyPoint);

                CharacterPoint.attack  = CharacterPoint.attack * current.BuffAttack / 100;
                CharacterPoint.defence = CharacterPoint.defence * current.BuffDefence / 100;
                CharacterPoint.speed   = CharacterPoint.speed * current.BuffSpeed / 100;

                EnemyPoint.attack  = EnemyPoint.attack * current.DebuffAttack / 100;
                EnemyPoint.defence = EnemyPoint.defence * current.DebuffDefence / 100;
                EnemyPoint.speed   = EnemyPoint.speed * current.DebuffSpeed / 100;

                if (GetAttackProbability(creature) == 100 || rand.Next(100) <= GetAttackProbability(creature))
                {
                    if (EnemyPoint.defence < CharacterPoint.attack)
                    {
                        if (EnemyPoint.HP <= -EnemyPoint.defence + CharacterPoint.attack)
                        {
                            EnemyPoint.HP = 0;
                        }
                        else
                        {
                            EnemyPoint.HP += EnemyPoint.defence - CharacterPoint.attack;
                        }
                    }
                    temp.Back(Attacker.Player, ref CharacterPoint, ref EnemyPoint);
                    return(true);
                }
                temp.Back(Attacker.Player, ref CharacterPoint, ref EnemyPoint);
                return(false);
            }
        }
Ejemplo n.º 18
0
 public LeadLine(UnitPoint mousePoint)
 {
     this.p2 = UnitPoint.Empty;
     this.CurrentMousePoint = CurrentPoint.FirstPoint;
     this.OnMouseDown(mousePoint);
 }
Ejemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     currentPoint       = CurrentPoint.POINT_ONE;
     transform.position = point1;
 }
Ejemplo n.º 20
0
        public JsonResult LoadRealTable(JsonExcel excelModels)
        {
            CurrentPoint current = new CurrentPoint();

            current.IO = excelModels.CurrentIOID;

            List <DeviceGroupModel> deviceModels = excelModels.devices;

            //读取所有的实时数据,并加载 mWebInfluxDbManager
            List <InfluxDBQueryPara> devices = new List <InfluxDBQueryPara>();

            foreach (DeviceGroupModel res in deviceModels)
            {
                InfluxDBQueryPara data = new InfluxDBQueryPara();
                data.IOCommunicateID = res.IO_COMM_ID;
                data.IODeviceID      = res.IO_DEVICE_ID;
                data.IOServerID      = res.IO_SERVER_ID;
                data.UpdateCycle     = res.UpdateCycle;
                devices.Add(data);
            }

            IEnumerable <IEnumerable <Serie> > realResult = mWebInfluxDbManager.MultiQueryReal(devices);

            #region 获取当前选择的Io点的实时值
            if (!string.IsNullOrWhiteSpace(excelModels.CurrentCommunicateID) && !string.IsNullOrWhiteSpace(excelModels.CurrentDeviceID) && !string.IsNullOrWhiteSpace(excelModels.CurrentServerID) && !string.IsNullOrWhiteSpace(excelModels.CurrentIOID) && !string.IsNullOrWhiteSpace(excelModels.CurrentGroupID))
            {
                string           IO_SERVER_ID = excelModels.CurrentServerID;
                string           IO_COMM_ID   = excelModels.CurrentCommunicateID;
                string           IO_DEVICE_ID = excelModels.CurrentDeviceID;
                string           IO_ID        = excelModels.CurrentIOID;
                string           GroupId      = excelModels.CurrentGroupID;
                int              devIndex     = devices.FindIndex(x => x.IOServerID == IO_SERVER_ID && x.IOCommunicateID == IO_COMM_ID && x.IODeviceID == IO_DEVICE_ID);
                DeviceGroupModel selItem      = deviceModels.Find(x => x.IO_SERVER_ID == IO_SERVER_ID && x.IO_COMM_ID == IO_COMM_ID && x.IO_DEVICE_ID == IO_DEVICE_ID && x.GroupId.ToString() == GroupId);
                List <string>    paranames    = selItem.IOPARANAMES.Split(',').ToList();
                List <string>    ioids        = selItem.IOPARAS.Split(',').ToList();
                List <string>    titles       = selItem.IOPARATITLES.Split(',').ToList();
                int              ioIndex      = ioids.FindIndex(x => x.Trim() == IO_ID);
                if (devIndex >= 0 && selItem != null && paranames.Count > 0 && ioids.Count > 0 && ioids.Count == paranames.Count && ioIndex >= 0)
                {
                    string ioName = paranames[ioIndex].Trim();
                    current.Name = titles[ioIndex].Trim();
                    var serie = realResult.ElementAt(devIndex).First();
                    if (serie.Values.Count > 0)
                    {
                        current.Time = serie.Values[0][serie.Columns.IndexOf("time")].ToString();//获取时间
                        int recordindex = serie.Columns.IndexOf("field_" + ioName.Trim().ToLower() + "_value");
                        if (recordindex >= 0)
                        {
                            current.Value = serie.Values[0][recordindex].ToString();
                        }
                    }
                }
            }
            #endregion

            for (int i = 0; i < excelModels.models.Count; i++)
            {
                PropertyInfo[] properties = excelModels.models[i].GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                if (properties.Length <= 0)
                {
                    continue;
                }
                foreach (PropertyInfo item in properties)
                {
                    string name  = item.Name;
                    object value = item.GetValue(excelModels.models[i], null);
                    if (value != null && value.ToString() != "")
                    {
                        if (value.ToString().Split('/').Length >= 8)
                        {
                            try
                            {
                                string           GroupId      = value.ToString().Split('/')[1];
                                string           IO_SERVER_ID = value.ToString().Split('/')[2];
                                string           IO_COMM_ID   = value.ToString().Split('/')[3];
                                string           IO_DEVICE_ID = value.ToString().Split('/')[4];
                                string           IO_ID        = value.ToString().Split('/')[5];
                                string           vtype        = value.ToString().Split('/')[7];
                                string           iostatus     = "异常";
                                string           iotime       = "";
                                string           iovalue      = "";
                                int              devIndex     = devices.FindIndex(x => x.IOServerID == IO_SERVER_ID && x.IOCommunicateID == IO_COMM_ID && x.IODeviceID == IO_DEVICE_ID);
                                DeviceGroupModel selItem      = deviceModels.Find(x => x.IO_SERVER_ID == IO_SERVER_ID && x.IO_COMM_ID == IO_COMM_ID && x.IO_DEVICE_ID == IO_DEVICE_ID && x.GroupId.ToString() == GroupId);
                                List <string>    paranames    = selItem.IOPARANAMES.Split(',').ToList();
                                List <string>    ioids        = selItem.IOPARAS.Split(',').ToList();
                                int              ioIndex      = ioids.FindIndex(x => x.Trim() == IO_ID);
                                if (devIndex >= 0 && selItem != null && paranames.Count > 0 && ioids.Count > 0 && ioids.Count == paranames.Count && ioIndex >= 0)
                                {
                                    string ioName = paranames[ioIndex].Trim();
                                    var    serie  = realResult.ElementAt(devIndex).First();
                                    if (serie.Values.Count > 0)
                                    {
                                        iotime = serie.Values[0][serie.Columns.IndexOf("time")].ToString();//获取时间
                                        int recordindex = serie.Columns.IndexOf("field_" + ioName.Trim().ToLower() + "_value");
                                        if (recordindex >= 0)
                                        {
                                            iostatus = "正常";
                                            iovalue  = serie.Values[0][recordindex].ToString();
                                        }
                                        else
                                        {
                                            iostatus = "异常";
                                        }
                                    }
                                    else
                                    {
                                        iostatus = "异常";
                                    }
                                }
                                else
                                {
                                    iostatus = "异常";
                                }

                                switch (vtype.Trim().ToLower())
                                {
                                case "time":
                                    item.SetValue(excelModels.models[i], iotime);
                                    break;

                                case "value":
                                    item.SetValue(excelModels.models[i], iovalue);
                                    break;

                                case "status":
                                    item.SetValue(excelModels.models[i], iostatus);
                                    break;
                                }
                            }
                            catch
                            {
                                continue;
                            }
                        }
                    }
                }
            }
            var result = Pager.ScadaTablePaging(excelModels.models, current, excelModels.models.Count());
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 return(_comparer(CurrentPoint, input));
Ejemplo n.º 22
0
        /// <summary>
        /// Process the action/choice of the user
        /// </summary>
        /// <param name="Method"></param>
        public void ProcessAction(string CommandMethod)
        {
            try
            {
                switch (CommandMethod)
                {
                case "CommandTerminate":

                    Match.Terminate();

                    break;

                case "CommandEnd":

                    Match.End(TennisMatch.MatchStatus.Terminated);

                    break;

                case "CommandResign":

                    Match.End(TennisMatch.MatchStatus.Resigned);

                    break;

                case "CommandUndo":

                    if (CurrentPoint == null || CurrentPoint.Point.Winner == 0 && CurrentPoint.Point.Serve != TennisPoint.PointServe.SecondServe)
                    {
                        //Undo the last played point if the current point is not present, or if it has not been played yet.
                        Match.Undo();
                    }

                    NewPoint();

                    break;

                case "CommandSwitchServer":

                    Match.SwitchServer();

                    NewPoint();

                    break;

                case "CommandExtend":

                    Match.Extend();

                    NewPoint();

                    break;

                default:

                    CurrentPoint.ProcessAction(CommandMethod);

                    if (CurrentPoint.PossibleActions.Count <= 1)
                    {
                        //no choices to make; start a new point
                        Match.Add(CurrentPoint.Point);

                        NewPoint();
                    }
                    break;
                }

                NotifyPropertyChanged("CurrentPoint");
                NotifyPropertyChanged("Duration");
                NotifyPropertyChanged("IsExtendPossible");
                NotifyPropertyChanged("SetScores");
                NotifyPropertyChanged("ScorePlayer1");
                NotifyPropertyChanged("ScorePlayer2");
                NotifyPropertyChanged("Server");
                NotifyPropertyChanged("InProgress");
                NotifyPropertyChanged("Winner");
                NotifyPropertyChanged("Completed");
                NotifyPropertyChanged("Undo");
                NotifyPropertyChanged("Sets");
                NotifyPropertyChanged("Switch");
                NotifyPropertyChanged("MatchType");
                NotifyPropertyChanged("Status");

                CurrentSetScore.Notify();
                TotalSets.Notify();
                StatisticsCollection.Notify();
            }
            catch (Exception e)
            {
                ExtendedEventArgs eaa = new ExtendedEventArgs();
                eaa.Error = "A fatal error occurred. Please try again or stop this match to preserve the statistics.";
                #if DEBUG
                eaa.Error = String.Format("A fatal error occurred. {1}:{0}", e.Message, e.Source);
                #endif
                OnFatalError(eaa);
            }
        }
Ejemplo n.º 23
0
 private void Go()
 {
     CurrentPoint.GoForward();
     Path.Add(CurrentPoint);
 }
Ejemplo n.º 24
0
 private void TurnLeft()
 {
     CurrentPoint.Left();
 }
Ejemplo n.º 25
0
 private void TurnRight()
 {
     CurrentPoint.Right();
 }
Ejemplo n.º 26
0
        public override MazeGenerationResults Generate()
        {
            var results = new MazeGenerationResults();

            if (!Map.Infinite)
            {
                // TODO: Ending generation sometimes ends prematurely. Find out why and fix.
                if (RemainingPoints.Count == 0)
                {
                    results.ResultsType = GenerationResultsType.GenerationCompleted;
                    return(results);
                }
            }

            if (CurrentPoint == null)
            {
                CurrentPoint = MazeGenerationUtils.PickStartingPoint(Map, RNG);
                var cell = Map.GetCell(CurrentPoint);

                cell.State        = CellState.Empty;
                cell.DisplayState = CellDisplayState.Path;

                results.Add(new MazeGenerationResult(CurrentPoint, cell.State, cell.DisplayState));
                return(results);
            }

            var doLooping = RNG.NextDouble() < Looping;
            var offsets   = CurrentPoint.GetAxisOffsets();

            Point pathToCellPoint = null;
            Point otherCellPoint  = null;

            while (offsets.Count > 0)
            {
                var offsetIndex = RNG.Next(0, offsets.Count);
                var offset      = offsets[offsetIndex];
                pathToCellPoint = CurrentPoint + offset;
                otherCellPoint  = CurrentPoint + offset * 2;
                var cellExists = Map.CellExists(otherCellPoint);
                if (cellExists)
                {
                    break;
                }
                offsets.RemoveAt(offsetIndex);
            }

            var otherCell  = Map.GetCell(otherCellPoint);
            var pathToCell = Map.GetCell(pathToCellPoint);

            if (doLooping || otherCell.State == CellState.Filled)
            {
                otherCell.State  = CellState.Empty;
                pathToCell.State = CellState.Empty;
            }

            RemainingPoints.Remove(otherCellPoint);

            otherCell.DisplayState  = otherCell.State == CellState.Empty ? CellDisplayState.Path : CellDisplayState.Wall;
            pathToCell.DisplayState = pathToCell.State == CellState.Empty ? CellDisplayState.Path : CellDisplayState.Wall;

            var otherResult = new MazeGenerationResult(otherCellPoint, otherCell.State, otherCell.DisplayState);
            var pathResult  = new MazeGenerationResult(pathToCellPoint, pathToCell.State, pathToCell.DisplayState);

            results.Results.Add(otherResult);
            results.Results.Add(pathResult);

            CurrentPoint = otherCellPoint;

            return(results);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 各種状態を更新する
        /// </summary>
        private void UpdateCurrentStatus()
        {
            RaisePropertyChanged("CurrentPoint");
            RaisePropertyChanged("CurrentDirection");
            CurrentMapStatus = _mapInstance.CurrentMapStatus;

#if DEBUG
            RaisePropertyChanged("StartPoint");
            RaisePropertyChanged("GoalPoint");
#endif

            if (_mapInstance.CurrentMap == null)
            {
                return;
            }

            // ゴールまでの直線距離 (壁がある場合は NG とする)
            var pre = -1;
            if (GoalPoint == CurrentPoint)
            {
                pre = 0;
            }
            else if (GoalPoint == CurrentPoint.Offset(0, 1, CurrentDirection))
            {
                pre = 1;
            }
            else
            {
                // 一つ先が道の場合
                if (_mapInstance.CurrentMap.CheckPath(CurrentPoint.Offset(0, 1, CurrentDirection)))
                {
                    // 二つ先がゴールかどうか確認する
                    if (_mapInstance.CurrentMap.GoalPoint == CurrentPoint.Offset(0, 2, CurrentDirection))
                    {
                        pre = 2;
                    }
                }
            }
            PreGoal = pre;

            // ゴールまでの歩数
            LeftStep = System.Math.Abs(CurrentPoint.X - GoalPoint.X)
                       + System.Math.Abs(CurrentPoint.Y - GoalPoint.Y);

            // アイテムまでの距離 (壁がある場合は NG とする)
            pre = -1;
            var pt = CurrentPoint.Offset(0, 1, CurrentDirection);
            if (_mapInstance.CurrentMap.CheckPath(pt))
            {
                foreach (var info in _mapInstance.CurrentMap.ItemData)
                {
                    if (pt == info.Key)
                    {
                        pre = 1;
                        break;
                    }
                }
                if (pre < 0)
                {
                    pt = pt.Offset(0, 1, CurrentDirection);
                    foreach (var info in _mapInstance.CurrentMap.ItemData)
                    {
                        if (pt == info.Key)
                        {
                            pre = 2;
                            break;
                        }
                    }
                }
            }
            PreItem = pre;
        }