예제 #1
0
        public override void RegisterBuyPoint(BuyPoint bp)
        {
            Vector3 swPoint, nePoint;

            WaterWarsUtils.FindSquareParcelCorners(bp.Location.Parcel, out swPoint, out nePoint);

            if (!Game.BuyPoints.ContainsKey(bp.Uuid))
            {
                m_log.InfoFormat(
                    "[WATER WARS]: Registering buy point {0} named {1} at {2} in parcel {3} ({4},{5})",
                    bp.Uuid, bp.Name, bp.Location.LocalPosition, bp.Location.Parcel.LandData.Name, swPoint, nePoint);
                Game.BuyPoints[bp.Uuid] = bp;
            }
            else
            {
                m_log.WarnFormat(
                    "[WATER WARS]: Attempt to register duplicate buy point {0} named {1} at {2} in parcel {3} ({4},{5})",
                    bp.Uuid, bp.Name, bp.Location.LocalPosition, bp.Location.Parcel.LandData.Name, swPoint, nePoint);
            }

            m_controller.EventManager.TriggerBuyPointRegistered(bp);
        }
예제 #2
0
        /// <summary>
        /// Change the specialization presentation of this buy point view
        /// </summary>
        /// <param name="assetType"></param>
        /// <param name="fields">Fields for which field views need to be created</param>
        public Dictionary <UUID, FieldView> ChangeSpecialization(AbstractGameAssetType assetType, List <Field> fields)
        {
            Dictionary <UUID, FieldView> fvs = new Dictionary <UUID, FieldView>();

            string morphItemName = m_veSceneObjectNames[assetType];

            ChangeSceneObject(m_itemStoreView, morphItemName);
            m_bp.Name = morphItemName;

            if (assetType != AbstractGameAssetType.None)
            {
                Vector3 p1, p2;
                WaterWarsUtils.FindSquareParcelCorners(m_bp.Location.Parcel, out p1, out p2);

//                m_log.InfoFormat("[WATER WARS]: Found corners of parcel at ({0}),({1})", p1, p2);

                int shortDimension = (int)Math.Floor(Math.Sqrt(fields.Count));
                int longDimension  = (int)Math.Ceiling((float)fields.Count / shortDimension);
//                m_log.InfoFormat("[WATER WARS]: Would space as [{0}][{1}]", shortDimension, longDimension);

                // XXX: For now, we're always going to short space the fields on the x axis
                // This shouldn't be a problem if all our regions are square but might start to look a bit odd if they
                // were different rectangular sizes

                // Adjust dimensions to leave a gap around the edges for the buypoint
                p1.X += 5;
                p1.Y += 5;
                p2.X -= 5;
                p2.Y -= 5;

                float xSpacing = (p2.X - p1.X) / (float)shortDimension;
                float ySpacing = (p2.Y - p1.Y) / (float)longDimension;

                List <Vector3> placementPoints = new List <Vector3>();

//                for (int y = y1; y < y2; y += ySpacing)
//                {
//                    for (float x = x1; x < x2; x += xSpacing)
//                    {
//                        placementPoints.Add(new Vector3(x, y, (float)heightHere + 0.1f));
//                    }
//                }

                for (int y = 0; y < longDimension; y++)
                {
                    for (float x = 0; x < shortDimension; x++)
                    {
                        Vector3 spacing = new Vector3(x * xSpacing, y * ySpacing, 2f);
                        placementPoints.Add(p1 + spacing);
                    }
                }

                m_fieldViewScale = new Vector3(xSpacing, ySpacing, 0.1f);
                Vector3 placementAdjustment = new Vector3(xSpacing / 2, ySpacing / 2, 0);

                int i = 0;
                foreach (Vector3 v in placementPoints)
                {
                    FieldView fv = CreateFieldView(fields[i++], v + placementAdjustment);
                    fvs.Add(fv.RootPart.UUID, fv);
                }
            }
            else
            {
                lock (m_fieldViews)
                {
                    foreach (FieldView fv in m_fieldViews.Values)
                    {
                        fv.Close();
                    }

                    m_fieldViews.Clear();
                }
            }

            return(fvs);
        }