Наследование: MonoBehaviour
Пример #1
0
    public override void OnDotSelected(Dot dot)
    {
        if (!string.IsNullOrEmpty(lastCheckedId) && lastCheckedId == dot.Index.ToString())
        {
            return;
        }

        lastCheckedId = dot.Index.ToString();

        if (selectedDots.Count == 0) {
            AddDot (dot);
        }
        else if(selectedDots[0].GetDotType() == dot.GetDotType() && isNeighbor (dot))
        {
            Dot lastDot = selectedDots[selectedDots.Count-1];
            string edge = dot.Index < lastDot.Index ? dot.Index + ":" + lastDot.Index : lastDot.Index + ":" + dot.Index;
            int edgeIndex = selectedEdges.IndexOf(edge);

            if(edgeIndex >= 0)
            {
                if(edgeIndex == selectedEdges.Count-1)
                {
                    UndoLastMove();
                }
                return;
            }

            AddDot (dot, edge);
        }
    }
Пример #2
0
        public float[,] GenerateHeightmap()
        {
            fullCells = 0;
            hmap = new float[size, size];

            // Build heightMap
            for (int x = 0; x < size; x++) {
                for (int y = 0; y < size; y++) {
                    hmap[x, y] = 0f;
                }
            }

            while (maxFC > fullCells) {
                if (fullCells == 0)
                    target = new Dot(size / 2, size / 2);
                else {
                    target = new Dot (rand.Next(0, size - 1), rand.Next (0, size - 1));
                }

                for (int i = 0; i < moleCount; i++) {
                    if (fullCells >= maxFC)
                        break;
                    int power = (fullCells + molePower > maxFC) ? maxFC - fullCells : molePower;
                    Mole (target, power);
                }
            }
            return hmap;
        }
Пример #3
0
    public override Solvability CheckSolvability(Dot[,] board)
    {
        int columns = board.GetLength (0);
        int rows = board.GetLength (1);
        HashSet<string> dotTypeSet = new HashSet<string>();

        for (int i = 0; i<columns; i++)
        {
            for(int j = 0; j < rows; j++)
            {
                Dot dot = board[i,j];
                dotTypeSet.Add(dot.GetDotType());

                if(i+1 < columns && board[i+1,j].GetDotType() == dot.GetDotType())
                {
                    return Solvability.HAS_MOVES;
                }

                if(j+1 < rows && board[i,j+1].GetDotType() == dot.GetDotType())
                {
                    return Solvability.HAS_MOVES;
                }
            }
        }

        if (columns * rows <= dotTypeSet.Count)
        {
            return Solvability.UNSOLVABLE;
        }
        else
        {
            return Solvability.NO_MOVES;
        }
    }
Пример #4
0
 public void SetCurrentDot(Dot current)
 {
     if(currentSelection != null) {
         previousSelection = currentSelection;
     }
     currentSelection = current;
 }
Пример #5
0
 //конструктор класса
 public Relaitions(Dot d1,Dot d2)
 {
     d1.InRelation =true;
     d2.InRelation = true;
     this.d1  = d1;
     this.d2  = d2;
     //Own = (int)OwnerDot;
 }
Пример #6
0
        void Mole(Dot Pl, int Po)
        {
            Dot place = Pl;
            int power = Po;

            while (power > 0) {
                int r = rand.Next (1, 1000);
                int newX;
                int newY;

                if (r < 126) {
                    newX = place.x - 1;
                    newY = place.y - 1;
                }
                else if (r < 251) {
                    newX = place.x - 1;
                    newY = place.y;
                }
                else if (r < 376) {
                    newX = place.x - 1;
                    newY = place.y + 1;
                }
                else if (r < 501) {
                    newX = place.x;
                    newY = place.y + 1;
                }
                else if (r < 626) {
                    newX = place.x + 1;
                    newY = place.y + 1;
                }
                else if (r < 751) {
                    newX = place.x;
                    newY = place.y + 1;
                }
                else if (r < 876) {
                    newX = place.x + 1;
                    newY = place.y - 1;
                }
                else {
                    newX = place.x;
                    newY = place.y - 1;
                }

                if (newX < 0 || newY < 0 || newX > (size - 1) || newY > (size - 1) )
                    continue;
                place = new Dot(newX, newY);
                if (hmap[newX, newY] == 0f) {
                    hmap[newX, newY] = (float)height;
                    power--;
                    fullCells++;
                }
            }
        }
Пример #7
0
 public Dot GetDotByBoardPosition(float x, float y)
 {
     Dot returnDot = new Dot();
     foreach(Dot dot in boardDots) {
         Vector2 pos = new Vector2(x,y);
         if(dot.boardPosition == pos) {
             returnDot = dot;
             break;
         }
     }
     return returnDot;
 }
    public void Init( Texture aTexture , int aiMaxIndex, int iDotSize, float afTimeBetweenMoves)
    {
        texture = aTexture;
        iMaxIndex = aiMaxIndex;

        dotLeft = new Dot();
        dotLeft.vSize = new Vector2(iDotSize,iDotSize);
        dotLeft.vPosition = Vector2.zero;

        dotRight = new Dot();
        dotRight.vSize = new Vector2(iDotSize,iDotSize);
        dotRight.vPosition = Vector2.zero;

        fTimeBetweenMoves = afTimeBetweenMoves;
    }
Пример #9
0
    public void ClearAllDotsOfType(Dot dot)
    {
        bool needsUpdate = false;
        for (int i = 0; i< columns; i++)
        {
            for(int j = 0; j < rows; j++)
            {
                if(dot.GetDotType() == (dots[i,j]).GetDotType())
                {
                    needsUpdate = true;
                    ClearDotAtPos(i,j);
                }
            }
        }

        if (needsUpdate)
        {
            UpdateBoard();
        }
    }
        private static void EnsurePreviewGenerated(Dot dot, Func<ISOMInput, Tuple<UIElement, VectorInt>> getPreview)
        {
            if (dot.Preview != null)
            {
                return;
            }

            var previewRaw = getPreview(dot.Input);

            dot.Preview = new Border()
            {
                BorderBrush = new SolidColorBrush(Color.FromArgb(192, dot.Color.R, dot.Color.G, dot.Color.B)),
                BorderThickness = new Thickness(2),
                CornerRadius = new CornerRadius(2),
                Child = previewRaw.Item1,
            };

            dot.PreviewSize = new VectorInt(previewRaw.Item2.X + 4, previewRaw.Item2.Y + 4);
        }
        private static IEnumerable<Tuple<Dot, Dot, double>> BuildDot_Distances(Dot dot, IEnumerable<Dot> otherDots)
        {
            double mult = .5d / Math.Sqrt(dot.Input.Weights.Length);        // the .5 doesn't mean anything.  It just helps control overall distance

            foreach (Dot other in otherDots)
            {
                double distance = MathND.GetDistance(dot.Input.Weights, other.Input.Weights) * mult;

                yield return Tuple.Create(dot, other, distance);
            }
        }
        public void AddItems(IEnumerable<ISOMInput> items)
        {
            foreach (ISOMInput item in items)
            {
                Point3D position = Math3D.GetRandomVector_Spherical(RADIUS).ToPoint();

                Dot dot = new Dot()
                {
                    IsStatic = false,
                    Input = item,
                    Color = GetDotColor(item),
                    Position = position,
                    Translate_3DDot = new TranslateTransform3D(position.ToVector()),
                };

                dot.Geometry_3DDot = BuildDot_Visual(_modelGroup, _dotGeometry, _dotMaterials, _specular, dot.Color, dot.Translate_3DDot);

                _distances.AddRange(BuildDot_Distances(dot, _dots.Concat(_staticDots)));

                _dots.Add(dot);
            }

            //TODO: Do this in a separate thread.  Don't store the dots and distances in global variables until after this finishes (that's a lot of work though for very little gain)
            MoveDots(_dots, _distances, chk3D.IsChecked.Value, 1500, RADIUS / 10000);

            foreach (Dot dot in _dots)
            {
                dot.Translate_3DDot.OffsetX = dot.Position.X;
                dot.Translate_3DDot.OffsetY = dot.Position.Y;
                dot.Translate_3DDot.OffsetZ = dot.Position.Z;
            }
        }
        private void ShowPreview(Dot dot, Point position)
        {
            if (_getPreview == null)
            {
                return;
            }

            EnsurePreviewGenerated(dot, _getPreview);

            Canvas.SetLeft(dot.Preview, position.X - (dot.PreviewSize.X / 2d));
            Canvas.SetTop(dot.Preview, position.Y - (dot.PreviewSize.Y / 2d));
            canvas.Children.Add(dot.Preview);
        }
