public void Init(string ctrlName, string skinName, float X, float Y, BoardManager board, int playerNb)
    {
        controllerName        = ctrlName;
        playersSkinName       = skinName;
        curentState           = EPlayerState.state_idle;
        curentOrientation     = EOrientation.up_left;
        currentLife           = maxLife;
        currentStamina        = maxStamina;
        hitAnimation          = false;
        deltaTimeHitAnimation = 0.0f;
        deltaBlinkAnimation   = 0.0f;

        boardMG = board;
        //
        // Put in start position
        posX         = X;
        posY         = Y;
        playerNumber = playerNb;
        boardMG.playerPos[playerNumber]          = new Vector2(X, Y);
        boardMG.playerPosCollision[playerNumber] = new Vector2(X, Y);
        offsetedCasePos = boardMG.map[(int)X, (int)Y].position;

        Vector2 screenPos = boardMG.gameMG.computeScreenPosFromBoard(offsetedCasePos.x, offsetedCasePos.y);

        Vector3 pos = transform.position;

        pos.x = screenPos.x;
        pos.y = screenPos.y + magicOffset;
        transform.position = pos;

        switchAnim();

        currentGameUI.SetActive(true);
        currentGameUI.GetComponent <playerUIScript>().Init();
    }
Exemple #2
0
 public OrientationTest(Line line, Point point, EOrientation expected)
 {
     m_Line       = line;
     m_Point      = point;
     m_Expected   = expected;
     m_Calculated = m_Point.Orientation(m_Line);
 }
Exemple #3
0
        public AEnnemy(SpriteManager s, EOrientation e) :
            base(s, e)
        {
            state_ = EState.ALIVE;

            deadTimer_ = TimeSpan.Zero;

            random_ = new Random();

            freePath_ = new Dictionary <EOrientation, bool>();

            freePath_.Add(EOrientation.DOWN, false);
            freePath_.Add(EOrientation.UP, false);
            freePath_.Add(EOrientation.RIGHT, false);
            freePath_.Add(EOrientation.LEFT, false);
            freePath_.Add(EOrientation.NEUTRAL, false);

            stateOrientationToSprite_ = new Dictionary <Tuple <EState, EOrientation>, SpriteManager.ESprite>();

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.UP), SpriteManager.ESprite.EYESUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.EYESDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.EYESLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.EYESRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.EYESDOWN);

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.UP), SpriteManager.ESprite.DEADENDINGUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.DEADENDINGDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.DEADENDINGLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.DEADENDINGRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.DEADENDINGDOWN);
        }
Exemple #4
0
        public AEnnemy(SpriteManager s, EOrientation e)
            : base(s, e)
        {
            state_ = EState.ALIVE;

            deadTimer_ = TimeSpan.Zero;

            random_ = new Random();

            freePath_ = new Dictionary<EOrientation, bool>();

            freePath_.Add(EOrientation.DOWN, false);
            freePath_.Add(EOrientation.UP, false);
            freePath_.Add(EOrientation.RIGHT, false);
            freePath_.Add(EOrientation.LEFT, false);
            freePath_.Add(EOrientation.NEUTRAL, false);

            stateOrientationToSprite_ = new Dictionary<Tuple<EState, EOrientation>, SpriteManager.ESprite>();

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.UP), SpriteManager.ESprite.EYESUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.EYESDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.EYESLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.EYESRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.EYESDOWN);

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.UP), SpriteManager.ESprite.DEADENDINGUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.DEADENDINGDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.DEADENDINGLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.DEADENDINGRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.DEADENDINGDOWN);
        }
