Exemplo n.º 1
0
        void Baboon(direction dir)
        {
            int revdir = (int)(dir == direction.EAST ? direction.WEST : direction.EAST); // the reverse direction

            mutex.WaitOne();

            while (travellers[revdir] != 0)
            {
                blockedCnt[(int)dir]++; // announce our intention to block
                mutex.Release();        // trade mutex for block
                blocked[(int)dir].WaitOne();
                mutex.WaitOne();
            }
            travellers[(int)dir]++; // we’re free to cross
            mutex.Release();
            Console.WriteLine("Crossing bridge from " + dir.ToString());

            mutex.WaitOne();
            travellers[(int)dir]--;
            if (!(travellers[(int)dir] == 0))
            {
                // if we’re the last one heading this way,
                // wakeup baboons waiting for us to finish.
                while (blockedCnt[(int)revdir]-- != 0)
                {
                    blocked[(int)revdir].Release();
                }
            }
            mutex.Release();
        }
Exemplo n.º 2
0
    public void animationPlay()
    {
        if (ComradeStatus == status.idle)
        {
            foreach (var item in GetComponents <AnimationPlayer>())
            {
                item.autoPlay = false;

                if (item.Tag == "WaveHand")
                {
                    item.autoPlay = true;
                }
            }
        }
        else
        {
            string tag = ComradeDirec.ToString();

            foreach (var item in GetComponents <AnimationPlayer>())
            {
                item.autoPlay = false;

                if (item.Tag == tag)
                {
                    item.autoPlay = true;
                }
            }
        }
    }
Exemplo n.º 3
0
        public override string ToString()
        {
            string retval = "";

            if (m_male != -1)
            {
                retval += m_male.ToString();
            }

            if (m_female != -1)
            {
                if (retval.Length != 0)
                {
                    retval += ",";
                }
                retval += m_female.ToString();
            }

            if (m_direction != direction.None)
            {
                if (retval.Length != 0)
                {
                    retval += ",";
                }
                retval += m_direction.ToString();
            }

            return(retval);
        }
Exemplo n.º 4
0
        private void button_AddThread_Click(object sender, EventArgs e)
        {
            direction Dir = direction.down;

            if (x0 == 0)
            {
            }
            else if (x1 == 0)
            {
                Dir = direction.right;
                x1++;
            }
            else if (x2 == 0)
            {
                Dir = direction.up;
                x2++;
            }
            else if (x3 == 0)
            {
                Dir = direction.left;
                x3++;
            }
            if (Dir == direction.down && x0 > 0)
            {
                return;
            }
            else
            {
                x0++;
            }
            ThreadInfoPanel TPanel = new ThreadInfoPanel();

            TPanel.mainThread        = ShowMsg;
            TPanel.Btn_ActClick      = Btn_ActClick;
            TPanel.Btn_PriorityClick = Btn_PriorityClick;
            TPanel.Btn_JoinClick     = Btn_JoinClick;
            TPanel.Refresh_Click     = Refresh_Click;
            Thread thread = new Thread(TPanel.ThreadFunc);

            thread.Name          = Dir.ToString();//DateTime.Now.ToLongTimeString();
            TPanel.DirTy         = Dir;
            TPanel.Location      = new Point(PairWidth, 0);
            PairWidth           += TPanel.Width;
            TPanel.GroupBox.Text = thread.Name;
            TPanel.Tag           = thread.ManagedThreadId;
            this.panel_Func.Controls.Add(TPanel);
            this.panel_Func.Height = TPanel.Height;
            thread.Start();
            if (!TPDic.ContainsKey(thread.ManagedThreadId))
            {
                TPDic.Add(thread.ManagedThreadId, TPanel);
            }
            if (!ThreadDic.ContainsKey(thread.ManagedThreadId))
            {
                ThreadDic.Add(thread.ManagedThreadId, thread);
            }
        }
Exemplo n.º 5
0
 public void AssigDirection()
 {
     selectedDirection = select.ToString();
     ManageScreen.Instance.movementTarget--;
     if (ManageScreen.Instance.movementTarget == 0)
     {
         ManageScreen.Instance.LoseScreen();
     }
 }
Exemplo n.º 6
0
    void animationPlay()
    {
        if (SoliderStatus == status.attack)
        {
            foreach (var item in GetComponents <AnimationPlayer>())
            {
                item.autoPlay = false;

                switch (SoliderDirec)
                {
                case direction.up:
                {
                    GetComponent <SpriteRenderer>().sprite = lookUp;
                    break;
                }

                case direction.down:
                {
                    GetComponent <SpriteRenderer>().sprite = lookDown;
                    break;
                }

                case direction.left:
                {
                    GetComponent <SpriteRenderer>().sprite = lookLeft;
                    break;
                }

                case direction.right:
                {
                    GetComponent <SpriteRenderer>().sprite = lookRight;
                    break;
                }
                }
            }
        }
        else
        {
            string tag = SoliderDirec.ToString();

            foreach (var item in GetComponents <AnimationPlayer>())
            {
                item.autoPlay = false;

                if (item.Tag == tag)
                {
                    item.autoPlay = true;
                }
            }
        }
    }
Exemplo n.º 7
0
    public static door create(direction _direction, Vector3 _position, float _rotation)
    {
        var go = new GameObject("door_" + _direction.ToString());
        var d  = go.AddComponent <door>();

        d.direction = _direction;

        var bc = go.AddComponent <BoxCollider2D>();

        bc.size      = new Vector2(0.5f, 1.1f);
        bc.isTrigger = true;

        var sr = go.AddComponent <SpriteRenderer>();

        sr.sortingLayerName = "background";
        sr.sortingOrder     = 3;
        d.sr = sr;

        go.transform.position = _position;
        go.transform.Rotate(new Vector3(0.0f, 0.0f, _rotation));

        return(d);
    }
