상속: MonoBehaviour
예제 #1
0
        private void ShowAutocorrection()
        {
            var spellChecker = new SpellChecker(_content.Text, (int)CursorPosition);

            if (spellChecker.IsCursorInMisspelledWord)
            {
                var box = new AutocorectionBoxView(spellChecker, ReplaceOnCurrentCursorWith);

                box.Show(this, CursorLocation.Move(30, 30));
            }
        }
예제 #2
0
파일: ClawWindow.cs 프로젝트: UserXXX/Claw
 private bool ShowCursorNS(Point position)
 {
     if (position.Y < RESIZE_BORDER)
     {
         cursorLocation = CursorLocation.Top;
         Cursor         = Cursors.SizeNS;
         return(true);
     }
     if (position.Y > Height - (RESIZE_BORDER + 1))
     {
         cursorLocation = CursorLocation.Bottom;
         Cursor         = Cursors.SizeNS;
         return(true);
     }
     return(false);
 }
예제 #3
0
파일: ClawWindow.cs 프로젝트: UserXXX/Claw
 private bool ShowCursorWE(Point position, double width)
 {
     if (position.X < RESIZE_BORDER)
     {
         cursorLocation = CursorLocation.Left;
         Cursor         = Cursors.SizeWE;
         return(true);
     }
     if (position.X > width - (RESIZE_BORDER + 1))
     {
         cursorLocation = CursorLocation.Right;
         Cursor         = Cursors.SizeWE;
         return(true);
     }
     return(false);
 }
예제 #4
0
    // Start is called before the first frame update
    void Start()
    {
        Stat garouStats = new Stat(2000, 109, 146, 116, 136, 136, 216);

        Move[] garouMoves = new Move[] { Resources.waterStreamFist, Resources.firePunch, Resources.crossChop };
        Stat   enemyStats = new Stat(1780, 150, 156, 124, 116, 144, 146);

        Move[] enemyMoves = new Move[] { Resources.machineGunBlows, Resources.firePunch, Resources.waterStreamFist };
        Dictionary <int, Move> garouAllMoves = new Dictionary <int, Move>();

        this.garou = new Character(Resources.Type.Fight, Resources.Type.None, "Garou", Resources.Rank.None, 25, garouStats, garouMoves, garouAllMoves, Resources.Status.Healthy);
        this.enemy = new Character(Resources.Type.Steel, Resources.Type.Electric, "Genos", Resources.Rank.S, 25, enemyStats, enemyMoves, garouAllMoves, Resources.Status.Healthy);

        this.battleState    = BattleState.Start;
        this.cursorLocation = CursorLocation.Fight;
        populateMoves();
        this.battleSequence = false;
    }
예제 #5
0
파일: ClawWindow.cs 프로젝트: UserXXX/Claw
        /// <summary>
        /// Shows the cursor corresponding to the cursor position.
        /// </summary>
        /// <param name="position">Position of the cursor.</param>
        private void ShowCursor(Point position)
        {
            const double EDGE_WIDTH  = 20;
            const double EDGE_HEIGHT = 60;

            double width = Opening ? Width : ActualWidth;

            if (position.X > EDGE_WIDTH && position.X < width - EDGE_HEIGHT && ShowCursorNS(position))
            {
                return;
            }
            if (position.Y > EDGE_HEIGHT && position.Y < Height - EDGE_HEIGHT && ShowCursorWE(position, width))
            {
                return;
            }
            if (position.X < EDGE_WIDTH && position.Y < EDGE_HEIGHT && position.Y >= EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * position.X && position.Y <= EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * position.X + RESIZE_BORDER)
            {
                cursorLocation = CursorLocation.TopLeft;
                Cursor         = Cursors.SizeNWSE;
                return;
            }
            if (position.X > width - EDGE_WIDTH && position.Y < EDGE_HEIGHT && position.Y >= (EDGE_HEIGHT / EDGE_WIDTH) * position.X + EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * width && position.Y <= (EDGE_HEIGHT / EDGE_WIDTH) * position.X + EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * Width + RESIZE_BORDER)
            {
                cursorLocation = CursorLocation.TopRight;
                Cursor         = Cursors.SizeNESW;
                return;
            }
            if (position.X < EDGE_WIDTH && position.Y > Height - EDGE_HEIGHT && position.Y <= Height - (EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * position.X) && position.Y >= Height - (EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * position.X) - RESIZE_BORDER)
            {
                cursorLocation = CursorLocation.BottomLeft;
                Cursor         = Cursors.SizeNESW;
                return;
            }
            if (position.X > width - EDGE_WIDTH && position.Y > Height - EDGE_HEIGHT && position.Y <= Height - ((EDGE_HEIGHT / EDGE_WIDTH) * position.X + EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * width) && position.Y >= Height - ((EDGE_HEIGHT / EDGE_WIDTH) * position.X + EDGE_HEIGHT - (EDGE_HEIGHT / EDGE_WIDTH) * Width) - RESIZE_BORDER)
            {
                cursorLocation = CursorLocation.BottomRight;
                Cursor         = Cursors.SizeNWSE;
                return;
            }

            cursorLocation = CursorLocation.Default;
            Cursor         = Cursors.Arrow;
        }
        static void Main(string[] args)
        {
            Console.WindowHeight = (int)(0.8 * Console.LargestWindowHeight);
            WriteLine(ConsoleColor.White, "X - Exit | P - Run/Pause | S - Step (hold for Slow) | B - Burst");
            WriteLine("Press P, S or B to make something happen.", reportInterval);
            Guid guid;

            byte[] bytes;
            var    cursorPos = new CursorLocation();

            while (!exit)
            {
                if (Console.KeyAvailable)
                {
                    ProcessKey(Console.ReadKey(true));
                }
                if (running || burst > 0)
                {
                    guid  = Guid.NewGuid();
                    bytes = guid.ToByteArray();
                    ++guidCount;
                    for (int i = 0; i < 16; i++)
                    {
                        var b = bytes[i];
                        ++counts[b];
                    }
                    if (burst > 0)
                    {
                        --burst;
                    }
                    if (burst == 0 && DateTime.Now > nextReport)
                    {
                        cursorPos.MoveCursor();
                        ReportFrequencies();
                    }
                }
                else
                {
                    Thread.Sleep(20);
                }
            }
        }