Пример #14
0
        private void pbxBoard_MouseClick(object sender, MouseEventArgs e)
        {
            game.MousePos = game.TranslateCoordinates(e.Location);
            Dot dot = new Dot(game.MousePos.X, game.MousePos.Y);
            if (game.MousePos.X > game.startX - 0.5f & game.MousePos.Y > game.startY - 0.5f)
            {
                switch (e.Button)
                {
                    case MouseButtons.Left:

                        #region PatternEditor
                        #if DEBUG
                        if (game.PE_On==true)
                        {
                            if(game.ListPatterns.Contains(game.aDots[dot.x, dot.y])==false)
                            {
                                 game.ListPatterns.Add(game.aDots[dot.x, dot.y]);
                            }
                            if (game.PE_EmptyDot)
                            {
                                if (game.aDots[dot.x, dot.y].PatternsAnyDot) game.aDots[dot.x, dot.y].PatternsAnyDot = false;
                                game.aDots[dot.x, dot.y].PatternsEmptyDot = true;
                            }
                            if (game.PE_FirstDot)
                            {
                                game.aDots[dot.x, dot.y].PatternsFirstDot = true;
                                game.PE_FirstDot = false;
                                pbxBoard.Invalidate();
                                game.PE_MoveDot = true;
                                MessageBox.Show("Ставьте точку хода (ЛКМ), на точку отмеченную как пустую");
                                break;
                            }
                            if (game.PE_MoveDot)
                            {
                                game.aDots[dot.x, dot.y].PatternsMoveDot = true;
                                game.PE_MoveDot = false;
                            }
                            if (game.PE_AnyDot)
                            {
                                if (game.aDots[dot.x, dot.y].PatternsEmptyDot) game.aDots[dot.x, dot.y].PatternsEmptyDot = false;
                                game.aDots[dot.x, dot.y].PatternsAnyDot = true;
                            }

                            break;
                        }
                        #endif
                        #endregion

                        #region Ходы игроков
                        if (game.aDots[game.MousePos.X, game.MousePos.Y].Own > 0) break;//предовращение хода если клик был по занятой точке
                        if (player_move == 2 | player_move == 0)
                        {
                        #if DEBUG
                            if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift | game.Autoplay)
                            {
                                MoveGamer(1, new Dot(game.MousePos.X, game.MousePos.Y, 1));
                                break;
                            }
                        #endif
                            if (MoveGamer(1, new Dot(game.MousePos.X, game.MousePos.Y, 1)) > 0) break;
                            player_move = 1;
                            //Application.DoEvents();
                        }
                        //============Ход компьютера=================
                        if (player_move == 1)
                        {
                            game.Redraw = false;
                            if (MoveGamer(2) > 0) break;
                            //if (MoveGamer(2) > 0) break;
                            game.Redraw=true;
                            player_move = 2;
                        }
                        #endregion
                        break;
                 #if DEBUG //паттерны и пр.
                    case MouseButtons.Right:
                        if (game.PE_On == true)
                        {
                            game.MakePattern();
                            break;
                        }
                        else {
                        //============Ход компьютера  в ручном режиме=================
                        MoveGamer(2, new Dot(dot.x, dot.y, 2));
                        }
                        break;
                    case MouseButtons.Middle:
                        if (game.PE_On == true)
                        {
                            game.ListPatterns.Remove(game.aDots[dot.x, dot.y]);
                            break;
                        }

                            game.ListMoves.Remove(game.aDots[dot.x, dot.y]);
                            game.UndoMove(dot.x, dot.y);
                        break;
                 #endif
                }
            }
            //lstMoves.DataSource = null;
            //lstMoves.DataSource = game.ListMoves;
            //if (lstMoves.Items.Count > 0) lstMoves.SetSelected(lstMoves.Items.Count - 1, true);
            //rtbStat.Text = game.Statistic();
        }
Пример #15
0
        public void Enumerate(List <Item> items)
        {
            if (hasEnumrate)
            {
                EB.Debug.Log("---Apple---Enumerate()");
                foreach (var item in items)
                {
                    item.valid = true;
                }

                if (_config.OnEnumerate != null)
                {
                    _config.OnEnumerate();
                }
            }
            else
            {
                var productIds = ArrayUtils.Map <Item, string>(items, delegate(Item item)
                {
                    return(item.productId);
                });
                var offersString = ArrayUtils.Join(productIds, ',');

                _onEnumerate += delegate(string json)
                {
                    var objects = JSON.Parse(json) as ArrayList;

                    foreach (var item in items)
                    {
                        item.valid = false;
                        foreach (var obj in objects)
                        {
                            if (Dot.String("productIdentifier", obj, string.Empty) == item.productId)
                            {
                                item.valid = true;
                                string   localeIdentifier     = Dot.String("localeIdentifier", obj, string.Empty);
                                string[] localeIdentifierData = localeIdentifier.Split('=');
                                if (localeIdentifierData.Length > 1)
                                {
                                    item.currencyCode = localeIdentifierData[1];
                                }
                                else
                                {
                                    item.currencyCode = string.Empty;
                                }
                                //item.localizedTitle = Dot.String("localizedTitle", obj, string.Empty);
                                //item.localizedDesc = Dot.String("localizedDescription", obj, string.Empty);
                                item.localizedCost = Dot.String("localizedPrice", obj, string.Empty);
                                item.cost          = Dot.Single("price", obj, item.cost);
                                item.cents         = Dot.Integer("cents", obj, (int)item.cost * 100);
                                break;
                            }
                        }
                    }

                    if (_config.OnEnumerate != null)
                    {
                        _config.OnEnumerate();
                    }

                    hasEnumrate = true;
                };
                EB.Debug.Log("---Apple---Enumerate():items.Count:{0},Enumerating IAP: {1}", items.Count, offersString);
                _IAPEnumerate(offersString);
            }
        }
Пример #16
0
 void PenCommV2Callbacks.onReceiveDot(IPenComm sender, Dot dot, ImageProcessingInfo info)
 {
 }
Пример #17
0
 public abstract void OnDotSelected(Dot dot);
Пример #18
0
 public void Visit(Dot dot) => Console.WriteLine($"{nameof(Dot)} area: {0}");
Пример #19
0
 public bool Compare(Dot dot)
 {
     return(Type == dot.Type);
 }