Exemple #5
0
		public ScrollBar(Manager manager, EOrientation orientation)
			: base(manager) {
			this.orientation = orientation;
			CanFocus = false;


			if (orientation == EOrientation.Horizontal) {
				strButton = "ScrollBar.ButtonHorz";
				strRail = "ScrollBar.RailHorz";
				strSlider = "ScrollBar.SliderHorz";
				strGlyph = "ScrollBar.GlyphHorz";
				strMinus = "ScrollBar.ArrowLeft";
				strPlus = "ScrollBar.ArrowRight";

				MinimumHeight = 16;
				MinimumWidth = 46;
				Width = 64;
				Height = 16;
			} else {
				strButton = "ScrollBar.ButtonVert";
				strRail = "ScrollBar.RailVert";
				strSlider = "ScrollBar.SliderVert";
				strGlyph = "ScrollBar.GlyphVert";
				strMinus = "ScrollBar.ArrowUp";
				strPlus = "ScrollBar.ArrowDown";

				MinimumHeight = 46;
				MinimumWidth = 16;
				Width = 16;
				Height = 64;
			}

			btnMinus = new Button(Manager);
			btnMinus.Init();
			btnMinus.Text = "";
			btnMinus.MousePress += new MouseEventHandler(ArrowPress);
			btnMinus.CanFocus = false;

			btnSlider = new Button(Manager);
			btnSlider.Init();
			btnSlider.Text = "";
			btnSlider.CanFocus = false;
			btnSlider.MinimumHeight = 16;
			btnSlider.MinimumWidth = 16;

			btnPlus = new Button(Manager);
			btnPlus.Init();
			btnPlus.Text = "";
			btnPlus.MousePress += new MouseEventHandler(ArrowPress);
			btnPlus.CanFocus = false;

			btnSlider.Move += new MoveEventHandler(btnSlider_Move);

			Add(btnMinus);
			Add(btnSlider);
			Add(btnPlus);
		}
        public static bool Intersects(Line a, Line b)
        {
            EOrientation baa = Orientation(b.A, a);
            EOrientation bba = Orientation(b.B, a);
            EOrientation aab = Orientation(a.A, b);
            EOrientation abb = Orientation(a.B, b);

            return((baa != bba && aab != abb) || (baa == EOrientation.On && aab == EOrientation.On));
        }
 /// <summary>
 /// The constructor of the Robot which sets the robotPosition and orientationEnum
 /// </summary>
 /// <param name="position">robotPosition</param>
 /// <param name="orientation">Orientation</param>
 /// <created>Stef Chappin</created>
 private Robot(EOrientation orientation, Map map)
 {
     xPosition = map.spawn.x;
     yPosition = map.spawn.y;
     orientationEnum = orientation;
     level = map;
     inventory = new List<string> ();
     goals = getGoals ();
 }
        /// <summary>
        /// do some damage to other ships?
        /// </summary>
        public void fu_ProcessCannons(EGameStage _moveStep)
        {
            Debug.Log("in processCannons");
            CPlayer player          = CGameController.Get.mu_PlayerDict[mu_deviceId];
            bool    portCannon      = false;
            bool    starboardCannon = false;

            switch (_moveStep)
            {
            case EGameStage.MOVE_1:
            {
                portCannon      = player.pu_movement1LeftMode == 2;
                starboardCannon = player.pu_movement1RightMode == 2;
            }
            break;

            case EGameStage.MOVE_2:
            {
                portCannon      = player.pu_movement2LeftMode == 2;
                starboardCannon = player.pu_movement2RightMode == 2;
            }
            break;

            case EGameStage.MOVE_3:
            {
                portCannon      = player.pu_movement3LeftMode == 2;
                starboardCannon = player.pu_movement3RightMode == 2;
            }
            break;

            case EGameStage.MOVE_4:
            {
                portCannon      = player.pu_movement4LeftMode == 2;
                starboardCannon = player.pu_movement4RightMode == 2;
            }
            break;
            }

            Debug.Log("port = " + portCannon.ToString() + " starboard = " + starboardCannon.ToString());
            int xStep = 0;
            int yStep = 0;

            if (starboardCannon)
            {
                EOrientation or = (EOrientation)(((int)pu_orientation + 1) % (int)EOrientation.MAX_ORIENTATION);
                fi_GetOffsetForOrientation(or, out xStep, out yStep);
                fi_TryShootEnemyShip(xStep, yStep, 3);
            }
            if (portCannon)
            {
                EOrientation or = (EOrientation)(((int)pu_orientation + (int)EOrientation.MAX_ORIENTATION - 1) % (int)EOrientation.MAX_ORIENTATION);
                fi_GetOffsetForOrientation(or, out xStep, out yStep);
                fi_TryShootEnemyShip(xStep, yStep, 3);
            }
//            ((CShipEntityView)mu_view).fu_FireCannons(portCannon, starboardCannon);
            ((CShipEntityView)mu_view).fu_FireCannons(true, true);
        }
        /// <summary>
        /// try tossing a hook and perhaps pull some other ship closer
        /// </summary>
        public void fu_ProcessHooks(EGameStage _moveStage)
        {
            CPlayer player        = CGameController.Get.mu_PlayerDict[mu_deviceId];
            bool    portHook      = false;
            bool    starboardHook = false;

            switch (_moveStage)
            {
            case EGameStage.MOVE_1:
            {
                portHook      = player.pu_movement1LeftMode == 2;
                starboardHook = player.pu_movement1RightMode == 2;
            }
            break;

            case EGameStage.MOVE_2:
            {
                portHook      = player.pu_movement2LeftMode == 2;
                starboardHook = player.pu_movement2RightMode == 2;
            }
            break;

            case EGameStage.MOVE_3:
            {
                portHook      = player.pu_movement3LeftMode == 2;
                starboardHook = player.pu_movement3RightMode == 2;
            }
            break;

            case EGameStage.MOVE_4:
            {
                portHook      = player.pu_movement4LeftMode == 2;
                starboardHook = player.pu_movement4RightMode == 2;
            }
            break;
            }

            int xStep = 0;
            int yStep = 0;

            if (starboardHook)
            {
                EOrientation or = (EOrientation)(((int)pu_orientation + 1) % (int)EOrientation.MAX_ORIENTATION);
                fi_GetOffsetForOrientation(or, out xStep, out yStep);
                fi_TryHookEnemyShip(xStep, yStep, 2);
            }
            if (portHook)
            {
                EOrientation or = (EOrientation)(((int)pu_orientation + (int)EOrientation.MAX_ORIENTATION - 1) % (int)EOrientation.MAX_ORIENTATION);
                fi_GetOffsetForOrientation(or, out xStep, out yStep);
                fi_TryHookEnemyShip(xStep, yStep, 2);
            }
        }
