Ejemplo n.º 1
0
        override protected JobHandle OnUpdate(JobHandle jobs)
        {
            var cmdBufferConcurrent = cmdBuffer.CreateCommandBuffer().ToConcurrent();
            var deltaTime           = Time.deltaTime;

            var swapBlocks = new SwapBlock()
            {
                cmdBuffer = cmdBufferConcurrent
            };

            var initBlockPos = new SetSpawnedBlockToInitialPosition()
            {
                levelInfo    = levelInfo,
                cmdBuffer    = cmdBufferConcurrent,
                viewCmdStack = viewCmdStack.ToConcurrent()
            };

            jobs = swapBlocks.Schedule(this, jobs);
            jobs = initBlockPos.Schedule(this, jobs);

            if (viewCmdStack.CanExecute <MoveDownCommand>())
            {
                var moveDownBlock = new MoveDown()
                {
                    cmdBuffer = cmdBuffer.CreateCommandBuffer().ToConcurrent(),
                    dt        = deltaTime,
                    levelInfo = levelInfo
                };

                jobs = moveDownBlock.Schedule(this, jobs);
            }

            return(jobs);
        }
Ejemplo n.º 2
0
        private async Task move(int sourceIndex, int destinationIndex)
        {
            try
            {
                var sourceItem      = Items[sourceIndex];
                var destinationItem = Items[destinationIndex];
                var desiredRank     = destinationItem.Rank;
                if (destinationIndex > sourceIndex)
                {
                    desiredRank++;
                }

                Items.Move(sourceIndex, destinationIndex);
                var response = await QueueClient.SetRank(sourceItem.ID, desiredRank);

                if ((response == null) || !response.Success)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", response != null?response.ErrorMessageClean : "Unable to move the selected video.", "OK");
                }

                MoveUp.ChangeCanExecute();
                MoveDown.ChangeCanExecute();
                MoveToTop.ChangeCanExecute();
                MoveToBottom.ChangeCanExecute();
            }
            catch (Exception ex)
            {
                //XXX : Handle error
                LoggerService.Instance.Log("ERROR: Queue.move: " + ex);
            }
        }
Ejemplo n.º 3
0
        void ReleaseDesignerOutlets()
        {
            if (MoveUp != null)
            {
                MoveUp.Dispose();
                MoveUp = null;
            }

            if (MoveLeft != null)
            {
                MoveLeft.Dispose();
                MoveLeft = null;
            }

            if (MoveRight != null)
            {
                MoveRight.Dispose();
                MoveRight = null;
            }

            if (MoveDown != null)
            {
                MoveDown.Dispose();
                MoveDown = null;
            }

            if (ZoomLevel != null)
            {
                ZoomLevel.Dispose();
                ZoomLevel = null;
            }
        }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     KeyW = new MoveUp();
     KeyS = new MoveDown();
     KeyA = new MoveLeft();
     KeyD = new MoveRight();
 }
Ejemplo n.º 5
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {//Stops movement when key is lifted
     MoveUp.Stop();
     MoveDown.Stop();
     MoveRight.Stop();
     MoveLeft.Stop();
 }
Ejemplo n.º 6
0
    public static void UpdateToiletPaper()
    {
        MoveDown toiletPaper = GameObject.FindObjectOfType <MoveDown>();

        toiletPaper.rollLongitude = DataManager.rollCapacity;
        toiletPaper.maxSpeed      = (15 + DataManager.userMPSSumIncrement) * DataManager.userMPSMulIncrement;
    }
Ejemplo n.º 7
0
    void Start()
    {
        player = gameObject.GetComponent <Player>();

        buttonUpArrow   = buttonW = new MoveUp(player);
        buttonDownArrow = buttonS = new MoveDown(player);
        buttonSpace     = new Jump(player);
    }