Пример #20
0
    void Awake()
    {
        if (dotsArre == null)
        {
            Debug.Log("ARRE IS NULL");
            DontDestroyOnLoad(gameObject);
            dotsArre = this;

            float windowaspect = (float)Screen.width / (float)Screen.height;
            //float targetaspect = 16.0f / 9.0f;
            dots = new Dot[80];
            Debug.Log("New dot array");
            float unit = windowaspect * 0.6f;
            //GameObject dot1 = Instantiate (Resources.Load("dot"),new Vector2(unit,unit), Quaternion.identity) as GameObject;
            int i = 0;
            for (int h = 0; h < boardSizeH; h++)
            {
                if (h % 2 == 0)
                {
                    float posX = -(((boardSizeW - 1) / 2) * unit);
                    float posY = -(boardSizeH / 2) * (unit) + h * (unit);
                    for (int w = 0; w < boardSizeW - 1; w++)
                    {
                        Vector2    pos    = new Vector2(posX, posY);
                        int        totNei = 6;
                        GameObject dot    = Instantiate(Resources.Load("dot"), pos, Quaternion.identity) as GameObject;
                        Dot        dotScr = dot.GetComponent <Dot>();
                        dot.transform.parent = transform;
                        dots[i] = dotScr;

                        if (h == 0 || h == boardSizeH - 1)
                        {
                            totNei -= 2;
                        }
                        if (w == 0 || w == boardSizeW - 2)
                        {
                            totNei -= 1;
                        }

                        dotScr.Initialize(i, h, w, totNei);
                        posX += unit;
                        i++;
                    }
                }
                else
                {
                    float posX = -((boardSizeW) / 2) * unit + 0.5f;
                    //Debug.Log("!=%2" + posX);
                    float posY = -(boardSizeH / 2) * unit + h * unit;
                    for (int w = 0; w < boardSizeW; w++)
                    {
                        Vector2    pos    = new Vector2(posX, posY);
                        int        totNei = 6;
                        GameObject dot    = Instantiate(Resources.Load("dot"), pos, Quaternion.identity) as GameObject;
                        Dot        dotScr = dot.GetComponent <Dot>();
                        dot.transform.parent = transform;
                        dots[i] = dotScr;

                        if (h == 0 || h == boardSizeH - 1)
                        {
                            totNei -= 2;
                        }
                        if (w == 0 || w == boardSizeW - 1)
                        {
                            totNei -= 3;
                        }
                        dotScr.Initialize(i, h, w, totNei);
                        i++;
                        posX += unit;
                    }
                }
            }
            Debug.Log("OK");
            fillNeighbors();
        }
        else if (dotsArre != this)
        {
            Debug.Log("ARRE NOT NULL");
            Destroy(gameObject);
        }
    }
Пример #21
0
    // Check to which direction the arrangement is made. 0 if none, 1 if upward, 2 if to the right, 3 if downward, 4 if to the left, 5 if vertical middle, 6 if horizontal middle
    public int DotMakeAnArrangement(Dot dot)
    {
        //check dots upward
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 1, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 2, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot up1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 1, dot.associatedGameObject.transform.position.z));
            Dot up2Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 2, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                up1Dot.colorID
                &&
                dot.colorID
                ==
                up2Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots upward!");

                up1Dot.associatedGameObject.SetActive(false);
                up2Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(up1Dot.associatedGameObject.transform.position);
                GenerateDot(up2Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(1);
            }
        }

        //check dots downward
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 1, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 2, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot down1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 1, dot.associatedGameObject.transform.position.z));
            Dot down2Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 2, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                down1Dot.colorID
                &&
                dot.colorID
                ==
                down2Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots downward!");

                down1Dot.associatedGameObject.SetActive(false);
                down2Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(down1Dot.associatedGameObject.transform.position);
                GenerateDot(down2Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(3);
            }
        }

        //check dots to the left
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 2, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot left1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));
            Dot left2Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 2, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                left1Dot.colorID
                &&
                dot.colorID
                ==
                left2Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots to the left!");

                left1Dot.associatedGameObject.SetActive(false);
                left2Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(left1Dot.associatedGameObject.transform.position);
                GenerateDot(left2Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(4);
            }
        }

        //check dots to the right
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 2, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot right1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));
            Dot right2Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 2, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                right1Dot.colorID
                &&
                dot.colorID
                ==
                right2Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots to the right!");

                right1Dot.associatedGameObject.SetActive(false);
                right2Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(right1Dot.associatedGameObject.transform.position);
                GenerateDot(right2Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(2);
            }
        }

        //check dots middle horizontal
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot right1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x + 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));
            Dot left1Dot  = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x - 1, dot.associatedGameObject.transform.position.y, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                right1Dot.colorID
                &&
                dot.colorID
                ==
                left1Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots middle horizontal!");

                right1Dot.associatedGameObject.SetActive(false);
                left1Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(right1Dot.associatedGameObject.transform.position);
                GenerateDot(left1Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(6);
            }
        }

        //check dots middle vertical
        if (
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 1, dot.associatedGameObject.transform.position.z))
            &&
            IsDotExistOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 1, dot.associatedGameObject.transform.position.z))
            )
        {
            Dot up1Dot   = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y + 1, dot.associatedGameObject.transform.position.z));
            Dot down1Dot = DotOnPosition(new Vector3(dot.associatedGameObject.transform.position.x, dot.associatedGameObject.transform.position.y - 1, dot.associatedGameObject.transform.position.z));

            if (dot.colorID
                ==
                up1Dot.colorID
                &&
                dot.colorID
                ==
                down1Dot.colorID
                )
            {
                Debug.Log("Make an arrangement of dots middle vertical!");

                up1Dot.associatedGameObject.SetActive(false);
                down1Dot.associatedGameObject.SetActive(false);
                dot.associatedGameObject.SetActive(false);

                //generate a new dot
                GenerateDot(up1Dot.associatedGameObject.transform.position);
                GenerateDot(down1Dot.associatedGameObject.transform.position);
                GenerateDot(dot.associatedGameObject.transform.position);

                return(5);
            }
        }

        return(0);
    }
Пример #22
0
 // Step 7. Get Dot(Pen to App)
 void PenSignal.onReceiveDot(Dot dot)
 {
     processDot(dot);
 }
Пример #23
0
    //initialise stat, call when tower is first built
    private void InitStat()
    {
        //level=1;
        cooldown=baseStat.cooldown;

        range=baseStat.range;

        if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower || type==_TowerType.Mine){
            damage=baseStat.damage;

            clipSize=baseStat.clipSize;
            currentClip=clipSize;
            if(currentClip<=0) currentClip=-1;
            reloadDuration=baseStat.reloadDuration;
            aoeRadius=baseStat.aoeRadius;
            stunDuration=baseStat.stunDuration;
            slow=baseStat.slow;
            dot=baseStat.dot;
        }
        else if(type==_TowerType.SupportTower){
            buff=baseStat.buff;
        }
        else if(type==_TowerType.ResourceTower){
            incomes=baseStat.incomes;
        }

        if(baseStat.shootObject!=null){
            shootObject=baseStat.shootObject.gameObject;
        }
        else{
            if(type==_TowerType.TurretTower){
                GameObject tempObj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                tempObj.AddComponent<ShootObject>();
                tempObj.active=false;

                shootObject=tempObj;
            }
        }

        if(baseStat.turretObject!=null){
            turretObject=baseStat.turretObject;
        }
        if(baseStat.barrelObject!=null){
            barrelObject=baseStat.barrelObject;
        }

        //since this is initialization, update shootpoint regardless of if there's a turretObject
        UpdateShootPoint();

        if(baseStat.baseObject!=null){
            baseObject=baseStat.baseObject;
        }

        UpdateTowerValue();
    }
Пример #24
0
    private MatchType ColumnOrRow()
    {
        //make a copy of current matches
        List <GameObject> matchCopy = findMatches.currentMatches as List <GameObject>;

        matchType.type  = 0;
        matchType.color = "";
        //Cycle through all of match copy and decide if a bomb needs to be made
        for (int i = 0; i < matchCopy.Count; i++)
        {
            //Store this dot
            Dot    thisDot     = matchCopy[i].GetComponent <Dot>();
            string color       = matchCopy[i].tag;
            int    column      = thisDot.column;
            int    row         = thisDot.row;
            int    columnMatch = 0;
            int    rowMatch    = 0;
            //Cycle through the rest of the pieces and compare
            for (int j = 0; j < matchCopy.Count; j++)
            {
                //Store the next dot
                Dot nextDot = matchCopy[j].GetComponent <Dot>();
                if (nextDot == thisDot)
                {
                    continue;
                }
                if (nextDot.column == thisDot.column && nextDot.tag == color)
                {
                    columnMatch++;
                }
                if (nextDot.row == thisDot.row && nextDot.tag == color)
                {
                    rowMatch++;
                }
            }

            //Return 3 if color or row
            //Return 2 if adjacent
            //Return 1 if color bomb
            if (columnMatch == 4 || rowMatch == 4)
            {
                matchType.type  = 1;
                matchType.color = color;
                return(matchType);
            }
            else if (columnMatch == 2 && rowMatch == 2)
            {
                matchType.type  = 2;
                matchType.color = color;
                return(matchType);
            }
            else if (columnMatch == 3 || rowMatch == 3)
            {
                matchType.type  = 3;
                matchType.color = color;
                return(matchType);
            }
        }

        matchType.type  = 0;
        matchType.color = "";
        return(matchType);        /*
                                   * int numberHorizontal = 0;
                                   * int numberVertical = 0;
                                   * Dot firstPice = findMatches.currentMatches[0].GetComponent<Dot>();
                                   *
                                   * if (firstPice != null)
                                   * {
                                   * foreach (GameObject currentPice in findMatches.currentMatches)
                                   * {
                                   * Dot dot = currentPice.GetComponent<Dot>();
                                   * if (dot.row == firstPice.row)
                                   * {
                                   * numberHorizontal++;
                                   *
                                   * }
                                   * if (dot.column == firstPice.column)
                                   * {
                                   * numberVertical++;
                                   *
                                   * }
                                   * }
                                   * }
                                   *
                                   * return (numberVertical == 5 || numberHorizontal == 5);
                                   */
    }