Exemple #10
0
 public ACharacter(SpriteManager s, EOrientation e)
 {
     orientation_ = EOrientation.NEUTRAL;
     totalElapsedTime_ = new TimeSpan();
     timePerFrame_ = new TimeSpan(1000000);
     blocked_ = true;
     orientationToSprite_ = new Dictionary<EOrientation, SpriteManager.ESprite>();
     spriteManager_ = s;
     atIntersection_ = false;
     hitBox_ = new Rectangle((int)position_.X + 4, (int)position_.Y + 4, 8, 8);
     destination_ = e;
     speedPerSec_ = 60;
 }
Exemple #11
0
 public ACharacter(SpriteManager s, EOrientation e)
 {
     orientation_         = EOrientation.NEUTRAL;
     totalElapsedTime_    = new TimeSpan();
     timePerFrame_        = new TimeSpan(1000000);
     blocked_             = true;
     orientationToSprite_ = new Dictionary <EOrientation, SpriteManager.ESprite>();
     spriteManager_       = s;
     atIntersection_      = false;
     hitBox_      = new Rectangle((int)position_.X + 4, (int)position_.Y + 4, 8, 8);
     destination_ = e;
     speedPerSec_ = 60;
 }
Exemple #12
0
    public static EOrientation inverseOrientation(EOrientation orientation)
    {
        switch (orientation)
        {
        default:
        case EOrientation.UP:
            return(EOrientation.DOWN);

        case EOrientation.DOWN:
            return(EOrientation.UP);

        case EOrientation.LEFT:
            return(EOrientation.RIGHT);

        case EOrientation.RIGHT:
            return(EOrientation.LEFT);
        }
    }
    private void LateUpdate()
    {
        Canvas.ForceUpdateCanvases();
        bool shouldResize = false;

        if (Contents.Exists(ct => ct.Top.hasChanged || ct.Bottom.hasChanged))
        {
            shouldResize = true;
        }
        if ((OldTopMargin != TopMargin || OldLeftMargin != LeftMargin) && Contents.Count > 0)
        {
            Contents[0].Top.anchoredPosition = Vector2.Scale(Vector2.down + Vector2.right, OpenMarginV);
            shouldResize = true;
        }
        if ((OldBottomMargin != BottomMargin || OldRightMargin != RightMargin) && Contents.Count > 0)
        {
            shouldResize = true;
        }
        if ((OldPadding != Padding || OldOrientation != Orientation) && Contents.Count > 0)
        {
            foreach (ContentTransform content in Contents.Skip(1))
            {
                content.Top.anchorMin        = Orientation == EOrientation.TopToBottom ? Vector2.zero : Vector2.one;
                content.Top.anchorMax        = content.Top.anchorMin;
                content.Top.anchoredPosition = PaddingV;
            }
            shouldResize = true;
        }


        if (shouldResize)
        {
            ResizeToFitContent();
        }

        OldTopMargin    = TopMargin;
        OldBottomMargin = BottomMargin;
        OldLeftMargin   = LeftMargin;
        OldRightMargin  = RightMargin;

        OldPadding     = Padding;
        OldOrientation = Orientation;
    }
