示例#1
0
    private void ProcessSelectedSimbol()
    {
        try{
            try{
                selectedCommand = commands[selectedCommand.newState + selectedSimbol.Value];
            }catch (Exception) {
                throw new Exception("new state doesn't contain this simbol");
            }
        }catch (Exception) {
            try{
                selectedCommand = commands[selectedCommand.newState + "*"];
            }catch (Exception) {
                if (selectedCommand.newState.ToLower().Contains("halt"))
                {
                    text.Message = "Halted";
                }
                else
                {
                    text.Message = "No command found for state: " + selectedCommand.newState + ", simbol: " + selectedSimbol.Value;
                }
                invalidate();
                if (thread != null)
                {
                    thread.Abort();
                }
                return;
            }
        }


        if (selectedCommand.newSimbol != "*")
        {
            selectedSimbol.Value = selectedCommand.newSimbol;
        }

        if (selectedCommand.dir == Direction.L)
        {
            headPos--;
            if (headPos < 0)
            {
                tape.Insert(0, new Simbol(" "));
                headPos++;
                RepositionTape();
            }
        }
        if (selectedCommand.dir == Direction.R)
        {
            headPos++;
            if (headPos >= tape.Count)
            {
                tape.Add(new Simbol(" "));
                RepositionTape();
            }
        }
        selectedSimbol = tape[headPos];
        head.Point     = new Point(selectedSimbol.Point.X, head.Point.Y);
        invalidate();
    }
示例#2
0
    public Simulator(Action invalidate, Action <Simulator> exit)
    {
        this.invalidate = invalidate;
        this.exit       = exit;

        GatherData();

        selectedSimbol  = tape[headPos];
        selectedCommand = new Command("", "", "", Direction.Stay, "0"); // first command only new state matters.
        head            = new Head();
        text            = new Text();
        slider          = new HorizontalSlider();
        InitButtons();
        Reposition();
        invalidate();
    }
示例#3
0
    public Monster(string _name, int _hp, int _fearLevel, int _combatLevel, int _staminaDamage, int _sanityDamage, int _evasionLevel, Type _type, Simbol _simbol, List <SAttribute> _sAttribute)
    {
        id            = _name;
        hp            = _hp;
        fearLevel     = _fearLevel;
        combatLevel   = _combatLevel;
        staminaDamage = _staminaDamage;
        sanityDamage  = _sanityDamage;
        evasionLevel  = _evasionLevel;
        type          = _type;
        simbol        = _simbol;

        // 리시트를 매개변수로 받거나 리스트간의 대입시 call by referance이므로 하나씩 Ad
        for (int i = 0; i < _sAttribute.Count; i++)
        {
            sAttribute.Add(_sAttribute[i]);
        }
    }
示例#4
0
    // 대입 연산자 오버로딩할랬는데 C#은 대입연산자는 오버로딩 불가능
    // ref는 참조자(&)를 의미
    public void CopyValue(ref Monster mon)
    {
        name = mon.id;

        id            = mon.id;
        hp            = mon.hp;
        fearLevel     = mon.fearLevel;
        combatLevel   = mon.combatLevel;
        staminaDamage = mon.staminaDamage;
        sanityDamage  = mon.sanityDamage;
        evasionLevel  = mon.evasionLevel;
        type          = mon.type;
        simbol        = mon.simbol;

        for (int i = 0; i < mon.sAttribute.Count; i++)
        {
            sAttribute.Add(mon.sAttribute[i]);
        }
    }
示例#5
0
        static void Main(string[] args)
        {
            String IgracJedan = "X";
            string IgracDva   = "O";

            Igra.Simbol[,] Polje = new Simbol[3, 3];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Polje[i, j] = new Simbol();
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Polje[i, j].Koordinatiziraj(i, j);
                }
            }

            int BrojPolja;

            while (true)
            {
                ispisiIgru(Polje);

                do
                {
                    Console.Write("Igrac 1 (X) - broj polja: ");

                    BrojPolja = Convert.ToInt32(Console.ReadLine());
                }while(zapisiSimbolUIgru(Polje, BrojPolja, IgracJedan) == false);

                if (provjeriZaPobjednika(Polje) == true)
                {
                    Console.Clear();
                    ispisiIgru(Polje);
                    Console.WriteLine("Igrac 1 je pobjednik!");
                    break;
                }

                if (provjeriIzjednaceno(Polje) == true)
                {
                    ispisiIgru(Polje);
                    Console.WriteLine("Izjednaceno!");
                    break;
                }

                ispisiIgru(Polje);

                do
                {
                    Console.Write("Igrac 2 (O) - broj polja: ");

                    BrojPolja = Convert.ToInt32(Console.ReadLine());
                }while(zapisiSimbolUIgru(Polje, BrojPolja, IgracDva) == false);

                if (provjeriZaPobjednika(Polje) == true)
                {
                    Console.Clear();
                    ispisiIgru(Polje);
                    Console.WriteLine("Igrac 2 je pobjednik!");
                    break;
                }

                if (provjeriIzjednaceno(Polje) == true)
                {
                    ispisiIgru(Polje);
                    Console.WriteLine("Izjednaceno!");
                    break;
                }
            }
        }