Пример #1
0
        /// <summary>
        /// prints the progress bar acorrding to pointers and current direction
        /// </summary>
        public override void Step()
        {
            if (this.currdir == direction.right)
            {
                this.PlacePointer(counter, this.pointer.Length);
                this.counter++;
                if (this.counter+this.pointer.Length == this.bar.Length)
                    this.currdir = direction.left;
            }
            else
            {
                this.PlacePointer(counter - this.pointer.Length, this.pointer.Length);
                this.counter--;
                if (this.counter == this.pointer.Length)
                    this.currdir = direction.right;
            }
            if (usepercent)
            {
                cur++;

                Console.SetCursorPosition(8, 0);
                Console.Write("{0}%", cur / max + 100);
            }

            Console.Write(this.bar + "\r");
        }
Пример #2
0
	IEnumerator disableDirectionForTime(direction dir, float time){
		if (dir == direction.RIGHT) rightDisabled = true;
		else leftDisabled = true;
		yield return new WaitForSeconds(time);
		if (dir == direction.RIGHT) rightDisabled = false;
		else leftDisabled = false;
	}
Пример #3
0
        public bool constructHorizontalLayer(List<Data.Rectangle> rectangle, int w,int h)
        {
            this.directionOfLayer = direction.Horizontal;
            int w1 = 0;
            this.start = h;
            this.end = -1;
            while (w1 < w )
            {
                if (rectangle.Count == 0)
                {
                    Console.WriteLine("Zabraklo prostokatow by skonczyc warstwe");
                    return false; //moze cos lepiej
                }
                Data.Rectangle rect = rectangle[0];
                rectangle.Remove(rect);
                this.listUsedRectangles.Add(rect); //niepotzrebne

                Data.PartOfSolution part = new Data.PartOfSolution();
                part.Xlu = w1;
                part.Ylu = h;
                part.Xrd = w1 + rect.Width;
                part.Yrd = h + rect.Height;
                this.listPartOfSolution.Add(part);
                w1 += rect.Width;

                if (this.end == -1 || this.end > part.Yrd)//h + rect.Height)
                    this.end = part.Yrd;// h + rect.Height;  //zapamietuje najglebsze wciecie!!!!!!
                this.lastPartEnd = part.Xrd;
                if (this.end2 < part.Yrd)
                    this.end2 = part.Yrd;
            }
            return true;
        }
        public void Move()
        {
            Vector3 position = gameObject.transform.position;
            float newX = position.x;

            switch (moveDiection)
            {
                case direction.left:
                    newX = position.x - Time.deltaTime * movementSpeed;
                    if (newX < minX)
                    {
                        moveDiection = direction.right;
                    }
                    else
                    {
                        position.x = newX;
                    }
                    break;
                case direction.right:
                    newX = position.x + Time.deltaTime * movementSpeed;
                    if (newX > maxX)
                    {
                        moveDiection = direction.left;
                    }
                    else
                    {
                        position.x = newX;
                    }
                    break;
            }

            gameObject.transform.position = position;
        }
Пример #5
0
        public Thread thread; //the algorithm thread it should run

        #endregion Fields

        #region Constructors

        //CONSTRUCTOR: Initializes the color, the total number of nodes in the system, it's id, and its randomized starting position
        public Node(Color c,int totalNodes,int id, int startingPosition)
        {
            //Initializes variables
            replyNum = 0;
            m_speed = 25;
            m_color = c;
            m_location = startingPosition;
            m_size = totalNodes;
            m_id = id;

            m_timestamp = 0;
            m_requestDeffered = new bool[m_size];
            for (int j = 0; j < m_size; j++)
                m_requestDeffered[j] = false;

            leftCS = 0;
            rightCS = 0;
            dir = direction.left;

            //Create the Node Image to display to the screen
            m_image = new Bitmap(40, 40);
            using (Graphics g = Graphics.FromImage(m_image))
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

                //Draws the faded border around the dot
                using (SolidBrush sb = new SolidBrush(Color.FromArgb(127, m_color)))
                    g.FillEllipse(sb, new Rectangle(0, 0, m_image.Width, m_image.Height));

                //Draws the actual small dot centered with the faded border
                g.FillEllipse(Brushes.Black, new Rectangle(m_image.Width / 2 - 2, m_image.Height / 2 - 2, 4, 4));
            }
        }
Пример #6
0
    public int ChangeDirection()
    {
        string newDir = movementBuffer[bufferIndex];

        if (newDir.ToLower().Equals("up"))
        {
            dir = direction.up;
        }
        else if (newDir.ToLower().Equals("down"))
        {
            dir = direction.down;
        }
        else if (newDir.ToLower().Equals("left"))
        {
            dir = direction.left;
        }
        else if (newDir.ToLower().Equals("right"))
        {
            dir = direction.right;
        }
        else //if (newDir.ToLower().Equals("stop") || newDir == null)
        {
            dir = direction.stop;

        }

        movementBuffer[bufferIndex] = "stop";

        if (bufferIndex < 5)
        {
            bufferIndex++;
        }

        return (int)dir;
    }
