Exemple #1
0
        /**
        * This function creates the alignments for both sequences using the previous pointers array
        * Time Complexity: O(n) where n is the length of the larger sequence because it the best alignment
        *                  is as long as the length of the longest sequence
        * Space Complexity: O(n) where n is the length of the larger sequence as it creates a string as long as it
        */
        void createAlignments(ref string[] alignment, ref directions[,] prev, ref GeneSequence sequenceA, ref GeneSequence sequenceB,
                                                                ref int lengthOfSequenceA, ref int lengthOfSequenceB)
        {
            int rowIterator = lengthOfSequenceA, columnIterator = lengthOfSequenceB;
            StringBuilder first = new StringBuilder(), second = new StringBuilder();
            while (rowIterator != 0 || columnIterator != 0)
            {

                if (prev[rowIterator, columnIterator] == directions.DIAGONAL) // match/sub
                {
                    first.Insert(0, sequenceA.Sequence[rowIterator - 1]);
                    second.Insert(0, sequenceB.Sequence[columnIterator - 1]);
                    rowIterator--;
                    columnIterator--;
                }
                else if (prev[rowIterator, columnIterator] == directions.LEFT) //insert
                {
                    first.Insert(0, '-');
                    second.Insert(0, sequenceB.Sequence[columnIterator - 1]);
                    columnIterator--;
                }
                else // delete
                {
                    first.Insert(0, sequenceA.Sequence[rowIterator - 1]);
                    second.Insert(0, '-');
                    rowIterator--;
                }
            }

            // Limiting the length of the string to 100 if it exceeds it
            alignment[0] = first.ToString().Substring(0, Math.Min(first.Length, 100));
            alignment[1] = second.ToString().Substring(0, Math.Min(second.Length, 100));
        }
Exemple #2
0
 /// <summary>
 /// Cookie constructor
 /// </summary>
 public Cookie(int idck, int xp, int yp, directions dir, string throwerName)
 {
     id = idck;
     x = xp;
     y = yp;
     direction = dir;
     thrower = throwerName;
     SendUpdate();
 }
Exemple #3
0
 void Swipe(directions direction)
 {
     switch (direction)
     {
         case directions.UP:
             Events.OnSwipe(directions.UP); break;
         case directions.DOWN:
             Events.OnSwipe(directions.DOWN); break;
         case directions.RIGHT:
             Events.OnSwipe(directions.RIGHT); break;
     }
 }
Exemple #4
0
        public MazeElement GetSide(directions side)
        {
            switch (side)
            {
                case directions.north:
                    return northWall;
                  case directions.east:
                    return eastWall;
                case directions.south:
                    return southWall;
                case directions.west:
                    return westWall;
            }

            return northWall;
        }
Exemple #5
0
 public void SetSide(directions side, MazeElement element)
 {
     switch (side)
     {
         case directions.north:
             northWall = element;
             break;
         case directions.east:
             eastWall = element;
             break;
         case directions.south:
             southWall = element;
             break;
         case directions.west:
             westWall = element;
             break;
     }
 }
Exemple #6
0
        public Tile(directions d, Waypoint wp, waypointTypes type)
        {
            this.direction = d;
            this.wp        = wp;
            this.type      = type;

            if (type.Equals(waypointTypes.StorageLocation) && !d.Equals(directions.EastNorthSouthWest))
            {
                throw new ArgumentException("something went wrong with storage locations");
            }
            if (d.Equals(directions.Invalid))
            {
                throw new ArgumentException("direction invalid");
            }
            if (wp == null)
            {
                throw new ArgumentException("wp is null");
            }
        }
Exemple #7
0
 private void turnRight()
 {
     if (dir == directions.NORTH)
     {
         dir = directions.EAST;
     }
     else if (dir == directions.EAST)
     {
         dir = directions.SOUTH;
     }
     else if (dir == directions.SOUTH)
     {
         dir = directions.WEST;
     }
     else
     {
         dir = directions.NORTH;
     }
 }
Exemple #8
0
    public bool canBeAccessedFromDirection(directions dir)
    {
        switch (dir)
        {
        case directions.Top:
            return(!collidesFromAbove);

        case directions.Bottom:
            return(!collidesFromBelow);

        case directions.Left:
            return(!collidesFromLeft);

        case directions.Right:
            return(!collidesFromRight);

        default:
            return(true);
        }
    }
Exemple #9
0
 void Update()
 {
     //move
     if (Input.GetKeyDown(KeyCode.LeftArrow))
     {
         dir = directions.LEFT;
     }
     if (Input.GetKeyDown(KeyCode.RightArrow))
     {
         dir = directions.RIGHT;
     }
     if (Input.GetKeyDown(KeyCode.UpArrow))
     {
         dir = directions.UP;
     }
     if (Input.GetKeyDown(KeyCode.DownArrow))
     {
         dir = directions.DOWN;
     }
 }
Exemple #10
0
        public void buildStation(waypointTypes typeOfStation, int row, int column, directions d, List <Waypoint> bufferPaths, int activationOrderID)
        {
            switch (typeOfStation)
            {
            case waypointTypes.PickStation:
                buildPickStation(row, column, d, bufferPaths, activationOrderID);
                break;

            case waypointTypes.ReplenishmentStation:
                buildReplenishmentStation(row, column, d, bufferPaths, activationOrderID);
                break;

            case waypointTypes.Elevator:
                buildElevator(row, column, d, bufferPaths);
                break;

            default:
                throw new ArgumentException("should built station, but typeOfStations is: " + typeOfStation);
            }
        }