예제 #7
0
    // Start is called before the first frame update
    void Start()
    {
        Stat garouStats = new Stat(1000, 109, 146, 116, 136, 136, 216);

        Move[] garouMoves = new Move[] { Resources.waterStreamFist, Resources.poisonPowder, Resources.crossChop, Resources.bulkUp };
        Stat   enemyStats = new Stat(890, 150, 156, 124, 116, 144, 146);

        Move[] enemyMoves = new Move[] { Resources.machineGunBlows, Resources.bulkUp, Resources.poisonPowder };
        Dictionary <int, Move> garouAllMoves = new Dictionary <int, Move>();

        this.garou = new Character(Resources.Type.Fight, Resources.Type.None, "Garou", Resources.Rank.None, 25, garouStats, garouMoves, garouAllMoves, Resources.Status.Healthy);
        this.enemy = new Character(Resources.Type.Electric, Resources.Type.None, "Genos", Resources.Rank.S, 25, enemyStats, enemyMoves, garouAllMoves, Resources.Status.Healthy);

        this.battleState    = BattleState.Start;
        this.cursorLocation = CursorLocation.Fight;
        populateMoves();
        this.battleSequence = false;

        this.playerNameText.GetComponent <UnityEngine.UI.Text>().text  = this.garou.getName();
        this.playerLevelText.GetComponent <UnityEngine.UI.Text>().text = "Lv" + this.garou.getLevel().ToString();
        this.enemyNameText.GetComponent <UnityEngine.UI.Text>().text   = this.enemy.getName();
        this.enemyLevelText.GetComponent <UnityEngine.UI.Text>().text  = "Lv" + this.enemy.getLevel().ToString();
    }
예제 #8
0
        }//XPosToPixel

        /// <summary>
        /// Helper function to convert a ypos(0-1) into a pixel offset into the display.
        /// Note:origin(0,0) is top left corner
        /// Each char is 40 pixels high.
        /// </summary>
        /// <param name="ypos"></param>
        /// <returns></returns>
        private static int YPosToPixel(int ypos)
        {
            return((CursorLocation.ValidYPos(ypos) * 40) + 4);
        }//YPosToPixel
