public override bool OnSceneCreate()
    {
        switch (createState)
        {
        case CreateState.ResourceRequest:
            resourceRequestSet.Add("cube", ResourceType.AssetBundle);
            ResourceManager.Instance.RegisterRequestSet(
                RequestResourceLabel, resourceRequestSet);
            createState = CreateState.ResourceRequestWait;
            break;

        case CreateState.ResourceRequestWait:
            if (resourceRequestSet.IsComplete() == true)
            {
                Object prefab = ResourceManager.Instance.GetAssetBundle("cube");
                Debug.Log(prefab);
                instance = Object.Instantiate(prefab) as GameObject;
                instance.transform.SetParent(transform.parent);
                createState = CreateState.Complete;
            }
            break;

        case CreateState.Complete:
            createState = CreateState.ResourceRequest;
            return(true);

        default:
            break;
        }
        return(false);
    }
Exemplo n.º 2
0
        public void Initialize(FSM FSM, Dictionary <string, object> InitParameter, CreateState Create)
        {
            // add state to fsm
            FSM.AddState(this);

            // parse state parameter
            if (InitParameter != null)
            {
                SetParameter(InitParameter);
            }

            // create for AddContent_Enter, AddContent_Update, AddContent_Leave, AddEventProcesser
            Create();

            // set blank content if no content
            if (this.Content_Enter == null)
            {
                this.Content_Enter = BlankContent;
            }
            if (this.Content_Update == null)
            {
                this.Content_Update = BlankContent;
            }
            if (this.Content_Leave == null)
            {
                this.Content_Leave = BlankContent;
            }
        }
 public override bool OnSceneCreate()
 {
     switch (createState)
     {
     case CreateState.ResourceRequest:
         resourceRequestSet.Add ("cube", ResourceType.AssetBundle);
         ResourceManager.Instance.RegisterRequestSet (
             RequestResourceLabel, resourceRequestSet);
         createState = CreateState.ResourceRequestWait;
         break;
     case CreateState.ResourceRequestWait:
         if (resourceRequestSet.IsComplete () == true)
         {
             Object prefab = ResourceManager.Instance.GetAssetBundle ("cube");
             Debug.Log (prefab);
             instance = Object.Instantiate (prefab) as GameObject;
             instance.transform.SetParent (transform.parent);
             createState = CreateState.Complete;
         }
         break;
     case CreateState.Complete:
         createState = CreateState.ResourceRequest;
         return true;
     default:
         break;
     }
     return false;
 }
Exemplo n.º 4
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
        MovementSM = new StateMachine();

        Standing   = new StandingState(this, MovementSM);
        Fly        = new FlyState(this, MovementSM);
        Swing      = new SwingState(this, MovementSM);
        Create     = new CreateState(this, MovementSM);
        Transition = new TransitionState(this, MovementSM);

        ActivCube = CubePrefabs[0];
        MovementSM.Initialize(Create);


        Platform  = GameObject.FindGameObjectWithTag("Platform");
        LastBlock = Platform;
    }
Exemplo n.º 5
0
        /// <summary>
        /// 创建控件终止
        /// </summary>
        public void End()
        {
            if (_nodeObject != null)
            {
                INodeEdit node = (INodeEdit)_nodeObject;

                //最后一个点为动态移动点,需要删除
                int count = node.NodeDatas.Count;
                if (count > 0)
                {
                    node.DeleteNode(count - 1);
                }

                //创建成功
                if (node.CreateSuccess)
                {
                    node.IsNodeCreating = false;
                    _studio.ControlPoint.ChangeSelectObj(new List <IDrawObj> {
                        _nodeObject
                    });
                    _nodeObject.Invalidate();
                }
                else
                {
                    _studio.Objs.Remove(_nodeObject);
                }

                _nodeObject = null;
                _studio.Container.Framework.Manager.ResetToolboxPointerFunction();
            }

            _studio.Container.Cursor = Cursors.Default;
            _state      = CreateState.NotCreate;
            _orthoState = OrthoMode.Invalid;
        }
Exemplo n.º 6
0
    public override bool OnSceneCreate()
    {
        switch (createState)
        {
        case CreateState.ResourceRequest:
            resourceRequestSet.Add("ExampleTexture", ResourceType.Asset);
            ResourceManager.Instance.RegisterRequestSet(
                RequestResourceLabel, resourceRequestSet);
            createState = CreateState.ResourceRequestWait;
            break;

        case CreateState.ResourceRequestWait:
            if (resourceRequestSet.IsComplete() == true)
            {
                createState = CreateState.Complete;
            }
            break;

        case CreateState.Complete:
            createState = CreateState.ResourceRequest;
            return(true);

        default:
            break;
        }
        return(false);
    }
Exemplo n.º 7
0
        /** creates a new outgoing Edge using the pathing protocol
         */
        public override void CreateEdgeTo(TransportAddress ta,
                                          EdgeListener.EdgeCreationCallback ecb)
        {
            if (!IsStarted)
            {
                throw new EdgeException("PathEdgeListener is not started");
            }
            string           rempath;
            TransportAddress base_ta = PathELManager.SplitPath(ta, out rempath);

            if (_path == PathELManager.Root && rempath == PathELManager.Root)
            {
                /*
                 * This is "normal" case, and we can skip all this stuff
                 */
                _el.CreateEdgeTo(ta, ecb);
            }
            else
            {
                CreateState cs = new CreateState(this, rempath, _path, ecb);

                /*
                 * Make the underlying Edge:
                 */
                _el.CreateEdgeTo(base_ta, cs.HandleEC);
            }
        }
        public IActionResult Index()
        {
            ICampaignState  initialState = new CreateState();
            CampaignContext context      = new CampaignContext(initialState);

            cache.Set("context", context);
            return(View());
        }
Exemplo n.º 9
0
        /// <summary>
        /// 武器の生成方法の切り替え
        /// </summary>
        public void ChangeCreateState()
        {
            // 生成方法の切り替え
            switch (currentState)
            {
            case CreateState.PLAYER_CIRCLE:
                currentState = CreateState.HAND_DISPLAY;
                break;

            case CreateState.HAND_DISPLAY:
                currentState = CreateState.PLAYER_CIRCLE;
                break;
            }
        }
Exemplo n.º 10
0
        /** creates a new outgoing Edge using the pathing protocol
         */
        public override void CreateEdgeTo(TransportAddress ta,
                                          EdgeListener.EdgeCreationCallback ecb)
        {
            if (!IsStarted)
            {
                throw new EdgeException("PathEdgeListener is not started");
            }
            string           rempath;
            TransportAddress base_ta = PathELManager.SplitPath(ta, out rempath);
            bool             root    = false;

            if (_path == PathELManager.Root && rempath == PathELManager.Root)
            {
                root = true;
            }
            CreateState cs = new CreateState(this, rempath, _path, ecb, root);

            _el.CreateEdgeTo(base_ta, cs.HandleEC);
        }
 public override bool OnSceneCreate()
 {
     switch (createState)
     {
     case CreateState.ResourceRequest:
         resourceRequestSet.Add ("ExampleTexture", ResourceType.Asset);
         ResourceManager.Instance.RegisterRequestSet (
             RequestResourceLabel, resourceRequestSet);
         createState = CreateState.ResourceRequestWait;
         break;
     case CreateState.ResourceRequestWait:
         if (resourceRequestSet.IsComplete () == true)
             createState = CreateState.Complete;
         break;
     case CreateState.Complete:
         createState = CreateState.ResourceRequest;
         return true;
     default:
         break;
     }
     return false;
 }
Exemplo n.º 12
0
        /// <summary>
        /// 开始创建控件
        /// </summary>
        /// <param name="type"></param>
        public void Begin(Type type)
        {
            End();

            _state        = CreateState.BeginCreate;
            _type         = type;
            _isNodeCreate = _type.IsSubclassOf(typeof(NSDrawNodes.DrawNodes));

            //ortho
            _orthoState = OrthoMode.Invalid;
            if (_studio.IsOrtho)
            {
                object[] attrs = _type.GetCustomAttributes(true);
                for (int i = 0; i < attrs.Length; i++)
                {
                    if (attrs[i] is OrthoAttribute)
                    {
                        _orthoState = ((OrthoAttribute)attrs[i]).State;
                        break;
                    }
                }
            }
        }
