コード例 #1
0
        public override int Execute(LogicLevel level)
        {
            if (level.IsReadyForAttack())
            {
                if (this.m_data != null && !level.IsAttackerHeroPlaced(this.m_data))
                {
                    if (level.GetVillageType() == this.m_data.GetVillageType())
                    {
                        int tileX = this.m_x >> 9;
                        int tileY = this.m_y >> 9;

                        if (level.GetTileMap().GetTile(tileX, tileY) != null)
                        {
                            if (level.GetTileMap().IsPassablePathFinder(this.m_x >> 8, this.m_y >> 8))
                            {
                                if (level.GetTileMap().IsValidAttackPos(tileX, tileY))
                                {
                                    LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

                                    if (playerAvatar != null)
                                    {
                                        if (playerAvatar.IsHeroAvailableForAttack(this.m_data))
                                        {
                                            if (level.GetBattleLog() != null)
                                            {
                                                if (!level.GetBattleLog().HasDeployedUnits() && level.GetTotalAttackerHeroPlaced() == 0)
                                                {
                                                    level.UpdateLastUsedArmy();
                                                }
                                            }

                                            if (level.GetGameMode().IsInAttackPreparationMode())
                                            {
                                                level.GetGameMode().EndAttackPreparation();
                                            }

                                            int health   = playerAvatar.GetHeroHealth(this.m_data);
                                            int upgLevel = playerAvatar.GetUnitUpgradeLevel(this.m_data);

                                            level.SetAttackerHeroPlaced(this.m_data,
                                                                        LogicPlaceHeroCommand.PlaceHero(this.m_data, level, this.m_x, this.m_y,
                                                                                                        this.m_data.GetHeroHitpoints(health, upgLevel), upgLevel));

                                            return(0);
                                        }
                                    }

                                    return(-5);
                                }

                                return(-4);
                            }

                            return(-2);
                        }

                        return(-3);
                    }

                    return(-23);
                }

                return(-5);
            }

            return(-1);
        }