Exemple #11
0
    public void InputArrow(directions dir)
    {
        if (actualState != InputGameplayState.GAME)
        {
            return;
        }

        imgInput.sprite = GetIcon(dir);
        imgInput.gameObject.SetActive(true);

        inputs.Add(dir);

        if (dir != pattern[inputs.Count - 1])
        {
            patternActual = 0;
            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.ERROR);
            PatternFail();
            return;
        }

        if (inputs.Count == pattern.Count)
        {
            patternActual++;

            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.CORRECT);

            if (patternActual >= CantPatterns.Count)
            {
                actualState = InputGameplayState.END;
                HideGammeplayImages();
                imgMSG.sprite = QuestionSprite;
                imgMSG.color  = new Color(0, 155, 255);
                imgMSG.gameObject.SetActive(true);
                triviaGameplayManager.StartGame();
            }
            else
            {
                PatternOK();
            }
        }
    }
Exemple #12
0
    public void init(worldScript _myWorldScript, int x, int y, int w, int h, int _i)
    {
        myWorldScript = _myWorldScript;
        posX          = x;
        posY          = y;
        width         = w;
        height        = h;
        tFactor       = 0f;
        id            = _i;

        currentTile = myWorldScript.getTileXY(posX, posY);

        myDirection   = getInitialDirection(currentTile, posX, posY);
        prevDirection = myDirection;

        switch (myDirection)
        {
        case directions.NORTH:
            transform.localPosition = new Vector3(transform.localPosition.x + 0.5f, transform.localPosition.y, transform.localPosition.z);
            nextPos = new Vector3((posX - (width / 2)) * 2, 1.5f, (((posY - 1) - (height / 2)) * -1) * 2);
            break;

        case directions.SOUTH:
            transform.localPosition = new Vector3(transform.localPosition.x - 0.5f, transform.localPosition.y, transform.localPosition.z);
            nextPos = new Vector3((posX - (width / 2)) * 2, 1.5f, (((posY + 1) - (height / 2)) * -1) * 2);
            break;

        case directions.WEST:
            transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + 0.5f);
            nextPos = new Vector3(((posX - 1) - (width / 2)) * 2, 1.5f, ((posY - (height / 2)) * -1) * 2);
            break;

        case directions.EAST:
            transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z - 0.5f);
            nextPos = new Vector3(((posX + 1) - (width / 2)) * 2, 1.5f, ((posY - (height / 2)) * -1) * 2);
            break;
        }

        currentPos = transform.localPosition;
        prevPos    = currentPos;
    }
Exemple #13
0
    //This is also used by the generateWalls class
    public static Vector3Int getVectorIncrement(directions direction)
    {
        switch (direction)
        {
        case directions.left:
            return(Vector3Int.left);

        case directions.right:
            return(Vector3Int.right);

        case directions.up:
            return(Vector3Int.up);

        case directions.down:
            return(Vector3Int.down);

        default:
            Debug.LogError("For some reason, this default clause was met! FIx this please");
            return(Vector3Int.up);
        }
    }
        public void move(directions dir, int len)
        {
            switch (dir)
            {
            case directions.down:
                setPosition(new Point(position.X, position.Y + len));
                break;

            case directions.left:
                setPosition(new Point(position.X - len, position.Y));
                break;

            case directions.right:
                setPosition(new Point(position.X + len, position.Y));
                break;

            case directions.up:
                setPosition(new Point(position.X, position.Y - len));
                break;
            }
        }
Exemple #15
0
        public void Update(IView view, directions playerDirection, directions shootDirection, bool shoot)
        {
            model.Player.direction = playerDirection;

            if (shoot)
            {
                model.Shoot(model.Player, shootDirection);
                shoot = false;
            }
            model.CheckCollisions();

            model.MoveAfterCheck();

            model.MakeExplosions();

            model.MakePrizes(model.prizeCount);

            UpdateView();

            view.Render();
        }
Exemple #16
0
    directions getInitialDirection(tile currentTile, int x, int y)
    {
        if (
            (Random.Range(0, 2) > 0) &&
            ((myWorldScript.getTileXY(x, y - 1).whichType == tileTypes.BUILDING) ||
             ((myWorldScript.getTileXY(x, y - 1).whichType == tileTypes.ROAD) && (myWorldScript.getTileXY(x, y - 1).whichRoadType == roadTypes.CROSS_VERTICAL)))
            )
        {
            myDirection = directions.NORTH;
        }

        if (
            (Random.Range(0, 2) > 0) &&
            ((myWorldScript.getTileXY(x, y + 1).whichType == tileTypes.BUILDING) ||
             ((myWorldScript.getTileXY(x, y + 1).whichType == tileTypes.ROAD) && (myWorldScript.getTileXY(x, y + 1).whichRoadType == roadTypes.CROSS_VERTICAL)))
            )
        {
            myDirection = directions.SOUTH;
        }

        if (
            (Random.Range(0, 2) > 0) &&
            ((myWorldScript.getTileXY(x - 1, y).whichType == tileTypes.BUILDING) ||
             ((myWorldScript.getTileXY(x - 1, y).whichType == tileTypes.ROAD) && (myWorldScript.getTileXY(x - 1, y).whichRoadType == roadTypes.CROSS_HORIZONTAL)))
            )
        {
            myDirection = directions.WEST;
        }

        if (
            (Random.Range(0, 2) > 0) &&
            ((myWorldScript.getTileXY(x + 1, y).whichType == tileTypes.BUILDING) ||
             ((myWorldScript.getTileXY(x + 1, y).whichType == tileTypes.ROAD) && (myWorldScript.getTileXY(x + 1, y).whichRoadType == roadTypes.CROSS_HORIZONTAL)))
            )
        {
            myDirection = directions.EAST;
        }

        return(myDirection);
    }