Exemple #14
0
 public void SetOrientation(EOrientation orien)
 {
     if (orien == EOrientation.Landscape_Left)
     {
         transform.localEulerAngles = new Vector3(0, 0, 90);
     }
     else if (orien == EOrientation.Landscape_Right)
     {
         transform.localEulerAngles = new Vector3(0, 0, -90);
     }
     else if (orien == EOrientation.Portrait_Down)
     {
         transform.localEulerAngles = new Vector3(0, 0, -180);
     }
     else // if( orien == EOrientation.Portrait )
     {
         transform.localEulerAngles = new Vector3(0, 0, 0);
     }
 }
        private void fi_GetOffsetForOrientation(EOrientation _orientation, out int _xOffset, out int _yOffset)
        {
            _xOffset = 0;
            _yOffset = 0;

            switch (_orientation)
            {
            case EOrientation.North:
            {
                _xOffset += 0;
                _yOffset += 1;
            }
            break;

            case EOrientation.East:
            {
                _xOffset += 1;
                _yOffset += 0;
            }
            break;

            case EOrientation.South:
            {
                _xOffset += 0;
                _yOffset += -1;
            }
            break;

            case EOrientation.West:
            {
                _xOffset += -1;
                _yOffset += 0;
            }
            break;

            case EOrientation.MAX_ORIENTATION:     // for center of swirl
                break;
            }
        }
Exemple #16
0
 public CRockEntity(int _x, int _y, EOrientation _orientation) : base(_x, _y, _orientation)
 {
 }
Exemple #17
0
 /// <summary>
 /// Check if the Robot can move towards an orientation at the Map
 /// </summary>
 /// <returns><c>true</c> If the Robot can move forward <c>false</c> If the Robot can't move forward</returns>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="orientation">Orientation.</param>
 /// <created>Stef Chappin</created>
 public bool checkCoordinates(int x, int y, EOrientation orientation)
 {
     var tile = map [y, x];
     switch (orientation) {
     case EOrientation.North:
         return tile.North;
     case EOrientation.East:
         return tile.East;
     case EOrientation.South:
         return tile.South;
     case EOrientation.West:
         return tile.West;
     default:
         return false;
     }
 }
Exemple #18
0
 public void setDestination(EOrientation eOrientation)
 {
     destination_ = eOrientation;
 }
Exemple #19
0
 public Form(EOrientation orientation = EOrientation.Vertical) : base(orientation)
 {
 }
Exemple #20
0
 public CSwirlCenterEntity(int _x, int _y, EOrientation _orientation) : base(_x, _y, _orientation)
 {
 }
