public void UpdateAgentWeight(Point p)
        {
            Label CellLabel = (Label)Display.GetControlFromPosition(p.X, p.Y);

            if (AgentWeight[p.X, p.Y] > 0)
            {
                if (CellLabel == null)
                {
                    CellLabel = MForm.Create_CellLabel(p);
                    Display.Controls.Add(CellLabel, p.X, p.Y);
                }
                if (CellLabel.Text.Contains("Weight"))
                {
                    Regex regex = new Regex(@"\[Weight : ([0-9]+)\]");
                    CellLabel.Text = regex.Replace(CellLabel.Text, "[Weight : " + AgentWeight[p.X, p.Y].ToString() + "]");
                }
                else
                {
                    CellLabel.Text = CellLabel.Text + " [Weight : " + AgentWeight[p.X, p.Y].ToString() + "]";
                }
            }
            else if (CellLabel != null)
            {
                Regex regex = new Regex(@"\[Weight : ([0-9]+)\]");
                CellLabel.Text = regex.Replace(CellLabel.Text, "");
            }
        }
Exemple #2
0
        public Point Environment_Click(Process P, Point?Position = null, bool isMovable = false)
        {
            if (Position == null)
            {
                Position = RoomDisplay.GetCellPositionFromCursorPosition();
            }
            if (Room.Map[Position.Value.X, Position.Value.Y] != null &&
                Room.Map[Position.Value.X, Position.Value.Y].type == P)
            {
                Room.EmptyFloor(Position.Value);
            }
            else
            {
                RoomObject RObject = null;
                switch (P)
                {
                case Process.SetAgent:
                    RObject = new Agent(Position.Value, Room, "[Agent : UP]");
                    break;

                case Process.SetDust:
                    RObject = new Dust(Position.Value, Room);
                    break;

                case Process.SetObstacles:
                    RObject = new Obstacle(Position.Value, Room, isMovable);
                    break;
                }
                if (RObject != null && RObject.ToString() != null)
                {
                    Label CellLabel = (Label)RoomDisplay.GetControlFromPosition(Position.Value.X, Position.Value.Y);
                    if (CellLabel == null)
                    {
                        CellLabel = Create_CellLabel(RObject);
                    }
                    else
                    {
                        Update_CellLabel(CellLabel, RObject);
                    }
                }
            }
            RoomDisplay.Refresh();
            return(Position.Value);
        }