コード例 #1
0
            public Entity[] CreateEntityGroup(PinouResourcesEntities.SpawnGroup group, Vector3 center)
            {
                Entity[] ents = new Entity[group.Entities.Length];
                if (group.Entities.Length > 1)
                {
                    if (Data.entityCreationMethod == EntityCreationMethod.AroundPlayer2D_XYPlane)
                    {
                        float randAngle = Random.Range(0f, 2 * Mathf.PI);
                        for (int i = 0; i < group.Entities.Length; i++)
                        {
                            Vector2 angleVector = new Vector2(Mathf.Cos(randAngle), Mathf.Sin(randAngle));
                            Vector2 posOffset   = angleVector * group.GroupRadius;

                            ents[i] = CreateEntity(group.Entities[i], center.ToV2() + posOffset, UnityEngine.Random.Range(0f, 360f));

                            randAngle += (2 * Mathf.PI) / group.Entities.Length;
                        }
                    }
                    else
                    {
                        throw new System.Exception("Not Implemented.");
                    }

                    return(ents);
                }
                else if (group.Entities.Length == 1)
                {
                    return(new Entity[] { CreateEntity(group.Entities[0], center, UnityEngine.Random.Range(0f, 360f)) });
                }

                return(new Entity[0]);
            }
コード例 #2
0
        private void CheckChunk(Entity player, Vector3 chunkPos)
        {
            float lastCheckDuration;

            if (_chunkChecked.ContainsKey(chunkPos) == false)
            {
                lastCheckDuration = 1 / 0.0f;
                _chunkChecked.Add(chunkPos, new ChunkData());
            }
            else
            {
                lastCheckDuration = (float)(DateTime.Now - _chunkChecked[chunkPos].CheckedTime).TotalSeconds;
                _chunkChecked[chunkPos].Check();
            }

            float credit = TotalCreditFactor(player) * _spawnCreditPerDurationFormula.Evaluate(lastCheckDuration) + _chunkChecked[chunkPos].GrabAllCredits();

            _chunkChecked[chunkPos].SetMaxCredits(TotalCreditFactor(player) * _spawnCreditPerDurationFormula.Evaluate(Mathf.Infinity));

            PinouResourcesEntities.SpawnGroup spawnGroup = PinouApp.Resources.Data.Entities.GetPool("LowLevel").GetRandomGroup();
            while (credit > spawnGroup.Cost)
            {
                credit -= spawnGroup.Cost;
                Entity[] entitiesCreated = PinouApp.Entity.CreateEntityGroup(spawnGroup, GetRandomPosInsideChunk(chunkPos));

                HandleRememberEntityChunks(entitiesCreated, _chunkChecked[chunkPos], spawnGroup.Cost / entitiesCreated.Length);

                spawnGroup = PinouApp.Resources.Data.Entities.GetPool("LowLevel").GetRandomGroup();
            }
        }
コード例 #3
0
 public Entity[] CreateEntityGroupAroundPlayer(PinouResourcesEntities.SpawnGroup group, Entity player)
 {
     return(CreateEntityGroup(group, GetAroundPlayerSpawnPosition(player)));
 }