Exemple #21
0
 public void setOrientation(EOrientation ort)
 {
     orientation_ = ort;
 }
 public LinearLayout(EOrientation orientation = EOrientation.Vertical)
 {
     Orientation = orientation;
 }
    void CheckInputs()
    {
        //
        // orientation inputs
        if (String.Compare(controllerName, "k") == 0)
        {
            if (Input.GetAxis("L_YAxis_" + controllerName) < 0)
            {
                curentOrientation = EOrientation.up_right;
                switchAnim();
            }
            else if (Input.GetAxis("L_YAxis_" + controllerName) > 0)
            {
                curentOrientation = EOrientation.down_left;
                switchAnim();
            }
            else if (Input.GetAxis("L_XAxis_" + controllerName) > 0)
            {
                curentOrientation = EOrientation.down_right;
                switchAnim();
            }
            else if (Input.GetAxis("L_XAxis_" + controllerName) < 0)
            {
                curentOrientation = EOrientation.up_left;
                switchAnim();
            }
        }
        else
        {
            if (Input.GetAxis("L_YAxis_" + controllerName) < 0 && Input.GetAxis("L_XAxis_" + controllerName) > 0)
            {
                curentOrientation = EOrientation.up_right;
                switchAnim();
            }
            else if (Input.GetAxis("L_YAxis_" + controllerName) > 0 && Input.GetAxis("L_XAxis_" + controllerName) < 0)
            {
                curentOrientation = EOrientation.down_left;
                switchAnim();
            }
            else if (Input.GetAxis("L_XAxis_" + controllerName) > 0 && Input.GetAxis("L_YAxis_" + controllerName) > 0)
            {
                curentOrientation = EOrientation.down_right;
                switchAnim();
            }
            else if (Input.GetAxis("L_XAxis_" + controllerName) < 0 && Input.GetAxis("L_YAxis_" + controllerName) < 0)
            {
                curentOrientation = EOrientation.up_left;
                switchAnim();
            }
        }


        //
        // actions inputs
        if (Input.GetButtonDown("A_" + controllerName) && currentStamina > closeAttackStamina)
        {
            curentState = EPlayerState.state_close_attack;
            switchAnim();
            StartCoroutine(WaitForAnimEnd(0.5f));
            float attX = 0, attY = 0;
            switch (curentOrientation)
            {
            case EOrientation.up_right:
                attX = posX; attY = posY + 1;
                break;

            case EOrientation.down_left:
                attX = posX; attY = posY - 1;
                break;

            case EOrientation.down_right:
                attX = posX - 1; attY = posY;
                break;

            case EOrientation.up_left:
                attX = posX + 1; attY = posY;
                break;
            }
            StartCoroutine(CheckPlayerCloseHit(0.25f, attX, attY));
            currentStamina -= closeAttackStamina;
        }
        else if (Input.GetButtonDown("X_" + controllerName))
        {
            int tmpPosY = (int)posY, tmpPosX = (int)posX;
            switch (curentOrientation)
            {
            case EOrientation.down_left:
                tmpPosY--;
                break;

            case EOrientation.down_right:
                tmpPosX--;
                break;

            case EOrientation.up_left:
                tmpPosX++;
                break;

            case EOrientation.up_right:
                tmpPosY++;
                break;
            }
            tryMoveTo((int)tmpPosX, (int)tmpPosY);
            switchAnim();
        }
        else if (Input.GetButtonDown("Y_" + controllerName))
        {
            if (isRangeAttackEnabled && Time.fixedTime >= attackZone.timeAttackCellDisplayed + attackZone.delayAttackCell)
            {
                isRangeAttackEnabled = false;

                curentState = EPlayerState.state_range_attack;
                switchAnim();
                currentStamina -= rangeAttackStamina;

                List <Vector2> atkPos = attackZone.DisplayAttackCell(new Vector2(posX, posY), 3, 3, 0, rangeAttackDelay);
                foreach (Vector2 pos in atkPos)
                {
                    StartCoroutine(CheckPlayerRangeHit(rangeAttackDelay, pos.x, pos.y));
                }
                StartCoroutine(WaitForAnimEnd(rangeAttackDelay));
            }
        }
        drawNextPosition();
    }
Exemple #24
0
        public ScrollBar(Manager manager, EOrientation orientation)
            : base(manager)
        {
            this.orientation = orientation;
            CanFocus         = false;


            if (orientation == EOrientation.Horizontal)
            {
                strButton = "ScrollBar.ButtonHorz";
                strRail   = "ScrollBar.RailHorz";
                strSlider = "ScrollBar.SliderHorz";
                strGlyph  = "ScrollBar.GlyphHorz";
                strMinus  = "ScrollBar.ArrowLeft";
                strPlus   = "ScrollBar.ArrowRight";

                MinimumHeight = 16;
                MinimumWidth  = 46;
                Width         = 64;
                Height        = 16;
            }
            else
            {
                strButton = "ScrollBar.ButtonVert";
                strRail   = "ScrollBar.RailVert";
                strSlider = "ScrollBar.SliderVert";
                strGlyph  = "ScrollBar.GlyphVert";
                strMinus  = "ScrollBar.ArrowUp";
                strPlus   = "ScrollBar.ArrowDown";

                MinimumHeight = 46;
                MinimumWidth  = 16;
                Width         = 16;
                Height        = 64;
            }

            btnMinus = new Button(Manager);
            btnMinus.Init();
            btnMinus.Text        = "";
            btnMinus.MousePress += new MouseEventHandler(ArrowPress);
            btnMinus.CanFocus    = false;

            btnSlider = new Button(Manager);
            btnSlider.Init();
            btnSlider.Text          = "";
            btnSlider.CanFocus      = false;
            btnSlider.MinimumHeight = 16;
            btnSlider.MinimumWidth  = 16;

            btnPlus = new Button(Manager);
            btnPlus.Init();
            btnPlus.Text        = "";
            btnPlus.MousePress += new MouseEventHandler(ArrowPress);
            btnPlus.CanFocus    = false;

            btnSlider.Move += new MoveEventHandler(btnSlider_Move);

            Add(btnMinus);
            Add(btnSlider);
            Add(btnPlus);
        }
