コード例 #1
0
ファイル: BaseFactionTrap.cs プロジェクト: Ravenwolfe/xrunuo
        public virtual int IsValidLocation( Point3D p, Map m )
        {
            //Region r = Region.Find( p, m );

            // Check if another trap exists in this point
            if ( m.GetItemsAtWorldPoint( p ).OfType<BaseFactionTrap>().Any() )
            {
                return 1075263; // There is already a trap belonging to your faction at this location
            }

            switch ( AllowedPlacing )
            {
                case AllowedPlacing.FactionStronghold:
                    {
                        StrongholdRegion region = Region.Find( p, m ) as StrongholdRegion;

                        if ( region != null && region.Faction == m_Faction )
                        {
                            return 0;
                        }

                        return 1010355; // This trap can only be placed in your stronghold
                    }
                case AllowedPlacing.AnyFactionTown:
                    {
                        Town town = Town.FromRegion( Region.Find( p, m ) );

                        if ( town != null )
                        {
                            return 0;
                        }

                        return 1010356; // This trap can only be placed in a faction town
                    }
                case AllowedPlacing.ControlledFactionTown:
                    {
                        Town town = Town.FromRegion( Region.Find( p, m ) );

                        if ( town != null && town.Owner == m_Faction )
                        {
                            return 0;
                        }

                        return 1010357; // This trap can only be placed in a town your faction controls
                    }
            }

            return 0;
        }