Exemple #1
0
        public void Rotate(Vector3 target)
        {
            var vector = target - transform.position;

            transform.rotation = Quaternion.LookRotation(vector);
            RotateAction?.Invoke(target);
        }
Exemple #2
0
        public PartyTurnActor()
        {
            MoveAction     moveAction     = new MoveAction(m_activeActions);
            RotateAction   rotateAction   = new RotateAction(m_activeActions);
            RestAction     restAction     = new RestAction();
            InteractAction interactAction = new InteractAction();
            SelectNextInteractiveObjectAction selectNextInteractiveObjectAction = new SelectNextInteractiveObjectAction();

            m_actions = new BaseAction[4][];
            for (Int32 i = 0; i < m_actions.Length; i++)
            {
                m_actions[i]     = new BaseAction[11];
                m_actions[i][0]  = moveAction;
                m_actions[i][1]  = rotateAction;
                m_actions[i][6]  = restAction;
                m_actions[i][2]  = interactAction;
                m_actions[i][10] = selectNextInteractiveObjectAction;
                m_actions[i][3]  = new MeleeAttackAction(i);
                m_actions[i][4]  = new RangedAttackAction(i);
                m_actions[i][9]  = new CastSpellAction(i);
                m_actions[i][5]  = new ConsumeItemAction(i);
                m_actions[i][8]  = new DefendAction(i);
                m_actions[i][7]  = new EquipAction(i);
            }
        }
        private void btnRotate_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem;

            RotateType = toolStripMenuItem?.Name;
            RotateAction?.Invoke();
        }
Exemple #4
0
    public bool OnTouchPressed(Vector3 position)
    {
        if (!_isInteractable)
        {
            return(false);
        }

        _isTouchInside = Contains(position);

        if (_isTouchInside)
        {
            if (_quantity > 0)
            {
                OnSelected();
            }
            else if (_quantity < 0)
            {
                _lock.StopAction();
                _lock.transform.SetRotation(0);

                _lock.Play(SequenceAction.Create(RotateAction.RotateBy(45.0f, 0.1f), RotateAction.RotateBy(-90.0f, 0.2f), RotateAction.RotateBy(45.0f, 0.1f)));
            }

            _listener.OnBoosterPressed(this);

            return(true);
        }

        return(false);
    }
Exemple #5
0
    void Start()
    {
        gameObject.Play(RotateAction.Create(end, isRelative, duration, Ease.FromType(easeType), direction));

        // Self-destroy
        Destroy(this);
    }
Exemple #6
0
        /// <summary>
        /// Transforms an orientation using a rotate or flip action, yielding a new orientation
        /// </summary>
        /// <param name="original">Orientation before action</param>
        /// <param name="action">Rotate or flip action to perform</param>
        /// <returns>Orientation after action</returns>
        public static Orientation RotateOrientation(Orientation original, RotateAction action)
        {
            switch (action)
            {
            case RotateAction.None:
                return(original);

            case RotateAction.TurnRight:
                return((Orientation)(((int)original + 2) % 8));

            case RotateAction.TurnAround:
                return(original ^ Orientation.UpsideDown);

            case RotateAction.TurnLeft:
                return((Orientation)(((int)original + 6) % 8));

            case RotateAction.FlipHorizontal:
                return(original ^ Orientation.Flip ^ (Orientation)((int)(original & Orientation.Right) << 1));

            case RotateAction.FlipTopRight:
                return(original ^ Orientation.RightFlip);

            case RotateAction.FlipVertical:
                return(original ^ Orientation.UpsideDownFlip ^ (Orientation)((int)(original & Orientation.Right) << 1));

            case RotateAction.FlipTopLeft:
                return(original ^ Orientation.LeftFlip);

            default:
                throw new ArgumentException("Action value was invalid", nameof(action));
            }
        }
        private void Gizmo_TransformationChanged(object sender, TransformationEvent transformationEvent)
        {
            switch (transformationEvent)
            {
            case TransformationEvent.TranslationStarted:
                TranslateAction translation = new TranslateAction(_vm.SelectedEntities, _vm);
                translation.TransformStartPoint         = _vm.SelectionLocation;
                GlobalManagement.Instance.CurrentAction = translation;
                break;

            case TransformationEvent.TranslationEnded:
                GlobalManagement.Instance.UndoStack.Push(GlobalManagement.Instance.CurrentAction);
                GlobalManagement.Instance.CurrentAction = null;
                break;

            case TransformationEvent.RotationStarted:
                RotateAction rotation = new RotateAction(_vm.SelectedEntities, _vm);
                mouseHandlingMode      = MouseHandlingMode.RotateObject;
                rotation.StartRotation = _vm.GizmoOrientation;
                rotation.PivotPoint    = _vm.SelectionLocation;
                GlobalManagement.Instance.CurrentAction = rotation;
                break;

            case TransformationEvent.RotationEnded:
                mouseHandlingMode = MouseHandlingMode.None;
                GlobalManagement.Instance.UndoStack.Push(GlobalManagement.Instance.CurrentAction);
                GlobalManagement.Instance.CurrentAction = null;
                break;
            }
        }