Exemple #25
0
 public void setFreePath(EOrientation e)
 {
     freePath_[e] = true;
 }
    private EOrientation ComputeOrientation(Cell cell)
    {
        Cell backCell  = procGrid.GetCellInDirection(cell, EDirection.Back);
        Cell rightCell = procGrid.GetCellInDirection(cell, EDirection.Right);
        Cell frontCell = procGrid.GetCellInDirection(cell, EDirection.Front);
        Cell leftCell  = procGrid.GetCellInDirection(cell, EDirection.Left);

        bool back  = backCell != null && backCell.enabled;
        bool right = rightCell != null && rightCell.enabled;
        bool front = frontCell != null && frontCell.enabled;
        bool left  = leftCell != null && leftCell.enabled;

        EOrientation resultOrientation = EOrientation.Front;

        if (back && !right && !front && !left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (!back && right && !front && !left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (!back && !right && front && !left)
        {
            resultOrientation = EOrientation.Right;
        }
        else if (!back && !right && !front && left)
        {
            resultOrientation = EOrientation.Front;
        }

        else if (back && right && !front && !left)
        {
            resultOrientation = EOrientation.Left;
        }
        else if (back && !right && front && !left)
        {
            resultOrientation = EOrientation.Right;
        }
        else if (back && !right && !front && left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (!back && right && front && !left)
        {
            resultOrientation = EOrientation.Back;
        }
        else if (!back && right && !front && left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (!back && !right && front && left)
        {
            resultOrientation = EOrientation.Right;
        }

        else if (back && right && front && !left)
        {
            resultOrientation = EOrientation.Left;
        }
        else if (back && right && !front && left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (back && !right && front && left)
        {
            resultOrientation = EOrientation.Right;
        }
        else if (!back && right && front && left)
        {
            resultOrientation = EOrientation.Back;
        }

        else if (back && right && front && left)
        {
            resultOrientation = EOrientation.Front;
        }
        else if (!back && !right && !front && !left)
        {
            resultOrientation = EOrientation.Front;
        }

        return(resultOrientation);
    }
Exemple #27
0
 public CStreamEntity(int _x, int _y, EOrientation _orientation) : base(_x, _y, _orientation)
 {
 }
Exemple #28
0
 public AOceanEntity(int _x, int _y, EOrientation _orientation)
 {
     pu_x           = _x;
     pu_y           = _y;
     pu_orientation = _orientation;
 }
Exemple #29
0
 /// <summary>
 /// Creates an instance of the Robot
 /// </summary>
 /// <param name="position">robotPosition.</param>
 /// <param name="orientation">Orientation.</param>
 /// <created>Stef Chappin</created>
 public static Robot Create(EOrientation orientation, Map map)
 {
     instance = new Robot (orientation, map);
     return instance;
 }
Exemple #30
0
 public StackPanel(Manager manager, EOrientation orientation)
     : base(manager)
 {
     this.orientation = orientation;
     this.Color       = Color.Transparent;
 }
Exemple #31
0
		public StackPanel(Manager manager, EOrientation orientation)
			: base(manager) {
			this.orientation = orientation;
			this.Color = Color.Transparent;
		}
Exemple #32
0
 public void setFreePath(EOrientation e)
 {
     freePath_[e] = true;
 }
Exemple #33
0
 public void setOrientation(EOrientation ort)
 {
     orientation_ = ort;
 }
        public void fu_CreateOcean(int _numRocks, int _numSwirls, int _numStreams)
        {
            // first, distribute some rocks
            UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks);
            AOceanEntity entity = null;
            int          x;
            int          y;

            // make rocks
            for (int i = 0; i < _numRocks; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));
                entity = new CRockEntity(x, y, EOrientation.North);
                mi_entityList.Add(entity);
            }

            // make ships
            foreach (var kvp in CGameController.Get.mu_PlayerDict)
            {
                Debug.Log("Creating Ship!");

                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));

                EOrientation or = (EOrientation)UnityEngine.Random.Range(0, (int)EOrientation.MAX_ORIENTATION);

                int deviceId = kvp.Key;
                entity = new CShipEntity(x, y, or, deviceId);
                mi_entityList.Add(entity);

                Debug.Log("Ship " + entity.ToString() + " created!");
            }

            // make swirls
            for (int i = 0; i < _numSwirls; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fi_IsPlaceOccupiedForSwirl(x, y));

                // top row
                entity = new CSwirlClockEntity(x - 1, y - 1, EOrientation.East);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x, y - 1, EOrientation.East);
                mi_entityList.Add(entity);
                entity = new CSwirlClockEntity(x + 1, y - 1, EOrientation.South);
                mi_entityList.Add(entity);

                // center row
                entity = new CStreamEntity(x - 1, y, EOrientation.North);
                mi_entityList.Add(entity);
                entity = new CSwirlCenterEntity(x, y, EOrientation.MAX_ORIENTATION);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x + 1, y, EOrientation.South);
                mi_entityList.Add(entity);

                // bottom row
                entity = new CSwirlClockEntity(x - 1, y + 1, EOrientation.North);
                mi_entityList.Add(entity);
                entity = new CStreamEntity(x, y + 1, EOrientation.West);
                mi_entityList.Add(entity);
                entity = new CSwirlClockEntity(x + 1, y + 1, EOrientation.West);
                mi_entityList.Add(entity);
            }

            // make streams
            for (int i = 0; i < _numStreams; i++)
            {
                do
                {
                    x = UnityEngine.Random.Range((int)0, (int)mu_xSize);
                    y = UnityEngine.Random.Range((int)0, (int)mu_ySize);
                } while (fu_IsPlaceOccupied(x, y));

                EOrientation or = (EOrientation)UnityEngine.Random.Range(0, (int)EOrientation.MAX_ORIENTATION);
                entity = new CRockEntity(x, y, or);
                mi_entityList.Add(entity);
            }
        }