Пример #25
0
    public Dot Clone()
    {
        Dot clone=new Dot();
        clone.damage=damage;
        clone.duration=duration;
        clone.interval=interval;

        return clone;
    }
Пример #26
0
 public async Task GrowAnimation()
 {
     await Dot.ScaleTo(1.0, 50);
 }
Пример #27
0
 private IEnumerator DotRoutine(Dot dot, int dmgType)
 {
     float timeStart=Time.time;
     while(Time.time-timeStart<dot.duration){
         ApplyDamage(dot.damage, dmgType);
         yield return new WaitForSeconds(dot.interval);
     }
 }
Пример #28
0
    private void UpgradeStat()
    {
        int levelM=level-1;

        if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower){
            damage=upgradeStat[levelM].damage;
            cooldown=upgradeStat[levelM].cooldown;
            clipSize=upgradeStat[levelM].clipSize;
            currentClip=clipSize;
            if(currentClip<=0) currentClip=-1;
            reloadDuration=upgradeStat[levelM].reloadDuration;
            range=upgradeStat[levelM].range;
            minRange=upgradeStat[levelM].minRange;
            aoeRadius=upgradeStat[levelM].aoeRadius;
            stunDuration=upgradeStat[levelM].stunDuration;
            slow=upgradeStat[levelM].slow;
            dot=upgradeStat[levelM].dot;
        }
        else if(type==_TowerType.SupportTower){
            buff=upgradeStat[levelM].buff;
            buff.buffID=towerID;
        }
        else if(type==_TowerType.ResourceTower){
            incomes=upgradeStat[levelM].incomes;
            cooldown=upgradeStat[levelM].cooldown;
        }

        if(upgradeStat[levelM].shootObject!=null)
            shootObject=upgradeStat[levelM].shootObject.gameObject;

        if(upgradeStat[levelM].turretObject!=null){

            if(turretObject.childCount>0) turretObject.gameObject.SetActiveRecursively(false);
            else turretObject.gameObject.active=false;

            Transform turretTemp=(Transform)Instantiate(upgradeStat[levelM].turretObject);
            turretTemp.position=turretObject.position;
            turretTemp.rotation=turretObject.rotation;
            turretTemp.parent=thisT;
            turretObject=turretTemp;
            //turretObject=upgradeStat[levelM].turretObject;

            UpdateShootPoint();

            Animation tempAni=null;
            //search for turret build animation component
            //if there's a build animation clip
            //~ if(upgradeStat[levelM].turretBuildAnimation!=null){
                //~ //if not on the baseObject itself
                //~ if(upgradeStat[levelM].turretBuildAnimationBody.gameObject!=upgradeStat[levelM].turretObject){
                    //~ foreach(Transform child in turretObject.transform){
                        //~ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation));
                        //~ if(tempAni!=null){
                            //~ if(tempAni.gameObject.name==upgradeStat[levelM].turretBuildAnimationBody.gameObject.name){
                                //~ turretBuildAnimationBody=tempAni;
                            //~ }
                        //~ }
                    //~ }
                //~ }
                //~ else{
                    //~ tempAni=(Animation)turretObject.GetComponent(typeof(Animation));
                    //~ if(tempAni!=null) turretBuildAnimationBody=tempAni;
                //~ }

                //~ //if there's an animation component, assign the animation clip
                //~ if(tempAni!=null){
                    //~ turretBuildAnimation=upgradeStat[levelM].turretBuildAnimation;
                    //~ turretBuildAnimationBody.AddClip(turretBuildAnimation, turretBuildAnimation.name);
                //~ }
            //~ }

            tempAni=null;
            //search for turret build animation component
            //if there's a build animation clip
            if(upgradeStat[levelM].turretFireAnimation!=null){
                //if not on the baseObject itself
                if(upgradeStat[levelM].turretFireAnimationBody.gameObject!=upgradeStat[levelM].turretObject){
                    foreach(Transform child in turretObject.transform){
                        tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation));
                        if(tempAni!=null){
                            if(tempAni.gameObject.name==upgradeStat[levelM].turretFireAnimationBody.gameObject.name){
                                turretFireAnimationBody=tempAni;
                            }
                        }
                    }
                }
                else{
                    tempAni=(Animation)turretObject.GetComponent(typeof(Animation));
                    if(tempAni!=null) turretFireAnimationBody=tempAni;
                }

                //if there's an animation component, assign the animation clip
                if(tempAni!=null){
                    turretFireAnimation=upgradeStat[levelM].turretFireAnimation;
                    turretFireAnimationBody.AddClip(turretFireAnimation, turretFireAnimation.name);
                }
            }
        }
        if(upgradeStat[levelM].barrelObject!=null){
            barrelObject=upgradeStat[levelM].barrelObject;
        }

        if(upgradeStat[levelM].baseObject!=null){

            if(baseObject.childCount>0) baseObject.gameObject.SetActiveRecursively(false);
            else baseObject.gameObject.active=false;

            Transform baseTemp=(Transform)Instantiate(upgradeStat[levelM].baseObject);
            baseTemp.position=baseObject.position;
            baseTemp.rotation=baseObject.rotation;
            baseTemp.parent=thisT;
            baseObject=baseTemp;

            //baseObject=upgradeStat[levelM].baseObject;

            Animation tempAni=null;
            //search for base animation component
            //if there's a build animation clip
            //~ if(upgradeStat[levelM].baseBuildAnimation!=null){
                //~ //if not on the baseObject itself
                //~ if(upgradeStat[levelM].baseBuildAnimationBody.gameObject!=upgradeStat[levelM].baseObject){
                    //~ foreach(Transform child in baseObject.transform){
                        //~ tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation));
                        //~ if(tempAni!=null){
                            //~ if(tempAni.gameObject.name==upgradeStat[levelM].baseBuildAnimationBody.gameObject.name){
                                //~ baseBuildAnimationBody=tempAni;
                            //~ }
                        //~ }
                    //~ }
                //~ }
                //~ else{
                    //~ tempAni=(Animation)baseObject.GetComponent(typeof(Animation));
                    //~ if(tempAni!=null) baseBuildAnimationBody=tempAni;
                //~ }

                //~ if(tempAni!=null){
                    //~ baseBuildAnimation=upgradeStat[levelM].baseBuildAnimation;
                    //~ baseBuildAnimationBody.AddClip(baseBuildAnimation, baseBuildAnimation.name);
                //~ }
            //~ }

            tempAni=null;
            //search for base animation component
            //if there's a build animation clip
            if(upgradeStat[levelM].baseFireAnimation!=null){
                //if not on the baseObject itself
                if(upgradeStat[levelM].baseFireAnimationBody.gameObject!=upgradeStat[levelM].baseObject){
                    foreach(Transform child in baseObject.transform){
                        tempAni=(Animation)child.gameObject.GetComponent(typeof(Animation));
                        if(tempAni!=null){
                            if(tempAni.gameObject.name==upgradeStat[levelM].baseFireAnimationBody.gameObject.name){
                                baseFireAnimationBody=tempAni;
                            }
                        }
                    }
                }
                else{
                    tempAni=(Animation)baseObject.GetComponent(typeof(Animation));
                    if(tempAni!=null) baseFireAnimationBody=tempAni;
                }

                if(tempAni!=null){
                    baseFireAnimation=upgradeStat[levelM].baseFireAnimation;
                    baseFireAnimationBody.AddClip(baseFireAnimation, baseFireAnimation.name);
                }
            }
        }

        //~ if(upgradeStat[levelM].turretBuildAnimationBody!=null) turretBuildAnimationBody=upgradeStat[levelM].turretBuildAnimationBody;
        //~ if(upgradeStat[levelM].turretBuildAnimation!=null) turretBuildAnimation=upgradeStat[levelM].turretBuildAnimation;
        //~ if(upgradeStat[levelM].baseBuildAnimationBody!=null) baseBuildAnimationBody=upgradeStat[levelM].baseBuildAnimationBody;
        //~ if(upgradeStat[levelM].baseBuildAnimation!=null) baseBuildAnimation=upgradeStat[levelM].baseBuildAnimation;

        //~ if(upgradeStat[levelM].turretFireAnimationBody!=null) turretFireAnimationBody=upgradeStat[levelM].turretFireAnimationBody;
        //~ if(upgradeStat[levelM].turretFireAnimation!=null) turretFireAnimation=upgradeStat[levelM].turretFireAnimation;
        //~ if(upgradeStat[levelM].baseFireAnimationBody!=null) baseFireAnimationBody=upgradeStat[levelM].baseFireAnimationBody;
        //~ if(upgradeStat[levelM].baseFireAnimation!=null) baseFireAnimation=upgradeStat[levelM].baseFireAnimation;

        //~ if(turretBuildAnimationBody!=null && turretBuildAnimation!=null) turretBuildAnimationBody.AddClip(turretBuildAnimation, turretBuildAnimation.name);
        //~ if(baseBuildAnimationBody!=null && baseBuildAnimation!=null) baseBuildAnimationBody.AddClip(baseBuildAnimation, baseBuildAnimation.name);
        //~ if(turretFireAnimationBody!=null && turretFireAnimation!=null) turretFireAnimationBody.AddClip(turretFireAnimation, turretFireAnimation.name);
        //~ if(baseFireAnimationBody!=null && baseFireAnimation!=null) baseFireAnimationBody.AddClip(baseFireAnimation, baseFireAnimation.name);

        level+=1;

        UpdateTowerValue();
        GameControl.TowerUpgradeComplete(this);
    }