예제 #9
0
        }//GetChar

        /// <summary>
        /// Helper function to convert a xpos(0-15) into a pixel offset into the display.
        /// Note:origin(0,0) is top left corner
        /// Each char is 30 pixels wide.
        /// </summary>
        /// <param name="xpos"></param>
        /// <returns></returns>
        private static int XPosToPixel(int xpos)
        {
            return((CursorLocation.ValidXPos(xpos) * 30) + 1);
        }//XPosToPixel
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        setCursorPosition();
        setupPanelGUI();
        if (this.battleState == BattleState.Start)
        {
            // animate the two characters arriving on screen
            // set text to "a hero appeared!"
            // transition to next WhatWillYouDo state
            string introText = "You found the " + this.enemy.getRank().ToString() + " class hero, " + this.enemy.getName() + "!";
            setExpositionText(introText);
            if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.X))
            {
                this.battleState = BattleState.WhatWillYouDo;
            }
        }
        else if (this.battleState == BattleState.WhatWillYouDo)
        {
            // show side menu with options of FIGHT and RUN
            // set text to "what will you do?"
            // upon menu selection, transition to appropriate state
            setExpositionText("What will you do?");
            if (Input.GetKeyDown(KeyCode.Z))
            {
                if (this.cursorLocation == CursorLocation.Fight)
                {
                    this.cursorLocation = CursorLocation.Move1;
                    this.battleState    = BattleState.Fight;
                }
                else if (this.cursorLocation == CursorLocation.Run)
                {
                    this.battleState = BattleState.Run;
                }
            }

            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                this.cursorLocation = CursorLocation.Fight;
            }

            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                this.cursorLocation = CursorLocation.Run;
            }
        }
        else if (this.battleState == BattleState.Fight)
        {
            // display moves in center menu
            // upon move selection, transition to aim state (if necessary)

            int numMoves = this.garou.getMoves().Length;
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                if (this.cursorLocation == CursorLocation.Move3)
                {
                    this.cursorLocation = CursorLocation.Move1;
                }

                if (this.cursorLocation == CursorLocation.Move4)
                {
                    this.cursorLocation = CursorLocation.Move2;
                }
            }

            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                if (this.cursorLocation == CursorLocation.Move1)
                {
                    if (numMoves >= 3)
                    {
                        this.cursorLocation = CursorLocation.Move3;
                    }
                }

                if (this.cursorLocation == CursorLocation.Move2)
                {
                    if (numMoves == 4)
                    {
                        this.cursorLocation = CursorLocation.Move4;
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                if (this.cursorLocation == CursorLocation.Move2)
                {
                    this.cursorLocation = CursorLocation.Move1;
                }

                if (this.cursorLocation == CursorLocation.Move4)
                {
                    this.cursorLocation = CursorLocation.Move3;
                }
            }

            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                if (this.cursorLocation == CursorLocation.Move1)
                {
                    if (numMoves >= 2)
                    {
                        this.cursorLocation = CursorLocation.Move2;
                    }
                }

                if (this.cursorLocation == CursorLocation.Move3)
                {
                    if (numMoves == 4)
                    {
                        this.cursorLocation = CursorLocation.Move4;
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                this.battleState = BattleState.Aim;
            }

            if (Input.GetKeyDown(KeyCode.X))
            {
                this.battleState    = BattleState.WhatWillYouDo;
                this.cursorLocation = CursorLocation.Fight;
            }
        }
        else if (this.battleState == BattleState.Aim)
        {
            // display aiming mechanism
            // upon aiming, transition to battle state
            setupAimTarget();
            if (Input.GetKeyDown(KeyCode.Z))
            {
                // should make a check for if using move is valid
                // (cost? situation?)
                this.battleState    = BattleState.Battle;
                this.battleSequence = true;
            }

            if (Input.GetKeyDown(KeyCode.X))
            {
                this.battleState = BattleState.Fight;
            }
        }
        else if (this.battleState == BattleState.Battle)
        {
            // miss/paralyze/move for first attacker
            // miss/paralyze/move for second attacker
            // status damage for opponent
            // status damage for player
            if (battleSequence)
            {
                StartCoroutine(battle());
            }
        }
        else if (this.battleState == BattleState.Run)
        {
            // if health is above 50%, switch text to "you ran away" and end battle
            // if health is lower than 50%, switch text to "run failed" and transition to WhatWillYouDo state
            string endText = "Ran away safely!";
            setExpositionText(endText);
        }
        else if (this.battleState == BattleState.Win)
        {
            // Text is "you defeated .."
            // apply experience bonus and end battle
            string endText = "You have successfully hunted " + this.enemy.getName() + "!";
            setExpositionText(endText);
        }
        else if (this.battleState == BattleState.Lose)
        {
            // Text is "you were defeated.." "the hero ranks up for defeating the hero hunter!"
            // end battle
            string endText = "You have been defeated by " + this.enemy.getName() + "...";
            setExpositionText(endText);
        }
    }