Exemple #17
0
        public MenuScreen(ContentManager MyContent, SpriteBatch SpriteBatch)
        {
            myContent = MyContent;
            spriteBatch = SpriteBatch;

            myScreenMessage = ScreenMessages.none;
            myScreenType = ScreenTypes.MenuScreen;

            menuTexture = myContent.Load<Texture2D>("graphics\\MenuScreen\\MenuTexture");
            font = myContent.Load<SpriteFont>("font\\menuButtonTextFont");

            ButtonBorders = new Rectangle[2];
            ButtonBorders[0] = new Rectangle(0,151,158,58);
            ButtonBorders[1] = new Rectangle(159, 151, 158, 58);

            Nyan = new Rectangle[4];
            Nyan[0] = new Rectangle(2, 212, 66, 40);
            Nyan[1] = new Rectangle(69, 212, 66, 40);
            Nyan[2] = new Rectangle(2, 253, 66, 40);
            Nyan[3] = new Rectangle(69, 253, 66, 40);

            Enemy = new Rectangle[4];
            Enemy[0] = new Rectangle(136, 212, 66, 40);
            Enemy[1] = new Rectangle(203, 212, 66, 40);
            Enemy[2] = new Rectangle(136, 253, 66, 40);
            Enemy[3] = new Rectangle(203, 253, 66, 40);

            Rainbow = new Rectangle[2];
            Rainbow[0] = new Rectangle(269, 212, 66, 40);
            Rainbow[1] = new Rectangle(343, 212, 66, 40);

            actionFramePos = new Vector2(0, 175);

            currentDirection = directions.Right;

            selectedMenuItem = menuItems.PlayGame;

            PlayGameButtonString = "Play Game";
            ExitGameButtonString = "Exit Game";
        }
Exemple #18
0
    private Sprite GetIcon(directions dir)
    {
        if (dir == directions.UP)
        {
            return(UpIcon);
        }
        if (dir == directions.RIGHT)
        {
            return(RightIcon);
        }
        if (dir == directions.DOWN)
        {
            return(DownIcon);
        }
        if (dir == directions.LEFT)
        {
            return(LeftIcon);
        }

        Debug.LogWarning("Se ingreso un numero de icono invalido");
        return(UpIcon);
    }
Exemple #19
0
        public void SetDirection(directions dir)
        {
            direction = dir;
            switch (direction)
            {
            case directions.Up:
                z = 0;
                break;

            case directions.Down:
                z = 180;
                break;

            case directions.Left:
                z = 270;
                break;

            case directions.Right:
                z = 90;
                break;
            }
        }
Exemple #20
0
        // METHODS
        public void seDéplacer(directions direction)
        {
            if (!Collision.Collided(direction))   // si le perso n'est pas en collision
            {
                this.Position = Vector2.Add(this.Position, new Vector2((float)direction * _vitesse, 0));
            }

            switch (direction)
            {
            case directions.DROITE:
                _ligne = 1;
                break;

            case directions.GAUCHE:
                _ligne = 2;
                break;

            case directions.FACE:
                _ligne = 0;
                break;
            }
        }
Exemple #21
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////// Helper Functions //////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /**
        * This function fills the first row and column with the cost of insert/delete for each one
        * Time Complexity: O(n+m) where n is the length of the first sequence and m is the length of the second sequence.
        *                   This is because it iterates over all letters in each sequence once
        * Space Complexity: O(1) because it passes the values by reference meaning it does not create a copy and 
        *                   it does not create any variables that depend on the size of the input.
        */
        void fillStartCells(ref int[,] values, ref directions[,] prev, int lengthA, int lengthB, bool banded)
        {
            for (int column = 0; column < lengthB + 1; column++)
            {
                if (banded == true && (column > distance))
                {
                    break;
                }
                values[0, column] = column * 5;
                prev[0, column] = directions.LEFT;
            }
            for (int row = 0; row < lengthA + 1; row++)
            {
                if (banded == true && (row > distance))
                {
                    break;
                }
                values[row, 0] = row * 5;
                prev[row, 0] = directions.TOP;
            }

        }
Exemple #22
0
        private static void GetNewDirection()
        {
            var inc = false;

            if (directionCounter == (2 * directionAmount))
            {
                inc = true;
                directionCounter = 0;
            }

            if (directionSteps < directionAmount)
            {
                return;
            }

            switch (direction)
            {
            case directions.RIGHT:
                direction = directions.UP; break;

            case directions.LEFT:
                direction = directions.DOWN; break;

            case directions.UP:
                direction = directions.LEFT; break;

            case directions.DOWN:
                direction = directions.RIGHT; break;

            default:
                direction = directions.UP; break;
            }
            directionSteps = 0;
            if (inc)
            {
                directionAmount++;
            }
        }
Exemple #23
0
    void SShoot(int pos, directions richting)
    {
        int layer = 0;

        if (_direction[directions.Right] || _direction[directions.Left])
        {
            layer = _switch.currentNum * 2;
            SwitchAllWeaponPositions(1);
        }
        else if (_direction[directions.Down])
        {
            layer = 2;
            SwitchAllWeaponPositions(0);
        }
        else
        {
            SwitchAllWeaponPositions(0);
        }
        Shoot trigger = _triggers.triggers[_switch.currentNum];

        //SwitchAllWeaponPositions(1);//sets the position at position 0
        trigger.ShootWeapon(0, _directionVectors[richting]);
    }
Exemple #24
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Enemy1")
     {
         if (dir == directions.Up)
         {
             dir = directions.Down;
         }
         else if (dir == directions.Down)
         {
             dir = directions.Up;
         }
         else if (dir == directions.Left)
         {
             dir = directions.Right;
         }
         else if (dir == directions.Right)
         {
             dir = directions.Left;
         }
         state = EnemyState.Moving;
     }
 }
