Ejemplo n.º 1
0
        public void UseMagic()
        {
            Func <bool> isLearnedMagic = () => {
                foreach (IMagic learnedMagic in MagicList)
                {
                    // XXX: Nullの場合,true?false?
                    if (learnedMagic?.GetType() == SelectMaigic.GetType())
                    {
                        return(true);
                    }
                }
                return(false);
            };
            Func <bool> isEnoughMagicPoint = () => {
                return(SelectMaigic.MagicPoint > MagicPoint);
            };

            if (!isLearnedMagic())
            {
                // TODO: 例外処理
                return;
            }
            if (!isEnoughMagicPoint())
            {
                // TODO: 例外処理
                return;
            }
            MagicPoint  -= SelectMaigic.MagicPoint;
            SelectMaigic = SelectMaigic;
            if (SelectMaigic.GetType() == typeof(IAttackMagic))
            {
                return;
            }
        }
Ejemplo n.º 2
0
        public static void AddSpell(IMagic spell)
        {
            string _level = SpellLevelToString(spell.SpellLevel);

            if (_level == "")
            {
                throw new System.Exception("Invalid Spell level");
            }

            //Checking if the level is already in the collection
            foreach (SpellLevelGroup magics in SpellsKnown)
            {
                if (magics.Level == _level)
                {
                    magics.Add(spell);
                    return;
                }
            }

            //Adding the level in the right spot of the collection (right before the first one greater than it)
            for (int i = 0; i < SpellsKnown.Count; i++)
            {
                if (LevelTextToInt(_level) < LevelTextToInt(SpellsKnown[i].Level) || i == SpellsKnown.Count - 1)
                {
                    SpellsKnown.Insert(i, new SpellLevelGroup(_level, new IMagic[] { spell }));
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        public SheetMusic(string id, Texture2D texture, string name, string description, Color color, string music, int lenght, IMagic magic)
        {
            if (allSheets == null)
            {
                allSheets = new Dictionary <string, SheetMusic>();
            }

            this.magic       = magic;
            this.lenght      = lenght;
            this.texture     = texture;
            this.color       = color;
            this.music       = music;
            this.name        = name;
            displayName      = name;
            sheetDescription = description;
            sheetMusicID     = id;

            if (allSheets.ContainsKey(id))
            {
                allSheets.Remove(id);
            }

            owned = false;
            allSheets.Add(id, this);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            IMagic.GetMagic();

            Type type = typeof(IMagic);

            MethodInfo method = type.GetMethod(nameof(IMagic.GetMagic));

            method.Invoke(null, null);
        }
Ejemplo n.º 5
0
 public void useMagic(IMagic magic, Player defender, int turnNumber)
 {
     if (magic.canUse(this))
     {
         magic.Use(this, defender);
     }
     else
     {
         base.Attack(defender, turnNumber);
     }
 }
Ejemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        magic = target as IMagic;

        showTimeLine = EditorGUILayout.Foldout(showTimeLine, "ShowTimeLine");
        if (showTimeLine)
        {
            DrawTimeLine();
        }
    }
Ejemplo n.º 7
0
        public IMagic choiceMagic()
        {
            int    magicsNumber    = wizarduseAbleMagic.Count;
            int    selectMagicInt  = UnityEngine.Random.Range(0, magicsNumber);
            string selectMagicName = wizarduseAbleMagic[selectMagicInt].ToString();
            Type   selectMagicType =
                Type.GetType("BattleScene.Magic." + selectMagicName);
            IMagic selectMagic =
                (IMagic)Activator.CreateInstance(selectMagicType);

            return(selectMagic);
        }
Ejemplo n.º 8
0
        public void wizardAttack(Player defender, int turnNumber)
        {
            IMagic magic = this.choiceMagic();

            if (magic.canUse(this))
            {
                magic.Use(this, defender);
            }
            else
            {
                base.Attack(defender, turnNumber);
            }
        }
Ejemplo n.º 9
0
        /*public IMagic choiceMagic()
         * {
         *  int magicsNumber = priestuseAbleMagics.Count;
         *  string selectMagicName;
         *  do
         *  {
         *      Debug.Log(this.priestuseAbleMagics[0]);
         *      Debug.Log(this.priestuseAbleMagics[1]);
         *      Debug.Log(this.priestuseAbleMagics[2]);
         *      int selectMagicInt = UnityEngine.Random.Range(0, magicsNumber);
         *      selectMagicName = priestuseAbleMagics[selectMagicInt].ToString();
         *      Debug.Log(selectMagicName);
         *  }
         *  while (selectMagicName == "Heal");
         *  Type selectMagicType =
         *      Type.GetType("BattleScene.Magic." + selectMagicName);
         *  IMagic selectMagic =
         *      (IMagic) Activator.CreateInstance(selectMagicType);
         *      Debug.Log(selectMagic.ToString());
         *  return selectMagic;
         * }*/
        public IMagic choiceMagic()
        {
            IMagic selectMagic    = null;
            int    selectMagicInt = UnityEngine.Random.Range(0, 2);

            if (selectMagicInt == 0)
            {
                selectMagic = new Poison();
            }
            else
            {
                selectMagic = new Parise();
            }
            return(selectMagic);
        }
Ejemplo n.º 10
0
        public SheetMusic(string id, Texture2D texture, string name, string description, Color color, string music, int length, IMagic magic)
        {
            if (allSheets == null)
            {
                allSheets = new Dictionary <string, SheetMusic>();
            }

            this.magic       = magic;
            this.length      = length;
            this.texture     = texture;
            this.color       = color;
            this.music       = music;
            this.name        = name;
            displayName      = name;
            sheetDescription = description;
            sheetMusicID     = id;
            allSheets.AddOrReplace(id, this);
        }
Ejemplo n.º 11
0
        public Wizard()
        {
            Hp               = 10;
            AttackPont       = 0;
            Characteristices = new Characteristic[] {
                Characteristic.magic,
                Characteristic.human
            };
            BattleCharacter myself = this;

            Slots = new Slot[] { new Slot(ref myself),
                                 new Slot(ref myself),
                                 new Slot(ref myself),
                                 new Slot(ref myself),
                                 new Slot(ref myself), };
            MagicList    = new IMagic[4];
            MagicList[0] = new FireBall();
            MagicList[1] = new FireBolt();
        }
Ejemplo n.º 12
0
 private void btn_Contest_Click(object sender, EventArgs e)
 {
     txt_ShoutContest.Text = "";
     txt_ShoutContest.Update();
     txt_MagicContest.Text = "";
     txt_MagicContest.Update();
     foreach (var animal in aniArr)
     {
         if (animal != null)
         {
             txt_ShoutContest.AppendText(animal.Shout() + Environment.NewLine);
             if (animal is IMagic)
             {
                 IMagic m = (IMagic)animal; //downcasting
                 txt_MagicContest.AppendText(m.ChangeThing() + Environment.NewLine);
             }
         }
     }
 }
Ejemplo n.º 13
0
    private void OnTriggerEnter(Collider other)
    {
        AttackInfo info;

        string layerName = LayerMask.LayerToName(other.gameObject.layer);

        //nearAttack
        if (layerName.Contains("Weapon"))
        {
            IWeapon    weapon = other.GetComponent <IWeapon>();
            ICharacter owner  = weapon.owner;
            info = (owner.CurrentState as IAttackState).CurrentSkillInfo;
        }//Magic
        else
        {
            IMagic magic = other.GetComponent <IMagic>();
            CalculateMagicAttack(magic, magic.owner, magic.info, magic.weapon);
        }
    }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            var magiccard = new IMagic[]
            {
                new MagicCard("Garruk Wildspeaker", "Lorwyn", 8.5),
                new MagicCard("Loxodon Warhammer", "Mirrodin", 1.00),
                new MagicCard("Knight Exemplar", "2011 Core Set", 4.00),

                new MagicProdukte("Display", "Return to Ravnica Boosterdisplay", 119.99),
                new MagicProdukte("Deck", "Amonkhet Planeswalker Deck", 11.99),
            };

            foreach (var mc in magiccard)
            {
                Console.WriteLine("");
                Console.WriteLine($"{mc.Name}, {mc.Edition}, {mc.Price} Euro");
                Console.ReadKey();
            }

            Serialization.Run(magiccard);
            Console.ReadKey();
        }
Ejemplo n.º 15
0
 private void CalculateMagicAttack(IMagic magic, ICharacter attacker, AttackInfo skillInfo, IWeapon weapon)
 {
     owner.HP -= (attacker.ATK + magic.atk + (weapon == null?0:weapon.ATK)) * skillInfo.DamageRate;
 }
Ejemplo n.º 16
0
 protected abstract void Invoke(IMagic magic, out bool carryOn);
Ejemplo n.º 17
0
        public void firstTurnAttack(Player defender, int turnNumber)
        {
            IMagic magic = this.choiceMagic();

            this.useMagic(magic, defender, turnNumber);
        }
Ejemplo n.º 18
0
 public void CastMagic(IMagic magic)
 {
     magic.Cast(this);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Конструктор создающий мага с определённым заклинанием.
 /// </summary>
 /// <param name="magic">Тип заклинания</param>
 public Mage(IMagic magic)
 {
     Magic = magic ?? throw new ArgumentException(nameof(magic));
 }
Ejemplo n.º 20
0
 public static void Meditate(this IMagic magician)
 {
     magician.ManaPoints = magician.MaximumManaPoints;
 }
Ejemplo n.º 21
0
 void Start()
 {
     playerMotor = GetComponent <IPlayerMotor>();
     magic       = GetComponent <IMagic>();
 }
Ejemplo n.º 22
0
 public Calculator(IMagic magic)
 {
     this.magic = magic;
 }
Ejemplo n.º 23
0
 public PopupSpell(IMagic spell)
 {
     InitializeComponent();
     Context        = spell;
     BindingContext = Context;
 }
Ejemplo n.º 24
0
 public MagicDecorator(IMagic magic)
 {
     _magic = magic;
 }