コード例 #1
0
ファイル: Square.cs プロジェクト: svetlanatanasov/jusTap
        public Square(string fileName, bool isTouchEnabled, SelectedColor color, PositionInGame position) : base()
        {
            _sprite = new CCSprite(fileName);
            //_square.AnchorPoint = point;

            _sprite.ContentSize = new CCSize(200, 200);
            ColorType           = color;
            CurrentPosition     = position;

            AddChild(_sprite);


            if (isTouchEnabled)
            {
                IsTouchEnabled = isTouchEnabled;
                var touchListener = new CCEventListenerTouchAllAtOnce();
                touchListener.OnTouchesBegan = OnTouchesBegan;

                AddEventListener(touchListener, this);
            }
            else //signal squares
            {
                //TODO: add +1 to square _sprite.AddChild
                _plusOneLabel          = new CCLabel("+1", "Fonts/arial", 36, CCLabelFormat.SpriteFont);
                _plusOneLabel.Position = new CCPoint(100, 100);
                _plusOneLabel.Visible  = false;
                _sprite.AddChild(_plusOneLabel, 1);
            }
        }
コード例 #2
0
ファイル: Animator.cs プロジェクト: svetlanatanasov/jusTap
        public void ChangeSquaresPosition(float timeForChanging, PositionInGame firstPosition, PositionInGame secondPosition, Action callback = null)
        {
            //var firstPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //var secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //while (firstPosition == secondPosition)
            //    secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);


            var firstSquarePosition  = _cordinatesGenerator.PositionAndSquare[firstPosition];
            var secondSquarePosition = _cordinatesGenerator.PositionAndSquare[secondPosition];

            var firstSquare  = firstSquarePosition;
            var secondSquare = secondSquarePosition;

            _cordinatesGenerator.PositionAndSquare[firstPosition]  = secondSquare;
            _cordinatesGenerator.PositionAndSquare[secondPosition] = firstSquare;


            var moveToFirstPosition  = new CCMoveTo(timeForChanging, new CCPoint(firstSquare.Position.X, firstSquare.Position.Y));
            var moveToSecondPosition = new CCMoveTo(timeForChanging, new CCPoint(secondSquare.Position.X, secondSquare.Position.Y));

            secondSquare.RunAction(moveToFirstPosition);

            if (callback != null)
            {
                var        moveCompletedAction = new CCCallFunc(callback);
                CCSequence mySequence          = new CCSequence(moveToSecondPosition, moveCompletedAction);

                firstSquare.RunAction(mySequence);
            }
            else
            {
                firstSquare.RunAction(moveToSecondPosition);
            }
        }
コード例 #3
0
ファイル: GameLayer.cs プロジェクト: svetlanatanasov/jusTap
 private Square CreateSquare(string fileName, SelectedColor color, PositionInGame position, bool isTouchEnabled)
 {
     return(new Square(fileName, isTouchEnabled, color, position));
 }