internal bool CanStartUpgrading(Data Data)
        {
            Player   Player   = this.Parent.Level.Player;
            Building Building = (Building)this.Parent;

            if (Player != null)
            {
                if (!this.UpgradeOnGoing)
                {
                    if (this.CanUpgrade(Data))
                    {
                        if (Data.GetDataType() == 4)
                        {
                            CharacterData Character = (CharacterData)Data;

                            if (Character.UnitOfType == 1)
                            {
                                if (Character.VillageType == 0)
                                {
                                    if (!Character.IsUnlockedForBarrackLevel(this.Parent.Level.ComponentManager.MaxBarrackLevel))
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    if (!Character.IsUnlockedForBarrackLevel(this.Parent.Level.Player.Variables.Village2BarrackLevel))
                                    {
                                        return(false);
                                    }
                                }
                            }
                            else
                            {
                                if (Character.VillageType == 0)
                                {
                                    if (!Character.IsUnlockedForBarrackLevel(this.Parent.Level.ComponentManager.MaxDarkBarrackLevel))
                                    {
                                        return(false);
                                    }
                                }
                                else
                                {
                                    Logging.Error(this.GetType(), "Unable to approve the upgrade. Builder village doesn't have UnitOfType 2");
                                    return(false);
                                }
                            }

                            return(Building.GetUpgradeLevel() + 1 >= Character.LaboratoryLevel[Player.GetUnitUpgradeLevel(Character)] && !Building.Constructing);
                        }

                        SpellData Spell = (SpellData)Data;

                        if (Spell.VillageType == 0)
                        {
                            if (Spell.UnitOfType == 1)
                            {
                                if (!Spell.IsUnlockedForSpellForgeLevel(this.Parent.Level.ComponentManager.MaxBarrackLevel))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (!Spell.IsUnlockedForSpellForgeLevel(this.Parent.Level.ComponentManager.MaxDarkBarrackLevel))
                                {
                                    return(false);
                                }
                            }

                            return(Building.GetUpgradeLevel() + 1 >= Spell.LaboratoryLevel[Player.GetUnitUpgradeLevel(Spell)] && !Building.Constructing);
                        }

                        Logging.Error(this.GetType(), "Unable to approve the upgrade. Builder village doesn't have spell");
                        return(false);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Gets a value indicating whether you can start upgrading.
        /// </summary>
        internal bool CanStartUpgrading(Data Data)
        {
            Player   Player   = this.Parent.Level.Player;
            Building Building = (Building)this.Parent;

            if (Player != null)
            {
                if (!this.UpgradeOnGoing)
                {
                    if (this.CanUpgrade(Data))
                    {
                        if (Data.GetDataType() == 4)
                        {
                            CharacterData Character = (CharacterData)Data;

                            if (Character.UnitOfType == 1)
                            {
                                if (!Character.IsUnlockedForBarrackLevel(this.Parent.Level.ComponentManager.MaxBarrackLevel))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (!Character.IsUnlockedForBarrackLevel(this.Parent.Level.ComponentManager.MaxDarkBarrackLevel))
                                {
                                    return(false);
                                }
                            }

                            if (Character.LaboratoryLevel[Player.GetUnitUpgradeLevel(Character)] >= Building.GetUpgradeLevel() && !Building.Constructing)
                            {
                                return(true);
                            }

                            return(false);
                        }

                        SpellData Spell = (SpellData)Data;

                        if (Spell.UnitOfType == 1)
                        {
                            if (!Spell.IsUnlockedForSpellForgeLevel(this.Parent.Level.ComponentManager.MaxBarrackLevel))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!Spell.IsUnlockedForSpellForgeLevel(this.Parent.Level.ComponentManager.MaxDarkBarrackLevel))
                            {
                                return(false);
                            }
                        }

                        if (Spell.LaboratoryLevel[Player.GetUnitUpgradeLevel(Spell)] >= Building.GetUpgradeLevel() && !Building.Constructing)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }