示例#1
0
        /// <summary>
        /// Loads this instance from json.
        /// </summary>
        public void LoadJson(JToken Json)
        {
            JsonHelper.GetJsonNumber(Json, "acc_hi", out this.AccountHighId);
            JsonHelper.GetJsonNumber(Json, "acc_lo", out this.AccountLowId);
            JsonHelper.GetJsonNumber(Json, "alli_hi", out this.AllianceHighId);
            JsonHelper.GetJsonNumber(Json, "alli_lo", out this.AllianceLowId);
            JsonHelper.GetJsonNumber(Json, "home_hi", out this.HomeHighId);
            JsonHelper.GetJsonNumber(Json, "home_lo", out this.HomeLowId);

            JsonHelper.GetJsonString(Json, "name", out this.Name);
            JsonHelper.GetJsonString(Json, "alliance", out this.AllianceName);

            JsonHelper.GetJsonNumber(Json, "score", out this.Score);
            JsonHelper.GetJsonNumber(Json, "score_p", out this.ScoreP);
            JsonHelper.GetJsonNumber(Json, "stars", out this.Stars);
            JsonHelper.GetJsonNumber(Json, "highscore", out this.HighScore);

            JsonHelper.GetJsonData(Json, "badge", out this.BadgeData);

            if (JsonHelper.GetJsonArray(Json, "spells", out JArray Spells))
            {
                this.Deck = new SpellDeck();
                this.Deck.Load(Spells);
            }
        }
示例#2
0
    void Awake()
    {
        state = false;

        Events.RelayByValue <Turn>(GameEvent.OnTurnStart, OnTurnStart);
        Events.RelayByValue <Player>(GameEvent.OnPlayerDeath, OnPlayerDeath);
        Events.RelayByVoid(InterfaceEvent.OnInfoRefresh, Refresh);

        keyedBuffs = new Dictionary <StatType, PlayerBuff>();
        foreach (var buff in buffs)
        {
            if (keyedBuffs.ContainsKey(buff.Type))
            {
                continue;
            }
            keyedBuffs.Add(buff.Type, buff);
        }

        damageable      = player.GetComponent <IDamageable>();
        cachedMaxHealth = damageable.Get("Health").maxValue;

        attributes = player.GetComponent <IAttributeHolder>();

        deck = player.GetComponent <SpellDeck>();
    }
示例#3
0
        /// <summary>
        /// Sets the player.
        /// </summary>
        public void SetPlayer(Player Player, SpellDeck Deck, bool Npc)
        {
            if (!Npc)
            {
                this.Deck   = Deck;
                this.Player = Player;

                int    SpellCnt = Deck.SpellCount;
                byte[] Tmp      = new byte[SpellCnt];

                for (byte I = 0; I < SpellCnt; I++)
                {
                    Tmp[I] = I;
                }

                int N = SpellCnt;

                while (N > 1)
                {
                    int  K     = XorShift.Next(N + 1);
                    byte Value = Tmp[K];
                    Tmp[K] = Tmp[N];
                    Tmp[N] = Value;

                    --N;
                }

                int Cnt = Math.Min(4, SpellCnt);

                for (int I = 0; I < Cnt; I++)
                {
                    this.Hand[I] = Tmp[I];

                    if (I > 0)
                    {
                        this.Hand[I] -= Tmp[I - 1];
                    }
                }

                for (int I = Cnt; I < SpellCnt; I++)
                {
                    this.SpellQueue.Add(Tmp[I]);
                }

                // TODO : Mike, check this

                int Idx = 0;

                for (int I = 0; I < SpellCnt; I++)
                {
                    Idx += this.Hand[I];
                }
            }
        }
示例#4
0
        public override object ReadJson(JsonReader Reader, Type ObjectType, object ExistingValue, JsonSerializer Serializer)
        {
            SpellDeck Deck = (SpellDeck)ExistingValue;

            if (Deck == null)
            {
                Deck = new SpellDeck();
            }

            Deck.Load(JArray.Load(Reader));

            return(Deck);
        }
示例#5
0
        public override void WriteJson(JsonWriter Writer, object Value, JsonSerializer Serializer)
        {
            SpellDeck Deck = (SpellDeck)Value;

            if (Deck != null)
            {
                Deck.Save().WriteTo(Writer);
            }
            else
            {
                Writer.WriteNull();
            }
        }
示例#6
0
        /// <summary>
        /// Sets the player.
        /// </summary>
        public void SetPlayer(Player Player, int Stars)
        {
            this.Stars = Stars;

            this.AccountHighId  = Player.HighId;
            this.AccountLowId   = Player.LowId;
            this.AllianceHighId = Player.ClanHighId;
            this.AllianceLowId  = Player.ClanLowId;
            this.HomeHighId     = Player.Home.HighId;
            this.HomeLowId      = Player.Home.LowId;

            this.Name         = Player.Name;
            this.AllianceName = Player.AllianceName;

            this.Score  = Player.Score;
            this.ScoreP = Player.MaxScore;

            this.BadgeData = Player.Badge;

            this.Deck = Player.Home.SpellDeck.Clone();
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Home"/> class.
        /// </summary>
        internal Home()
        {
            // Game

            this.Random          = new Random(Resources.Random.Next());
            this.ShopCycle       = new ShopCycle();
            this.SpellDeck       = new SpellDeck();
            this.SpellCollection = new SpellCollection();

            this.DeckPresets    = new int[5][];
            this.DeckPresets[0] = new int[8];
            this.DeckPresets[1] = new int[8];
            this.DeckPresets[2] = new int[8];
            this.DeckPresets[3] = new int[8];
            this.DeckPresets[4] = new int[8];

            // Game Timers.

            this.FreeChestTimer     = new Timer();
            this.NextShopCycleTimer = new Timer();
            this.NextShopCycleTimer.StartTimer(new Time(), 86400);
        }
示例#8
0
    public void ShowFor(Player player)
    {
        current = player.GetComponent <SpellDeck>();
        var spells = current.Spells.ToArray();

        start = spells.Length - 3;
        for (var i = 0; i < spells.Length - 3; i++)
        {
            marks[i].Show();
        }
        for (var i = start; i < marks.Length; i++)
        {
            marks[i].Hide();
        }

        var tier = Tier;

        foreach (var choice in choices)
        {
            choice.Initialize(tier);
        }

        entry.Play(showArgs);
    }