Exemplo n.º 13
0
        public CreateMaze(bool hard, bool _singleplayer)
        {
            singleplayer = _singleplayer;
            hl = goalSet = p1set = p2set = done = false;

            state = CreateState.WALLS;

            failWindow = new Rectangle(3 * Program.game.screenWidth / 8, 3 * Program.game.screenHeight / 8,
                Program.game.screenWidth / 4, Program.game.screenHeight / 4);

            wallButton = new Button(new Point(30, 30), 136, 72, "Wall", "Buttons/wall");
            goalButton = new Button(new Point(200, 30), 136, 72, "Goal", "Buttons/goal");
            p1Button = new Button(new Point(370, 30), 136, 72, "Player One", "Buttons/playerOne");
            p2Button = new Button(new Point(540, 30), 136, 72, "Player Two", "Buttons/playerTwo");
            backButton = new Button(new Point(Program.game.screenWidth - 166, 30), 136, 72, "Back", "Buttons/back");
            saveButton = new Button(new Point(Program.game.screenWidth - 332, 30), 136, 72, "Save", "Buttons/save");
            okButton = new Button(new Point(Program.game.screenWidth / 2 - 40, failWindow.Bottom - failWindow.Height / 3 - 25), 80, 50, "okay", "Buttons/ok");

            buttons = new List<Button>();
            buttons.Add(wallButton);
            buttons.Add(goalButton);
            buttons.Add(p1Button);
            buttons.Add(p2Button);
            buttons.Add(backButton);
            buttons.Add(saveButton);

            hlColor = new Color(25, 255, 55, 25);
            tempColor = new Color(0, 0, 0, 25);
            wallColor = Color.Black;
            goalColor = Color.Red;

            border = new List<Rectangle>();
            walls = new List<Rectangle>();
            twalls = new List<Rectangle>();
            tgoals = new List<Rectangle>();
            tplayers = new List<Rectangle>();
            p1 = new Ball(new Point(0, 0), Color.Blue);
            p2 = new Ball(new Point(0, 0), Color.Yellow);

            border.Add(new Rectangle(Program.game.sx(0), Program.game.sy(0), 10, 490));
            border.Add(new Rectangle(Program.game.sx(960), Program.game.sy(0), 10, 490));
            border.Add(new Rectangle(Program.game.sx(0), Program.game.sy(0), 970, 10));
            border.Add(new Rectangle(Program.game.sx(0), Program.game.sy(480), 970, 10));

            int cols = 6, rows = 3, size = 160;
            if (hard)
            {
                cols *= 2;
                rows *= 2;
                size /= 2;
            }

            for (int i = 0; i < cols; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    if (j > 0)
                        twalls.Add(new Rectangle(Program.game.sx(i * size), Program.game.sy(j * size), size + 10, 10));
                    if (i > 0)
                        twalls.Add(new Rectangle(Program.game.sx(i * size), Program.game.sy(j * size), 10, size + 10));
                    tgoals.Add(new Rectangle(Program.game.sx(10 + i * size), Program.game.sy(10 + j * size), size - 10, size - 10));
                    tplayers.Add(new Rectangle(Program.game.sx(i * size + size / 2 - 15), Program.game.sy(j * size + size / 2 - 15), 40, 40));
                }
            }
        }
Exemplo n.º 14
0
 /** creates a new outgoing Edge using the pathing protocol
  */
 public override void CreateEdgeTo(TransportAddress ta,
                                   EdgeListener.EdgeCreationCallback ecb) {
   if( !IsStarted ) {
     throw new EdgeException("PathEdgeListener is not started");
   }
   string rempath;
   TransportAddress base_ta = PathELManager.SplitPath(ta, out rempath);
   if( _path == PathELManager.Root && rempath == PathELManager.Root ) {
     /*
      * This is "normal" case, and we can skip all this stuff
      */
     _el.CreateEdgeTo(ta, ecb);
   }
   else {
     CreateState cs = new CreateState(this, rempath, _path, ecb);
     /*
      * Make the underlying Edge:
      */
     _el.CreateEdgeTo(base_ta, cs.HandleEC);
   }
 }