Пример #7
0
 void Update()
 {
     //Debug.Log(Input.GetAxis("PlayBall"));
     if (rigidbody2D.velocity.x < 0)
     {
         direct = direction.left;
     }
     if (rigidbody2D.velocity.x > 0)
     {
         direct = direction.right;
     }
     if (!gameStarted && Input.GetAxis("PlayBall") > 0.1f)
     {
         float ran = Random.Range(0, 2);
         if (ran > 1f)
             transform.rotation = Quaternion.Euler(0, 0, 180);
         else
             transform.rotation = Quaternion.Euler(0, 0, 0);
         gameStarted = true;
         rigidbody2D.velocity = GlobalBallSpeed.GetBallSpeed(transform.rotation.eulerAngles.z);
     }
     else if(gameStarted)
     {
         if (transform.position.x > 15f)
         {
             GlobalBallSpeed.score.x++;
             restartGame();
         }
         else if (transform.position.x < -15f)
         {
             GlobalBallSpeed.score.y++;
             restartGame();
         }
     }
 }
Пример #8
0
 public char GetSymbolByDirection(direction Direction)
 {
     if (Direction == direction.left) return Program.map[x - 1, y];
     if (Direction == direction.right) return Program.map[x + 1, y];
     if (Direction == direction.up) return Program.map[x, y - 1];
     return Program.map[x, y + 1];
 }
Пример #9
0
 //AI Stupid
 void Move()
 {
     switch (currentDirection)
     {
         case direction.right:
             sp.flipX = true;
             if (timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.right * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.left;
             }
             break;
         case direction.left:
             sp.flipX = false;
             if (timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.left * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.right;
             }
             break;
     }
 }
Пример #10
0
 //Ghost constructor
 public StupidGhost(int x, int y, direction Direction)
 {
     this.X = x;
     this.Y = y;
     currentStatePlace = Program.map.EmptySpace;
     objectDirection = Direction;
     Program.map.RenderChar(x, y, GetSymbol());
 }
Пример #11
0
			public testcase (string o, string p, string r, string e, direction d)
			{
				original = o;
				pattern = p;
				replacement = r;
				expected = e;
				direction = d;
			}
Пример #12
0
 //Ghost constructor
 public SmartGhost(int x, int y, direction Direction)
 {
     this.X = x;
     this.Y = y;
     currentStatePlace = Program.map.Jewel;
     objectDirection = Direction;
     Program.map.RenderChar(x, y, GetSymbol());
 }
Пример #13
0
 public SwayBar()
     : base()
 {
     this.bar = "|                         |";
     this.pointer = "***";
     this.blankPointer = this.BlankPointer();
     this.currdir = direction.right;
     this.counter = 1;
 }
Пример #14
0
        private static List <Edge> visitation(ref List <Point> list, direction direct)
        {
            List <Edge> result_edges = new List <Edge>();

            if (direct == direction.left)
            {
                for (int p1 = 0; p1 < list.Count(); ++p1)
                {
                    int  p2 = (p1 == list.Count() - 1 ? 0 : p1 + 1);
                    int  p3 = (p1 >= list.Count() - 2 ? (p1 == list.Count() - 2 ? 0 : 1) : p1 + 2);
                    Edge e1 = new Edge(list[p1], list[p2]);
                    Edge e2 = new Edge(list[p2], list[p3]);
                    result_edges.Add(e1);
                    result_edges.Add(e2);
                    Form1.DrawEvents.Add(new Painting(list, result_edges));
                    if ((e1.Vertex2.X - e1.Vertex1.X) * (e2.Vertex2.Y - e2.Vertex1.Y) - (e1.Vertex2.Y - e1.Vertex1.Y) * (e2.Vertex2.X - e2.Vertex1.X) < 0)
                    {
                        list.RemoveAt(p2);
                        p1 = -1;//p2 - 3;
                    }
                    result_edges.Clear();
                    Form1.DrawEvents.Add(new Painting(list, result_edges));
                    //if (p1 < 0) p1 = 0;
                }
            }
            if (direct == direction.right)
            {
                for (int p1 = 0; p1 < list.Count(); ++p1)
                {
                    int  p2 = (p1 == list.Count() - 1 ? 0 : p1 + 1);
                    int  p3 = (p1 >= list.Count() - 2 ? (p1 == list.Count() - 2 ? 0 : 1) : p1 + 2);
                    Edge e1 = new Edge(list[p1], list[p2]);
                    Edge e2 = new Edge(list[p2], list[p3]);
                    result_edges.Add(e1);
                    result_edges.Add(e2);
                    Form1.DrawEvents.Add(new Painting(list, result_edges));
                    if ((e1.Vertex2.X - e1.Vertex1.X) * (e2.Vertex2.Y - e2.Vertex1.Y) - (e1.Vertex2.Y - e1.Vertex1.Y) * (e2.Vertex2.X - e2.Vertex1.X) > 0)
                    {
                        list.RemoveAt(p2);
                        p1 = -1;//p2 - 3;
                    }
                    result_edges.Clear();
                    Form1.DrawEvents.Add(new Painting(list, result_edges));
                    //if (p1 < 0) p1 = 0;
                }
            }

            for (int p1 = 0; p1 < list.Count(); ++p1)
            {
                int p2 = (p1 == list.Count() - 1 ? 0 : p1 + 1);
                list[p1].Highlighted = true;
                list[p2].Highlighted = true;
                result_edges.Add(new Edge(list[p1], list[p2]));
                Form1.DrawEvents.Add(new Painting(list, result_edges));
            }
            return(result_edges);
        }