Ejemplo n.º 8
0
        void GetRandomBlock()
        {
            int RandomPosition = rand.Next(0, 4);

            switch (RandomBlock)
            {
            case 0:
                t_block   = new T_Block(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = t_block.MoveLeft;
                moveRight = t_block.MoveRight;
                moveDown  = t_block.MoveDown;
                rotate    = t_block.Rotate;

                BlockColor        = t_block.color;
                returnCoordinates = t_block.returnCoordinates;

                break;

            case 1:
                square    = new Square(StartPoint, BlockSize, board);
                moveLeft  = square.MoveLeft;
                moveRight = square.MoveRight;
                moveDown  = square.MoveDown;
                rotate    = square.Rotate;

                BlockColor        = square.color;
                returnCoordinates = square.returnCoordinates;

                break;

            case 2:
                stick     = new Stick(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = stick.MoveLeft;
                moveRight = stick.MoveRight;
                moveDown  = stick.MoveDown;
                rotate    = stick.Rotate;

                BlockColor        = stick.color;
                returnCoordinates = stick.returnCoordinates;

                break;

            case 3:
                z_block   = new Z_Block(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = z_block.MoveLeft;
                moveRight = z_block.MoveRight;
                moveDown  = z_block.MoveDown;
                rotate    = z_block.Rotate;

                BlockColor        = z_block.color;
                returnCoordinates = z_block.returnCoordinates;
                break;

            //
            default:
                break;
            }
        }
Ejemplo n.º 9
0
    public Vec2 NeedVel()
    {
        Vec2 t = Vec2.Zero;

        t += MoveLeft.Pressed() ? new Vec2(-1, 0) : Vec2.Zero;
        t += MoveRight.Pressed() ? new Vec2(1, 0) : Vec2.Zero;
        t += MoveDown.Pressed() ? new Vec2(0, -1) : Vec2.Zero;
        return(t);
    }
Ejemplo n.º 10
0
    void FixedUpdate()
    {
        //this is a standtard push that scales diretly to frame rate
        //Time.deltaTime negates the frame rate diffirences and the really high number helps the cube to actually move

        rb.AddForce(0, 0, forwardSpeed * Time.deltaTime);


        if (Input.GetKey("d"))
        {
            Command _moveRight = new MoveRight(rb, lateralSpeed);
            Invoker invoker    = new Invoker();
            invoker.SetCommand(_moveRight);

            invoker.ExecuteComand();
            //commandDisplay.text += "\n" + _moveRight.ToString();
        }

        if (Input.GetKey("a"))
        {
            Command _moveLeft = new MoveLeft(rb, lateralSpeed);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(_moveLeft);
            //  commandDisplay.text += "\n" + _moveLeft.ToString();
            invoker.ExecuteComand();
        }

        if (Input.GetKey("w"))
        {
            Command _moveUp = new MoveUp(rb, lateralSpeed);
            Invoker invoker = new Invoker();
            invoker.SetCommand(_moveUp);
            //   commandDisplay.text += "\n" + _moveUp.ToString();
            invoker.ExecuteComand();
        }

        if (Input.GetKey("s"))
        {
            //loacal _moveDown  //calling the command in commmand
            Command _moveDown = new MoveDown(rb, lateralSpeed);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(_moveDown);
            //  commandDisplay.text += "\n" + _moveDown.ToString();
            invoker.ExecuteComand();
        }

        if (rb.position.y < -1f)
        {
            FindObjectOfType <GameManager>().EndGame();
        }

        if (rb.GetComponentInParent <Transform>().position.z > halfWay)
        {
            OnHalfWay?.Invoke();
        }
    }
Ejemplo n.º 11
0
    void Awake()
    {
        anim = GetComponent<Animator>();

        myCollider = GetComponent<Collider2D>();

        startScale = transform.localScale;

		moveDown = GetComponent<MoveDown> ();
    }
Ejemplo n.º 12
0
    void Awake()
    {
        anim = GetComponent <Animator>();

        myCollider = GetComponent <Collider2D>();

        startScale = transform.localScale;

        moveDown = GetComponent <MoveDown> ();
    }
Ejemplo n.º 13
0
        void GetRandomBlock()
        {
            int RandomPosition = rand.Next(0, 4);

            switch (RandomBlock)
            {
                case 0:
                    t_block = new T_Block(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = t_block.MoveLeft;
                    moveRight = t_block.MoveRight;
                    moveDown = t_block.MoveDown;
                    rotate = t_block.Rotate;

                    BlockColor = t_block.color;
                    returnCoordinates = t_block.returnCoordinates;

                    break;
                case 1:
                    square = new Square(StartPoint, BlockSize,board);
                    moveLeft = square.MoveLeft;
                    moveRight = square.MoveRight;
                    moveDown = square.MoveDown;
                    rotate = square.Rotate;

                    BlockColor = square.color;
                    returnCoordinates = square.returnCoordinates;

                    break;
                case 2:
                    stick = new Stick(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = stick.MoveLeft;
                    moveRight = stick.MoveRight;
                    moveDown = stick.MoveDown;
                    rotate = stick.Rotate;

                    BlockColor = stick.color;
                    returnCoordinates = stick.returnCoordinates;

                    break;
                case 3:
                    z_block = new Z_Block(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = z_block.MoveLeft;
                    moveRight = z_block.MoveRight;
                    moveDown = z_block.MoveDown;
                    rotate = z_block.Rotate;

                    BlockColor = z_block.color;
                    returnCoordinates = z_block.returnCoordinates;
                    break;
                //
                default:
                    break;

            }
        }
        public void Update()
        {
            //Check keys in keymap
            //Has Released Keys
            foreach (var item in keyMap.OnReleasedKeyMap)
            {
                if (Input.GetKeyUp(item.Key))
                {
                    Debug.Log(string.Format("onReleasedKeyMap Key released {0}", item.Value.ToString())); //Log key to console
                    Command command = null;
                    switch (item.Value)
                    {
                    case "Move Up":
                        //trigger Move Up command
                        command = new MoveUp();
                        break;

                    case "Move Down":
                        //trigger Move Down command
                        command = new MoveDown();
                        break;

                    case "Move Left":
                        //trigger Move Left command
                        command = new MoveLeft();
                        break;

                    case "Move Right":
                        //trigger Move Down command
                        command = new MoveRight();
                        break;

                    case "Undo":
                        if (Commands.Count > 0)
                        {
                            command = (Command)Commands.Pop();
                            if (command is ICommandWithUndo)     //if the popped command has an undo command use it
                            {
                                command = ((ICommandWithUndo)command).UndoCommand;
                            }
                        }
                        break;
                    }
                    if (command != null)
                    {
                        if (command is ICommandWithUndo)
                        {
                            Commands.Push((ICommandWithUndo)command); //only push commands with undo to the stack
                        }
                        command.Execute(MoveCommandTarget);
                    }
                }
            }
        }
Ejemplo n.º 15
0
    void Start()
    {
        //Bind keys with commands
        buttonB = new DoNothing();
        buttonW = new MoveUp();
        buttonS = new MoveDown();
        buttonA = new MoveLeft();
        buttonD = new MoveRight();

        elementStartPos = elementTrans.position;
    }
Ejemplo n.º 16
0
 protected override void RenderContent(UnityEngine.Object undoRecordObject)
 {
     MoveForward.RenderEditorGUI(undoRecordObject);
     MoveBack.RenderEditorGUI(undoRecordObject);
     StrafeLeft.RenderEditorGUI(undoRecordObject);
     StrafeRight.RenderEditorGUI(undoRecordObject);
     MoveUp.RenderEditorGUI(undoRecordObject);
     MoveDown.RenderEditorGUI(undoRecordObject);
     Pan.RenderEditorGUI(undoRecordObject);
     LookAround.RenderEditorGUI(undoRecordObject);
     Orbit.RenderEditorGUI(undoRecordObject);
 }
        public override void Update(GameTime gameTime)
        {
            var kstate = Keyboard.GetState();

            if (kstate.IsKeyDown(slowMode))
            {
                speed = (speed == originalSpeed) ? speed / slowModeModifier : speed * slowModeModifier;
            }

            if (kstate.IsKeyDown(godMode) && pastKey.IsKeyUp(godMode))
            {
                isGod = !isGod;
            }

            // for testing the win states
            if (kstate.IsKeyDown(win) && pastKey.IsKeyUp(win))
            {
                winner = 1; // win -> see win screen
            }
            //for testing lose life
            if (kstate.IsKeyDown(hit) && pastKey.IsKeyUp(hit))
            {
                if (invincible == false)
                {
                    takeHit(); //player is hit
                }
            }

            if (kstate.IsKeyDown(upKey))
            {
                position = new MoveUp(speed).getNewPosition(position, velocity);
            }
            if (kstate.IsKeyDown(downKey))
            {
                position = new MoveDown(speed).getNewPosition(position, velocity);
            }
            if (kstate.IsKeyDown(leftKey))
            {
                position = new MoveLeft(speed).getNewPosition(position, velocity);
            }
            if (kstate.IsKeyDown(rightKey))
            {
                position = new MoveRight(speed).getNewPosition(position, velocity);
            }
            if (kstate.IsKeyDown(shootKey) && pastKey.IsKeyUp(shootKey))
            {
                shoot();
            }
            pastKey = Keyboard.GetState();

            bulletsUpdateAndCleanup(gameTime);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Function for creating commands
        /// </summary>
        /// <param name="command">Command name</param>
        /// <returns>New command object</returns>
        public ICommand CreateCommand(string command)
        {
            ICommand resultCommand;

            if (this.commandDictionary.ContainsKey(command))
            {
                return(this.commandDictionary[command]);
            }

            switch (command)
            {
            case "u":
                resultCommand = new MoveUp();
                break;

            case "d":
                resultCommand = new MoveDown();
                break;

            case "l":
                resultCommand = new MoveLeft();
                break;

            case "r":
                resultCommand = new MoveRight();
                break;

            case "restart":
                resultCommand = new RestartCommand();
                break;

            case "top":
                resultCommand = new ScoreCommand();
                break;

            case "exit":
                resultCommand = new ExitCommand();
                break;

            case "undo":
                resultCommand = new UndoCommand();
                break;

            default:
                throw new InvalidCommandException(GlobalErrorMessages.InvalidCommandMessage);
            }

            this.commandDictionary.Add(command, resultCommand);
            return(resultCommand);
        }
Ejemplo n.º 19
0
    void IBattleCharacter.Death()
    {
        var view = this as IBattleCharacter;

        view.PlayMotion("Die");
        view.StopMove();
        showHpBarTime = -1;
        if (Agent)
        {
            Agent.enabled = false;
        }
        IsDead = true;
        MoveDown.BeginMove(this.Character, 1, 1, 5);
    }
Ejemplo n.º 20
0
        private void GameOver()
        {
            ZebraMover.Stop();
            BlueMove.Stop();
            PurpleMove.Stop();
            GreenMove.Stop();
            GameEnd.Visible         = true;
            PlayAgainButton.Visible = true;

            //Stops orange car from moving
            MoveUp.Stop();
            MoveDown.Stop();
            MoveRight.Stop();
            MoveLeft.Stop();
        }
Ejemplo n.º 21
0
    void FixedUpdate()
    {
        rb.AddForce(0, 0, forwardSpeed * Time.deltaTime);


        if (Input.GetKey("d"))
        {
            Command _moveRight = new MoveRight(rb, lateralSpeed);
            Invoker invoker    = new Invoker();
            invoker.SetCommand(_moveRight);

            invoker.ExecuteCommand();
            //commandDisplay.text += "\n" + _moveRight.ToString();
        }

        if (Input.GetKey("a"))
        {
            Command _moveLeft = new MoveLeft(rb, lateralSpeed);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(_moveLeft);
            //commandDisplay.text += "\n" + _moveLeft.ToString();
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("w"))
        {
            Command _moveUp = new MoveUp(rb, lateralSpeed);
            Invoker invoker = new Invoker();
            invoker.SetCommand(_moveUp);
            //commandDisplay.text += "\n" + _moveUp.ToString();
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("s"))
        {
            //loacal _moveDown  //calling the command in commmand
            Command _moveDown = new MoveDown(rb, lateralSpeed);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(_moveDown);
            //commandDisplay.text += "\n" + _moveDown.ToString();
            invoker.ExecuteCommand();
        }

        if (rb.position.y < -1f)
        {
            FindObjectOfType <GameManager>().EndGame();
        }
    }
Ejemplo n.º 22
0
    public void SpawnObjectInitial()
    {
        for (int i = 0; i < INITIAL_AMOUNT; i++)
        {
            // Offset Accrued

            offset += Readers._instance.n[counter].isSameHeight * SEPARATION;


            //Assign values to variables from Readers
            prefab_id = Readers._instance.n[counter].prefab_id;
            position  = Readers._instance.n[counter].position;
            sound_id  = Readers._instance.n[counter].sound_id;


            //Refer to SoundID
            md = prefabs[prefab_id].gameObject.GetComponent(typeof(MoveDown)) as MoveDown;

            md.soundID = sound_id;

            //Refer to SpriteRenderer
            sprite = prefabs[prefab_id].gameObject.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if (sprite)
            {
                sprite.sortingOrder = -counter;
            }


            Instantiate(prefabs[prefab_id], new Vector3(position, (counter * SEPARATION) + transform.position.y + offset, 0), Quaternion.identity);

            if (counter == (INITIAL_AMOUNT - 1))
            {
                //  SET Guides Position
                GuideRefs[0].transform.position = new Vector3(1, (counter * SEPARATION) + transform.position.y + offset + SEPARATION, 1);
                GuideRefs[1].transform.position = new Vector3(1, GuideRefs[0].transform.position.y + SEPARATION, 1);

                GuideColRef.transform.position = new Vector3(1, GuideRefs[0].transform.position.y - SEPARATION, 1);

                //Restart Offset
                offset = 0;
            }


            counter++;
        }
    }
Ejemplo n.º 23
0
        public async Task SendMoveMessage(string moveCommand)
        {
            await Task.Run(() =>
            {
                ICommand command = null;
                Player p         = Server.GetPlayerById(Context.ConnectionId);
                switch (moveCommand)
                {
                case "moveleft":
                    command = new MoveLeft(p, Server.current);
                    break;

                case "moveright":
                    command = new MoveRight(p, Server.current);
                    break;

                case "moveup":
                    command = new MoveUp(p, Server.current);
                    break;

                case "movedown":
                    command = new MoveDown(p, Server.current);
                    break;

                case "moveleftup":
                    command = new MoveLeftUp(p, Server.current);
                    break;

                case "moveleftdown":
                    command = new MoveLeftDown(p, Server.current);
                    break;

                case "moverightup":
                    command = new MoveRightUp(p, Server.current);
                    break;

                case "moverightdown":
                    command = new MoveRightDown(p, Server.current);
                    break;
                }
                p.SetCommand(command);
            });
        }
Ejemplo n.º 24
0
 public Schema()
     : base()
 {
     InstanceType = typeof(__SoPersonOb__);
     ClassName    = "PersonObj";
     Properties.ClearExposed();
     FirstName = Add <__TString__>("FirstName");
     FirstName.DefaultValue = "";
     FirstName.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__FirstName__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__FirstName__ = (System.String)_v_; }, false);
     LastName = Add <__TString__>("LastName");
     LastName.DefaultValue = "";
     LastName.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__LastName__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__LastName__ = (System.String)_v_; }, false);
     SortOrder = Add <__TLong__>("SortOrder");
     SortOrder.DefaultValue = 0L;
     SortOrder.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__SortOrder__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__SortOrder__ = (System.Int64)_v_; }, false);
     MoveUp = Add <__TLong__>("MoveUp$");
     MoveUp.DefaultValue = 0L;
     MoveUp.Editable     = true;
     MoveUp.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__MoveUp__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__MoveUp__ = (System.Int64)_v_; }, false);
     MoveUp.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.MoveUp()
         {
             App = (PersonObj)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonObj)pup).Handle((Input.MoveUp)input); });
     MoveDown = Add <__TLong__>("MoveDown$");
     MoveDown.DefaultValue = 0L;
     MoveDown.Editable     = true;
     MoveDown.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__MoveDown__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__MoveDown__ = (System.Int64)_v_; }, false);
     MoveDown.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.MoveDown()
         {
             App = (PersonObj)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonObj)pup).Handle((Input.MoveDown)input); });
     ItemDropped = Add <__TLong__>("ItemDropped$");
     ItemDropped.DefaultValue = 0L;
     ItemDropped.Editable     = true;
     ItemDropped.SetCustomAccessors((_p_) => { return(((__SoPersonOb__)_p_).__bf__ItemDropped__); }, (_p_, _v_) => { ((__SoPersonOb__)_p_).__bf__ItemDropped__ = (System.Int64)_v_; }, false);
     ItemDropped.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.ItemDropped()
         {
             App = (PersonObj)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonObj)pup).Handle((Input.ItemDropped)input); });
 }