Exemplo n.º 8
0
        /// <summary>
        /// Move the current TreeView node up or down.
        /// </summary>
        /// <param name="d">Direction, up or down</param>
        /// <returns></returns>
        public bool moveNodeUpDown(direction d)
        {
            TreeNode tn, p;
            Node     n, move;
            int      i;

            System.Diagnostics.Debug.Assert(d == direction.up | d == direction.down, "Up and down only");
            tn = theTV.SelectedNode;              // Get selected tree node
            System.Diagnostics.Debug.Assert(checkTreeNode(false, tn) == null, "Tree verify failed for move " + d);
            if (tn == null)
            {
                return(false);
            }
            if (d == direction.up & tn.PrevNode == null)
            {
                return(false);
            }
            if (d == direction.down & tn.NextNode == null)           // cannot move further down
            {
                return(false);
            }
            p = tn.Parent;
            if (p == null)            // it is a premise
            {
                return(false);
            }
            i = p.Nodes.IndexOf(tn);
            try
            {
                p.Nodes.RemoveAt(i);
                if (d == direction.up)
                {
                    p.Nodes.Insert(i - 1, tn);
                }
                else if (d == direction.down)
                {
                    p.Nodes.Insert(i + 1, tn);
                }
                else
                {
                    return(false);
                }
                // move in node structure
                n    = (Node)p.Tag;
                move = (Node)n.kids[i];
                n.kids.RemoveAt(i);
                if (d == direction.up)
                {
                    n.kids.Insert(i - 1, move);
                }
                else if (d == direction.down)
                {
                    n.kids.Insert(i + 1, move);
                }
                // move selection
                theTV.SelectedNode = tn;

                modifiedCount++;                  // mark as changed
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Oops error while moving {0} i={1} count = {2}  {3}",
                                              d.ToString(), i, p.Nodes.Count.ToString(), e.Message));
            }
            return(true);
        }
Exemplo n.º 9
0
        private void allocate()
        {
            foreach (string word in words)
            {
                int x = 0;
                int y = 0;

                direction wordDirection = direction.UnAllocated;

                switch (decider.Next(0, 2))
                {
                case 0:
                    wordDirection = direction.Right;
                    x             = decider.Next(0, mapset.GetLength(0) - word.Length);
                    y             = decider.Next(0, mapset.GetLength(1));
                    guessWords.Add(new Word(x, y, x + word.Length - 1, y, word));
                    break;

                case 1:
                    wordDirection = direction.Down;
                    x             = decider.Next(0, mapset.GetLength(0));
                    y             = decider.Next(0, mapset.GetLength(1) - word.Length);
                    guessWords.Add(new Word(x, y, x, y + word.Length - 1, word));
                    break;
                    //case 2:
                    //    wordDirection = direction.DownRight;
                    //    x = decider.Next(0, mapset.GetLength(0) - word.Length);
                    //    y = decider.Next(0, mapset.GetLength(1) - word.Length);
                    //    guessWords.Add(new Word(x, y, x + word.Length -1, y + word.Length - 1, word));
                    //    break;
                    //case 3:
                    //    wordDirection = direction.UpRight;
                    //    x = decider.Next(0, mapset.GetLength(0) - word.Length);
                    //    y = decider.Next(mapset.GetLength(1) - word.Length, mapset.GetLength(1));
                    //    guessWords.Add(new Word(x, y, x + word.Length -1, y - word.Length + 1, word));
                    //    break;
                }

                for (int i = 0; i < word.Length; i++)
                {
                    switch (wordDirection)
                    {
                    case direction.Right:
                        mapset[x + i, y].setChar(char.ToUpper(word[i]));
                        break;

                    case direction.Down:
                        mapset[x, y + i].setChar(char.ToUpper(word[i]));
                        break;
                        //case direction.DownRight:
                        //    mapset[x + i, y + i].setChar(char.ToUpper(word[i]));
                        //    break;
                        //case direction.UpRight:
                        //    mapset[x + i, y - i].setChar(char.ToUpper(word[i]));
                        //    break;
                    }
                }
                Console.WriteLine(word + " going " + wordDirection.ToString());
            }

            foreach (Individual.Field field in mapset)
            {
                if (field.fieldType.Equals(Individual.Field.Type.empty))
                {
                    field.setChar((char)decider.Next(65, 91));
                }
            }
        }
Exemplo n.º 10
0
        //Изменение направления, параметр – первая буква направления
        public void ChangeTrend(char c)
        {
            direction newtrend = trend;

            for (direction y = direction.Up; y <= direction.Left; y++)
            {
                if (char.ToLower(c) == char.ToLower(y.ToString()[0]))
                {
                    newtrend = y;
                    break;
                }
            }
            switch (trend)
            {
            case direction.Up:
                switch (newtrend)
                {
                case direction.Right:
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case direction.Down:
                    image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    break;

                case direction.Left:
                    image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;
                }
                break;

            case direction.Right:
                switch (newtrend)
                {
                case direction.Down:
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case direction.Left:
                    image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    break;

                case direction.Up:
                    image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;
                }

                break;

            case direction.Down:
                switch (newtrend)
                {
                case direction.Left:
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case direction.Up:
                    image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    break;

                case direction.Right:
                    image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;
                }
                break;

            case direction.Left:
                switch (newtrend)
                {
                case direction.Up:
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case direction.Right:
                    image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    break;

                case direction.Down:
                    image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;
                }
                break;
            }
            trend = newtrend;
        }