Пример #29
0
 public static bool CheckNeighbors(Dot c1, Dot c2)
 {
     return((c1.Column == c2.Column || c1.Row == c2.Row) && Mathf.Abs(c1.Column - c2.Column) <= 1 &&
            Mathf.Abs(c1.Row - c2.Row) <= 1);
 }
Пример #30
0
 public void OnDotTouched(Dot dot)
 {
     //Debug.Log("new dot touched : " + dot.name);
     BoardController.Instance.UpdateDotSelection(dot, currentDotPath);
 }
Пример #31
0
        public void SelectConstruct(ConstructType type)
        {
            switch (type)
            {
            case ConstructType.ParallelLine:
                if (_selectedShapes.Count == 2)
                {
                    if (_selectedShapes[0] is LineLike && _selectedShapes[1] is Dot ||
                        _selectedShapes[0] is Dot && _selectedShapes[1] is LineLike)
                    {
                        var line = _selectedShapes[0] as LineLike ?? _selectedShapes[1] as LineLike;
                        var dot  = _selectedShapes[0] as Dot ?? _selectedShapes[1] as Dot;
                        _shapes.Add(Line.ParallelLine(line, dot));
                    }
                }
                break;

            case ConstructType.PerpendicularLine:
                if (_selectedShapes.Count == 2)
                {
                    if (_selectedShapes[0] is LineLike && _selectedShapes[1] is Dot ||
                        _selectedShapes[0] is Dot && _selectedShapes[1] is LineLike)
                    {
                        var line = _selectedShapes[0] as LineLike ?? _selectedShapes[1] as LineLike;
                        var dot  = _selectedShapes[0] as Dot ?? _selectedShapes[1] as Dot;
                        _shapes.Add(Line.PerpendicularLine(line, dot));
                    }
                }
                break;

            case ConstructType.Tangent:
                if (_selectedShapes.Count == 2)
                {
                    if (_selectedShapes[0] is Circle && _selectedShapes[1] is Dot ||
                        _selectedShapes[0] is Dot && _selectedShapes[1] is Circle)
                    {
                        var cir = _selectedShapes[0] as Circle ?? _selectedShapes[1] as Circle;
                        var dot = _selectedShapes[0] as Dot ?? _selectedShapes[1] as Dot;
                        _shapes.Add(Line.TangentLine(cir, dot));
                    }
                    else if (_selectedShapes[0] is Ellipse && _selectedShapes[1] is Dot ||
                             _selectedShapes[0] is Dot && _selectedShapes[1] is Ellipse)
                    {
                        var elp = _selectedShapes[0] as Ellipse ?? _selectedShapes[1] as Ellipse;
                        var dot = _selectedShapes[0] as Dot ?? _selectedShapes[1] as Dot;
                        _shapes.Add(Line.TangentLine(elp, dot));
                    }
                }
                break;

            case ConstructType.Reflection:    // 첫 선택이 대칭축, 두번째 선택이 대칭시킬 도형
                if (_selectedShapes.Count == 2)
                {
                    if (_selectedShapes[0] is LineLike)
                    {
                        var axis = _selectedShapes[0] as LineLike;

                        if (_selectedShapes[1] is Ellipse)
                        {
                            _shapes.Add(Ellipse.FromReflection(axis, _selectedShapes[1] as Ellipse));
                        }
                        else if (_selectedShapes[1] is Circle)
                        {
                            _shapes.Add(Circle.FromReflection(axis, _selectedShapes[1] as Circle));
                        }
                        else if (_selectedShapes[1] is Line)
                        {
                            _shapes.Add(Line.FromReflection(axis, _selectedShapes[1] as Line));
                        }
                        else if (_selectedShapes[1] is Vector)
                        {
                            _shapes.Add(Vector.FromReflection(axis, _selectedShapes[1] as Vector));
                        }
                        else if (_selectedShapes[1] is Segment)
                        {
                            _shapes.Add(Segment.FromReflection(axis, _selectedShapes[1] as Segment));
                        }
                        else
                        {
                            _shapes.Add(Dot.FromReflection(axis, _selectedShapes[1] as Dot));
                        }
                    }
                }
                break;

            case ConstructType.Ellipse:
            {
                if (_selectedShapes.Count == 3)
                {
                    var f1  = _selectedShapes[0] as Dot;
                    var f2  = _selectedShapes[1] as Dot;
                    var pin = _selectedShapes[2] as Dot;
                    if (f1 == null)
                    {
                        return;
                    }
                    if (f2 == null)
                    {
                        return;
                    }
                    if (pin == null)
                    {
                        return;
                    }
                    AddShape(Ellipse.FromThreeDots(f1, f2, pin));
                }
                break;
            }
            }
        }
Пример #32
0
 private void AnimateMove(Dot dot)
 {
     AnimateX(dot);
     AnimateY(dot);
 }
Пример #33
0
 void PenCommV2Callbacks.onErrorDetected(IPenComm sender, ErrorType errorType, long timestamp, Dot dot, string extraData, ImageProcessErrorInfo imageProcessErrorInfo)
 {
 }
Пример #34
0
 public void AddDot(Dot dot)
 {
     service.Dots.Add(dot);
     service.SaveChanges();
 }