Ejemplo n.º 25
0
        public static void CommanderDemo()
        {
            Unit[,] units          = new Unit[50, 50];
            Explosive[,] explosion = new Explosive[0, 0];
            MapFacade mapOriginal = new MapFacade(10, 10, units, explosion);


            Player player = new Player("aaaa", "Player", 0);

            Console.WriteLine("Pradine pozicija " + player.getPos()[0] + "-" + player.getPos()[1]);

            ICommand command = new MoveDown(player, mapOriginal);

            player.SetCommand(command);
            player.Move();

            Console.WriteLine("Pajudejimas i apacia " + player.getPos()[0] + "-" + player.getPos()[1]);

            player.Undo();

            Console.WriteLine("Pozicija po undo " + player.getPos()[0] + "-" + player.getPos()[1]);
        }
Ejemplo n.º 26
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {//Start timer to move car
            if (e.KeyCode == Keys.Up)
            {
                MoveUp.Start();
            }

            if (e.KeyCode == Keys.Down)
            {
                MoveDown.Start();
            }

            if (e.KeyCode == Keys.Right)
            {
                MoveRight.Start();
            }

            if (e.KeyCode == Keys.Left)
            {
                MoveLeft.Start();
            }
        }
Ejemplo n.º 27
0
    public void SpawnObject(float positionY)
    {
        if (counter < Readers._instance.n.Length)
        {
            //

            // Offset Accrued
            offset += Readers._instance.n[counter].isSameHeight * SEPARATION;// / SPEED_SCALAR IS NOT HOW SEPARATED WILL BE FROM EACH OTHER;


            //Assign values to variables from Readers
            prefab_id = Readers._instance.n[counter].prefab_id;
            position  = Readers._instance.n[counter].position;
            sound_id  = Readers._instance.n[counter].sound_id;


            //Refer to SoundID
            md = prefabs[prefab_id].gameObject.GetComponent(typeof(MoveDown)) as MoveDown;


            md.soundID = sound_id;

            //Refer to SpriteRenderer
            sprite = prefabs[prefab_id].gameObject.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if (sprite)
            {
                sprite.sortingOrder = -counter;
            }
            /**/

            Instantiate(prefabs[prefab_id], new Vector3(position, positionY + offset, 0), Quaternion.identity);



            counter++;
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="GestureController"/> class.
        /// </summary>
        public GestureController()
        {
            // Define the gestures

            IRelativeGestureSegment moveDown = new MoveDown();

            AddGesture(GestureType.MoveDown, moveDown);

            IRelativeGestureSegment moveIn = new MoveIn();

            AddGesture(GestureType.MoveIn, moveIn);

            IRelativeGestureSegment moveLeft = new MoveLeft();

            AddGesture(GestureType.MoveLeft, moveLeft);

            IRelativeGestureSegment moveRight = new MoveRight();

            AddGesture(GestureType.MoveRight, moveRight);

            IRelativeGestureSegment moveOut = new MoveOut();

            AddGesture(GestureType.MoveOut, moveOut);

            IRelativeGestureSegment moveUp = new MoveUp();

            AddGesture(GestureType.MoveUp, moveUp);

            IRelativeGestureSegment handCloseOrOpen = new HandCloseOrOpen();

            AddGesture(GestureType.HandCloseOrOpen, handCloseOrOpen);

            IRelativeGestureSegment headMoved = new HeadMoved();

            AddGesture(GestureType.HeadMoved, headMoved);

            //CvInvoke.cvNamedWindow("Source");
        }
Ejemplo n.º 29
0
 void Update()
 {
     if (Input.GetKey(KeyCode.A))
     {
         moveLeft = new MoveLeft(transform, speed);
         moveLeft.Execute();
     }
     if (Input.GetKey(KeyCode.D))
     {
         moveRight = new MoveRight(transform, speed);
         moveRight.Execute();
     }
     if (Input.GetKey(KeyCode.W))
     {
         moveUp = new MoveUp(transform, speed);
         moveUp.Execute();
     }
     if (Input.GetKey(KeyCode.S))
     {
         moveDown = new MoveDown(transform, speed);
         moveDown.Execute();
     }
 }
Ejemplo n.º 30
0
        private void OnUIElementManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs args)
        {
            double translationX = args.Cumulative.Translation.X - m_lastCapturedPoint.X;
            double translationY = args.Cumulative.Translation.Y - m_lastCapturedPoint.Y;

            if ((Math.Abs(translationX) > RECOGNIZE_DISTANCE) ||
                (Math.Abs(translationY) > RECOGNIZE_DISTANCE))
            {
                //Handle the case when one coordinat is zero
                if (translationX == 0f)
                {
                    if (translationY < 0f)
                    {
                        MoveTop.Raise(this, EventArgs.Empty);
                    }
                    else if (CanRaiseEvent())
                    {
                        MoveDown.Raise(this, EventArgs.Empty);
                        m_lastEventTimestamp = DateTime.UtcNow;
                    }

                    m_lastCapturedPoint = args.Cumulative.Translation;
                    return;
                }
                else if (translationY == 0f)
                {
                    if (translationX < 0f)
                    {
                        MoveLeft.Raise(this, EventArgs.Empty);
                    }
                    else if (CanRaiseEvent())
                    {
                        MoveRight.Raise(this, EventArgs.Empty);
                        m_lastEventTimestamp = DateTime.UtcNow;
                    }

                    m_lastCapturedPoint = args.Cumulative.Translation;
                    return;
                }

                //Handling logic for standard case
                float xToY = (float)translationX / (float)translationY;
                float yToX = (float)translationY / (float)translationX;
                if (Math.Abs(xToY) < 0.4f)
                {
                    if (translationY < 0f)
                    {
                        MoveTop.Raise(this, EventArgs.Empty);
                    }
                    else if (CanRaiseEvent())
                    {
                        MoveDown.Raise(this, EventArgs.Empty);
                        m_lastEventTimestamp = DateTime.UtcNow;
                    }

                    m_lastCapturedPoint = args.Cumulative.Translation;
                    return;
                }
                else if (Math.Abs(yToX) < 0.4f)
                {
                    if (translationX < 0f)
                    {
                        MoveLeft.Raise(this, EventArgs.Empty);
                    }
                    else if (CanRaiseEvent())
                    {
                        MoveRight.Raise(this, EventArgs.Empty);
                        m_lastEventTimestamp = DateTime.UtcNow;
                    }

                    m_lastCapturedPoint = args.Cumulative.Translation;
                    return;
                }
            }
        }
Ejemplo n.º 31
0
    void Update()
    {
        playerController.Run();
        if (delay <= 0) {
            if (rowNum < levelRows.Length) {
                string levelRow = levelRows[rowNum];
                rowNum++;
                string[] enemyIds = levelRow.Split(',');
                for (int i = 0; i < enemyIds.Length; i++) {
                    DbItem enemyItem = null;
                    EnemyBehaviour enemy = null;
                    string enemyId = enemyIds[i];
                    string movementId = null;
                    if (enemyIds[i].Contains(":")) {
                        enemyId = enemyIds[i].Split(':')[0];
                        movementId = enemyIds[i].Split(':')[1];
                        //enemyId = enemyIds[i].Substring(0, enemyIds[i].IndexOf(':'));
                        //movementId = enemyIds[i].Substring(enemyIds[i].IndexOf(':') + 1);
                    }
                    switch (enemyId) {
                        case "0":
                            break;
                        case "1": {
                                enemyItem = ItemDatabase.GetItemByFileId("0");
                                enemy = new Blinky();
                                enemy.SetHealth(3);
                                break;
                            }
                        case "2": {
                                enemyItem = ItemDatabase.GetItemByFileId("1");
                                enemy = new Skrull();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "3": {
                                enemyItem = ItemDatabase.GetItemByFileId("2");
                                enemy = new RedReaper();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "4": {
                                enemyItem = ItemDatabase.GetItemByFileId("6");
                                enemy = new Striker();
                                enemy.SetHealth(8);
                                enemy.SetExplosionFX(ItemDatabase.GetItemByName("ExplosionOrange").gameModel);
                                break;
                            }
                        default:
                            Debug.Log("Unknown Item ID: " + enemyIds[i]);
                            break;
                    }
                    if (enemy != null && enemyItem != null) {
                        enemy.SetModel((GameObject)GameObject.Instantiate(enemyItem.gameModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyItem.gameModel.transform.rotation));
                        enemy.GetModel().GetComponent<CollisionController>().SetObject(enemy);
                        //print("EnemyObject: " + enemy);
                        if (movementId != null) {
                            //print("MoveId: " + movementId);
                            EnemyMovement movement = null;
                            switch (movementId) {
                                case "0":
                                    break;
                                case "1":
                                    {
                                        movement = new MoveDown();
                                        movement.SetEnemy(enemy.GetModel());
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveDown>();
                                        break;
                                    }
                                case "2":
                                    {
                                        //MoveRightAngle moveRightAngle = new MoveRightAngle();
                                        movement = new MoveRightAngle();
                                        movement.SetEnemy(enemy.GetModel());
                                        //moveRightAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveRightAngle;
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveRightAngle>();
                                        break;
                                    }
                                case "3":
                                    {
                                        movement = new MoveLeftAngle();
                                        movement.SetEnemy(enemy.GetModel());

                                        //MoveLeftAngle moveLeftAngle = new MoveLeftAngle();
                                        //EnemyMovement movement = moveLeftAngle;
                                        //movement.SetEnemy(enemy.GetModel());
                                        //moveLeftAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveLeftAngle;
                                        //enemy.SetMovement(movement);

                                        //enemyObject.AddComponent<MoveLeftAngle>();
                                        break;
                                    }
                                default:
                                    Debug.Log("Unkown Movement ID: " + movementId);
                                    break;
                            }
                            if (movement is ScreenAware) {
                                ((ScreenAware)movement).SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                            }
                            enemy.SetMovement(movement);
                        }
                    }
                    if (enemy != null) {
                        //GameObject enemyModel = enemyItem.gameModel;
                        //GameObject enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;

                        //enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;
                        //enemyObject.GetComponent<EnemyBehaviour>().SetHealth(enemyItem.health);
                        //enemyObject.GetComponent<EnemyBehaviour>().SetMovement(movement);

                        //enemyObject.AddComponent<MoveDown>();

                        //spawnedObjects.Add(enemy);
                        GarbageCollector.AddGameObject(enemy);
                    }
                }
            }
            delay = spawnDelay * Time.deltaTime;
        } else {
            delay -= Time.deltaTime;
        }

        //List<EnemyBehaviour> markedObjects = new List<EnemyBehaviour>();
        List<ObjectModel> om = GarbageCollector.GetObjects();
        foreach (ObjectModel o in om) {
            if (o is EnemyBehaviour) {
                ((EnemyBehaviour)o).Move(2.5f);
            }
        }
        List<GameObject> markedItems = new List<GameObject>();
        foreach (KeyValuePair<GameObject, Vector3> item in SpawnItem.GetItems()) {
            GameObject spawnedItem = (GameObject)Instantiate(item.Key, item.Value, Quaternion.identity);
            markedItems.Add(item.Key);
        }
        foreach (GameObject g in markedItems) {
            SpawnItem.RemoveItem(g);
        }

        GarbageCollector.Clean();
    }
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (KeyValidator.IsUpKey(e.Key))
            {
                e.Handled = true;
                MoveUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDownKey(e.Key))
            {
                e.Handled = true;
                MoveDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsLeftKey(e.Key))
            {
                e.Handled = true;
                MoveLeft?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsRightKey(e.Key))
            {
                e.Handled = true;
                MoveRight?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageDownKey(e.Key))
            {
                e.Handled = true;
                MovePageDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageUpKey(e.Key))
            {
                e.Handled = true;
                MovePageUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDeleteKey(e.Key))
            {
                if (!ReadOnlyMode)
                {
                    e.Handled = true;
                    ByteDeleted?.Invoke(this, new EventArgs());

                    return;
                }
            }
            else if (KeyValidator.IsBackspaceKey(e.Key))
            {
                e.Handled = true;
                ByteDeleted?.Invoke(this, new EventArgs());

                MovePrevious?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsEscapeKey(e.Key))
            {
                e.Handled = true;
                EscapeKey?.Invoke(this, new EventArgs());
                return;
            }

            //MODIFY BYTE
            if (!ReadOnlyMode)
            {
                if (KeyValidator.IsHexKey(e.Key))
                {
                    string key;
                    if (KeyValidator.IsNumericKey(e.Key))
                    {
                        key = KeyValidator.GetDigitFromKey(e.Key).ToString();
                    }
                    else
                    {
                        key = e.Key.ToString().ToLower();
                    }

                    switch (_keyDownLabel)
                    {
                    case KeyDownLabel.FirstChar:
                        FirstHexChar.Content = key;
                        _keyDownLabel        = KeyDownLabel.SecondChar;
                        Action = ByteAction.Modified;
                        Byte   = ByteConverters.HexToByte(FirstHexChar.Content.ToString() + SecondHexChar.Content.ToString())[0];
                        break;

                    case KeyDownLabel.SecondChar:
                        SecondHexChar.Content = key;
                        _keyDownLabel         = KeyDownLabel.NextPosition;

                        Action = ByteAction.Modified;
                        Byte   = ByteConverters.HexToByte(FirstHexChar.Content.ToString() + SecondHexChar.Content.ToString())[0];

                        //Move focus event
                        MoveNext?.Invoke(this, new EventArgs());
                        break;
                    }
                }
            }
        }
Ejemplo n.º 33
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (playerObject == null)
            {
                return;
            }

            var moved = false;

            if (PlayerSettings.canMove)
            {
                var calc = PlayerSettings.minPlayerSpeed * (PlayerSettings.maxPlayerSize / playerObject.size);

                var speed = calc > PlayerSettings.maxPlayerSpeed ? PlayerSettings.maxPlayerSpeed : calc;
                var mover = new PlayerMover();
                if (PlayerSettings.movingUp)
                {
                    var newCoord = playerObject.yCoord - speed;
                    if (newCoord < 0)
                    {
                        return;
                    }

                    ICommand moveUp = new MoveUp(playerObject, newCoord);
                    mover.performMove(moveUp);
                    moved = true;
                }

                if (PlayerSettings.movingDown)
                {
                    var newCoord = playerObject.yCoord + speed;
                    if (newCoord > maxY)
                    {
                        return;
                    }

                    ICommand moveDown = new MoveDown(playerObject, newCoord);
                    mover.performMove(moveDown);
                    moved = true;
                }

                if (PlayerSettings.movingLeft)
                {
                    var newCoord = playerObject.xCoord - speed;
                    if (newCoord < 0)
                    {
                        return;
                    }

                    ICommand moveLeft = new MoveLeft(playerObject, newCoord);
                    mover.performMove(moveLeft);
                    moved = true;
                }

                if (PlayerSettings.movingRight)
                {
                    var newCoord = playerObject.xCoord + speed;
                    if (newCoord > maxX)
                    {
                        return;
                    }

                    ICommand moveRight = new MoveRight(playerObject, newCoord);
                    mover.performMove(moveRight);
                    moved = true;
                }

                //Create memento only if moved.
                if (moved)
                {
                    playerObject.SetPosition(new TwoDimensionalPosition
                    {
                        X = playerObject.xCoord,
                        Y = playerObject.yCoord
                    });

                    playerPositions.AddMemento(playerObject.CreateMemento());
                }
            }
            else
            {
                timer--;
                savedPositionCount--;

                var newPos = playerPositions.GetMemento(savedPositionCount);

                if (newPos.GetSavedPosition(playerObject.Uuid) != null)
                {
                    playerObject.MoveX(newPos.GetSavedPosition(playerObject.Uuid).X);
                    moved = true;
                }

                if (newPos.GetSavedPosition(playerObject.Uuid) != null)
                {
                    playerObject.MoveY(newPos.GetSavedPosition(playerObject.Uuid).Y);
                    moved = true;
                }

                //Stop moving back either when timer ends or when out of saved positions
                if (timer <= 0 || savedPositionCount <= 0)
                {
                    PlayerSettings.canMove = true;
                }
            }

            //Send player locations to server.
            if (moved)
            {
                var content = new Dictionary <string, string>
                {
                    { "playerUuid", currentPlayer.Uuid },
                    { "xCoord", playerObject.objectControl.Location.X.ToString() },
                    { "yCoord", playerObject.objectControl.Location.Y.ToString() }
                };

                updater.PostData("api/player/move", Processor.PostDataType.Post, content);
            }

            CheckForCollision();
        }
Ejemplo n.º 34
0
	void Start()
	{
		playerObject = GameObject.FindGameObjectWithTag (Tags.player);
		moveDown = GetComponent<MoveDown> ();
	}