Exemple #35
0
 public GridLayout(int rows, EOrientation orientation) : base()
 {
     this.rows        = rows;
     this.orientation = orientation;
 }
Exemple #36
0
 /// <summary>
 /// Checks if a move in a certain direction is possible
 /// </summary>
 /// <returns><c>true</c>, if move is possible, <c>false</c> otherwise.</returns>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="canInstruction">Can instruction.</param>
 public bool checkMove(int x, int y, ECanInstructions canInstruction, EOrientation robotOrientation)
 {
     var tile = map [y, x];
     switch (canInstruction) {
     case ECanInstructions.Forward:
         switch (robotOrientation) {
         case EOrientation.North:
             return tile.North;
         case EOrientation.East:
             return tile.East;
         case EOrientation.South:
             return tile.South;
         case EOrientation.West:
             return tile.West;
         default:
             return false;
         }
     case ECanInstructions.Backward:
         switch (robotOrientation) {
         case EOrientation.North:
             return tile.South;
         case EOrientation.East:
             return tile.West;
         case EOrientation.South:
             return tile.North;
         case EOrientation.West:
             return tile.East;
         default:
             return false;
         }
     case ECanInstructions.Left:
         switch (robotOrientation) {
         case EOrientation.North:
             return tile.West;
         case EOrientation.East:
             return tile.North;
         case EOrientation.South:
             return tile.East;
         case EOrientation.West:
             return tile.South;
         default:
             return false;
         }
     case ECanInstructions.Right:
         switch (robotOrientation) {
         case EOrientation.North:
             return tile.East;
         case EOrientation.East:
             return tile.South;
         case EOrientation.South:
             return tile.West;
         case EOrientation.West:
             return tile.North;
         default:
             return false;
         }
     case ECanInstructions.None:
         return false;
     default:
         return false;
     }
 }
Exemple #37
0
 public void setDestination(EOrientation eOrientation)
 {
     destination_ = eOrientation;
 }
 public CShipEntity(int _x, int _y, EOrientation _orientation, int _deviceId) : base(_x, _y, _orientation)
 {
     mu_deviceId = _deviceId;
 }