Пример #15
0
    public static void Main(string[] args)
    {
        WriteLine("Module01 Exercises");
        module01();

        WriteLine("\n\nModule02 Exercises");
        module02();
        direction dir = direction.NORTH;
    }
Пример #16
0
 void ShootDown()
 {
     shootDirection = new Vector3(0, 0, -1);
     if (buttonClicked == direction.Down)
     {
         Dash(new Vector3(0, 0, -1));
     }
     buttonClicked = direction.Down;
 }
Пример #17
0
 void ShootUp()
 {
     shootDirection = new Vector3(0, 0, 1);
     if (buttonClicked == direction.Up)
     {
         Dash(new Vector3(0, 0, 1));
     }
     buttonClicked = direction.Up;
 }
Пример #18
0
 void ShootLeft()
 {
     shootDirection = new Vector3(-1, 0, 0);
     if (buttonClicked == direction.Left)
     {
         Dash(Vector3.left);
     }
     buttonClicked = direction.Left;
 }
Пример #19
0
 public Car(direction direction, double CarRow, double CarColumn, int SpawnPosition, double speed, bool TravellingLeftward)
 {
     CarDirection            = direction;
     this.CarRow             = CarRow;
     this.CarColumn          = CarColumn;
     this.SpawnPosition      = SpawnPosition;
     this.Speed              = speed;
     this.TravellingLeftward = TravellingLeftward;
 }
Пример #20
0
    private bool isOppositeDirection(direction checkDirection)
    {
        if (currentDirection == checkDirection)
        {
            return(true);
        }

        return(false);
    }
Пример #21
0
 public WaterObjects(direction WaterDirection, double WaterRow, double WaterColumn, int SpawnPosition, double speed, bool TravellingLeftward)
 {
     this.WaterDirection     = WaterDirection;
     this.WaterRow           = WaterRow;
     this.WaterColumn        = WaterColumn;
     this.SpawnPosition      = SpawnPosition;
     this.Speed              = speed;
     this.TravellingLeftward = TravellingLeftward;
 }
Пример #22
0
    private void goInDirection(direction d)
    {
        if (d != direction.NONE)
        {
            transform.rotation = directionToRotation [d];
        }

        rb.velocity = directionToVelocity [d] * speed;
    }
Пример #23
0
 void ShootRight()
 {
     shootDirection = new Vector3(1, 0, 0);
     if (buttonClicked == direction.Right)
     {
         Dash(Vector3.right);
     }
     buttonClicked = direction.Right;
 }
Пример #24
0
		public void move (direction direction)
		{
				//scanner = gameEngine.Instance.getScanner ();
				//start_move ();
				RichmanAnimator rplayer = character_stage.GetComponent<RichmanAnimator> () as RichmanAnimator;
				coming_steps = Random.Range (1, 6);
				rplayer.move (coming_steps);
				player_status = status.MOVING;
		}
        private static position getPosition(int x, int y, direction direction)
        {
            position newPosition = new position();

            newPosition.x         = x;
            newPosition.y         = y;
            newPosition.direction = direction;
            return(newPosition);
        }
Пример #26
0
 public Cell(int x, int y, int value, direction direction, int ringValue)
 {
     this.x          = x;
     this.y          = y;
     this.value      = value;
     this.Neighbours = new List <Cell>();
     this.direction  = direction;
     this.ringValue  = ringValue;
 }
Пример #27
0
 // Use this for initialization
 void Start()
 {
     animator         = GetComponent <Animator>();
     sprite           = GetComponent <SpriteRenderer>();
     rb               = GetComponent <Rigidbody2D>();
     audio            = GetComponent <AudioSource>();
     CavemanDirection = direction.down;
     animator.runtimeAnimatorController = down;
 }
Пример #28
0
    /// <summary>
    /// Figures out the input of the user and applies it to the player, and changes the animation conditions depending on the input.
    /// </summary>
    void Update()
    {
        walkV           = Input.GetAxisRaw("Vertical");
        walkH           = Input.GetAxisRaw("Horizontal");
        switchInventory = Input.GetAxisRaw("Inventory Scroll");
        action          = Input.GetAxis("Action");
        pick            = Input.GetAxis("Pick");

        if (animCon.animFinished)
        {
            if (switchInventory != 0)
            {
                walkV    = 0;
                walkH    = 0;
                movement = direction.forward;
                invCon.MoveInventory(switchInventory);
                animCon.SwitchInventory();
                invCon.ShowItem();
            }
            else if (action != 0 && invCon.currItem != null)
            {
                if (invCon.currItem.tag == "tool")
                {
                    animCon.UseTool(invCon.currItem.GetComponent <Tool>().AnimVar());
                    isInteracting = true;
                }
                else if (invCon.currItem.tag == "seeds")
                {
                    invCon.RemoveItem(invCon.currItem);
                    animCon.UseSeeds();
                    isInteracting = true;
                }
                else if (invCon.currItem.tag == "crop" || invCon.currItem.tag == "fence")
                {
                    animCon.Throw();
                    isInteracting = true;
                }
            }
            else if (pick != 0) //and there's something there and there's nothing in the player's hands
            {
                //Will need changing when merged and able to look at grid system
                Vector2      mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                RaycastHit2D hit      = Physics2D.Raycast(transform.position, mousePos, 1);
                if (hit.collider != null)
                {
                    animCon.PickUp();
                    invCon.AddItem(hit.collider.gameObject);
                    Destroy(hit.collider.gameObject);
                }
            }
            else
            {
                MovePlayer();
                CheckDirection();
            }
        }
    }
