Esempio n. 1
0
    protected override void ApplyOn(HexCubMap map, Tile tile)
    {
        Dictionary <HexPos, List <HexPos> > positions = PlacementRule.GetMeristemProximateList(map, Occupation.Any, 1, maxDistance);

        foreach (KeyValuePair <HexPos, List <HexPos> > data in positions)
        {
            Emit(data.Value.Where(e => e.isFree).ToList(), data.Key);
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Expands the pool.
 /// </summary>
 /// <param name="prefab">Prefab.</param>
 /// <param name="amount">Amount.</param>
 public void ExpandPool(PlacementRule pool, int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         GameObject p = Instantiate(pool.prefab);
         p.name = pool.prefab.name;                 //Preserve name (for pooling findign purposes)
         p.transform.SetParent(poolStore.transform);
         p.transform.localScale = Vector3.one;
         p.SetActive(false);
         pool.pool.Enqueue(p);
     }
 }
Esempio n. 3
0
 public ARPlacementStateData(GameObject modelFloor, GameObject firstSelectedPlane, GameObject secondSelectedPlane, Vector3 modelPlacementLocation,
                             GameObject arFloor, GameObject firstARSelectedPlane, GameObject secondARSelectedPlane, Vector3 arPlacementLocation, Vector3 arPlacementAlignment, PlacementRule placementRule, bool validTarget, float beamHeight)
 {
     this.modelFloor             = modelFloor;
     this.firstSelectedPlane     = firstSelectedPlane;
     this.secondSelectedPlane    = secondSelectedPlane;
     this.modelPlacementLocation = modelPlacementLocation;
     this.arFloor = arFloor;
     this.firstARSelectedPlane  = firstARSelectedPlane;
     this.secondARSelectedPlane = secondARSelectedPlane;
     this.arPlacementLocation   = arPlacementLocation;
     this.arPlacementAlignment  = arPlacementAlignment;
     this.placementRule         = placementRule;
     this.validTarget           = validTarget;
     this.beamHeight            = beamHeight;
 }
Esempio n. 4
0
        public async Task <IActionResult> CreatePlacementRule(
            [Bind("PlacementRuleId,Place,Points")] PlacementRule placementrule)
        {
            Tour tour = _context.Tours.Where(t => t.TourId.Equals(
                                                 HttpContext.Session.GetInt32("ChosenTourId"))).Include(t => t.PlacementRules).FirstOrDefault();

            if (EnsureUnique(placementrule.Place, tour.TourId))
            {
                // Need to put something in here that essentially says we can't
                // cuz it's not unique.
                return(NotFound());
            }

            tour.PlacementRules.Add(placementrule);
            _context.SaveChanges();

            return(RedirectToAction("PlacementRules", new { id = tour.TourId }));
        }
        /// <summary>
        /// Coroutine loop handling creation and destruction of objects
        /// </summary>
        /// <returns></returns>
        private IEnumerator SpawnLoop()
        {
            while (true)
            {
                yield return(null);

                //Spawn up to amountToSpawnAtOnce objects
                if (spawnRequests.Count > 0 && objectsToPool.Length > 0)
                {
                    for (int i = 0; i < amountToSpawnAtOnce; i++)
                    {
                        SpawnRequest req = spawnRequests.Peek();
                        //Completed request, move onto next
                        if (req.ruleidx >= objectsToPool.Length)
                        {
                            spawnRequests.Pop();
                            continue;
                        }
                        PlacementRule rule = objectsToPool[req.ruleidx];

                        if (!req.ruleStarted)
                        {
                            //Get rng seed
                            int seed = rule.rule.GetRandomSeed(req.ruleidx, req.node);
                            //Create generator
                            req.NewRandom(seed);
                            //Get number to spawn
                            req.Start(rule.rule.Init(req.randomGenerator));
                        }

                        List <GameObject> objects;
                        if (!spawnedGoPerRequest.TryGetValue(req, out objects))
                        {
                            objects = new List <GameObject>();
                            spawnedGoPerRequest[req] = objects;
                        }

                        //Spawn a single object
                        rule.rule.SpawnObjectOnChunk(
                            req.randomGenerator,
                            this.transform,
                            req.ruleidx,
                            rule.pool,
                            objects,
                            req.node,
                            req.mesh
                            );
                        //Increment the amount spawned, and if this rule is complete move to the next (eventually moving to the next rule layer)
                        req.amountSpawned++;
                        req.Complete();
                    }
                }

                //Destroy up to amountToDestroyAtOnce objects
                if (destroyRequests.Count > 0)
                {
                    int destroy = amountToDestroyAtOnce;
                    while (destroy > 0 && destroyRequests.Count > 0)
                    {
                        //Destroy request if empty
                        SpawnRequest first = destroyRequests.Peek();
                        if (first == null)
                        {
                            destroyRequests.Pop();
                            break;
                        }

                        List <GameObject> toDestroy;
                        if (spawnedGoPerRequest.TryGetValue(first, out toDestroy))
                        {
                            //Gameobject list associated with request has been cleared
                            if (toDestroy.Count < 1)
                            {
                                destroyRequests.Pop();
                                continue;
                            }

                            //Start destroying gameobjects
                            GameObject obj = toDestroy[0];

                            PlacementRule pool;
                            if (!pools.TryGetValue(obj.name, out pool))
                            {
                                //No pool
                                GameObject.Destroy(obj);
                            }
                            else
                            {
                                //Pool exists
                                pool.pool.Push(obj);
                            }
                            toDestroy.RemoveAt(0);
                            destroy--;
                            continue;
                        }
                        //No gameobject list associated with request
                        else
                        {
                            destroyRequests.Pop();
                            continue;
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        // GET: Tour/TourStandings/5
        public async Task <IActionResult> TourStandings(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            HttpContext.Session.SetInt32("ChosenTourId", (int)id);

            // New Code, build a TourViewModel with necessary components
            TourViewModel tvm = new TourViewModel();

            var t = (from tour in _context.Tours
                     where tour.TourId == id
                     select tour).FirstOrDefault();

            tvm.Tour = t;


            var players = (from player in _context.Users
                           where player.UserTours.Any(ut => ut.UserId.Equals(player.Id) && ut.TourId == id)
                           select player).ToList();
            var placementrulesquery = (from placementrule in _context.PlacementRules
                                       where placementrule.TourId == tvm.Tour.TourId
                                       select placementrule).ToList();
            var standings    = new Dictionary <ApplicationUser, StandingsViewModel>();
            var placementmap = new Dictionary <int, PlacementRule>();

            foreach (var player in players)
            {
                standings.Add(player, new StandingsViewModel {
                    Score = 0, Player = player
                });
            }
            foreach (var placementrule in placementrulesquery)
            {
                placementmap.Add(placementrule.Place, placementrule);
            }

            var tourevents = (from tourevent in _context.TourEvents
                              where tourevent.TourId == tvm.Tour.TourId
                              select tourevent).ToList();
            var tourresults = new List <TourResult>();

            foreach (var tourevent in tourevents)
            {
                var toureventresults = (from toureventresult in _context.TourResult
                                        where toureventresult.TourEventId == tourevent.TourEventId
                                        select toureventresult).Include(ter => ter.User).ToList();
                tourresults.AddRange(toureventresults);
            }

            foreach (var tourresult in tourresults)
            {
                StandingsViewModel standing      = standings[tourresult.User];
                PlacementRule      placementrule = placementmap[tourresult.Place];
                standing.Score += placementrule.Points;
            }

            tvm.Standings = standings.Values.OrderByDescending(s => s.Score).ToList();

            return(View(tvm));
        }
Esempio n. 7
0
 protected void Awake()
 {
     _placementRule   = GetComponent <PlacementRule>();
     _validationRules = GetComponents <ValidationRule>();
 }
Esempio n. 8
0
        public override void ExecuteCmdlet()
        {
            IDictionary <string, string> tagPairs = null;

            if (Tag != null)
            {
                tagPairs = new Dictionary <string, string>();

                foreach (string key in Tag.Keys)
                {
                    tagPairs.Add(key, Tag[key].ToString());
                }
            }

            if (ParameterSetName == ParentObjectParameterSet)
            {
                ResourceGroupName = PoolObject.ResourceGroupName;
                Location          = PoolObject.Location;
                var NameParts = PoolObject.Name.Split('/');
                AccountName = NameParts[0];
                PoolName    = NameParts[1];
            }

            PSNetAppFilesVolumeDataProtection dataProtection = null;

            if (ReplicationObject != null || !string.IsNullOrWhiteSpace(SnapshotPolicyId) || Backup != null)
            {
                dataProtection = new PSNetAppFilesVolumeDataProtection
                {
                    Replication = ReplicationObject,
                    Snapshot    = new PSNetAppFilesVolumeSnapshot()
                    {
                        SnapshotPolicyId = SnapshotPolicyId
                    },
                    Backup = Backup
                };
            }

            var volumeBody = new Management.NetApp.Models.Volume()
            {
                ServiceLevel             = ServiceLevel,
                UsageThreshold           = UsageThreshold,
                CreationToken            = CreationToken,
                SubnetId                 = SubnetId,
                Location                 = Location,
                ExportPolicy             = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyFromPs(ExportPolicy) : null,
                DataProtection           = (dataProtection != null) ? ModelExtensions.ConvertDataProtectionFromPs(dataProtection) : null,
                VolumeType               = VolumeType,
                ProtocolTypes            = ProtocolType,
                Tags                     = tagPairs,
                SnapshotId               = SnapshotId,
                SnapshotDirectoryVisible = SnapshotDirectoryVisible,
                SecurityStyle            = SecurityStyle,
                BackupId                 = BackupId,
                ThroughputMibps          = ThroughputMibps,
                KerberosEnabled          = KerberosEnabled.IsPresent,
                SmbEncryption            = SmbEncryption,
                SmbContinuouslyAvailable = SmbContinuouslyAvailable,
                LdapEnabled              = LdapEnabled,
                CoolAccess               = CoolAccess,
                CoolnessPeriod           = CoolnessPeriod,
                UnixPermissions          = UnixPermissions,
                AvsDataStore             = AvsDataStore,
                IsDefaultQuotaEnabled    = IsDefaultQuotaEnabled,
                DefaultUserQuotaInKiBs   = DefaultUserQuotaInKiB,
                DefaultGroupQuotaInKiBs  = DefaultGroupQuotaInKiB,
                NetworkFeatures          = NetworkFeature,
                CapacityPoolResourceId   = CapacityPoolResourceId,
                ProximityPlacementGroup  = ProximityPlacementGroup,
                VolumeSpecName           = VolumeSpecName,
                PlacementRules           = PlacementRule?.ToPlacementKeyValuePairs()
            };

            if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName)))
            {
                var anfVolume = AzureNetAppFilesManagementClient.Volumes.CreateOrUpdate(volumeBody, ResourceGroupName, AccountName, PoolName, Name);
                WriteObject(anfVolume.ToPsNetAppFilesVolume());
            }
        }