예제 #11
0
    IEnumerator battle()
    {
        this.battleSequence = false;
        string critText = "It's a critical hit!";

        // print resultant accuracy
        float diff     = Math.Abs(this.targetCenter.transform.position.x - this.target.transform.position.x);
        float accuracy = (1f - (diff / (this.targetLine.GetComponent <RectTransform>().rect.width / 2f))) * 100f;

        this.aimText.GetComponent <UnityEngine.UI.Text>().text = accuracy.ToString() + "%";

        // determine who attacks first

        bool garouAttackFirst = false;

        if (this.garou.getCurrentStats().getSpd() > this.enemy.getCurrentStats().getSpd())
        {
            garouAttackFirst = true;
        }

        if (garouAttackFirst)
        {
            Move move = getSelectedMove();
            reduceGarouEnergy(move.getCost(), move.getPenalty());
            yield return(new WaitForSeconds(1));

            string useMoveText = "Garou used " + move.getName() + "!!";
            setExpositionText(useMoveText);
            yield return(new WaitForSeconds(1));

            if (accuracy >= 100f - ((move.getAccuracy() / 100f) * 30f))
            {
                // success
                float eff = getEffectiveness(move.getType(), this.enemy);
                if (eff > -0.0001f && eff < 0.001f)
                {
                    useMoveText = "Doesn't affect " + this.enemy.getName() + "...";
                    setExpositionText(useMoveText);
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    if (accuracy >= 97f)
                    {
                        // crit
                        garouAttack(move, eff, true);
                        yield return(new WaitForSeconds(1));

                        setExpositionText(critText);
                    }
                    else
                    {
                        // regular
                        garouAttack(move, eff, false);
                    }

                    if (eff >= 2.0f)
                    {
                        useMoveText = "It's Super Effective!";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff <= 0.5f)
                    {
                        useMoveText = "Not very effective...";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // fail
                useMoveText = "Garou's attack missed..";
                setExpositionText(useMoveText);
            }

            yield return(new WaitForSeconds(1));

            // random enemy move
            Move enemyMove = getEnemyMove();
            reduceEnemyEnergy(enemyMove.getCost(), enemyMove.getPenalty());
            yield return(new WaitForSeconds(1));

            useMoveText = this.enemy.getName() + " used " + enemyMove.getName() + "!!";
            setExpositionText(useMoveText);

            yield return(new WaitForSeconds(1));

            float         enemyAccuracy = getEnemyAccuracy(enemyMove);
            System.Random rnd           = new System.Random();
            int           r             = rnd.Next(1, 100);
            print(r);
            print(enemyAccuracy);
            print(100f - (enemyAccuracy * 100f));
            if (r >= 100f - (enemyAccuracy * 100f))
            {
                // success
                float eff = getEffectiveness(enemyMove.getType(), this.garou);
                if (eff > -0.0001f && eff < 0.001f)
                {
                    useMoveText = "Doesn't affect " + this.garou.getName() + "...";
                    setExpositionText(useMoveText);
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    if (accuracy >= 97f)
                    {
                        // crit
                        enemyAttack(enemyMove, eff, true);
                        yield return(new WaitForSeconds(1));

                        setExpositionText(critText);
                    }
                    else
                    {
                        // regular
                        enemyAttack(enemyMove, eff, false);
                    }

                    if (eff >= 2.0f)
                    {
                        useMoveText = "It's Super Effective!";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff <= 0.5f)
                    {
                        useMoveText = "Not very effective...";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // fail
                useMoveText = this.enemy.getName() + "'s attack missed..";
                setExpositionText(useMoveText);
            }
        }
        else
        {
            // random enemy move
            Move enemyMove = getEnemyMove();
            reduceEnemyEnergy(enemyMove.getCost(), enemyMove.getPenalty());
            yield return(new WaitForSeconds(1));

            string useMoveText = this.enemy.getName() + " used " + enemyMove.getName() + "!!";
            setExpositionText(useMoveText);

            yield return(new WaitForSeconds(1));

            float         enemyAccuracy = getEnemyAccuracy(enemyMove);
            System.Random rnd           = new System.Random();
            int           r             = rnd.Next(1, 100);
            print(r);
            print(enemyAccuracy);
            print(100f - (enemyAccuracy * 100f));
            if (r >= 100f - (enemyAccuracy * 100f))
            {
                // success
                float eff = getEffectiveness(enemyMove.getType(), this.garou);
                if (eff > -0.0001f && eff < 0.001f)
                {
                    useMoveText = "Doesn't affect " + this.garou.getName() + "...";
                    setExpositionText(useMoveText);
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    if (accuracy >= 97f)
                    {
                        // crit
                        enemyAttack(enemyMove, eff, true);
                        yield return(new WaitForSeconds(1));

                        setExpositionText(critText);
                    }
                    else
                    {
                        // regular
                        enemyAttack(enemyMove, eff, false);
                    }

                    if (eff >= 2.0f)
                    {
                        useMoveText = "It's Super Effective!";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff <= 0.5f)
                    {
                        useMoveText = "Not very effective...";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // fail
                useMoveText = this.enemy.getName() + "'s attack missed..";
                setExpositionText(useMoveText);
            }

            yield return(new WaitForSeconds(1));

            Move move = getSelectedMove();
            reduceGarouEnergy(move.getCost(), move.getPenalty());
            yield return(new WaitForSeconds(1));

            useMoveText = "Garou used " + move.getName() + "!!";
            setExpositionText(useMoveText);
            yield return(new WaitForSeconds(1));

            if (accuracy >= 100f - ((move.getAccuracy() / 100f) * 30f))
            {
                // success
                float eff = getEffectiveness(move.getType(), this.enemy);
                if (eff > -0.0001f && eff < 0.001f)
                {
                    useMoveText = "Doesn't affect " + this.enemy.getName() + "...";
                    setExpositionText(useMoveText);
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    if (accuracy >= 97f)
                    {
                        // crit
                        garouAttack(move, eff, true);
                        yield return(new WaitForSeconds(1));

                        setExpositionText(critText);
                    }
                    else
                    {
                        // regular
                        garouAttack(move, eff, false);
                    }

                    if (eff >= 2.0f)
                    {
                        useMoveText = "It's Super Effective!";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff <= 0.5f)
                    {
                        useMoveText = "Not very effective...";
                        setExpositionText(useMoveText);
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // fail
                useMoveText = "Garou's attack missed..";
                setExpositionText(useMoveText);
            }
        }
        yield return(new WaitForSeconds(1));

        this.battleState    = BattleState.WhatWillYouDo;
        this.cursorLocation = CursorLocation.Fight;
    }
예제 #12
0
 private void Awake()
 {
     Instance = this;
 }
예제 #13
0
        //Analyzer오류 분석

        public override void TokenAnalyze(int caretoffset = int.MaxValue)
        {
            //TODO:토큰 분석 로직
            //tokens에 직접 접근하여 분석한다.

            //네임스페이스를 분석 후 토큰을 추가한다
            //GetTokens(Context, -1) 이런식으로 가져와서 분석한다.

            //최근 네임스페이스를 저장하고 해당 파일들이 변형되었는지 체크한다.

            //ResetCompletionData(CompletionWordType.Function);


            //Action
            //Condiction
            //Function
            //일반적인 함수들

            //nameSpace
            //Const
            //Variable
            //오브젝트들

            //Setting(Property)

            //ArgType
            //KeyWord
            //Special


            //함수와 오브젝트의 요소들을 저장해야함.


            //cursorLocation 현재 위치를 적습니다.
            CursorLocation cl = CursorLocation.None;

            TOKEN ctoken  = GetToken(0);
            TOKEN btoken  = GetToken(-1);
            TOKEN bbtoken = GetToken(-2);

            if (btoken != null)
            {
                if (btoken.Type == TOKEN_TYPE.KeyWord)
                {
                    switch (btoken.Value)
                    {
                    case "var":
                    case "const":
                    case "as":
                        cl = CursorLocation.ObjectName;
                        break;

                    case "function":
                        cl = CursorLocation.FunctionName;
                        break;

                    case "import":
                        cl = CursorLocation.ImportFile;
                        break;
                    }
                }
            }
            cursorLocation = cl;


            //토근 분석에 사용되는 요소
            tokenAnalyzer.Init(Tokens);

            try
            {
                maincontainer = tokenAnalyzer.ConatainerAnalyzer(caretoffset);
                if (maincontainer.cursorLocation != CursorLocation.None)
                {
                    cursorLocation = maincontainer.cursorLocation;
                }
            }
            catch (Exception e)
            {
                TOKEN errortoken = tokenAnalyzer.GetLastToken;
                if (!(errortoken is null))
                {
                    tokenAnalyzer.ThrowException(e.ToString(), tokenAnalyzer.GetLastToken);
                }
                //tokenAnalyzer.ErrorMessage;

                //return;
            }
            if (tokenAnalyzer.IsError)
            {
                //토큰 분석 오류
            }


            tokenAnalyzer.Complete(textEditor);
        }
예제 #14
0
        public Function FunctionAnalyzer(int startindex)
        {
            Function function = new Function();
            TOKEN    tk       = GetCurrentToken();



            if (tk.Type != TOKEN_TYPE.Identifier)
            {
                ThrowException("함수의 이름에는 식별자가 와야 합니다.", tk);
            }
            string funcname = tk.Value;

            function.funcname = funcname;


            CursorLocation cl = CursorLocation.None;

            int argstartoffset = tk.EndOffset;
            int argendoffset   = 0;

            if (!CheckCurrentToken(TOKEN_TYPE.Symbol, "("))
            {
                ThrowException("함수의 이름 다음에는 인자선언이 와야 합니다.", tk);
            }



            while (true)
            {
                Function.Arg arg = new Function.Arg();

                tk = GetCurrentToken();

                if (tk.Type == TOKEN_TYPE.Identifier)
                {
                    string argname = tk.Value;

                    arg.argname = argname;
                }
                else
                {
                    if (function.args.Count == 0)
                    {
                        if (tk.Type != TOKEN_TYPE.Symbol)
                        {
                            //무조건 심불이 와야됨
                            ThrowException("잘못된 인자 선언입니다. )가 와야합니다.", tk);
                        }
                        if (tk.Value == ")")
                        {
                            argendoffset = tk.EndOffset;
                            break;
                        }
                        //인자가 없을 수 있음.
                    }

                    ThrowException("잘못된 인자 선언입니다. 인자 이름이 와야 합니다.", tk);
                }


                tk = GetCurrentToken();
                if (tk.Type != TOKEN_TYPE.Symbol)
                {
                    //무조건 심불이 와야됨
                    ThrowException("잘못된 인자 선언입니다. ) , :가 와야합니다.", tk);
                }

                if (tk.Value == ")")
                {
                    argendoffset = tk.EndOffset;
                    break;
                }
                else if (tk.Value == ",")
                {
                }
                else if (tk.Value == ":")
                {
                    tk = GetCommentTokenIten();
                    if (tk.Type == TOKEN_TYPE.Identifier)
                    {
                        //일반 타입
                        arg.argtype = tk.Value;
                        GetCurrentToken();
                    }
                    else if (tk.Type == TOKEN_TYPE.Comment)
                    {
                        //특수처리된 타입
                        arg.argtype = tk.Value;
                        GetCurrentToken();
                    }
                    else
                    {
                        ThrowException("인자 타입을 선언해야 합니다.", tk);
                    }
                }


                function.args.Add(arg);
            }


            if (cl == CursorLocation.None)
            {
                if (argstartoffset <= startindex && startindex <= argendoffset)
                {
                    cl = CursorLocation.FunctionArgName;
                }
            }


            function.cursorLocation = cl;



            function.preCompletion = new ObjectItem(CompletionWordType.Function, funcname);

            return(function);
        }
예제 #15
0
    IEnumerator battle2()
    {
        this.battleSequence = false;

        // print accuracy of move
        float diff     = Math.Abs(this.targetCenter.transform.position.x - this.target.transform.position.x);
        float accuracy = (1f - (diff / (this.targetLine.GetComponent <RectTransform>().rect.width / 2f))) * 100f;

        this.aimText.GetComponent <UnityEngine.UI.Text>().text = accuracy.ToString() + "%";

        // determine who attacks first
        Character firstAttacker;
        Character secondAttacker;
        Move      firstMove;
        Move      secondMove;
        string    firstName;
        string    secondName;
        float     firstAccuracy;
        float     secondAccuracy;

        if (this.garou.getCurrentStats().getSpd() > this.enemy.getCurrentStats().getSpd())
        {
            firstAttacker  = this.garou;
            secondAttacker = this.enemy;

            firstMove  = getSelectedMove();
            secondMove = getEnemyMove();

            firstName  = "Garou";
            secondName = this.enemy.getName();

            firstAccuracy = accuracy;
            System.Random rnd = new System.Random();
            secondAccuracy = rnd.Next(1, 100);
        }

        else
        {
            firstAttacker  = this.enemy;
            secondAttacker = this.garou;

            firstMove  = getEnemyMove();
            secondMove = getSelectedMove();

            firstName  = this.enemy.getName();
            secondName = "Garou";

            System.Random rnd = new System.Random();
            firstAccuracy  = rnd.Next(1, 100);
            secondAccuracy = accuracy;
        }

        // first attacker loses energy
        reduceEnergy(firstAttacker, firstMove.getCost(), firstMove.getPenalty());

        // end match if first attacker dies on energy cost
        if (setWinOrLose())
        {
            yield break;
        }

        // first move
        setExpositionText(firstName + " used " + firstMove.getName() + "!");
        yield return(new WaitForSeconds(1));

        // determine if first move hits and crit
        bool[] hc             = hitAndCrit(firstAttacker, firstMove, firstAccuracy);
        bool   firstMoveHits  = hc[0];
        bool   firstMoveCrits = hc[1];
        float  eff            = getEffectiveness(firstMove.getType(), secondAttacker);

        // move does not affect target
        if (eff > -0.0001f && eff < 0.001f)
        {
            setExpositionText("Doesn't affect " + secondName + "...");
            yield return(new WaitForSeconds(1));
        }
        else
        {
            if (firstMoveHits)
            {
                // hit

                // determine type of first move
                if (firstMove.GetType() == typeof(DamageMove))
                {
                    damageAttack(firstAttacker, firstMove, eff, firstMoveCrits);
                    yield return(new WaitForSeconds(1));

                    if (firstMoveCrits)
                    {
                        setExpositionText("It's a critical hit!");
                        yield return(new WaitForSeconds(1));
                    }

                    // effectiveness
                    if (eff >= 2.0f)
                    {
                        setExpositionText("It's Super Effective!");
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff <= 0.5f)
                    {
                        setExpositionText("Not very effective...");
                        yield return(new WaitForSeconds(1));
                    }

                    // end match if health is 0
                    if (setWinOrLose())
                    {
                        yield break;
                    }
                }
                else if (firstMove.GetType() == typeof(StatusMove))
                {
                    StatusMove       firstStatusMove = (StatusMove)firstMove;
                    Resources.Status status          = firstStatusMove.getStatus();
                    if (firstStatusMove.getTarget())
                    {
                        // target is enemy
                        if (secondAttacker.getStatus() != Resources.Status.Healthy)
                        {
                            // already has a status ailment
                            setExpositionText(secondName + " is already " + getStatusText(status) + "!");
                            yield return(new WaitForSeconds(1));
                        }
                        else
                        {
                            if (firstMoveCrits)
                            {
                                // crit
                                secondAttacker.setStatus(getBadStatus(status));
                                setExpositionText("It's a Crit!");
                                yield return(new WaitForSeconds(1));

                                setExpositionText(secondName + " has been " + getStatusText(getBadStatus(status)) + "!");
                                yield return(new WaitForSeconds(1));
                            }
                            else
                            {
                                // normal
                                secondAttacker.setStatus(status);
                                setExpositionText(secondName + " has been " + getStatusText(status) + "!");
                                yield return(new WaitForSeconds(1));
                            }
                        }
                    }
                    else
                    {
                        // target is self
                    }
                }
                else if (firstMove.GetType() == typeof(StatMove))
                {
                    StatMove             firstStatMove = (StatMove)firstMove;
                    Resources.StatType[] stats         = firstStatMove.getStats();
                    int f = firstStatMove.getFactor();
                    if (firstMoveCrits)
                    {
                        f++;
                        setExpositionText("It's a Crit!");
                        yield return(new WaitForSeconds(1));
                    }
                    foreach (Resources.StatType stat in stats)
                    {
                        if (firstStatMove.getTarget())
                        {
                            // target is enemy
                            if (secondAttacker.changeStat(stat, f))
                            {
                                // stat already max or min
                                if (f > 0)
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " won't go any higher!");
                                }
                                else
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " can't go any lower!");
                                }
                            }
                            else
                            {
                                // stat can increase or decrease
                                if (f > 0)
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " increased by " + f.ToString() + "!");
                                }
                                else
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " decreased by " + f.ToString() + "!");
                                }
                            }
                        }
                        else
                        {
                            // target is self
                            if (firstAttacker.changeStat(stat, f))
                            {
                                // stat is already max or min
                                if (f > 0)
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " won't go any higher!");
                                }
                                else
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " can't go any lower!");
                                }
                            }
                            else
                            {
                                // stat can increase or decrease
                                if (f > 0)
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " increased by " + f.ToString() + "!");
                                }
                                else
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " decreased by " + f.ToString() + "!");
                                }
                            }
                        }
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // miss
                if (firstMove.GetType() == typeof(DamageMove))
                {
                    setExpositionText(firstName + "'s attack missed...");
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    setExpositionText(firstName + " failed...");
                    yield return(new WaitForSeconds(1));
                }
            }

            this.cursorLocation = CursorLocation.Fight;
        }

        // second attacker loses energy
        reduceEnergy(secondAttacker, secondMove.getCost(), secondMove.getPenalty());

        // end match if first attacker dies on energy cost
        if (setWinOrLose())
        {
            yield break;
        }

        // second move
        setExpositionText(secondName + " used " + secondMove.getName() + "!");
        yield return(new WaitForSeconds(1));

        // determine if second move hits and crit
        bool[] hc2             = hitAndCrit(secondAttacker, secondMove, secondAccuracy);
        bool   secondMoveHits  = hc2[0];
        bool   secondMoveCrits = hc2[1];
        float  eff2            = getEffectiveness(secondMove.getType(), firstAttacker);

        // move does not affect target
        if (eff2 > -0.0001f && eff2 < 0.001f)
        {
            setExpositionText("Doesn't affect " + firstName + "...");
            yield return(new WaitForSeconds(1));
        }
        else
        {
            if (secondMoveHits)
            {
                // hit

                // determine type of first move
                if (secondMove.GetType() == typeof(DamageMove))
                {
                    damageAttack(secondAttacker, secondMove, eff2, secondMoveCrits);
                    yield return(new WaitForSeconds(1));

                    if (secondMoveCrits)
                    {
                        setExpositionText("It's a critical hit!");
                        yield return(new WaitForSeconds(1));
                    }

                    // effectiveness
                    if (eff2 >= 2.0f)
                    {
                        setExpositionText("It's Super Effective!");
                        yield return(new WaitForSeconds(1));
                    }
                    else if (eff2 <= 0.5f)
                    {
                        setExpositionText("Not very effective...");
                        yield return(new WaitForSeconds(1));
                    }

                    // end match if health is 0
                    if (setWinOrLose())
                    {
                        yield break;
                    }
                }
                else if (secondMove.GetType() == typeof(StatusMove))
                {
                    StatusMove       secondStatusMove = (StatusMove)secondMove;
                    Resources.Status status           = secondStatusMove.getStatus();
                    if (secondStatusMove.getTarget())
                    {
                        // target is enemy
                        if (firstAttacker.getStatus() != Resources.Status.Healthy)
                        {
                            // already has a status ailment
                            setExpositionText(firstName + " is already " + getStatusText(status) + "!");
                            yield return(new WaitForSeconds(1));
                        }
                        else
                        {
                            if (secondMoveCrits)
                            {
                                // crit
                                firstAttacker.setStatus(getBadStatus(status));
                                setExpositionText("It's a Crit!");
                                yield return(new WaitForSeconds(1));

                                setExpositionText(firstName + " has been " + getStatusText(getBadStatus(status)) + "!");
                                yield return(new WaitForSeconds(1));
                            }
                            else
                            {
                                // normal
                                firstAttacker.setStatus(status);
                                setExpositionText(firstName + " has been " + getStatusText(status) + "!");
                                yield return(new WaitForSeconds(1));
                            }
                        }
                    }
                    else
                    {
                        // target is self
                    }
                }
                else if (secondMove.GetType() == typeof(StatMove))
                {
                    StatMove             secondStatMove = (StatMove)secondMove;
                    Resources.StatType[] stats          = secondStatMove.getStats();
                    int f = secondStatMove.getFactor();
                    if (secondMoveCrits)
                    {
                        f++;
                        setExpositionText("It's a Crit!");
                        yield return(new WaitForSeconds(1));
                    }
                    foreach (Resources.StatType stat in stats)
                    {
                        if (secondStatMove.getTarget())
                        {
                            // target is enemy
                            if (firstAttacker.changeStat(stat, f))
                            {
                                // stat already max or min
                                if (f > 0)
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " won't go any higher!");
                                }
                                else
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " can't go any lower!");
                                }
                            }
                            else
                            {
                                // stat can increase or decrease
                                if (f > 0)
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " increased by " + f.ToString() + "!");
                                }
                                else
                                {
                                    setExpositionText(firstName + "'s " + stat.ToString() + " decreased by " + f.ToString() + "!");
                                }
                            }
                        }
                        else
                        {
                            // target is self
                            if (secondAttacker.changeStat(stat, f))
                            {
                                // stat is already max or min
                                if (f > 0)
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " won't go any higher!");
                                }
                                else
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " can't go any lower!");
                                }
                            }
                            else
                            {
                                // stat can increase or decrease
                                if (f > 0)
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " increased by " + f.ToString() + "!");
                                }
                                else
                                {
                                    setExpositionText(secondName + "'s " + stat.ToString() + " decreased by " + f.ToString() + "!");
                                }
                            }
                        }
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
            else
            {
                // miss
                if (secondMove.GetType() == typeof(DamageMove))
                {
                    setExpositionText(secondName + "'s attack missed...");
                    yield return(new WaitForSeconds(1));
                }
                else
                {
                    setExpositionText(secondName + " failed...");
                    yield return(new WaitForSeconds(1));
                }
            }
        }

        // apply poison / burn damage
        float poison           = 0.06f;
        float burn             = 0.04f;
        float badlyPoison      = 0.1f;
        float badlyBurn        = 0.06f;
        int   garouTotalHealth = this.garou.getOriginalStats().getHp();
        int   enemyTotalHealth = this.enemy.getOriginalStats().getHp();

        Resources.Status garouStatus = this.garou.getStatus();
        Resources.Status enemyStatus = this.enemy.getStatus();

        // apply garou damage for status
        if (garouStatus == Resources.Status.Poison)
        {
            reduceHealth(this.garou, (int)Math.Round((float)garouTotalHealth * poison));
            setExpositionText("Garou is hurt by poison!");
            yield return(new WaitForSeconds(1));
        }
        else if (garouStatus == Resources.Status.Burn)
        {
            reduceHealth(this.garou, (int)Math.Round((float)garouTotalHealth * burn));
            setExpositionText("Garou is hurt by its burn!");
            yield return(new WaitForSeconds(1));
        }
        else if (garouStatus == Resources.Status.BadlyPoison)
        {
            reduceHealth(this.garou, (int)Math.Round((float)garouTotalHealth * badlyPoison));
            setExpositionText("Garou is hurt by poison!");
            yield return(new WaitForSeconds(1));
        }
        else if (garouStatus == Resources.Status.BadlyBurn)
        {
            reduceHealth(this.garou, (int)Math.Round((float)garouTotalHealth * badlyBurn));
            setExpositionText("Garou is hurt by its burn!");
            yield return(new WaitForSeconds(1));
        }

        // end match if garou dies on status damage
        if (setWinOrLose())
        {
            yield break;
        }

        // apply enemy damage for status
        if (enemyStatus == Resources.Status.Poison)
        {
            reduceHealth(this.enemy, (int)Math.Round((float)enemyTotalHealth * poison));
            setExpositionText(this.enemy.getName() + " is hurt by poison!");
            yield return(new WaitForSeconds(1));
        }
        else if (enemyStatus == Resources.Status.Burn)
        {
            reduceHealth(this.enemy, (int)Math.Round((float)enemyTotalHealth * burn));
            setExpositionText(this.enemy.getName() + " is hurt by its burn!");
            yield return(new WaitForSeconds(1));
        }
        else if (enemyStatus == Resources.Status.BadlyPoison)
        {
            reduceHealth(this.enemy, (int)Math.Round((float)enemyTotalHealth * badlyPoison));
            setExpositionText(this.enemy.getName() + " is hurt by poison!");
            yield return(new WaitForSeconds(1));
        }
        else if (enemyStatus == Resources.Status.BadlyBurn)
        {
            reduceHealth(this.enemy, (int)Math.Round((float)enemyTotalHealth * badlyBurn));
            setExpositionText(this.enemy.getName() + " is hurt by its burn!");
            yield return(new WaitForSeconds(1));
        }

        // end match if enemy dies on status damage
        if (setWinOrLose())
        {
            yield break;
        }

        this.battleState    = BattleState.WhatWillYouDo;
        this.cursorLocation = CursorLocation.Fight;
    }