Пример #29
0
 private void ChangeStates()
 {
     timeSinceLastStateChange = 0;
     timeToChangeState        = GetRandomTime();
     SpiderGuyDirection       = GetRandomDirection();
     SpiderGuyState           = GetRandomState();
     SetAnimatorOverride();
     SetAnimations();
 }
    //Instantiate modul
    void CreateModul(GameObject modul, Vector3 pos, direction oppositDirection)
    {
        GameObject   newModul = Instantiate(modul, pos, Quaternion.identity);
        ModulManager script   = newModul.GetComponent <ModulManager>();

        script.RotateToDoor(oppositDirection);
        modulCount++;
        BuildLevel(newModul, oppositDirection);
    }
Пример #31
0
 public PuzzleState(int[][] aPuzzle)
 {
     Parent         = null;
     PathFromParent = null;
     Cost           = 0;
     Puzzle         = aPuzzle;
     EvaluationFunction_Conflict = 0;
     HeuristicValue = 0;
 }
Пример #32
0
 public PuzzleState(PuzzleState aParent, direction aFromParent, int[][] aPuzzle)
 {
     Parent         = aParent;
     PathFromParent = aFromParent;
     Puzzle         = aPuzzle;
     Cost           = Parent.Cost + 1;
     EvaluationFunction_Conflict = 0;
     HeuristicValue = 0;
 }
Пример #33
0
        private void UpdateSnakeShape(direction moveto)
        {
            switch (moveto)
            {
            case direction.up:
                SnakeHead_y--;
                break;

            case direction.down:
                SnakeHead_y++;
                break;

            case direction.right:
                SnakeHead_x++;
                break;

            case direction.left:
                SnakeHead_x--;
                break;

            default:
                break;
            }

            // remove the tale
            int[] tale = SnakeShape.Last.Value;
            Console.SetCursorPosition(tale[0], tale[1]);
            Console.Write(' ');

            //move the snake to the next position by its coordinates
            // put first let's check if its head get crashed into the walls or its body
            int[] NewHead = { SnakeHead_x, SnakeHead_y };
            if (NewHead[0] == Width || NewHead[0] <= 0 || NewHead[1] > Hieght || NewHead[1] == 0)
            {
                GameOver = true;
            }
            foreach (int[] item in SnakeShape)
            {
                if (NewHead[0] == item[0] && NewHead[1] == item[1])
                {
                    GameOver = true;
                }
            }
            SnakeShape.AddFirst(NewHead);
            if (!(Fruit_x == SnakeHead_x && Fruit_y == SnakeHead_y))
            {
                // remeove the old coordinates of the tale
                // but only if the snake didn't catch the fruit
                SnakeShape.Remove(SnakeShape.Last);
            }
            else
            {
                // if the fruit has been eaten then put another one and update the score
                PrintFruit();
                Score += 10;
            }
        }
Пример #34
0
        static bool fixPosition(ref Point p, direction dir, bool positive, int step)//请将Point务必设置为临时变量
        {
            int m, n;

            dirTo_mn(dir, out m, out n, positive);
            p.X += m * step;
            p.Y += n * step;
            return(checkP(p));
        }
Пример #35
0
 // Initiate a dash depending on inputted direction.
 void initiateDash()
 {
     canDash = false;
     dashing = true;
     moving  = false;
     Instantiate(dashEffect, transform.position, Quaternion.identity);
     sfxSource.PlayOneShot(dashSound);
     if (Input.GetKey(KeyCode.UpArrow) && Input.GetKey(KeyCode.LeftArrow))
     {
         dir       = direction.NW;
         targetPos = new Vector2(pos.x - dashLenComponent, pos.y + dashLenComponent);
     }
     else if (Input.GetKey(KeyCode.UpArrow) && Input.GetKey(KeyCode.RightArrow))
     {
         dir       = direction.NE;
         targetPos = new Vector2(pos.x + dashLenComponent, pos.y + dashLenComponent);
     }
     else if (Input.GetKey(KeyCode.DownArrow) && Input.GetKey(KeyCode.LeftArrow))
     {
         dir       = direction.SW;
         targetPos = new Vector2(pos.x - dashLenComponent, pos.y - dashLenComponent);
     }
     else if (Input.GetKey(KeyCode.DownArrow) && Input.GetKey(KeyCode.RightArrow))
     {
         dir       = direction.SE;
         targetPos = new Vector2(pos.x + dashLenComponent, pos.y - dashLenComponent);
     }
     else if (Input.GetKey(KeyCode.UpArrow))
     {
         dir       = direction.N;
         targetPos = new Vector2(pos.x, pos.y + dashLen);
     }
     else if (Input.GetKey(KeyCode.LeftArrow))
     {
         dir       = direction.W;
         targetPos = new Vector2(pos.x - dashLen, pos.y);
     }
     else if (Input.GetKey(KeyCode.RightArrow))
     {
         dir       = direction.E;
         targetPos = new Vector2(pos.x + dashLen, pos.y);
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         dir       = direction.S;
         targetPos = new Vector2(pos.x, pos.y - dashLen);
     }
     else if (dir == direction.W)
     {
         targetPos = new Vector2(pos.x - dashLen, pos.y);
     }
     else if (dir == direction.E)
     {
         targetPos = new Vector2(pos.x + dashLen, pos.y);
     }
 }
