예제 #1
0
    public static Direction ToDirection(this NpcDirection dir)
    {
        switch (dir)
        {
        case NpcDirection.South:
            return(Direction.South);

        case NpcDirection.SouthWest:
            return(Direction.SouthWest);

        case NpcDirection.West:
            return(Direction.West);

        case NpcDirection.NorthWest:
            return(Direction.NorthWest);

        case NpcDirection.North:
            return(Direction.North);

        case NpcDirection.NorthEast:
            return(Direction.NorthEast);

        case NpcDirection.East:
            return(Direction.East);

        case NpcDirection.SouthEast:
            return(Direction.SouthEast);

        case NpcDirection.None:
        default:
            return(Direction.South);
        }
    }
예제 #2
0
 private void SetWndDirection(NpcDirection direction)
 {
     m_direction = direction;
     if (direction == NpcDirection.Right)
     {
         MyHead.Parent.localScale = new Vector3(-1f, 1f, 1f);
         MyHead.MainBg.localScale = new Vector3(-1f, 1f, 1f);
         MyHead.PanelMask.transform.localScale = new Vector3(-1f, 1f, 1f);
         Vector3 lPos = MyHead.MainBg.localPosition;
         if (lPos.x < 0)
         {
             MyHead.MainBg.localPosition = new Vector3(-lPos.x, lPos.y, lPos.z);
         }
     }
     else
     {
         MyHead.Parent.localScale = new Vector3(1f, 1f, 1f);
         MyHead.MainBg.localScale = new Vector3(1f, 1f, 1f);
         MyHead.PanelMask.transform.localScale = new Vector3(1f, 1f, 1f);
         Vector3 lPos = MyHead.MainBg.localPosition;
         if (lPos.x > 0)
         {
             MyHead.MainBg.localPosition = new Vector3(-lPos.x, lPos.y, lPos.z);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Moves all enemies on the screen.
        /// </summary>
        private void MoveEnemies()
        {
            // Don't move all the time.
            if (_moveEnemiesAfter < _difficulty.MoveEnemySpeed)
            {
                _moveEnemiesAfter++;
                return;
            }

            _moveEnemiesAfter = 0;
            int modX = 0, modY = 0;

            switch (_currentNpcDirection)
            {
            case NpcDirection.Left:
                modX = 1;
                _currentNpcDirection = NpcDirection.Right;
                break;

            case NpcDirection.Right:
                modX = -1;
                _currentNpcDirection = NpcDirection.Left;
                break;

            case NpcDirection.Down:
                modY = 1;
                _currentNpcDirection = NpcDirection.Left;
                break;
            }

            for (var enemyRow = 0; enemyRow < EnemyLines; enemyRow++)
            {
                MoveTheEnemy(enemyRow, modX, modY);
            }
        }
예제 #4
0
        public NpcActorModule(BaseNpc Master)
            : base(Master)
        {
            Animation_ = new NpcAnimation(Master.GetComponent <Animator>());
            Fsm_       = new BaseFsm(Master);

            Direction = NpcDirection.Right;
        }
예제 #5
0
    public static void UpdateNPCPanelValue(UIPanel panel, float toValue, NpcDirection direction = NpcDirection.Left)
    {
        float from = panel.clipOffset.x;

        if (direction == NpcDirection.Right)
        {
            from = -from;
        }
    }
예제 #6
0
        private void Prepare()
        {
            _score = 0;
            _currentNpcDirection = NpcDirection.Left;
            _moveEnemiesAfter    = 0;

            // Get start position
            _spaceShip.PositionX = (Console.WindowWidth / 2) - 2;
            _spaceShip.PositionY = Console.WindowHeight - 1;

            _shots = new Shots();
        }
예제 #7
0
        public void SetDirection(NpcDirection Dir)
        {
            if (Direction == Dir)
            {
                return;
            }

            Direction = Dir;
            switch (Direction)
            {
            case NpcDirection.Left:
                Master.GetComponent <SpriteRenderer>().flipX = true;
                break;

            case NpcDirection.Right:
                Master.GetComponent <SpriteRenderer>().flipX = false;
                break;

            default:
                break;
            }
        }
예제 #8
0
    /// <summary>
    /// 设置窗口的九种位置
    /// </summary>
    private void SetWndAlign(UIWidget.Pivot align, NpcDirection direction)
    {
        if (direction == NpcDirection.Left)
        {
            MyHead.SprMainBgLeft.pivot = align;
        }

        switch (align)
        {
        case UIWidget.Pivot.Left:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.Left;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.Left;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.Right;
            }
            break;

        case UIWidget.Pivot.Right:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.Right;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.Right;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.Left;
            }
            break;

        case UIWidget.Pivot.Top:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.Top;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.Top;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.Top;
            }
            break;

        case UIWidget.Pivot.Bottom:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.Bottom;
            }
            else
            {
                MyHead.WndAnchorRight.side = UIAnchor.Side.Bottom;
            }
            break;

        case UIWidget.Pivot.TopLeft:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.TopLeft;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.TopLeft;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.TopRight;
            }
            break;

        case UIWidget.Pivot.TopRight:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.TopRight;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.TopRight;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.TopLeft;
            }
            break;

        case UIWidget.Pivot.BottomLeft:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.BottomLeft;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.BottomLeft;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.BottomRight;
            }
            break;

        case UIWidget.Pivot.BottomRight:
            if (direction == NpcDirection.Left)
            {
                MyHead.WndAnchorLeft.side = UIAnchor.Side.BottomRight;
            }
            else
            {
                MyHead.WndAnchorRight.side  = UIAnchor.Side.BottomRight;
                MyHead.SprMainBgRight.pivot = UIWidget.Pivot.BottomLeft;
            }
            break;
        }
    }