Пример #35
0
    private void CheckToMakeBomb()
    {
        //How many objects are in findMatches currentMatches?
        if (findMatches.currentMatches.Count > 3)
        {
            //What type of match?
            MatchType typeOfMatch = ColumnOrRow();
            if (typeOfMatch.type == 1)
            {
                //make a color bomb
                //is the current dot match?
                if (currentDot != null && currentDot.isMatched && currentDot.tag == typeOfMatch.color)
                {
                    currentDot.isMatched = false;
                    currentDot.MakeColorBomb();
                }

                else
                {
                    if (currentDot.otherDot != null)
                    {
                        Dot otherDot = currentDot.otherDot.GetComponent <Dot>();
                        if (otherDot.isMatched && otherDot.tag == typeOfMatch.color)
                        {
                            otherDot.isMatched = false;
                            otherDot.MakeColorBomb();
                        }
                    }
                }
            }
            else if (typeOfMatch.type == 2)
            {
                //make a adjacent bomb

                if (currentDot != null && currentDot.isMatched && currentDot.tag == typeOfMatch.color)
                {
                    currentDot.isMatched = false;
                    currentDot.MakeAdjacentBomb();
                }
                else
                {
                    if (currentDot.otherDot != null)
                    {
                        Dot otherDot = currentDot.otherDot.GetComponent <Dot>();
                        if (otherDot.isMatched && otherDot.tag == typeOfMatch.color)
                        {
                            otherDot.isMatched = false;
                            otherDot.MakeAdjacentBomb();
                        }
                    }
                }
            }
            else if (typeOfMatch.type == 3)
            {
                findMatches.CheckBombs(typeOfMatch);
            }
        }

        /*
         * if (findMatches.currentMatches.Count ==4)
         * {
         *  findMatches.CheckBombs();
         * }
         * if (findMatches.currentMatches.Count >= 5)
         * //if (findMatches.currentMatches.Count == 5 || findMatches.currentMatches.Count == 8)
         * {
         *  if (ColumnOrRow())
         *  {
         *      //make a color bomb
         *      //is the current dot match?
         *      if (currentDot != null)
         *      {
         *          if (currentDot.isMatched)
         *          {
         *              if (!currentDot.isColorBomb)
         *              {
         *                  currentDot.isMatched = false;
         *                  currentDot.MakeColorBomb();
         *              }
         *          }
         *          else
         *          {
         *              if (currentDot.otherDot != null)
         *              {
         *                  Dot otherDot = currentDot.otherDot.GetComponent<Dot>();
         *                  if (otherDot.isMatched)
         *                  {
         *                      if (!otherDot.isColorBomb)
         *                      {
         *                          otherDot.isMatched = false;
         *                          otherDot.MakeColorBomb();
         *                      }
         *                  }
         *              }
         *          }
         *      }
         *
         *  }
         *  else
         *  {
         *      //make a adjacent bomb
         *
         *      if (currentDot != null)
         *      {
         *          if (currentDot.isMatched)
         *          {
         *              if (!currentDot.isAdjacentBomb)
         *              {
         *                  currentDot.isMatched = false;
         *                  currentDot.MakeAdjacentBomb();
         *              }
         *          }
         *          else
         *          {
         *              if (currentDot.otherDot != null)
         *              {
         *                  Dot otherDot = currentDot.otherDot.GetComponent<Dot>();
         *                  if (otherDot.isMatched)
         *                  {
         *                      if (!otherDot.isAdjacentBomb)
         *                      {
         *                          otherDot.isMatched = false;
         *                          otherDot.MakeAdjacentBomb();
         *                      }
         *                  }
         *              }
         *          }
         *      }
         *  }
         *
         * }
         */
    }
Пример #36
0
 public void UpdateDot(Dot dot)
 {
     service.Dots.Update(dot);
     service.SaveChanges();
 }
Пример #37
0
 public async Task ShrinkAnimation()
 {
     await Dot.ScaleTo(0, 50);
 }
Пример #38
0
 public VectorDot2(Dot dotBegin, Dot dotEnd)
 {
     this.dotBegin = dotBegin;
     this.dotEnd   = dotEnd;
 }
        /// <summary>
        /// This is used to help make the movable items stay aligned to a global scene
        /// </summary>
        /// <remarks>
        /// If you save a SOM result view, and this control shows the contents of a single node, then these
        /// static points would be the surrounding nodes.  This way, individual items in this control will
        /// align with their neighbors
        /// </remarks>
        public void AddStaticItems(IEnumerable<Tuple<ISOMInput, Point3D>> items)
        {
            MeshGeometry3D bigGeometry = null, smallGeometry = null;
            if (_showStaticDots)
            {
                bigGeometry = UtilityWPF.GetSphere_Ico(DOTRADIUS * 2, 1, true);
                //smallGeometry = UtilityWPF.GetSphere_Ico(DOTRADIUS * .3, 1, true);
            }

            foreach (var item in items)
            {
                Dot dot = new Dot()
                {
                    IsStatic = true,
                    Input = item.Item1,
                    Position = item.Item2,

                    Color = GetDotColor(item.Item1),
                    Translate_3DDot = new TranslateTransform3D(item.Item2.ToVector()),
                };

                if (_showStaticDots)
                {
                    dot.Geometry_3DDot = BuildDot_Visual(_modelGroup, bigGeometry, _dotMaterials, _specular, dot.Color, dot.Translate_3DDot);
                }

                _staticDots.Add(dot);

                _distances.AddRange(BuildDot_Distances(dot, _dots));
            }

            //if (_showStaticDots)
            //{
            //    Point3D center = Math3D.GetCenter(items.Select(o => o.Item2));
            //    BuildDot_Visual(_modelGroup, smallGeometry, _dotMaterials, _specular, Colors.White, new TranslateTransform3D(center.ToVector()));
            //}
        }
Пример #40
0
 public void Set(Dot dotBegin, Dot dotEnd)
 {
     this.dotBegin = dotBegin;
     this.dotEnd   = dotEnd;
 }
        private void grdViewPort_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                if (_getPreview == null)
                {
                    return;
                }

                var hitResult = GetMouseOver(e);
                Dot dot = hitResult.Item1;

                //NOTE: This mousemove event will fire again if the region the mouse is over gets invalidated, so this if statement stops that
                if (dot != null && _mouseOver != null && dot.Token == _mouseOver.Token)
                {
                    return;
                }

                _mouseOver = dot;

                canvas.Children.Clear();

                if (dot == null)
                {
                    return;
                }

                // Find dots near this one
                var nearby = GetNearbyDots(dot, _dots, RADIUS / 3d);

                Point center = new Point(canvas.ActualWidth / 2, canvas.ActualHeight / 2);

                // Put the mouse over image in the center
                ShowPreview(dot, center);

                // Lay out the other ones out
                if (nearby.Length > 0)
                {
                    ShowNearbyPreviews(nearby, dot, hitResult.Item2, center);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), TITLE, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #42