Exemplo n.º 15
0
 /** creates a new outgoing Edge using the pathing protocol
  */
 public override void CreateEdgeTo(TransportAddress ta,
                                   EdgeListener.EdgeCreationCallback ecb) {
   if( !IsStarted ) {
     throw new EdgeException("PathEdgeListener is not started");
   }
   string rempath;
   TransportAddress base_ta = PathELManager.SplitPath(ta, out rempath);
   bool root = false;
   if( _path == PathELManager.Root && rempath == PathELManager.Root ) {
     root = true;
   }
   CreateState cs = new CreateState(this, rempath, _path, ecb, root);
   _el.CreateEdgeTo(base_ta, cs.HandleEC);
 }
        private void HandleFinish(Standard input, Action <InputControl> consumeControl)
        {
            // Ready for next object to be created
            if (input.action.wasJustReleased)
            {
                m_AudioModule.Play(m_Trigger, true);
                m_GuideModule.SetVisible(false);
                m_HighlightModule.SetFaceHighlight(m_Object, null);

                m_Dragging = false;
                m_State    = CreateState.Start;
                m_Object.ToMesh();
                m_Object.Refresh();
            }
            else
            {
                if (m_IsDirectSelect)
                {
                    m_DraggedPoint = m_DragOrigin + (Vector3.Project(rayOrigin.position - m_DragOrigin, m_DragDirection));
                }
                else if (m_VertexSnap.valid)
                {
                    m_DraggedPoint = m_DragOrigin + (Vector3.Project(m_VertexSnap.point - m_DragOrigin, m_DragDirection));
                }
                else
                {
                    m_DraggedPoint = VRMath.CalculateNearestPointRayRay(m_DragOrigin, m_DragDirection, rayOrigin.position, rayOrigin.forward);
                }

                if (!m_Dragging)
                {
                    m_Offset   = m_IsDirectSelect ? m_DraggedPoint - m_DragOrigin : Vector3.zero;
                    m_Dragging = true;
                }

                m_DraggedPoint -= m_Offset;

                Vector3 localDragOrigin   = m_Object.transform.InverseTransformPoint(m_DragOrigin);
                Vector3 localDraggedPoint = m_Object.transform.InverseTransformPoint(m_DraggedPoint);
                Vector3 vertexTranslation = localDraggedPoint - localDragOrigin;

                if (vertexTranslation.magnitude > MAX_TRANSLATE_DISTANCE)
                {
                    vertexTranslation = vertexTranslation.normalized * MAX_TRANSLATE_DISTANCE;
                }

                vertexTranslation = Snapping.Snap(vertexTranslation, m_SnapIncrement, VECTOR3_ONE);

                if (vertexTranslation != m_PreviousVertexTranslation)
                {
                    m_PreviousVertexTranslation = vertexTranslation;
                    m_AudioModule.Play(m_Drag);
                }

                foreach (int ind in m_SelectedIndices)
                {
                    m_SettingPositions[ind] = m_Positions[ind] + vertexTranslation;
                }

                m_Object.SetVertices(m_SettingPositions);
                m_Object.msh.vertices = m_SettingPositions;
                m_Object.RefreshUV();
                m_Object.msh.RecalculateBounds();
                m_HighlightModule.UpdateVertices(m_Object);
            }

            setHighlight(m_Object.gameObject, false);
            consumeControl(input.action);
        }
        private void HandleStart(Standard input, Action <InputControl> consumeControl)
        {
            GameObject first = getFirstGameObject(rayOrigin);

            if (first == null)
            {
                if (m_HighlightModule != null)
                {
                    m_HighlightModule.Clear();
                }

                return;
            }

            pb_Object pb = first.GetComponent <pb_Object>();

            if (pb == null)
            {
                m_HighlightModule.Clear();
                return;
            }

            pb_RaycastHit hit;

            if (pb_HandleUtility.FaceRaycast(new Ray(rayOrigin.position, rayOrigin.forward), pb, out hit))
            {
                m_IsDirectSelect = hit.distance < m_DirectSelectThreshold;

                if (m_HighlightModule != null)
                {
                    m_HighlightModule.color = m_IsDirectSelect ? directSelectFaceColor : highlightFaceColor;
                    m_HighlightModule.SetFaceHighlight(pb, new pb_Face[] { pb.faces[hit.face] }, true);
                }

                setHighlight(pb.gameObject, false);

                consumeControl(input.action);

                if (!input.action.wasJustPressed)
                {
                    return;
                }

                m_AudioModule.Play(m_Trigger, true);

                m_Object          = pb;
                m_Face            = pb.faces[hit.face];
                m_SelectedIndices = pb.sharedIndices.AllIndicesWithValues(m_Face.distinctIndices);

                m_DragOrigin    = pb.transform.TransformPoint(hit.point);
                m_DragDirection = pb.transform.TransformDirection(hit.normal);
                m_DragDirection.Normalize();

                if (m_GuideModule != null)
                {
                    m_GuideModule.SetVisible(true);
                    m_GuideModule.transform.position = m_DragOrigin;
                    m_GuideModule.transform.rotation = Quaternion.LookRotation(m_DragDirection);
                }

                m_State = CreateState.Finish;
                m_ProBuilderObjectsInScene = UnityEngine.Object.FindObjectsOfType <pb_Object>().Where(x => x != m_Object).Select(y => y.gameObject).ToArray();

                m_Positions        = new Vector3[pb.vertexCount];
                m_SettingPositions = new Vector3[pb.vertexCount];
                System.Array.Copy(pb.vertices, m_Positions, pb.vertexCount);
                System.Array.Copy(pb.vertices, m_SettingPositions, pb.vertexCount);

                m_Object.ToMesh();
            }
            else
            {
                if (m_HighlightModule != null)
                {
                    m_HighlightModule.SetFaceHighlight(pb, null);
                }
            }
        }