Exemple #25
0
    /// <summary>
    /// Determines the opposite direction.
    /// </summary>
    public static Vector3 DetermineOppositeDirection(directions dir)
    {
        Vector3 resultingVector = Vector3.one;

        switch (dir)
        {
        case VectorDirection.directions.Up:
            resultingVector = Vector3.down;
            break;

        case VectorDirection.directions.Down:
            resultingVector = Vector3.up;
            break;

        case VectorDirection.directions.Right:
            resultingVector = Vector3.left;
            break;

        case VectorDirection.directions.Left:
            resultingVector = Vector3.right;
            break;

        case VectorDirection.directions.Forward:
            resultingVector = Vector3.back;
            break;

        case VectorDirection.directions.Back:
            resultingVector = Vector3.forward;
            break;

        case VectorDirection.directions.Equally:
            resultingVector = Vector3.zero;
            break;
        }

        return(resultingVector);
    }
        public void RenderPlayer(Bitmap screen)
        {
            using (Graphics g = Graphics.FromImage(screen))
            {
                switch (player.direction)
                {
                case directions.up:
                    g.DrawImage(playerImages[0], new Rectangle(player.position_x, player.position_y, player.size_x, player.size_y));
                    casePlayerDirection = directions.up;
                    break;

                case directions.down:
                    g.DrawImage(playerImages[1], new Rectangle(player.position_x, player.position_y, player.size_x, player.size_y));
                    casePlayerDirection = directions.down;
                    break;

                case directions.left:
                    g.DrawImage(playerImages[2], new Rectangle(player.position_x, player.position_y, player.size_x, player.size_y));
                    casePlayerDirection = directions.left;
                    break;

                case directions.right:
                    g.DrawImage(playerImages[3], new Rectangle(player.position_x, player.position_y, player.size_x, player.size_y));
                    casePlayerDirection = directions.right;
                    break;

                case directions.none:
                    int i = (int)casePlayerDirection;
                    g.DrawImage(playerImages[i], new Rectangle(player.position_x, player.position_y, player.size_x, player.size_y));
                    break;

                default:
                    break;
                }
            }
        }
Exemple #27
0
        };                                                           // invalid.
        private pwCell InDirection(directions dir)
        {
            switch (dir)
            {
            case directions.up:
                if (myPoint.y == 0)
                {
                    return(null);
                }
                return(cells[(int)myPoint.x, (int)myPoint.y - 1]);

            case directions.right:
                if (myPoint.x == width - 1)
                {
                    return(null);
                }
                return(cells[(int)myPoint.x + 1, (int)myPoint.y]);

            case directions.down:
                if (myPoint.y == height - 1)
                {
                    return(null);
                }
                return(cells[(int)myPoint.x, (int)myPoint.y + 1]);

            case directions.left:
                if (myPoint.x == 0)
                {
                    return(null);
                }
                return(cells[(int)myPoint.x - 1, (int)myPoint.y]);

            default:
                return(null);
            }
        }
Exemple #28
0
    bool turnIfMetBoundary()
    {
        //The boundary tle isn't blocking the way
        if (!boundaryTilemap.HasTile(currentPosition + getVectorIncrement(currentDirection)))
        {
            return(false);
        }

        //First finding all unblocked areas
        List <directions> allDirections       = new List <directions>(new directions[] { directions.up, directions.down, directions.left, directions.right });
        List <directions> availableDirections = new List <directions>();

        foreach (directions direction in allDirections)
        {
            if (!boundaryTilemap.HasTile(currentPosition + getVectorIncrement(direction)))
            {
                availableDirections.Add(direction);
            }
        }

        //Picking any one of those free directions to turn to
        currentDirection = availableDirections[Random.Range(0, availableDirections.Count)];
        return(true);
    }
Exemple #29
0
 private static void copyBorders()
 {
     // For all cells associated with a symmetry point, copy their association and borders.
     foreach (var cell in cells)
     {
         if (cell.centerPoint != invalid)
         {
             for (int k = 0; k < 4; k++)
             {
                 if (cell.IsBorder((directions)k))
                 {
                     Point      opposite = Symmetry(cell.myPoint, cell.centerPoint);
                     pwCell     newCell  = cells[(int)opposite.x, (int)opposite.y];
                     directions oppside  = (directions)((k + 2) % 4);
                     if (!newCell.IsBorder(oppside))
                     {
                         Console.WriteLine($"Copying border from {cell.myPoint} to {opposite}.");
                         newCell.SetBorder(oppside);
                     }
                 }
             }
         }
     }
 }
Exemple #30
0
 private static void associateDeadEnds()
 {
     // For each cell, if it's a dead end (borders on three sides), make sure that the association points out, so we can trim it.
     foreach (var cell in cells)
     {
         directions dirOut = directions.multi;
         if (cell.associates != directions.multi)
         {
             continue;                                      // Already associated!
         }
         for (int k = 0; k < 4; k++)
         {
             if (cell.IsBorder((directions)k))
             {
                 continue;
             }
             pwCell newCell = cell.InDirection((directions)k);
             if (newCell.associates == (directions)((k + 2) % 4))
             {
                 continue;                                                  // if associates to this one, it might as well be a border!
             }
             if (dirOut != directions.multi)
             {
                 dirOut = directions.multi;
                 break;
             }
             dirOut = (directions)k;
         }
         if (dirOut != directions.multi)
         {
             cell.associates = dirOut;
             Console.WriteLine($"Associating dead-end cell at {cell.myPoint} to direction {dirOut}");
             changesThisPass++;
         }
     }
 }
 private void EnterDown(object sender, MouseEventArgs e)
 {
     MouseLastLocation = directions.down;
 }
 private void EnterUp(object sender, MouseEventArgs e)
 {
     MouseLastLocation = directions.up;
 }
 private void EnterRight(object sender, MouseEventArgs e)
 {
     MouseLastLocation = directions.right;
 }
Exemple #34
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="x">敌人的x座标</param>
 /// <param name="y">敌人的y座标</param>
 /// <param name="life">敌人的生命</param>
 /// <param name="speed">敌人的速度</param>
 /// <param name="dir">敌人的方向</param>
 public Enemy(int x, int y, int type, directions dir)
     : base(x, y, SetLife(type), SetSpeed(type), imgEnemy1[0].Width, imgEnemy1[0].Height, dir)
 {
     this.type = type;
     BeBorn();
 }