0
 public Segment(Dot dot1, Dot dot2)
 {
     this.dot1 = dot1;
     this.dot2 = dot2;
 }
        private void ShowNearbyPreviews(Dot[] nearby, Dot dot, RayHitTestParameters cameraRay, Point center2D)
        {
            #region previews, sizes

            int dotMinSize = Math.Min(dot.PreviewSize.X, dot.PreviewSize.Y);
            int minSize = dotMinSize;

            foreach (Dot nearDot in nearby)
            {
                EnsurePreviewGenerated(nearDot, _getPreview);

                minSize = Math1D.Min(minSize, nearDot.PreviewSize.X, nearDot.PreviewSize.Y);
            }

            double halfMin = minSize / 2d;
            double stepDist = halfMin * .05;

            #endregion

            #region project plane

            // Get a plane that is perpendicular to the look ray
            ITriangle plane = Math3D.GetPlane(dot.Position, cameraRay.Direction);

            // Project the points onto that plane
            var nearbyOnPlane = nearby.
                Select(o => new { Dot = o, PlanePoint = Math3D.GetClosestPoint_Plane_Point(plane, o.Position) }).
                ToArray();

            RotateTransform3D rotate = new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRotation(new DoubleVector(cameraRay.Direction, _camera.UpDirection), new DoubleVector(new Vector3D(0, 0, -1), new Vector3D(0, 1, 0)))));

            #endregion

            // Lay these previews down along the directions of the projected points
            // nearby is sorted by distance from the center image

            // Don't start counter at a distance of zero, that's just wasted steps.  Figure out what cntr to use that is the distance of the two images touching
            int startIncrement = Convert.ToInt32(Math.Floor(((dotMinSize / 2d) + halfMin) / stepDist));

            // Remember the locations of each image rect
            List<Rect> existing = new List<Rect>();
            existing.Add(new Rect(center2D.X - (dot.PreviewSize.X / 2d), center2D.Y - (dot.PreviewSize.Y / 2d), dot.PreviewSize.X, dot.PreviewSize.Y));

            foreach (var nextDot in nearbyOnPlane)
            {
                #region project dot plane

                // Get the 2D direction this sketch is from the main
                Vector direction = rotate.Transform(nextDot.PlanePoint - dot.Position).ToVector2D();

                Vector dirUnit = direction.ToUnit();
                if (Math2D.IsInvalid(dirUnit))
                {
                    dirUnit = Math3D.GetRandomVector_Circular_Shell(1).ToVector2D();        // sitting on top of each other, just push it in a random direction
                }
                dirUnit = new Vector(dirUnit.X, -dirUnit.Y);

                #endregion

                #region find clear space

                Point point = new Point();
                Rect rect = new Rect();
                double halfX = nextDot.Dot.PreviewSize.X / 2d;
                double halfY = nextDot.Dot.PreviewSize.Y / 2d;

                // Keep walking along that direction until the rectangle doesn't intersect any existing sketches
                for (int cntr = startIncrement; cntr < 1000; cntr++)
                {
                    point = center2D + (dirUnit * (stepDist * cntr));
                    rect = new Rect(point.X - halfX, point.Y - halfY, nextDot.Dot.PreviewSize.X, nextDot.Dot.PreviewSize.Y);

                    if (!existing.Any(o => o.IntersectsWith(rect)))
                    {
                        break;
                    }
                }

                existing.Add(rect);

                #endregion

                ShowPreview(nextDot.Dot, point);
            }
        }
Пример #44
0
 public void Set(Dot dot1, Dot dot2)
 {
     this.dot1 = dot1;
     this.dot2 = dot2;
 }
        private static Dot[] GetNearbyDots(Dot dot, IEnumerable<Dot> all, double radius)
        {
            double radiusSquared = radius * radius;

            return all.
                Where(o => o.Token != dot.Token).
                Select(o => new { Dot = o, DistSquared = (o.Position - dot.Position).LengthSquared }).
                Where(o => o.DistSquared <= radiusSquared).
                OrderBy(o => o.DistSquared).
                Select(o => o.Dot).
                ToArray();
        }
Пример #46
0
 public VectorDot1(Dot dotEnd)
 {
     this.dotEnd = dotEnd;
 }
Пример #47
0
 public void Visit(Dot dot)
 {
     dot.Left.Accept(this);
     _sb.AppendFormat(".{0}", dot.Right);
 }
Пример #48
0
 public void Set(Dot dotEnd)
 {
     this.dotEnd = dotEnd;
 }
Пример #49
0
    private void UpgradeStat()
    {
        int levelM=level-1;

        if(type==_TowerType.TurretTower || type==_TowerType.DirectionalAOETower || type==_TowerType.AOETower){
            damage=upgradeStat[levelM].damage;
            cooldown=upgradeStat[levelM].cooldown;
            clipSize=upgradeStat[levelM].clipSize;
            currentClip=clipSize;
            if(currentClip<=0) currentClip=-1;
            reloadDuration=upgradeStat[levelM].reloadDuration;
            range=upgradeStat[levelM].range;
            minRange=upgradeStat[levelM].minRange;
            aoeRadius=upgradeStat[levelM].aoeRadius;
            stunDuration=upgradeStat[levelM].stunDuration;
            slow=upgradeStat[levelM].slow;
            dot=upgradeStat[levelM].dot;
        }
        else if(type==_TowerType.SupportTower){
            buff=upgradeStat[levelM].buff;
            buff.buffID=towerID;
        }
        else if(type==_TowerType.ResourceTower){
            incomes=upgradeStat[levelM].incomes;
            cooldown=upgradeStat[levelM].cooldown;
        }

        if(upgradeStat[levelM].shootObject!=null)
            shootObject=upgradeStat[levelM].shootObject.gameObject;

        if(upgradeStat[levelM].turretObject!=null){

            if(turretObject.childCount>0) turretObject.gameObject.SetActiveRecursively(false);
            else turretObject.gameObject.active=false;

            Transform turretTemp=(Transform)Instantiate(upgradeStat[levelM].turretObject);
            turretTemp.position=turretObject.position;
            turretTemp.rotation=turretObject.rotation;
            turretTemp.parent=thisT;
            turretObject=turretTemp;
            //turretObject=upgradeStat[levelM].turretObject;

            UpdateShootPoint();
        }
        if(upgradeStat[levelM].barrelObject!=null){
            barrelObject=upgradeStat[levelM].barrelObject;
        }

        if(upgradeStat[levelM].baseObject!=null){

            if(baseObject.childCount>0) baseObject.gameObject.SetActiveRecursively(false);
            else baseObject.gameObject.active=false;

            Transform baseTemp=(Transform)Instantiate(upgradeStat[levelM].baseObject);
            baseTemp.position=baseObject.position;
            baseTemp.rotation=baseObject.rotation;
            baseTemp.parent=thisT;
            baseObject=baseTemp;

            //baseObject=upgradeStat[levelM].baseObject;
        }

        level+=1;

        UpdateTowerValue();
        GameControl.TowerUpgradeComplete(this);
    }
Пример #50
0
    public void Move(Dot dot)
    {
        var dotTransform = dot.GetComponent <RectTransform>();

        Move(dotTransform.localPosition.x, dotTransform.localPosition.y);
    }
Пример #51
0
 public abstract Solvability CheckSolvability(Dot[,] board);
Пример #52
0
        static private Dictionary <string, List <Unit> > GenMorseDictionary()
        {
            Dot  dot  = new Dot();
            Dash dash = new Dash();

            return(new Dictionary <string, List <Unit> >()
            {
                { "a", new List <Unit>()
                  {
                      dot, dash
                  } },
                { "b", new List <Unit>()
                  {
                      dash, dot, dot, dot
                  } },
                { "c", new List <Unit>()
                  {
                      dash, dot, dash, dot
                  } },
                { "d", new List <Unit>()
                  {
                      dash, dot
                  } },
                { "e", new List <Unit>()
                  {
                      dot
                  } },
                { "f", new List <Unit>()
                  {
                      dot, dot, dash, dot
                  } },
                { "g", new List <Unit>()
                  {
                      dash, dash, dot
                  } },
                { "h", new List <Unit>()
                  {
                      dot, dot, dot, dot
                  } },
                { "i", new List <Unit>()
                  {
                      dot, dot
                  } },
                { "j", new List <Unit>()
                  {
                      dot, dash, dash, dash
                  } },
                { "k", new List <Unit>()
                  {
                      dash, dot, dash
                  } },
                { "l", new List <Unit>()
                  {
                      dot, dash, dot, dot
                  } },
                { "m", new List <Unit>()
                  {
                      dash, dash
                  } },
                { "n", new List <Unit>()
                  {
                      dash, dot
                  } },
                { "o", new List <Unit>()
                  {
                      dash, dash, dash
                  } },
                { "p", new List <Unit>()
                  {
                      dot, dash, dash, dot
                  } },
                { "q", new List <Unit>()
                  {
                      dash, dash, dot, dash
                  } },
                { "r", new List <Unit>()
                  {
                      dot, dash, dot
                  } },
                { "s", new List <Unit>()
                  {
                      dot, dot, dot
                  } },
                { "t", new List <Unit>()
                  {
                      dash
                  } },
                { "u", new List <Unit>()
                  {
                      dot, dot, dash
                  } },
                { "v", new List <Unit>()
                  {
                      dot, dot, dot, dash
                  } },
                { "w", new List <Unit>()
                  {
                      dot, dash, dash
                  } },
                { "x", new List <Unit>()
                  {
                      dash, dot, dot, dash
                  } },
                { "y", new List <Unit>()
                  {
                      dash, dot, dash, dash
                  } },
                { "z", new List <Unit>()
                  {
                      dash, dash, dot, dot
                  } },
                { "0", new List <Unit>()
                  {
                      dash, dash, dash, dash, dash
                  } },
                { "1", new List <Unit>()
                  {
                      dot, dash, dash, dash, dash
                  } },
                { "2", new List <Unit>()
                  {
                      dot, dot, dash, dash, dash
                  } },
                { "3", new List <Unit>()
                  {
                      dot, dot, dot, dash, dash
                  } },
                { "4", new List <Unit>()
                  {
                      dot, dot, dot, dot, dash
                  } },
                { "5", new List <Unit>()
                  {
                      dot, dot, dot, dot, dot
                  } },
                { "6", new List <Unit>()
                  {
                      dash, dot, dot, dot, dot
                  } },
                { "7", new List <Unit>()
                  {
                      dash, dash, dot, dot, dot
                  } },
                { "8", new List <Unit>()
                  {
                      dash, dash, dash, dot, dot
                  } },
                { "9", new List <Unit>()
                  {
                      dash, dash, dash, dash, dot
                  } },
                { "letterSpace", new List <Unit>()
                  {
                      null
                  } },
                { "wordSpace", new List <Unit>()
                  {
                      null, null, null
                  } }
            });
        }