Exemplo n.º 18
0
        public bool MouseDown(MouseButtons button, PointF location, PointF revertPoint)
        {
            if (_studio.IsGrid)
            {
                revertPoint = Tool.GetGridPointF(revertPoint);
            }

            if (_state == CreateState.BeginCreate)
            {
                _state = CreateState.HasCreate;

                if (_nodeObject != null)
                {
                    End();
                    return(true);
                }

                if (_isNodeCreate)
                {
                    _nodeObject        = (IDrawVector)_studio.CreateDrawObj(_type);
                    _nodeObject.Parant = _studio.Container;
                    ((ObjName)_studio.NameManager).CreateName(_nodeObject);
                    _studio.Objs.Add(_nodeObject);
                    INodeEdit node = (INodeEdit)_nodeObject;
                    node.IsNodeCreating = true;
                    node.AddNode(revertPoint);
                    node.AddNode(revertPoint);
                    _nodeObject.LoadInitializationEvent();
                }

                return(true);
            }

            if (_state == CreateState.HasCreate)
            {
                if (_isNodeCreate && _nodeObject != null)
                {
                    INodeEdit node      = (INodeEdit)_nodeObject;
                    int       count     = node.NodeDatas.Count;
                    PointF    lastPoint = node.NodeDatas[count - 2];

                    revertPoint = GetOrthoHoriorVert(lastPoint, revertPoint);
                    //预防在同一位置重复添加点
                    if (Point.Ceiling(lastPoint) == Point.Ceiling(revertPoint))
                    {
                        return(true);
                    }

                    node.MoveNode(revertPoint, count - 1);
                    node.AddNode(revertPoint);

                    //添加点后创建成功,则直接结束
                    if (node.CreateFinish)
                    {
                        End();
                        return(true);
                    }
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 19
0
        public async Task <ActionResult> Post([FromBody] State state)
        {
            var stateId = await _mediator.Send(CreateState.Of(state));

            return(Ok(stateId));
        }
Exemplo n.º 20
0
        public void update()
        {
            if (!failedSave)
            {
                if (wallButton.isSelected())
                    state = CreateState.WALLS;
                else if (goalButton.isSelected())
                    state = CreateState.GOAL;
                else if (p1Button.isSelected())
                    state = CreateState.P1;
                else if (p2Button.isSelected() && !singleplayer)
                    state = CreateState.P2;
                else if (saveButton.isSelected())
                    state = CreateState.SAVE;
                else if (backButton.isSelected())
                    Program.game.startCreateMazeSelect();

                bool clicked = Program.game.ms.newPointReady;
                Point point = Program.game.ms.point;
                hl = false;
                switch (state)
                {
                    case CreateState.WALLS:
                        wallsUpdate(point, clicked);
                        break;
                    case CreateState.GOAL:
                        goalUpdate(point, clicked);
                        break;
                    case CreateState.P1:
                        p1Update(point, clicked);
                        break;
                    case CreateState.P2:
                        p2Update(point, clicked);
                        break;
                    case CreateState.SAVE:
                        if (done)
                            saveMaze();
                        break;
                }
            }
            else if (okButton.isSelected())
            {
                state = CreateState.WALLS;
                // done = false;
                failedSave = false;
                foreach (Button button in buttons)
                    button.selectable = true;
            }
        }