Exemple #35
0
	/// <summary>
	/// Reads the first two touche positions and handles them.
	/// </summary>
	//TODO: Move distance handling etc to Game Logic?
	private void HandlePinchInput() {
		float prevTouchDeltaMag = 0;
		float touchDeltaMag = 0;
		float deltaMagnitudeDifference = 0;
		Touch touchZero = Input.GetTouch(0);
		Touch touchOne = Input.GetTouch(1);

		Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
		Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;

		prevTouchDeltaMag = ( touchZeroPrevPos - touchOnePrevPos ).magnitude;
		touchDeltaMag = ( touchZero.position - touchOne.position ).magnitude;

		deltaMagnitudeDifference = prevTouchDeltaMag - touchDeltaMag;

		if (Input.touchCount >= 2) {
			if (touchZero.phase == TouchPhase.Ended || touchOne.phase == TouchPhase.Ended) {
				distance = 0;
				direction = directions.NONE;
			}
		}

		if (Mathf.Abs(distance) < 10) {
			distance += deltaMagnitudeDifference;
		}

		if (prevTouchDeltaMag > touchDeltaMag) {
			//Zoom Out (-)
			if (distance >= 10) {
				if (direction == directions.NONE || direction == directions.OUT) {
					distance += deltaMagnitudeDifference;
					AppManager.Instance.ZoomOut(Mathf.Abs(this.distance));
					direction = directions.OUT;
				}
			}
		}

		else if (prevTouchDeltaMag < touchDeltaMag) {
			//Zoom In (+)
			if (distance <= -10) {
				if (direction == directions.NONE || direction == directions.IN) {
					distance += deltaMagnitudeDifference;
					AppManager.Instance.ZoomIn(Mathf.Abs(this.distance));
					direction = directions.IN;
				}
			}
		}

	}
Exemple #36
0
    // Update is called once per frame
    void Update()
    {
        //foreach (KeyCode kcode in System.Enum.GetValues(typeof(KeyCode)))
        //{
        //    if (Input.GetKeyDown(kcode))
        //        text.text += ("" + kcode);
        //}
        if (Input.GetKeyDown(KeyCode.JoystickButton2))
        {
            OnKeyPress(directions.up);
        }
        else if (Input.GetKeyDown(KeyCode.JoystickButton3))
        {
            OnKeyPress(directions.right);
        }
        else if (Input.GetKeyDown(KeyCode.RightShift))
        {
            OnKeyPress(directions.down);
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            OnKeyPress(directions.left);
        }
        else if (Input.GetKeyDown(KeyCode.JoystickButton7))
        {
            OnKeyPress(directions.click);
        }
        //   text.text += Input.GetAxisRaw("Oculus_GearVR_LThumbstickX") != 0 ? "x: " + Input.GetAxis("Horizontal") : "";
        //  text.text += Input.GetAxisRaw("Oculus_GearVR_LThumbstickY") != 0 ? "y: " + Input.GetAxis("Vertical") : "";

        //if (Input.GetKeyDown(KeyCode.JoystickButton2))
        //{
        //    OnKeyPress(directions.up);
        //}
        //else if (Input.GetKeyDown(KeyCode.JoystickButton3))
        //{
        //    OnKeyPress(directions.right);
        //}
        //else if (Input.GetKeyDown(KeyCode.JoystickButton0))
        //{
        //    OnKeyPress(directions.left);
        //}
        //else if (Input.GetKeyDown(KeyCode.Joystick1Button1))
        //{
        //    OnKeyPress(directions.down);
        //}
        //else if (Input.GetKeyDown(KeyCode.RightShift))
        //{
        //    OnKeyPress(directions.click);
        //}
        //else if (Input.GetKeyDown(KeyCode.LeftShift))
        //{
        //    OnKeyPress(directions.click);
        //}

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            OnKeyPress(directions.up);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OnKeyPress(directions.right);
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            OnKeyPress(directions.left);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            OnKeyPress(directions.down);
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            OnKeyPress(directions.click);
        }

        if ((prevDirection != directions.right || joystickTimer.ElapsedMilliseconds > 200f) && Input.GetAxisRaw("Oculus_GearVR_LThumbstickX") == 1)
        {
            joystickTimer.Reset();
            joystickTimer.Start();
            prevDirection = directions.right;
            OnKeyPress(directions.right);
        }
        else if ((prevDirection != directions.left || joystickTimer.ElapsedMilliseconds > 200f) && Input.GetAxisRaw("Oculus_GearVR_LThumbstickX") == -1)
        {
            joystickTimer.Reset();
            joystickTimer.Start();
            prevDirection = directions.left;
            OnKeyPress(directions.left);
        }
        else if ((prevDirection != directions.down || joystickTimer.ElapsedMilliseconds > 200f) && Input.GetAxisRaw("Oculus_GearVR_LThumbstickY") == -1)
        {
            joystickTimer.Reset();
            joystickTimer.Start();
            prevDirection = directions.down;
            OnKeyPress(directions.down);
        }
        else if ((prevDirection != directions.up || joystickTimer.ElapsedMilliseconds > 200f) && Input.GetAxisRaw("Oculus_GearVR_LThumbstickY") == 1)
        {
            joystickTimer.Reset();
            joystickTimer.Start();
            prevDirection = directions.up;
            OnKeyPress(directions.up);
        }
    }
Exemple #37
0
 private directions setFacing(directions a)
 {
     return(this.facing = a);
 }
	void ChangeDirection(directions _d) {
		currentDirection = _d;
		print (currentDirection);
	}
