Esempio n. 1
0
        /// <summary>
        /// Konstruktor szescioparametrowy. Tworzy
        /// nowy bunkier drewniany na planszy.
        /// </summary>
        /// <param name="yBegin">Poczatek bunkru.</param>
        /// <param name="yEnd">Koniec bunkru.</param>
        /// <param name="hitBound">Prostokat opisujacy bunkier.</param>
        /// <param name="soldierNum">Liczba zolnierzy.</param>
        /// <param name="type">Typ bunkru.</param>
        /// <param name="collisionRectangle">Lista prostokatow z ktorymi moga wystapic zderzenia.</param>
        public FlakBunkerTile(float yBegin, float yEnd, float viewXShift, Quadrangle hitBound, int soldierNum, int generalNum, int type,
                              List <Quadrangle> collisionRectangle)
            : base(yBegin, yEnd, viewXShift, hitBound, soldierNum, generalNum, type, collisionRectangle)
        {
            //instalacja przy starcie nie jest zniszczona.
            enemyState = EnemyInstallationState.Intact;
            //pole razenia Ustawione podczas ustawiania indeksu.
            horizon     = null;
            currentTime = 0;


            initialDirection = Model.Level.Direction.Right;

            direction = initialDirection;
            OnDirectionChanged();
        }
Esempio n. 2
0
        protected void  YRotation(int time, float timeUnit)
        {
            if (this.IsDestroyed)
            {
                return;
            }
            if (direction == Direction.Right)
            {
                if (Mathematics.IndexToPosition(this.TileIndex) > this.refToLevel.UserPlane.Position.X)
                {
                    direction       = Direction.Changing;
                    changeDirection = Direction.Left;
                }
            }

            if (direction == Direction.Left)
            {
                if (Mathematics.IndexToPosition(this.TileIndex) < this.refToLevel.UserPlane.Position.X)
                {
                    direction       = Direction.Changing;
                    changeDirection = Direction.Right;
                }
            }
            float scaleFactor = time / timeUnit;

            if (direction == Direction.Changing)
            {
                float dir = changeDirection != initialDirection ? 1 : -1;

                yAngle += dir * DirectionChangePerSecond * scaleFactor;
                bool completed = false;
                if (dir == 1 && yAngle >= Mogre.Math.PI)
                {
                    completed = true;
                    yAngle    = Mogre.Math.PI;
                }

                if (dir == -1 && yAngle <= 0)
                {
                    completed = true;
                    yAngle    = 0;
                }

                if (completed)
                {
                    adjustingBarrelAfterDirectionChange = true;
                    if (changeDirection.HasValue)
                    {
                        if (changeDirection == Direction.Left)
                        {
                            direction = Model.Level.Direction.Left;
                        }
                        else if (changeDirection == Direction.Right)
                        {
                            direction = Model.Level.Direction.Right;
                        }
                        OnDirectionChanged();
                    }
                    changeDirection = null;
                }
            }

            //   Console.WriteLine("direction: " + direction + ";  changeDirection: " + changeDirection + "; yAngle:" + yAngle+"; adjustingBarrelAfterDirectionChange: " + adjustingBarrelAfterDirectionChange );
        }