Пример #36
0
        static public void AutoMove(direction?dir)
        {
            if (dir is null)
            {
                dir = currentDirection;
            }
            else
            {
                currentDirection = dir.Value;
            }

            switch (dir.Value)
            {
            case direction.left:
                locationX--;
                break;

            case direction.up:
                locationY--;
                break;

            case direction.down:
                locationY++;
                break;

            case direction.right:
                locationX++;
                break;
            }

            if (locationX < 1)
            {
                locationX = size - 2;
            }
            else if (locationX > size - 2)
            {
                locationX = 1;
            }
            else if (locationY > size - 2)
            {
                locationY = 0;
            }
            else if (locationY < 0)
            {
                locationY = size - 2;
            }

            Console.SetCursorPosition(locationX, locationY);
            Console.Write("*");
            Console.SetCursorPosition(locationX, locationY);
            lengthSnace.Enqueue(locationX);
            lengthSnace.Enqueue(locationY);
            bodySnace.Add(locationX);
            bodySnace.Add(locationY);
            Thread.Sleep(speed);
        }
Пример #37
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (target != null)
        {
            Vector2 pos_camera = new Vector2(transform.position.x, transform.position.y);



            if (Input.GetAxisRaw("Horizontal") < 0)
            {
                player_x    = direction.LEFT;
                pos_camera += Vector2.right * DISTANCE_MAX * 2;
            }

            if (Input.GetAxisRaw("Horizontal") > 0)
            {
                player_x    = direction.RIGHT;
                pos_camera -= Vector2.right * DISTANCE_MAX * 2;
            }

            if (Input.GetAxisRaw("Vertical") < 0)
            {
                player_x    = direction.DOWN;
                pos_camera += Vector2.up * DISTANCE_MAX * 2;
            }

            if (Input.GetAxisRaw("Vertical") > 0)
            {
                player_x    = direction.UP;
                pos_camera -= Vector2.up * DISTANCE_MAX * 2;
            }

            Vector2 pos_player = new Vector2(target.position.x, target.position.y);
            delta_pos = (pos_player - pos_camera);
            float distance = delta_pos.sqrMagnitude;


            if (-DISTANCE_MAX <= distance && distance >= DISTANCE_MAX)
            {
                if (delta_pos.x >= DISTANCE_MAX || delta_pos.x <= -DISTANCE_MAX)
                {
                    _rigid.AddForce(Vector2.right * Time.deltaTime * delta_pos.normalized.x * DELTA_SPEED);
                }

                if (delta_pos.y >= DISTANCE_MAX || delta_pos.y <= -DISTANCE_MAX)
                {
                    _rigid.AddForce(Vector2.up * Time.deltaTime * delta_pos.normalized.y * DELTA_SPEED);
                }
            }
        }
        else
        {
            target             = GameObject.Find("player(Clone)").transform;
            transform.position = target.transform.position - Vector3.forward * DELTA_CAMERA;
        }
    }
        static void Main(string[] args)
        {
            string factoryID;

            string [] factories;

            loginService = ConnectionUtils.getLoginService();
            sessionID    = testLogin();


            factories = getFactories(loginService, sessionID);
            factoryID = factories[0];


            bool connected = connectToFactory(factoryID);

            registerMQListener(factoryID);
            Console.WriteLine("Connected to factory: " + connected);


            loginService.Close();
            factoryService = ConnectionUtils.getFactoryService();
            factory connectedFactory = factoryService.getFactory(sessionID);

            printFactory(connectedFactory);


            string itemId1 = createItem(1, 17, 42, FactoryServiceReference.direction.SOUTH);
            string itemId2 = createItem(89, 0, 0, FactoryServiceReference.direction.NORTH);

            connectedFactory = factoryService.getFactory(sessionID);
            printFactory(connectedFactory);


            int       x   = 20;
            int       y   = 20;
            direction dir = direction.WEST;
            position  pos = getPosition(20, 20, direction.WEST);

            Console.WriteLine("Moving item " + itemId1 + " to " + x + "," + y + ", direction:" + dir);
            factoryService.moveItem(sessionID, itemId1, pos);

            connectedFactory = factoryService.getFactory(sessionID);
            printFactory(connectedFactory);


            Console.WriteLine("deleting item " + itemId1);
            factoryService.deleteItem(sessionID, itemId1);

            connectedFactory = factoryService.getFactory(sessionID);
            printFactory(connectedFactory);


            Console.WriteLine("Warte auf input");
            Console.ReadKey();
        }