Пример #53
0
 public void ApplyDot(Dot dot, int dmgType)
 {
     StartCoroutine(DotRoutine(dot, dmgType));
 }
Пример #54
0
 public static void DrawCenterCrosshair()
 {
     Dot.Draw(d.Crosshair2dCenter_sw, dColors.Black, 4f);
     Dot.Draw(d.Crosshair2dCenter_ac, dColors.White, 2f);
 }
Пример #55
0
        private int MoveGamer(int Player, Dot pl_move=null)
        {
            toolStripStatusLabel2.ForeColor = Player == 1 ? game.colorGamer1 : game.colorGamer2;
            toolStripStatusLabel2.Text = "Ход игрока" + Player + "...";
            Application.DoEvents();
            if (pl_move== null) pl_move = game.PickComputerMove(game.LastMove);
            if (pl_move == null)
            {
                MessageBox.Show("Сдаюсь! \r\n" + game.Statistic());
                game.NewGame();
                return 1;
            }
            pl_move.Own=Player;
            game.MakeMove(pl_move,Player);
            game.ListMoves.Add(pl_move);
            pbxBoard.Invalidate();
            statusStrip1.Refresh();
            int pl = Player == 1 ? 2 : 1;
            toolStripStatusLabel2.ForeColor = pl == 1 ? game.colorGamer1 : game.colorGamer2;
            toolStripStatusLabel2.Text = "Ход игрока" + pl + "...";
            if (game.GameOver())
            {
                MessageBox.Show("Game over! \r\n" + game.Statistic());
                return 1;
            }

            //lstMoves.DataSource = null;
            //lstMoves.DataSource = game.ListMoves;
            //if (lstMoves.Items.Count > 0) lstMoves.SetSelected(lstMoves.Items.Count - 1, true);
            //rtbStat.Text = game.Statistic();
            return 0;
        }
Пример #56
0
 private void UpdateAdding()
 {
     if (_isAnyGuiUseMouse)
     {
         return;
     }
     if (Mouse.GetState().LeftButton == ButtonState.Pressed)
     {
         if (_drawState != DrawState.NONE)
         {
             if (!_wasDrawing)
             {
                 _lastPoint  = GetDot(_pos);
                 _wasDrawing = true;
             }
             else if (_drawState == DrawState.DOT || _drawState == DrawState.ELLIPSE)
             {
                 _lastPoint.MoveTo(_pos);
             }
         }
     }
     if (_wasDrawing && Mouse.GetState().LeftButton == ButtonState.Released)
     {
         if (_drawState == DrawState.DOT)
         {
             AddShape(_lastPoint);
         }
         else if (_drawState == DrawState.ELLIPSE)
         {
             _ellipseLastPoint = _lastPoint;
             _drawState        = DrawState.ELLIPSE_POINT;
             _wasDrawing       = false;
             return;
         }
         else
         {
             var p = GetDot(_pos);
             AddShape(p);
             AddShape(_lastPoint);
             Shape sp = null;
             if (_drawState == DrawState.CIRCLE)
             {
                 sp = Circle.FromTwoDots(_lastPoint, p);
                 AddShape(sp);
             }
             else if (_drawState == DrawState.SEGMENT)
             {
                 sp = Segment.FromTwoDots(_lastPoint, p);
                 AddShape(sp);
             }
             else if (_drawState == DrawState.LINE)
             {
                 sp = Line.FromTwoDots(_lastPoint, p);
                 AddShape(sp);
             }
             else if (_drawState == DrawState.VECTOR)
             {
                 sp = Vector.FromTwoDots(_lastPoint, p);
                 AddShape(sp);
             }
             else if (_drawState == DrawState.ELLIPSE_POINT)
             {
                 AddShape(_ellipseLastPoint);
                 sp = Ellipse.FromThreeDots(_ellipseLastPoint, _lastPoint, p);
                 AddShape(sp);
             }
         }
         _wasDrawing = false;
         _drawState  = DrawState.NONE;
     }
 }
Пример #57
0
    void MoveDotTo(Dot dot, int x, int y, bool dropDown = false)
    {
        dot.SetPosition(x, y);

        dot.gameObject.transform.parent = transform;
        Vector2 pos = Vector2.zero;
        pos.x += (x-(columns-1)/2f)*spacingX;
        pos.y += (y-(rows-1)/2f)*spacingY;
        if (dropDown)
        {
            dot.gameObject.transform.localPosition = new Vector3 (pos.x, pos.y + rows*spacingY, 0);
        }
        dot.TranslateTo(pos, dropSpeed);
    }
Пример #58
0
        /// <summary>
        /// 가까운 점이 있다면 그 점을, 없다면 새 점을
        /// </summary>
        private Dot GetDot(Vector2 coord, List <Shape> nears)
        {
            Dot   nearestDot = null;
            Shape nearest    = null;
            float distDot    = int.MaxValue;
            float dist       = int.MaxValue;

            foreach (var s in nears)
            {
                if (s is Dot)
                {
                    if (s.IsEnoughClose(coord))
                    {
                        nearestDot = s as Dot;
                        distDot    = s.Distance;
                    }
                }
                else
                {
                    if (s.Distance <= dist)
                    {
                        nearest = s;
                        dist    = s.Distance;
                    }
                }
            }
            if (nearestDot == null) // 가장 가까운게 점이 아니라면
            {
                if (nears.Count == 0)
                {
                    return(Dot.FromCoord(coord));
                }
                if (nears.Count == 1)
                {
                    return(OneShapeRuleDot(nearest, coord));
                }
                else if (nears.Count == 2)
                {
                    Vector2[] intersects = Geometry.GetIntersect(nears[0], nears[1]);
                    if (intersects.Length != 0)
                    {
                        Vector2 dot = intersects[0];
                        if (intersects.Length == 2)
                        {
                            dot = Vector2.Distance(coord, intersects[0]) < Vector2.Distance(intersects[1], coord)
                                ? intersects[0] : intersects[1];
                        }
                        return(Dot.FromIntersection(nears[0], nears[1], dot));
                    }
                    else
                    {
                        return(OneShapeRuleDot(nearest, coord));
                    }
                }
                else
                {
                    return(OneShapeRuleDot(nearest, coord));
                }
            }
            else if (nearestDot is Dot)
            {
                return(nearestDot as Dot);
            }
            else
            {
                return(Dot.FromCoord(coord));
            }
        }
Пример #59
0
 public override void OnDotSelected(Dot dot)
 {
     logic.OnDotSelected (dot);
 }
Пример #60
0
 private Dot OneShapeRuleDot(Shape nearest, Vector2 coord)
 {
     return(Dot.FromOneShape(nearest, coord));
 }