private void ShowGrimoireEditor(Grimoire g)
        {
            GrimoireEditor editor = new GrimoireEditor();

            editor.LoadGrimoire(g);
            editor.Show();
        }
        public override void DoAction(Grimoire grimoire)
        {
            int x = 3;
            int y = x + 4;

            z += y;
        }
Example #3
0
    private void Toggle()
    {
        if (UIManager.IsMaxMapOn || UIManager.IsInventory)
        {
            return;
        }
        grimoire.gameObject.SetActive(false);
        if (_IsSpellbook)
        {
            grimoire     = _necronomicon;
            _IsSpellbook = false;

            _spellBookIcon.SwapPosition(true);
            _necronomiconIcon.SwapPosition(false);
            _necronomicon.SetMouseCursor();
        }
        else
        {
            grimoire     = _spellBook;
            _IsSpellbook = true;

            _spellBookIcon.SwapPosition(false);
            _necronomiconIcon.SwapPosition(true);
            MouseCursor.Instance.Set(CursorIcon.kTargeting);
        }
        grimoire.gameObject.SetActive(true);
    }
Example #4
0
        static void Main(string[] args)
        {
            var popoi   = new Grimoire(new Mage("Popoi", 50, 80, 10, 5, 5, 30, 50));
            var link    = new Warrior("Link", 50, 80, 10, 5, 5, 30, 50);
            var psyduck = new Healer("Psyduck", 50, 80, 10, 5, 5, 30);

            psyduck.MagicCasting += popoi.Healer_MagicCasting;
            psyduck.MagicCasting += link.Healer_MagicCasting;
            psyduck.MagicCasting += psyduck.Healer_MagicCasting;

            var chopper = new Sword(new Warrior("Chopper", 50, 80, 10, 5, 5, 30, 50));
            var johnDoe = new Paladin("johnDoe", 50, 20, 60, 12, 50, 2);
            var mike    = new Paladin("mike", 50, 20, 60, 12, 50, 2);

            var game = new Game(
                new List <Character> {
                popoi, link, johnDoe
            },
                new List <Character> {
                psyduck, chopper, mike
            });

            while (!game.HasEnded())
            {
                game.PlayTurn();
            }

            game.DisplayScore();

            Console.ReadKey();
        }
 private IEnumerator <Yielder> Routine(Grimoire grimoire)
 {
     if (frameDelay > 0)
     {
         yield return(new WaitFrames(frameDelay));
     }
     Console.WriteLine(message);
     yield break;
 }
        public override PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer)
        {
            timer.ThrowIfTimedOut();

            CalcFunction func;

            if (!grimoire.Functions.TryGetValue(FunctionName, out func))
            {
                throw new SimplificationException(
                          $"Unknown function '{FunctionName}'.",
                          this
                          );
            }
            if (func.ArgumentCount != Arguments.Count)
            {
                string expectedArgCountString = (func.ArgumentCount == 1)
                    ? $"{func.ArgumentCount} argument"
                    : $"{func.ArgumentCount} arguments"
                ;
                throw new SimplificationException(
                          $"Function '{FunctionName}' expects {expectedArgCountString}, got {Arguments.Count}.",
                          this
                          );
            }

            ImmutableList <PrimitiveExpression> simplifiedArgs = Arguments
                                                                 .ConvertAll(arg => arg.Simplified(grimoire, timer));

            timer.ThrowIfTimedOut();

            PrimitiveExpression result;

            try
            {
                result = func.Call.Invoke(simplifiedArgs);
            }
            catch (OverflowException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (DivideByZeroException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (FunctionDomainException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (TimeoutException ex)
            {
                throw new SimplificationException(this, ex);
            }
            return(result.Repositioned(Index, Length));
        }
Example #7
0
 private void InitWeapon()
 {
     // 책
     _spellBook = GameObject.Find("Weapons/SpellBook").GetComponent <SpellBook>();
     _spellBook.Init(_characterStats);
     _necronomicon = GameObject.Find("Weapons/Necronomicon").GetComponent <Necronomicon>();
     _necronomicon.Init(_characterStats);
     grimoire     = _spellBook;
     _IsSpellbook = true;
     // 텔레포트
     _teleport.Init();
 }
        private void buttonAddGrim_Click(object sender, EventArgs e)
        {
            var ag        = new AddGrimoireForm();
            var dialogRes = ag.ShowDialog();

            if (dialogRes == DialogResult.OK)
            {
                Grimoire g = new Grimoire();
                g.Name  = ag.GrimoireName;
                g.Layer = ag.GrimoireLayer;
                Warlock.AddGrimoire(g);
                UpdateGrimoireList();
            }
        }
Example #9
0
 void Start()
 {
     m_actorProperties         = new Properties();
     m_movementController      = GetComponent(typeof(MovementController))          as MovementController;
     m_physicsController       = GetComponent(typeof(PhysicsController))           as PhysicsController;
     m_boxCollider             = GetComponent(typeof(BoxCollider2D))               as BoxCollider2D;
     m_inputHandler            = GetComponent(typeof(InputHandler))                as InputHandler;
     m_spellCharges            = GetComponent(typeof(SpellCharges))                as SpellCharges;
     m_componentAnimator       = GetComponent(typeof(Animator))                    as Animator;
     m_grimoire                = GetComponent(typeof(Grimoire))                    as Grimoire;
     m_particleManager         = GetComponentInChildren(typeof(ParticleManager))   as ParticleManager;
     m_renderer                = GetComponentInChildren(typeof(Renderer))          as Renderer;
     m_renderer.material.color = actorColor;
     m_invulnerable            = false;
 }
Example #10
0
 public void LoadGrimoire(Grimoire grimoire)
 {
     this.loadedGrimoire = grimoire;
     if (grimoire != null)
     {
         LoadSpellList(grimoire.LoadSpells, listPanelLoadSpells);
         LoadSpellList(grimoire.PreExecuteSpells, listPanelPreExecSpells);
         LoadSpellList(grimoire.ExecuteSpells, listPanelExecSpells);
         LoadSpellList(grimoire.PostExecuteSpells, listPanelPostExecSpells);
     }
     else
     {
         this.Shown += (object sender, EventArgs e) => { this.Close(); };
     }
 }
        public override PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer)
        {
            timer.ThrowIfTimedOut();

            PrimitiveExpression ret;

            if (!grimoire.Constants.TryGetValue(Name, out ret))
            {
                throw new SimplificationException(
                          $"Unknown constant '{Name}'.",
                          this
                          );
            }

            return(ret.Repositioned(Index, Length));
        }
        public override void DoAction(Grimoire grimoire)
        {
            switch (AddToThis)
            {
            case CoroutineToAddToTest.PreExecute:
                CoroutineEngine.PreExecute.StartCoroutine(Routine(grimoire));
                break;

            case CoroutineToAddToTest.Execute:
                CoroutineEngine.Execute.StartCoroutine(Routine(grimoire));
                break;

            case CoroutineToAddToTest.PostExecute:
                CoroutineEngine.PostExecute.StartCoroutine(Routine(grimoire));
                break;

            default:
                break;
            }
        }
Example #13
0
    public override void Update()
    {
        if (isActive)
        {
            if (!lockedIn)
            {
                base.Update();
                if (GamepadInput.GamePad.GetButtonDown(GamepadInput.GamePad.Button.Start, (GamepadInput.GamePad.Index)controllerNumber))
                {
                    lockedIn   = true;
                    justLocked = true;
                    colorPicker.SetActive(true);
                }
            }
            else
            {
                if (GamepadInput.GamePad.GetButtonDown(GamepadInput.GamePad.Button.B, (GamepadInput.GamePad.Index)controllerNumber))
                {
                    lockedIn = false;
                    lockedText.gameObject.SetActive(false);
                    colorPicker.SetActive(false);
                }

                if (justLocked)
                {
                    lockedText.gameObject.SetActive(true);

                    Grimoire actorGrimoire = GameManager.GetAllActors()[controllerNumber - 1].GetComponent <Grimoire>();

                    actorGrimoire.Reset();
                    actorGrimoire.AllocateSpace(3);

                    actorGrimoire.AddPage(spell1.m_current);
                    actorGrimoire.AddPage(spell2.m_current);
                    actorGrimoire.AddPage(spell3.m_current);

                    justLocked = false;
                }
            }
        }
    }
Example #14
0
        public void ReloadNew(int spellLevel)
        {
            this.m_SpellLevel = spellLevel;
            int      i = 0;
            Grimoire loadedGrimoire = UIGrimoireManager.Instance.LoadedGrimoire;

            if (loadedGrimoire && spellLevel - 1 < loadedGrimoire.Spells.Length)
            {
                GenericSpell[] spellData = loadedGrimoire.Spells[spellLevel - 1].SpellData;
                for (int j = 0; j < spellData.Length; j++)
                {
                    GenericSpell genericSpell = spellData[j];
                    if (!(genericSpell == null))
                    {
                        if (i >= this.m_Spells.Count)
                        {
                            Debug.LogWarning(string.Concat(new object[]
                            {
                                "Grimoire has too many spells for UI (",
                                UIGrimoireManager.Instance.LoadedGrimoire.name,
                                " S.L.",
                                spellLevel,
                                ")"
                            }));
                            break;
                        }
                        this.m_Spells[i].SetSpell(genericSpell);
                        this.m_Spells[i].SetVisibility(true);
                        this.m_Spells[i].SetSelected(i < (4 + (int)IEModOptions.ExtraWizardSpells) && spellLevel == UIGrimoireManager.Instance.LevelButtons.CurrentLevel);
                        this.m_Spells[i].SetDisabled(GameState.InCombat || !UIGrimoireManager.Instance.CanEditGrimoire);
                        i++;
                    }
                }
            }
            while (i < this.m_Spells.Count)
            {
                this.m_Spells[i].SetVisibility(false);
                i++;
            }
        }
        public static bool mod_ShowOnSpellBar(GenericAbility ability, CharacterStats stats, int spellLevel)
        {
            if (ability.Passive)
            {
                return(false);
            }
            GenericSpell         genericSpell         = ability as GenericSpell;
            GenericCipherAbility genericCipherAbility = ability as GenericCipherAbility;

            if (!genericSpell)
            {
                return(genericCipherAbility && (spellLevel <= 0 || genericCipherAbility.SpellLevel == spellLevel));
            }

            if (genericSpell.SpellClass != stats.CharacterClass && spellLevel > 0 && genericSpell.SpellLevel == spellLevel && IEModOptions.HideAnticlassSpells)
            {
                return(true);
            }

            if (genericSpell.SpellClass != stats.CharacterClass || (spellLevel > 0 && genericSpell.SpellLevel != spellLevel))
            {
                return(false);
            }
            if (stats.CharacterClass != CharacterStats.Class.Wizard || !genericSpell.NeedsGrimoire)
            {
                return(true);
            }
            Equipment component = stats.GetComponent <Equipment>();

            if (component == null || component.CurrentItems == null || component.CurrentItems.Grimoire == null)
            {
                return(false);
            }
            Grimoire component2 = component.CurrentItems.Grimoire.GetComponent <Grimoire>();

            return(!(component2 == null) && component2.HasSpell(genericSpell));
        }
Example #16
0
 public abstract PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer);
Example #17
0
 public override void DoAction(Grimoire grimoire)
 {
     Console.WriteLine("Repeating: " + data);
 }
        public override PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer)
        {
            timer.ThrowIfTimedOut();

            PrimitiveExpression primOperand = Operand.Simplified(grimoire, timer);

            try
            {
                switch (Operation)
                {
                case Operation.Negate:
                    if (primOperand.Type == PrimitiveType.IntegerLong)
                    {
                        return(new PrimitiveExpression(Index, Length, -primOperand.LongValue));
                    }
                    else if (primOperand.Type == PrimitiveType.IntegerBig)
                    {
                        return(new PrimitiveExpression(Index, Length, -primOperand.BigIntegerValue));
                    }
                    else if (primOperand.Type == PrimitiveType.Decimal)
                    {
                        return(new PrimitiveExpression(Index, Length, -primOperand.DecimalValue));
                    }
                    break;

                case Operation.Factorial:
                    if (primOperand.Type == PrimitiveType.IntegerLong)
                    {
                        return(new PrimitiveExpression(Index, Length, MathFuncs.Factorial(primOperand.LongValue, timer)));
                    }
                    else if (primOperand.Type == PrimitiveType.IntegerBig)
                    {
                        return(new PrimitiveExpression(Index, Length, MathFuncs.Factorial(primOperand.BigIntegerValue, timer)));
                    }
                    else if (primOperand.Type == PrimitiveType.Decimal)
                    {
                        throw new FunctionDomainException("Factorials are not defined on fractional numbers.");
                    }
                    break;

                default:
                    break;
                }
            }
            catch (OverflowException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (DivideByZeroException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (FunctionDomainException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (TimeoutException ex)
            {
                throw new SimplificationException(this, ex);
            }

            throw new SimplificationException($"Cannot handle unary operator {Operation}.", this);
        }
Example #19
0
        void Generate()
        {
            Warlock.Reset();

            for (int i = 0; i < 4; i++)
            {
                Grimoire grimoire = new Grimoire();
                grimoire.Name = $"Default{i}";

                Spell a   = new Spell();
                var   eqA = new FirstEqualsSecond("a", "d");
                a.SetConditional(eqA);
                a.AddAction(new WarlockActionEcho("Test"));
                a.AddAction(new WarlockActionEcho("Test 1"));
                a.AddAction(new WarlockActionEcho("Test 1"));
                grimoire.LoadSpells.Add(a);

                string[] s = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" };
                Random   r = new Random();
                stressTestVal = (int)numericUpDownStress.Value;
                for (int j = 0; j < stressTestVal; j++)
                {
                    string N()
                    {
                        return(s[r.Next(9)]);
                    }

                    Spell a1    = new Spell();
                    var   aeqC  = new EWConditionGroup();
                    var   aeqC1 = new EWConditionGroup();
                    var   aeqC2 = new EWConditionGroup();

                    //Group1
                    aeqC1.AddConditional(new FirstEqualsSecond(N(), N()));
                    aeqC1.AddOperator(QuestionOp.AND);
                    aeqC1.AddConditional(new FirstEqualsSecond(N(), N()));

                    aeqC.AddConditional(aeqC1);

                    //if (r.Next(0, 2) == 0)
                    //{
                    aeqC.AddOperator(QuestionOp.OR);

                    //Group 2
                    aeqC2.AddConditional(new FirstEqualsSecond("a", "a"));
                    aeqC2.AddOperator(QuestionOp.AND);
                    aeqC2.AddConditional(new FirstEqualsSecond("a", "a"));
                    aeqC.AddConditional(aeqC2);
                    //}

                    a1.SetConditional(aeqC);

                    a1.AddAction(new WarlockActionNone());
                    grimoire.LoadSpells.Add(a1);
                }
                //a.AddAction(new WarlockActionMega());


                Spell b   = new Spell();
                var   eqB = new FirstEqualsSecond("a", "b");
                b.SetConditional(eqB, true);
                b.AddAction(new WarlockActionEcho("Test Else"));
                grimoire.LoadSpells.Add(b);

                Spell b2   = new Spell();
                var   eqB2 = new FirstEqualsSecond("a", "a");
                b2.SetConditional(eqB2, true);
                b2.AddAction(new WarlockActionEcho("Test Else 2"));
                b2.AddAction(new WarlockActionCoroutineTest());
                grimoire.LoadSpells.Add(b2);

                Spell c = new Spell();
                //(("a"=="l" AND "c"=="c") OR ("b"=="b" AND "c"=="c"))
                //should always create group as base, otherwise if only one conditional just set as that conditional
                var eqC  = new EWConditionGroup();
                var eqC1 = new EWConditionGroup();
                var eqC2 = new EWConditionGroup();

                //Group1
                eqC1.AddConditional(new FirstEqualsSecond("a", "l"));
                eqC1.AddOperator(QuestionOp.AND);
                eqC1.AddConditional(new FirstEqualsSecond("c", "c"));

                eqC.AddConditional(eqC1);
                eqC.AddOperator(QuestionOp.OR);

                //Group 2
                eqC2.AddConditional(new FirstEqualsSecond("b", "b"));
                eqC2.AddOperator(QuestionOp.AND);
                eqC2.AddConditional(new FirstEqualsSecond("c", "c"));

                eqC.AddConditional(eqC2);
                c.SetConditional(eqC);

                c.AddAction(new WarlockActionEcho("Big Test"));

                var wam = (WarlockActionMega)FormatterServices.GetUninitializedObject(typeof(WarlockActionMega));
                c.AddAction(wam);
                //c.AddAction(new WarlockActionMega());
                //c.AddAction(new WarlockActionMega());
                grimoire.PostExecuteSpells.Add(c);

                Warlock.AddGrimoire(grimoire);
                buttonTest.Enabled = true;
                Console.WriteLine("Spell c: " + eqC.ToString());
            }

            UpdateGrimoireList();
            //LoadEditor();
        }
        public override PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer)
        {
            timer.ThrowIfTimedOut();

            PrimitiveExpression primLeft = LeftSide.Simplified(grimoire, timer);

            timer.ThrowIfTimedOut();
            PrimitiveExpression primRight = RightSide.Simplified(grimoire, timer);

            timer.ThrowIfTimedOut();

            // type check
            switch (Operation)
            {
            case Operation.BinaryAnd:
            case Operation.BinaryOr:
            case Operation.BinaryXor:
                if (primLeft.Type == PrimitiveType.Decimal || primRight.Type == PrimitiveType.Decimal)
                {
                    throw new SimplificationException(
                              "Cannot perform a bitwise operation on a floating-point number.",
                              this
                              );
                }
                break;

            default:
                break;
            }

            try
            {
                // mixed types? coerce
                if (primLeft.Type == PrimitiveType.IntegerLong)
                {
                    if (primRight.Type == PrimitiveType.IntegerBig)
                    {
                        // IntegerLong < IntegerBig
                        primLeft = new PrimitiveExpression(primLeft.Index, primLeft.Length, new BigInteger(primLeft.LongValue));
                    }
                    else if (primRight.Type == PrimitiveType.Decimal)
                    {
                        // IntegerLong < Decimal
                        primLeft = new PrimitiveExpression(primLeft.Index, primLeft.Length, (decimal)primLeft.LongValue);
                    }
                }
                else if (primLeft.Type == PrimitiveType.IntegerBig)
                {
                    if (primRight.Type == PrimitiveType.IntegerLong)
                    {
                        // IntegerBig > IntegerLong
                        primRight = new PrimitiveExpression(primRight.Index, primRight.Length, new BigInteger(primRight.LongValue));
                    }
                    else if (primRight.Type == PrimitiveType.Decimal)
                    {
                        // IntegerBig < Decimal
                        primLeft = new PrimitiveExpression(primLeft.Index, primLeft.Length, (decimal)primLeft.BigIntegerValue);
                    }
                }
                else if (primLeft.Type == PrimitiveType.Decimal)
                {
                    if (primRight.Type == PrimitiveType.IntegerLong)
                    {
                        // Decimal > IntegerLong
                        primRight = new PrimitiveExpression(primRight.Index, primRight.Length, (decimal)primRight.LongValue);
                    }
                    else if (primRight.Type == PrimitiveType.IntegerBig)
                    {
                        // Decimal > IntegerBig
                        primRight = new PrimitiveExpression(primRight.Index, primRight.Length, (decimal)primRight.BigIntegerValue);
                    }
                }
            }
            catch (OverflowException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (DivideByZeroException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (FunctionDomainException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (TimeoutException ex)
            {
                throw new SimplificationException(this, ex);
            }

            timer.ThrowIfTimedOut();

            Debug.Assert(primLeft.Type == primRight.Type);

            int newIndex  = primLeft.Index;
            int newLength = primRight.Index + primRight.Length - primLeft.Index;

            try
            {
                switch (Operation)
                {
                case Operation.Add:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a + b),
                               (a, b) => checked (a + b),
                               (a, b) => checked (a + b)
                               ));

                case Operation.Divide:
                    return(new PrimitiveExpression(
                               newIndex, newLength,
                               checked (primLeft.ToDecimal() / primRight.ToDecimal())
                               ));

                case Operation.IntegralDivide:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a / b),
                               (a, b) => checked (a / b),
                               (a, b) => Math.Truncate(checked (a / b))
                               ));

                case Operation.Multiply:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a * b),
                               (a, b) => checked (a * b),
                               (a, b) => checked (a * b)
                               ));

                case Operation.Power:
                    if (primLeft.Type == PrimitiveType.IntegerLong)
                    {
                        return(Pow(newIndex, newLength, primLeft.LongValue, primRight.LongValue, timer));
                    }
                    else if (primLeft.Type == PrimitiveType.IntegerBig)
                    {
                        return(Pow(newIndex, newLength, primLeft.BigIntegerValue, primRight.BigIntegerValue, timer));
                    }
                    else if (primLeft.Type == PrimitiveType.Decimal)
                    {
                        return(Pow(newIndex, newLength, primLeft.DecimalValue, primRight.DecimalValue, timer));
                    }
                    break;

                case Operation.Remainder:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a % b),
                               (a, b) => checked (a % b),
                               (a, b) => checked (a % b)
                               ));

                case Operation.Subtract:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a - b),
                               (a, b) => checked (a - b),
                               (a, b) => checked (a - b)
                               ));

                case Operation.BinaryAnd:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a & b),
                               (a, b) => checked (a & b),
                               null
                               ));

                case Operation.BinaryOr:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a | b),
                               (a, b) => checked (a | b),
                               null
                               ));

                case Operation.BinaryXor:
                    return(BinaryOp(
                               newIndex, newLength, primLeft, primRight,
                               (a, b) => checked (a ^ b),
                               (a, b) => checked (a ^ b),
                               null
                               ));
                }
            }
            catch (OverflowException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (DivideByZeroException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (FunctionDomainException ex)
            {
                throw new SimplificationException(this, ex);
            }
            catch (TimeoutException ex)
            {
                throw new SimplificationException(this, ex);
            }

            throw new SimplificationException($"Cannot handle binary operator {Operation}.", this);
        }
Example #21
0
 public override bool Evaluate(Grimoire grimoire)
 {
     return(a == b);
 }
Example #22
0
 public override void DoAction(Grimoire grimoire)
 {
     Console.WriteLine("Bad joke here");
 }
Example #23
0
 public override void DoAction(Grimoire grimoire)
 {
 }
 public override PrimitiveExpression Simplified(Grimoire grimoire, CalcTimer timer)
 {
     // nothing to simplify
     return(this);
 }