Пример #39
0
        public static int calculateDistance()
        {
            int result = 0;

            valueCoordinates[1] = new Tuple <int, int>(spiralDistanceHorizontalCurrent, spiralDistanceVerticalCurrent);
            for (int i = 2; i <= 325489; i++)
            {
                switch (currentDirection)
                {
                case direction.HORIZONTALMINUS:
                {
                    spiralDistanceHorizontalCurrent--;
                    break;
                }

                case direction.HORIZONTALPLUS:
                {
                    spiralDistanceHorizontalCurrent++;
                    if (spiralDistanceVerticalCurrent == 0 && spiralDistanceHorizontalCurrent == 1)
                    {
                        currentDirection = (direction)(((int)currentDirection + 1) % 4);
                    }
                    break;
                }

                case direction.VERTICALMINUS:
                {
                    spiralDistanceVerticalCurrent--;
                    break;
                }

                case direction.VERTICALPLUS:
                {
                    spiralDistanceVerticalCurrent++;
                    break;
                }
                }

                if (Math.Abs(spiralDistanceVerticalCurrent) == Math.Abs(spiralDistanceVerticalMax) &&
                    Math.Abs(spiralDistanceHorizontalCurrent) == Math.Abs(spiralDistanceHorizontalMax))
                {
                    currentDirection = (direction)(((int)currentDirection + 1) % 4);
                }
                if (spiralDistanceVerticalCurrent == -spiralDistanceVerticalMax && spiralDistanceHorizontalCurrent == -spiralDistanceHorizontalMax)
                {
                    spiralDistanceHorizontalMax++;
                }
                if (spiralDistanceVerticalCurrent == -spiralDistanceVerticalMax && spiralDistanceHorizontalCurrent == spiralDistanceHorizontalMax)
                {
                    spiralDistanceVerticalMax++;
                }
                valueCoordinates[1] = new Tuple <int, int>(spiralDistanceHorizontalCurrent, spiralDistanceVerticalCurrent);
            }
            result = Math.Abs(spiralDistanceVerticalCurrent) + Math.Abs(spiralDistanceHorizontalCurrent);
            return(result);
        }
Пример #40
0
        public Animation(int speed, Bitmap[] frames, direction direction)
        {
            this.speed  = speed;
            this.frames = frames;
            index       = frames.Length - 1;
            lastTime    = currentTimeMillis();
            timer       = 0;

            currentDirection = (int)direction;
        }
Пример #41
0
 void Start()
 {
     animatorController = new GameObject[4];
     size                   = transform.lossyScale.x;
     myDirection            = direction.Up;
     animatorController [0] = animatorController1;
     animatorController [1] = animatorController2;
     animatorController [2] = animatorController3;
     animatorController [3] = animatorController4;
 }
Пример #42
0
    private void Flip()
    {
        currentDirection = (currentDirection == direction.LEFT) ? direction.RIGHT : direction.LEFT;

        selfTransform.localScale = new Vector3(
            (currentDirection == direction.LEFT) ? -initialScale.x : initialScale.x,
            initialScale.y,
            1
        );
    }
 public void AddDamagedThruster(direction damagePoint)
 {
     if (ThrustersDamagable)
     {
         if (!damagedThrusters.Contains(damagePoint))
         {
             damagedThrusters.Add(damagePoint);
         }
     }
 }
Пример #44
0
    private direction birthDirection;                 //生成的方位
    void Awake()
    {
        //初始化颜色
        grayLevel = Random.Range(0, 6);
        IniGrayLevel();

        myCamera       = GameObject.FindWithTag("MainCamera");
        birthDirection = (direction)Random.Range(0, 4);
        SetBirthPosition();
    }
Пример #45
0
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();

        currentDirection = direction.left;
        currentState     = states.idle;

        colider = GetComponent <Collider2D>();
        frog    = GetComponent <Rigidbody2D>();
    }