Exemple #39
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////// Banded Algorithm //////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /**
        * This function performs the banded algorithm on the two sequences using dynamic programming to come up with
        * the best alignment for both. The band is set to whatever the distance is. Currently it is d = 3 which makes the
        * bandwidth equals 2d+1 = 7.
        * Time Complexity: O(n+m) where n is the length of the first sequence and m is the length of the second sequence. This
        *                   is because the algorithm iterates over a specific number of cells for each row and column. As we don't
        *                   care about constants, the time would depend on the length of sequence A and B. Meaning each time
        *                   the array size is increased by a row or a column, we have to compute those bandwidth number of cells
        *                   again, so it is O(n+m).
        * Space Complexity: O(nm) where n is the length of the first sequence and m is the length of the second sequence. This
        *                   is because the algorithm creates an array of n x m 
        */
        void bandedAlgorithm(ref int score, ref string[] alignment, ref GeneSequence sequenceA, ref GeneSequence sequenceB)
        {

            // Limiting the lengths of the sequences to the max characters to align
            int lengthOfSequenceA = Math.Min(sequenceA.Sequence.Length, MaxCharactersToAlign);
            int lengthOfSequenceB = Math.Min(sequenceB.Sequence.Length, MaxCharactersToAlign);

            // Create two arrays to hold the intermediate values and the alignment details
            int[,] values = new int[lengthOfSequenceA + 1, lengthOfSequenceB + 1];
            directions[,] prev = new directions[lengthOfSequenceA + 1, lengthOfSequenceB + 1];

            // first fill first row and column with cost of inserts/deletes
            fillStartCells(ref values, ref prev, lengthOfSequenceA, lengthOfSequenceB, true);

            int columnStart = 1;
            bool alignmentFound = false;
            int row = 1;
            int column = columnStart;
            // Now iterate through the rest of the cells filling out the min value for each
            for (row = 1; row < lengthOfSequenceA + 1; row++)
            {
                for (column = columnStart; column < lengthOfSequenceB + 1; column++)
                {
                    if ((distance + row) < column)
                    {
                        break;
                    }
                    // Compute values for each direction
                    int costOfTop_Delete = values[row - 1, column] + 5;
                    if ((distance + row) == column)
                    {
                        costOfTop_Delete = int.MaxValue;
                    }
                    int costOfLeft_Insert = values[row, column - 1] + 5;
                    if ((distance + column) == row)
                    {
                        costOfLeft_Insert = int.MaxValue;
                    }
                    // Compute cost of moving from diagonal depending on whether the letters match
                    int costOfMovingFromDiagonal = (sequenceA.Sequence[row - 1] == sequenceB.Sequence[column - 1]) ? -3 : 1;
                    int costOfDiagonal = values[row - 1, column - 1] + costOfMovingFromDiagonal;

                    // value of cell would be the minimum cost out of the three directions
                    int costOfMin = Math.Min(costOfDiagonal, Math.Min(costOfLeft_Insert, costOfTop_Delete));
                    values[row, column] = costOfMin;

                    // Store the direction
                    if (costOfMin == costOfDiagonal)
                    {
                        prev[row, column] = directions.DIAGONAL;
                    }
                    else if (costOfMin == costOfLeft_Insert)
                    {
                        prev[row, column] = directions.LEFT;
                    }
                    else
                    {
                        prev[row, column] = directions.TOP;
                    }
                    if (column == lengthOfSequenceB && row == lengthOfSequenceA)
                        alignmentFound = true;
                }
                if (row > distance)
                    columnStart++;
            }
           
            // score would be value of the last cell
            if (alignmentFound)
            {
                score = values[lengthOfSequenceA, lengthOfSequenceB];
                // Create the alignments
                createAlignments(ref alignment, ref prev, ref sequenceA, ref sequenceB, 
                                                ref lengthOfSequenceA, ref lengthOfSequenceB);

            }
            else {
                score = int.MaxValue;
                alignment[0] = "No Alignment Possible";
                alignment[1] = "No Alignment Possible";
            }
        }
Exemple #40
0
 /// <summary>
 /// Add a cookie to the jar
 /// </summary>
 public static void AddCookie(int x, int y, directions dir, int id, string throwerName)
 {
     cookies.Add(new Cookie(id, x, y, dir, throwerName));
 }
Exemple #41
0
        public void SwapSlot(int slot, directions dir)
        {
            int row = SlotNumberToRow(slot);
            int col = SlotNumberToCol(slot);

            int newrow=0;
            int newcol=0;

            switch (dir)
            {
                case directions.up:
                    newrow = row - 1;
                    newcol = col;
                    break;

                case directions.right:
                    newrow = row;
                    newcol = col + 1;
                    break;

                case directions.down:
                    newrow = row + 1;
                    newcol = col;
                    break;

                case directions.left:
                    newrow = row;
                    newcol = col - 1;
                    break;
            }

            int newslot = RowColToSlot(newrow, newcol);

            slots[newslot] = slots[slot];
            slots[slot] = 0;
        }