Exemple #8
0
        public void Run_ShouldNotThrowException__IfRobotNotPlaced()
        {
            _robot.Position = null;
            var action = new RotateAction(_robot, _mapProvider, RotateDirection.Left);

            action.Run();
        }
Exemple #9
0
    public BaseAction GetAction()
    {
        if (actionType == ActionType.Move)
        {
            return(MoveAction.Create(v31, b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Scale)
        {
            return(ScaleAction.Create(v31, b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Rotate)
        {
            return(RotateAction.Create(f1, b1, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Fade)
        {
            return(FadeAction.Create(f1, b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Tint)
        {
            return(TintAction.Create(c1.RGB(), b1, b2, duration, Ease.FromType(easeType), direction));
        }

        if (actionType == ActionType.Delay)
        {
            return(DelayAction.Create(duration));
        }

        return(null);
    }
Exemple #10
0
        private static RotateAction GetRotateAction(MultipleRecords multipleRecords)
        {
            var action = new RotateAction();

            action.Angle = SerializerHelper.GetAngle(multipleRecords);
            return(action);
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            m_RotateAction = (RotateAction)m_Action;

            m_AngleProp = serializedObject.FindProperty("m_Angle");
        }
Exemple #12
0
        public void Run_ShouldHandleMultipleActions()
        {
            var action = new RotateAction(_robot, _mapProvider, RotateDirection.Right);

            action.Run();
            action.Run();
            Assert.Equal(Direction.North, _robot.Direction);
        }
Exemple #13
0
        public void Run_ShouldNotChangePosition()
        {
            var action = new RotateAction(_robot, _mapProvider, RotateDirection.Left);

            action.Run();
            Assert.Equal(3, _robot.Position.Latitude);
            Assert.Equal(2, _robot.Position.Longitude);
        }
Exemple #14
0
        public void Run_ShouldUpdateDirection_WhenRotateLeft(Direction robotDirection, Direction expectedDirection)
        {
            _robot.Direction = robotDirection;
            var action = new RotateAction(_robot, _mapProvider, RotateDirection.Left);

            action.Run();
            Assert.Equal(expectedDirection, _robot.Direction);
        }
Exemple #15
0
 public void RotateToSelfGeneratesNoOps()
 {
     foreach (Orientation orientation in Enum.GetValues(typeof(Orientation)))
     {
         var actions = RotateAction.GenerateActions(orientation, orientation);
         Assert.IsEmpty(actions, "rotation 0 generates no actions");
     }
 }
Exemple #16
0
 void Rotate(int degrees)
 {
     if (!(app.Window.Focus is Gtk.Entry))
     {
         var action = new RotateAction(app.Document, app.IconView.SelectedPages, degrees);
         action.Do();
         undo_manager.AddUndoAction(action);
     }
 }
Exemple #17
0
        public void Rotate2StepsGenerates2Actions()
        {
            var actions = RotateAction.GenerateActions(Orientation.Top, Orientation.Bottom);

            Assert.AreEqual(2, actions.Length, "rotation 2 generates 2 actions");
            Assert.AreEqual(actions[0], actions[1], "both actions are the same");
            actions = RotateAction.GenerateActions(Orientation.Left, Orientation.Right);
            Assert.AreEqual(2, actions.Length, "rotation 2 generates 2 actions");
            Assert.AreEqual(actions[0], actions[1], "both actions are the same");
        }
Exemple #18
0
        public void Run_ShouldRotateToSameDirection()
        {
            var action = new RotateAction(_robot, _mapProvider, RotateDirection.Right);

            action.Run();
            action.Run();
            action.Run();
            action.Run();
            Assert.Equal(Direction.South, _robot.Direction);
        }
Exemple #19
0
    public void OnSelected()
    {
        if (!_isUnlocked)
        {
            _lock.StopAction();
            _lock.transform.SetRotation(0);

            _lock.Play(SequenceAction.Create(RotateAction.RotateBy(45.0f, 0.1f), RotateAction.RotateBy(-90.0f, 0.2f), RotateAction.RotateBy(45.0f, 0.1f)));
        }
    }
Exemple #20
0
    void Start()
    {
        gameObject.Play(RotateAction.Create(end.Variance(variance), isRelative, duration, Ease.FromType(easeType), direction),
                        () => {
            Debug.Log("Finish Rotate ACtion Scripts");
        }
                        );

        // Self-destroy
        Destroy(this);
    }
Exemple #21
0
        public void StartTransformAction(LocalOrientation localOrientation, DragActionType dragActionType, int part = -1, IRevertable revertable = null)
        {
            AbstractTransformAction transformAction;

            Vector3 pivot;

            draggingDepth = control.PickingDepth;
            if (part != -1)
            {
                pivot = localOrientation.Origin;
            }
            else
            {
                BoundingBox box = BoundingBox.Default;

                foreach (IEditableObject obj in GetObjects())
                {
                    obj.GetSelectionBox(ref box);
                }

                pivot = box.GetCenter();

                if (box == BoundingBox.Default)
                {
                    return;
                }
            }

            switch (dragActionType)
            {
            case DragActionType.TRANSLATE:
                transformAction = new TranslateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.ROTATE:
                transformAction = new RotateAction(control, control.GetMousePos(), pivot, draggingDepth);
                break;

            case DragActionType.SCALE:
                transformAction = new ScaleAction(control, control.GetMousePos(), pivot);
                break;

            case DragActionType.SCALE_INDIVIDUAL:
                transformAction = new ScaleActionIndividual(control, control.GetMousePos(), localOrientation);
                break;

            default:
                return;
            }

            StartTransformAction(transformAction, part, revertable);
        }
Exemple #22
0
        public void Rotate1StepGenerates1Action()
        {
            var actions = RotateAction.GenerateActions(Orientation.Top, Orientation.Right);

            Assert.AreEqual(1, actions.Length, "rotation 1 generates 1 action");
            Assert.AreEqual(RotateAction.Right, actions[0], "action is Right");
            actions = RotateAction.GenerateActions(Orientation.Top, Orientation.Left);
            Assert.AreEqual(1, actions.Length, "rotation 3 generates 1 action");
            Assert.AreEqual(RotateAction.Left, actions[0], "action[0] is Left");
            actions = RotateAction.GenerateActions(Orientation.Left, Orientation.Bottom);
            Assert.AreEqual(1, actions.Length, "rotation -1 generates 1 action");
            Assert.AreEqual(RotateAction.Left, actions[0], "action[0] is Left");
        }
    void Update()
    {
        ShmupController shmup  = ShmupController.Instance;
        float           spawnX = Random.Range(shmup.VerticalMarginSize, shmup.Width - shmup.VerticalMarginSize);

        if (Time.fixedTime >= nextSpawnTime)
        {
            GameObject enemy = Instantiate(baseEnemyPrefab, shmup.transform.position + new Vector3(spawnX, shmup.Height, 0), transform.rotation);
            enemy.transform.SetParent(ShmupController.Instance.transform);
            GameObject actionObject = enemy.transform.GetChild(0).gameObject;

            float rand = Random.Range(0, 100);
            if (rand <= 75f)
            {
                MoveAction action = actionObject.AddComponent <MoveAction>();
                action.MoveAmount = 1;
                float directionRand = Random.Range(0, 100);
                if (directionRand <= 40f)
                {
                    action.Direction = MoveAction.MoveDirection.Left;
                }
                else if (directionRand <= 80f)
                {
                    action.Direction = MoveAction.MoveDirection.Right;
                }
                else
                {
                    action.Direction = MoveAction.MoveDirection.Down;
                }
            }
            else
            {
                RotateAction action = actionObject.AddComponent <RotateAction>();
                switch ((int)Random.Range(0, 1.99f))
                {
                case 0:
                    action.Direction = RotateAction.RotateDirection.Clockwise;
                    break;

                default:
                    action.Direction = RotateAction.RotateDirection.CounterClockwise;
                    break;
                }
            }

            Rigidbody2D rb = enemy.GetComponent <Rigidbody2D>();
            rb.velocity = -transform.up * Random.Range(minMoveSpeed, maxMoveSpeed);

            nextSpawnTime = Time.fixedTime + Random.Range(minSpawnInterval, maxSpawnInterval);
        }
    }
        private void rotateToolStripButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                RotateAction action = new RotateAction(solutionsTree, solutionsCheckedListBox, solutionsCheckedListBox.SelectedSolutionNode);
                UndoRedoManager.Instance.SaveAndExecute(action);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
    void Awake()
    {
        _Draw._Cam   = Camera.main;
        lineMaterial = new Material(Shader.Find("Custom/GizmoShader"));

        transformAction = new TransformAction(this);
        rotateAction    = new RotateAction(this);
        scaleAction     = new ScaleAction(this);
        Item            = gameObject;
        CurrentScale    = Item.transform.localScale;



        TimerForArrows = TimerdelayForArrows;
    }
Exemple #26
0
    // 从from_block 拷贝颜色和位置等信息
    public void     relayFrom(StackBlock from_block)
    {
        this.setColorType(from_block.color_type);

        this.step                = from_block.step;
        this.next_step           = from_block.next_step;
        this.step_timer          = from_block.step_timer;
        this.swap_action         = from_block.swap_action;
        this.color_change_action = from_block.color_change_action;

        this.velocity = from_block.velocity;

        // 为了使其全局的位置不发生变化,计算偏移植
        this.position_offset = StackBlockControl.calcIndexedPosition(from_block.place) + from_block.position_offset - StackBlockControl.calcIndexedPosition(this.place);

        //this.position_offset = from_block.transform.position - StackBlockControl.calcIndexedPosition(this.place);
        // 如果按上面这样做,旋转的中心就会受到偏移的影响,这样是不对的
    }
Exemple #27
0
    // from_block から色や位置などをコピーする.
    public void     relayFrom(StackBlock from_block)
    {
        this.setColorType(from_block.color_type);

        this.step                = from_block.step;
        this.next_step           = from_block.next_step;
        this.step_timer          = from_block.step_timer;
        this.swap_action         = from_block.swap_action;
        this.color_change_action = from_block.color_change_action;

        this.velocity = from_block.velocity;

        // グローバルの位置がかわらないよう、オフセットを計算する.
        this.position_offset = StackBlockControl.calcIndexedPosition(from_block.place) + from_block.position_offset - StackBlockControl.calcIndexedPosition(this.place);

        //this.position_offset = from_block.transform.position - StackBlockControl.calcIndexedPosition(this.place);
        // 上こちらにすると、回転の中心をずらしたことの影響を受けてしまうのでだめ.
    }
Exemple #28
0
        public void Rotate(bool left)
        {
            if (this.rotateAction != null)
            {
                return;
            }

            this.rotationInfo = this.rotationInfo.GetRotated(left);
            this.UpdateCubeArray();

            Vector2 position = this.GetPostion();

            this.rotateAction = new RotateAction(
                figure: this.Figure,
                multiplier: left ? 1f : -1f,
                position: position,
                parameters: this.parameters.FigureRotation);

            this.rotateAction.Complete += () => this.rotateAction = null;
        }
Exemple #29
0
 void Rotate (int degrees)
 {
     if (!(app.Window.Focus is Gtk.Entry)) {
         var action = new RotateAction (app.Document, app.IconView.SelectedPages, degrees);
         action.Do ();
         undo_manager.AddUndoAction (action);
     }
 }
    void OnStart()
    {
        if (!FB.IsLoggedIn)
        {
            // Check to show login FB
            if (UserData.Instance.ShowLoginFBTimes < 3 &&
                !Manager.Instance.isShowLoginFB &&
                UserData.Instance.Level >= 10)
            {
                UserData.Instance.ShowLoginFBTimes++;
                Manager.Instance.isShowLoginFB = true;
                Manager.Instance.ShowConfirm("Connect Facebook", "Please connect with facebook to save your progress and see your friends",
                                             (isOK) =>
                {
                    if (isOK)
                    {
                        Debug.Log("Connect FB, choosse OK ...");
                        ConnectFacebook();

                        UserData.Instance.ShowLoginFBTimes = 3;
                    }
                    else
                    {
                        Debug.Log("Cancel, no connect FB ...");
                    }
                });
            }
        }

        if (!Manager.Instance.isShowNewVersion && UserData.Instance.Level >= 4)
        {
            SCross.Instance.ShowMessage("cyrus_bean_jump", "1.6.0", (result, message) => {
            });
            Manager.Instance.isShowNewVersion = true;
        }


        if (UserData.Instance.Level > 15)
        {
            SCross.Instance.GetImage("cyrus_bean_jump", (result, message) => {
                if (result)
                {
                    SCross.Instance.ShowPopupScross();
                }
            });
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        // Update Facebook
        FBManager.Instance.OnUpdate();

        // Play BGM
        SoundManager.Instance.PlayMusic(SoundID.MainMenu);

        // Sunlight
        if (sunlight != null)
        {
            // Get top
            float top = Camera.main.orthographicSize;

            // Get right
            float right = Camera.main.GetOrthographicWidth();

            sunlight.transform.position      = new Vector3(right - Random.Range(0.0f, 0.1f), top + 2.0f, 0);
            sunlight.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(240.0f, 250.0f));

            int count = sunlight.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                sunlight.transform.GetChild(i).localScale = new Vector3(Random.Range(9.0f, 10.0f), Random.Range(0.85f, 1.0f), 1.0f);
            }

            float startOpacity = Random.value * 0.1f;
            sunlight.SetAlpha(startOpacity, true);

            var rotate  = RotateAction.RotateBy(Random.Range(-20.0f, -25.0f), 18.0f, Ease.Linear, LerpDirection.PingPongForever);
            var fadeIn  = FadeAction.RecursiveFadeTo(Random.Range(0.6f, 0.7f), 18.0f);
            var delay1  = DelayAction.Create(6.0f);
            var fadeOut = FadeAction.RecursiveFadeTo(startOpacity, 18.0f);
            var delay2  = DelayAction.Create(6.0f);
            var fade    = SequenceAction.Create(fadeIn, delay1, fadeOut, delay2);
            var action  = ParallelAction.ParallelAll(rotate, RepeatAction.RepeatForever(fade, false));

            sunlight.Play(action);
        }

        // Get ignore raycast
        _ignoreRaycast = GameObject.FindObjectOfType <IgnoreRaycast>();

        if (!UserData.Instance.PlayedCutscene1)
        {
            UserData.Instance.PlayedCutscene1 = true;
            cutscene1.SetActive(true);
        }

        // Update Connect button
        UpdateConnectFacebook(true);

        googleAnalytics.LogScreen("Main Menu");

        _requestUpdater.Play(UpdateRequests);

        Manager.Instance.SetUpdateSendRequests(true);
    }
Exemple #31
0
 void AnimateRotateAction(RotateAction action)
 {
     AnimateRotation(action.dir);
 }