Пример #46
0
    // Update is called once per frame
    void Update()
    {
        Vector3 tempPos;
        if (p.moving == true) {
            //for one leg
            tempPos = firstLeg.transform.localPosition;
            tempPos.x += ((int)dir) * speed * Time.deltaTime;
            firstLeg.transform.localPosition = tempPos;

            if (tempPos.x >= fmaxdis) {
                dir = direction.left;
            } else if (tempPos.x <= fmindis) {
                dir = direction.right;
            }

            //for second leg

            tempPos = secondLeg.transform.localPosition;
            tempPos.x += ((int)dir) * speed * Time.deltaTime * -1;
            secondLeg.transform.localPosition = tempPos;

            tempPos = thirdLeg.transform.localPosition;
            tempPos.x += ((int)dir) * speed * Time.deltaTime * -1;
            thirdLeg.transform.localPosition = tempPos;

            tempPos = fourthLeg.transform.localPosition;
            tempPos.x += ((int)dir) * speed * Time.deltaTime * 1;
            fourthLeg.transform.localPosition = tempPos;

        } else {

            //TODO can be done with less code!

            //first leg
            tempPos = firstLeg.transform.localPosition;
            tempPos.x = startpositions[0];
            firstLeg.transform.localPosition = tempPos;

            //second Leg
            tempPos = secondLeg.transform.localPosition;
            tempPos.x = startpositions[1];
            secondLeg.transform.localPosition = tempPos;

            //third leg
            tempPos = thirdLeg.transform.localPosition;
            tempPos.x = startpositions[2];
            thirdLeg.transform.localPosition = tempPos;

            //fourth leg
            tempPos = fourthLeg.transform.localPosition;
            tempPos.x = startpositions[3];
            fourthLeg.transform.localPosition = tempPos;

        }
    }
Пример #47
0
 void Move()
 {
     switch (currentDirection)
     {
         case direction.right:
             if(timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.right * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.left;
             }
             break;
         case direction.left:
             if (timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.left * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.right;
             }
             break;
         case direction.up:
             if (timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.up * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.down;
             }
             break;
         case direction.down:
             if (timer < time)
             {
                 timer += Time.deltaTime;
                 this.transform.Translate(Vector2.down * speed * Time.deltaTime);
             }
             else
             {
                 timer = 0f;
                 currentDirection = direction.up;
             }
             break;
     }
 }
Пример #48
0
        public SwayBar(bool usepercent = false)
            : base()
        {
            this.usepercent = usepercent;

            this.bar = "|                         |";
            this.pointer = "***";
            this.blankPointer = this.BlankPointer();
            this.currdir = direction.right;
            this.counter = 1;
        }
Пример #49
0
 public void Move(int i, direction dir)
 {
     if (dir == direction.RIGHT)
         x = x + i;
     else if (dir == direction.LEFT)
         x = x - i;
     else if (dir == direction.DOWN)
         y = y + i;
     else if (dir == direction.UP)
         y = y - 1;
 }
Пример #50
0
 public void HandleSnake(ctrl key)
 {
     if (key == ctrl.RightArrow && Direction != direction.LEFT)
         Direction = direction.RIGHT;
     else if (key == ctrl.LeftArrow && Direction != direction.RIGHT)
         Direction = direction.LEFT;
     else if (key == ctrl.UpArrow && Direction != direction.DOWN)
         Direction = direction.UP;
     else if (key == ctrl.DownArrow && Direction != direction.UP)
         Direction = direction.DOWN;
 }
Пример #51
0
    // Update is called once per frame
    void Update()
    {
        float currentZaxis = Input.acceleration.z - initZ;

        if((currentZaxis > 0.2) && (EventStarted == false))
        {
            EventStarted = true;
            startTime = Time.time;
            tiltCapReached = true;
            currentDir = direction.up;
            EventSent = false;

        }

        else if((currentZaxis < -0.3) && (EventStarted == false))
        {
            EventStarted = true;
            startTime = Time.time;
            tiltCapReached = true;
            currentDir = direction.down;
            EventSent=false;
        }

        if (((Time.time - startTime) < 1) && tiltCapReached)
        {
            EventStarted = false;
            startTime = -1.0f;
            tiltCapReached = false;

            if (currentDir == direction.down)
            {
                print("tilt DOWN");
                if(!EventSent)
                {
                    print("currentZ = " + currentZaxis);
                    SendEvent(direction.down);
                }
            } else if (currentDir == direction.up)
            {
                print("tilt UP");
                if(!EventSent)
                {
                    SendEvent(direction.up);
                }
            }
        }
        else
        {
            //print("NO");
            EventSent = false;
            count = 0;
        }
    }
Пример #52
0
 //Moving pacman
 public override void ChangePositionByDirection(direction Direction)
 {
     if (x > 27) x = 0;
     else if (x < 0) x = 27;
     Program.map.RenderChar(x, y, currentStatePlace);
     if (Direction == direction.left) x--;
     if (Direction == direction.right) x++;
     if (Direction == direction.up) y--;
     if (Direction == direction.down) y++;
     CalcScore();
     Program.map.RenderChar(x, y, GetSymbol());
 }
Пример #53
0
 public snake(point pos, int length, direction dir)
 {
     Direction = dir;
     pList = new List<point>();
     for (int i = 0; i < length; i++)
     {
         point p = new point(pos);
         p.Move(i, dir);
         pList.Add(p);
     }
     Draw();
 }