Exemple #42
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////// Unrestricted Algorithm ////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /**
        * This function performs the unrestricted algorithm on the two sequences using dynamic programming to come up with
        * the best alignment for both.
        * Time Complexity: O(nm) where n is the length of the first sequence and m is the length of the second sequence. This
        *                   is because the algorithm iterates over all cells in the array of n x m
        * Space Complexity: O(nm) where n is the length of the first sequence and m is the length of the second sequence. This
        *                   is because the algorithm creates an array of n x m 
        */
        void unrestrictedAlgorithm (ref int score, ref string[] alignment, ref GeneSequence sequenceA, ref GeneSequence sequenceB)
        {
            // Limiting the lengths of the sequences to the max characters to align
            int lengthOfSequenceA = Math.Min(sequenceA.Sequence.Length, MaxCharactersToAlign);
            int lengthOfSequenceB = Math.Min(sequenceB.Sequence.Length, MaxCharactersToAlign);

            // Create two arrays to hold the intermediate values and the alignment details
            int[,] values = new int[lengthOfSequenceA + 1, lengthOfSequenceB + 1];
            directions[,] prev = new directions[lengthOfSequenceA + 1, lengthOfSequenceB + 1];

            // first fill first row and column with cost of inserts/deletes
            fillStartCells(ref values, ref prev, lengthOfSequenceA, lengthOfSequenceB, false);

            // Now iterate through the rest of the cells filling out the min value for each
            for (int row = 1; row < lengthOfSequenceA + 1; row++)
            {
                for (int column = 1; column < lengthOfSequenceB + 1; column++)
                {
                    // Compute values for each direction
                    int costOfTop_Delete = values[row - 1, column] + 5;
                    int costOfLeft_Insert = values[row, column - 1] + 5;
                    // Compute cost of moving from diagonal depending on whether the letters match
                    int costOfMovingFromDiagonal = (sequenceA.Sequence[row - 1] == sequenceB.Sequence[column - 1]) ? -3 : 1;
                    int costOfDiagonal = values[row - 1, column - 1] + costOfMovingFromDiagonal;

                    // value of cell would be the minimum cost out of the three directions
                    int costOfMin = Math.Min(costOfTop_Delete, Math.Min(costOfLeft_Insert, costOfDiagonal));
                    values[row, column] = costOfMin;

                    // Store the direction
                    if (costOfMin == costOfDiagonal)
                    {
                        prev[row, column] = directions.DIAGONAL;
                    }
                    else if (costOfMin == costOfLeft_Insert)
                    {
                        prev[row, column] = directions.LEFT;
                    }
                    else
                    {
                        prev[row, column] = directions.TOP;
                    }
                }
            }

            // score would be value of the last cell
            score = values[lengthOfSequenceA, lengthOfSequenceB];

            // Create the alignments
            createAlignments(ref alignment, ref prev, ref sequenceA, ref sequenceB, ref lengthOfSequenceA, ref lengthOfSequenceB);
            
        }
 private void EnterLeft(object sender, MouseEventArgs e)
 {
     MouseLastLocation = directions.left;
 }
Exemple #44
0
 public HumanPlayer(int id, string username, int xPos, int yPos, int score, directions facing) : base(id, username, xPos, yPos, score)
 {
     this.facing = facing;
 }
Exemple #45
0
 public P2Tank(int x, int y, int speed, int life, directions dir)
     : base(x, y, life, speed, dir, imgTank2)
 {
 }
Exemple #46
0
    void Walk(directions direction)
    {
        Vector3    newPosition = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
        directions rotation    = CheckRotation();

        switch (direction)
        {
        case directions.up:
            if (rotation == directions.north)
            {
                newPosition.z += Variables.unityUnit;
            }
            else if (rotation == directions.south)
            {
                newPosition.z -= Variables.unityUnit;
            }
            else if (rotation == directions.west)
            {
                newPosition.x -= Variables.unityUnit;
            }
            else
            {
                newPosition.x += Variables.unityUnit;
            }
            break;

        case directions.down:
            if (rotation == directions.north)
            {
                newPosition.z -= Variables.unityUnit;
            }
            else if (rotation == directions.south)
            {
                newPosition.z += Variables.unityUnit;
            }
            else if (rotation == directions.west)
            {
                newPosition.x += Variables.unityUnit;
            }
            else
            {
                newPosition.x -= Variables.unityUnit;
            }
            break;

        case directions.left:
            if (rotation == directions.north)
            {
                newPosition.x -= Variables.unityUnit;
            }
            else if (rotation == directions.south)
            {
                newPosition.x += Variables.unityUnit;
            }
            else if (rotation == directions.west)
            {
                newPosition.z -= Variables.unityUnit;
            }
            else
            {
                newPosition.z += Variables.unityUnit;
            }
            break;

        case directions.right:
            if (rotation == directions.north)
            {
                newPosition.x += Variables.unityUnit;
            }
            else if (rotation == directions.south)
            {
                newPosition.x -= Variables.unityUnit;
            }
            else if (rotation == directions.west)
            {
                newPosition.z += Variables.unityUnit;
            }
            else
            {
                newPosition.z -= Variables.unityUnit;
            }
            break;

        default:
            break;
        }

        if (newPosition.x <= ((Variables.mapXWidth - 1) * Variables.unityUnit) && newPosition.z <= ((Variables.mapYWidth - 1) * Variables.unityUnit))
        {
            if (newPosition.x < 0 || newPosition.z < 0)
            {
                return;
            }
        }

        foreach (var item in gameMap.ListOfFloorTiles)
        {
            FloorTile floorTile = item.GetComponent <FloorTile>();
            if (floorTile.position == new Vector3(newPosition.x, 0, newPosition.z))
            {
                floorTile.hasWalked     = true;
                this.transform.position = newPosition;
                Debug.Log("Moved to position: " + newPosition);
            }
        }
    }
Exemple #47
0
    public Position randomDirection()
    {
        bool[] ar = new bool[] {false,false,false,false};
        Position Chosen;
        Chosen.x = 0;
        Chosen.y = 0;

        while( !ar[0] || !ar[1] || !ar[2] || !ar[3] )
        {
            int random = UnityEngine.Random.Range(0,4);;
            if ( random == 0 && !ar[0])
            {
                ar[0] = true;

                if (current.x > 0 && maze[current.x - 1,current.y].visited == false)
                {
                    aDirection = directions.Up;
                    Chosen.x--;
                    return Chosen;
                }
            }
            else if (random == 1 && !ar[1] )
            {
                ar[1] = true;

                if ( current.y < ( sizeOfMap - 1) && maze[current.x,current.y + 1].visited == false)
                {
                    aDirection = directions.Right;
                    Chosen.y++;
                    return Chosen;
                }
            }
            else if (random == 2 && !ar[2] )
            {
                ar[2] = true;

                if (current.x <(sizeOfMap  - 1) && maze[current.x + 1,current.y].visited == false)
                {
                    aDirection = directions.Down;
                    Chosen.x++;
                    return Chosen;
                }
            }
            else if (random == 3 && !ar[3] )
            {
                ar[3] = true;

                if (current.y > 0 && maze[current.x,current.y - 1].visited == false)
                {
                    aDirection = directions.Left;
                    Chosen.y--;
                    return Chosen;
                }
            }
        }
        Chosen.x = -1;
        Chosen.y = -1;
        return Chosen;
    }