Пример #54
0
    public void createConnectMesh(direction dir)
    {
        float scaleX = 0.5f;
        float scaleY = 0.5f;
        float scaler = (1 / (scale / 2) - 1);

        //Work clockwise with meshes.
        Vector3[] vertices = mesh.vertices;
        int[] triangles = mesh.triangles;

        for(int i = 0;i < triangles.Length;i++)
            newTriangles.Add(triangles[i]);
        for(int i = 0;i < vertices.Length;i++)
            newVertices.Add(vertices[i]);

        if(dir == direction.up)
        {
            topLeft = new Vector3(-scaleX,scaleY * scaler);
            topRight = new Vector3(scaleX,scaleY * scaler);
                
            newVertices.Add(topLeft);   //Top Left
            newVertices.Add(topRight);  //Top Right
            newTriangles.Add(4 + (count * 2));
            newTriangles.Add(5 + (count * 2));
            newTriangles.Add(3);
            newTriangles.Add(5 + (count * 2));
            newTriangles.Add(1);
            newTriangles.Add(3);
        }
        else if(dir == direction.right)
        {
            topRight = new Vector3(scaleX * scaler,scaleY);
            botRight = new Vector3(scaleX * scaler,-scaleY);
                
            newVertices.Add(topRight);  //Top Right
            newVertices.Add(botRight);  //Bottom Right
            newTriangles.Add(1);
            newTriangles.Add(4 + (count * 2));
            newTriangles.Add(2);
            newTriangles.Add(4 + (count * 2));
            newTriangles.Add(5 + (count * 2));
            newTriangles.Add(2);
        }

        mesh.Clear();
        mesh.vertices = newVertices.ToArray();
        mesh.triangles = newTriangles.ToArray();
        mesh.Optimize();
        mesh.RecalculateNormals();
        newTriangles.Clear();
        newVertices.Clear();
        count++;
    }
Пример #55
0
        // constructeurs
        public Player(int posx, int posy)
        {
            Console.WriteLine(posx);
            Console.WriteLine(posy);
            this.hitbox = new Rectangle(posx, posy, 25, 27);
            this.hitbox2 = new Rectangle((220 / 2), (990 / 2), 25, 27);// position perso sur la map

            this.frameline = 1; /*positionnement des */
            this.framecolumn = 2;/* frame sur l'image des prites*/
            this.direction = direction.Down; // met le personnage vers le bas, vers nous
            this.effect = SpriteEffects.None;
            this.animation = true;
            this.timer = 0;
        }
Пример #56
0
        public Derp(double x, double y, int team)
        {
            ContentManager Content = Game.game.Content;

            this.x = x;
            this.y = y;
            facing = direction.EAST;
            state = derpState.MOVING;
            stats = new DerpStats(10, 1, 1, 1, 0, 0, 0, 0);
            this.team = team;

            if (team == 1)
                graphic = Content.Load<Texture2D>(@"GameBlocks\Derp_1");
            else if (team == 2)
                graphic = Content.Load<Texture2D>(@"GameBlocks\Derp_2");
        }
Пример #57
0
 private void setFacingDirection()
 {
     int temp = (int)(facingAngle / (Math.PI / 4));
     switch (temp)
     {
     case 0: facingDirection = direction.NORTH; break;
     case 1: case -7: facingDirection = direction.NORTHWEST; break;
     case 2: case -6: facingDirection = direction.WEST; break;
     case 3: case -5: facingDirection = direction.SOUTHWEST; break;
     case 4: case -4: facingDirection = direction.SOUTH; break; ;
     case 5: case -3: facingDirection = direction.SOUTHEAST; break;
     case 6: case -2: facingDirection = direction.EAST; break;
     case 7: case -1: facingDirection = direction.NORTHEAST; break;
     default: facingDirection = direction.UNKNOWN; break;
     }
     setFacingString();
 }
Пример #58
0
 private void ChooseAttackAnimation(direction facing)
 {
     switch(facing){
     case direction.up:
         curAnim.Play("attackUp");
         break;
     case direction.down:
         curAnim.Play("attackDown");
         break;
     case direction.left:
         curAnim.Play("attackLeft");
         break;
     case direction.right:
         curAnim.Play("attackRight");
         break;
     }
 }
Пример #59
0
 /// <summary>
 /// prints the progress bar acorrding to pointers and current direction
 /// </summary>
 public override void Step()
 {
     if (this.currdir == direction.right)
     {
         this.PlacePointer(counter, this.pointer.Length);
         this.counter++;
         if (this.counter+this.pointer.Length == this.bar.Length)
             this.currdir = direction.left;
     }
     else
     {
         this.PlacePointer(counter - this.pointer.Length, this.pointer.Length);
         this.counter--;
         if (this.counter == this.pointer.Length)
             this.currdir = direction.right;
     }
     Console.Write(this.bar + "\r");
 }
Пример #60
0
 private void InputMovement()
 {
     if (Input.GetKey(KeyCode.W)) {
         rigidbody.MovePosition(rigidbody.position + Vector3.forward * speed * Time.deltaTime);
         playerDirection = direction.up;
     }
     if (Input.GetKey(KeyCode.S)) {
         rigidbody.MovePosition(rigidbody.position - Vector3.forward * speed * Time.deltaTime);
         playerDirection = direction.down;
     }
     if (Input.GetKey(KeyCode.D)) {
         rigidbody.MovePosition(rigidbody.position + Vector3.right * speed * Time.deltaTime);
         playerDirection = direction.right;
     }
     if (Input.GetKey(KeyCode.A)){
         rigidbody.MovePosition(rigidbody.position - Vector3.right * speed * Time.deltaTime);
         playerDirection = direction.left;
     }
 }