Exemple #48
0
    private void ChangeCurPanel(directions d)
    {
        if (ftueActive || uiController.disableButtons || uiController.isSleeping)
        {
            return;
        }

        if (d == directions.up)
        {
            if (curPanel.isBack || (curPanel.upNeighbor.isVideo && videoOptions.mediaController.disableVideoOptions))
            {
                return;
            }
            else if (curPanel.upNeighbor != null && curPanel.upNeighbor.isVideo)
            {
                ShowVideoOptions();
                indicator.SetActive(false);
                prevPanel = curPanel;
                curPanel  = curPanel.upNeighbor ?? curPanel;
                moveIndicator();
            }
            else if (prevPanel == null)
            {
                curPanel = curPanel.upNeighbor ?? curPanel;
                if (viewPort.activeInHierarchy && indicator.transform.localPosition.y > -84 && viewPort.transform.localPosition.y > 50)
                {
                    var curPos = viewPort.transform.localPosition;
                    viewPort.transform.localPosition = new Vector3(curPos.x, curPos.y - 131, curPos.z);
                }
                moveIndicator();
            }
        }
        else if (d == directions.right)
        {
            if (curPanel.isVideo)
            {
                curPanel = curPanel.rightNeighbor ?? curPanel;
                moveIndicator();
            }
            else if (prevPanel != null)
            {
                backIndicator.SetActive(false);
                indicator.SetActive(true);
                curPanel  = prevPanel;
                prevPanel = null;
            }
            else
            {
                curPanel = curPanel.rightNeighbor ?? curPanel;
                moveIndicator();
            }
        }
        else if (d == directions.down)
        {
            if (curPanel.isBack)
            {
                return;
            }
            else if (prevPanel != null)
            {
                HideOptions();
                vidOptionsIndicator.SetActive(false);
                indicator.SetActive(true);
                curPanel  = prevPanel;
                prevPanel = null;
            }
            else
            {
                curPanel = curPanel.downNeighbor ?? curPanel;
                if (viewPort.activeInHierarchy && indicator.transform.localPosition.y < -200 && viewPort.transform.localPosition.y < 280)
                {
                    var curPos = viewPort.transform.localPosition;
                    viewPort.transform.localPosition = new Vector3(curPos.x, curPos.y + 131, curPos.z);
                }
                moveIndicator();
            }
        }
        else if (d == directions.left)
        {
            if (curPanel.isVideo)
            {
                curPanel = curPanel.leftNeighbor ?? curPanel;
                moveIndicator();
            }
            else if (curPanel.leftNeighbor != null && curPanel.leftNeighbor.isBack)
            {
                backIndicator.SetActive(true);
                indicator.SetActive(false);
                prevPanel = curPanel;
                curPanel  = curPanel.leftNeighbor ?? curPanel;
            }
            else
            {
                curPanel = curPanel.leftNeighbor ?? curPanel;
                moveIndicator();
            }
        }
        else if (d == directions.click)
        {
            indicator.SetActive(false);
            if (curPanel != null && !curPanel.isVideo)
            {
                prevPanel = null;
            }
            curPanel.thisButton.onClick.Invoke();
            backIndicator.SetActive(false);
        }
    }
    // Used to generate a random direction and check to see if it's a valid direction
    private Position randomDirection()
    {
        bool[] ar = new bool[] {false,false,false,false};
        Position Chosen;
        Chosen.x = 0;
        Chosen.y = 0;

        while( !ar[0] || !ar[1] || !ar[2] || !ar[3] ) // Checks to see if any walls can be broken down
        {
            int random = UnityEngine.Random.Range(0,4);;
            if ( random == 0 && !ar[0])
            {
                ar[0] = true;

                if (current.x > 0 && maze[current.x - 1,current.y].visited == false) // Checks if we aren't at top border
                {
                    aDirection = directions.Up;
                    Chosen.x--;
                    return Chosen;
                }
            }
            else if (random == 1 && !ar[1] ) // Checks if we aren't at right border
            {
                ar[1] = true;

                if ( current.y < ( sizeOfMap - 1) && maze[current.x,current.y + 1].visited == false)
                {
                    aDirection = directions.Right;
                    Chosen.y++;
                    return Chosen;
                }
            }
            else if (random == 2 && !ar[2] ) // Checks if we aren't at bottom border
            {
                ar[2] = true;

                if (current.x <(sizeOfMap  - 1) && maze[current.x + 1,current.y].visited == false)
                {
                    aDirection = directions.Down;
                    Chosen.x++;
                    return Chosen;
                }
            }
            else if (random == 3 && !ar[3] ) // Checks if we aren't at the left border
            {
                ar[3] = true;

                if (current.y > 0 && maze[current.x,current.y - 1].visited == false)
                {
                    aDirection = directions.Left;
                    Chosen.y--;
                    return Chosen;
                }
            }
        }
        Chosen.x = -1; // Can't move anywhere so we must go back
        Chosen.y = -1;
        return Chosen;
    }
Exemple #50
0
 void Update()
 {
     //move
     if (Input.GetKeyDown(KeyCode.LeftArrow)) dir = directions.LEFT;
     if (Input.GetKeyDown(KeyCode.RightArrow)) dir = directions.RIGHT;
     if (Input.GetKeyDown(KeyCode.UpArrow)) dir = directions.UP;
     if (Input.GetKeyDown(KeyCode.DownArrow)) dir = directions.DOWN;
 }
Exemple #51
0
 void SwitchDirection()
 {
     if (currentDirection == directions.Right) currentDirection = directions.Left;
     else if (currentDirection == directions.Left) currentDirection = directions.Right;
 }