private void AddOffset(PositionProvider pp, Dictionary <Placeholder, Vector2> tempPositions)
    {
        Vector2 temp;

        _positions = new Dictionary <Placeholder, Vector2>();
        foreach (KeyValuePair <Placeholder, Vector2> kvp in tempPositions)
        {
            temp = kvp.Value;
            switch (kvp.Key)
            {
            case Placeholder.EAST:
                temp.x += pp.GetSideLength(PositionProvider.Side.X) / 4 - pp.SquareSize;
                _positions.Add(kvp.Key, temp);
                break;

            case Placeholder.NORTH:
                temp.y += pp.GetSideLength(PositionProvider.Side.Y) / 4 - pp.SquareSize;
                _positions.Add(kvp.Key, temp);
                break;

            case Placeholder.WEST:
                temp.x -= pp.GetSideLength(PositionProvider.Side.X) / 4;
                _positions.Add(kvp.Key, temp);
                break;

            case Placeholder.SOUTH:
                temp.y -= pp.GetSideLength(PositionProvider.Side.Y) / 4;
                _positions.Add(kvp.Key, temp);
                break;
            }
        }
    }
            public void seek(PositionProvider index)
            {
                if (present != null)
                {
                    if (isFileCompressed)
                    {
                        index.getNext();
                    }
                    present.seek(index);
                }

                // data stream could be empty stream or already reached end of stream before present stream.
                // This can happen if all values in stream are nulls or last row group values are all null.
                if (_secondsStream.available() > 0)
                {
                    if (isFileCompressed)
                    {
                        index.getNext();
                    }
                    data.seek(index);
                }

                if (_nanosStream.available() > 0)
                {
                    if (isFileCompressed)
                    {
                        index.getNext();
                    }
                    nanos.seek(index);
                }
            }
Example #3
0
        private void UpdateFoodAmount()
        {
            if (FoodCount <= foodCount)
            {
                return;
            }

            var positionProvider = new PositionProvider(obstacles, mapSize);

            while (FoodCount > foodCount)
            {
                var position = positionProvider.CreatePosition();

                if (CellType.Free != (map[position.X, position.Y] & CellType.AttributeMask))
                {
                    continue;
                }

                map[position.X, position.Y] |= CellType.Food;
                ++foodCount;
            }

            while (PoisonCount > poisonCount)
            {
                var position = positionProvider.CreatePosition();

                if (CellType.Free != (map[position.X, position.Y] & CellType.AttributeMask))
                {
                    continue;
                }

                map[position.X, position.Y] |= CellType.Poison;
                ++poisonCount;
            }
        }
Example #4
0
    private void PositionCamera(PositionProvider pp)
    {
        _cam.transform.position = new Vector3(pp.Middle.x, pp.Middle.y - 0.5f, _cam.transform.position.z);

        float scaleOrthoSize = (pp.MapSize.x + pp.MapSize.y) / 2 * 0.9f;

        _cam.orthographicSize = 11 < scaleOrthoSize ? scaleOrthoSize : 11;
    }
Example #5
0
    public override void Init(PositionProvider pp)
    {
        _pp = pp;

        ReceivePrefab("Board");

        _virusPrefab    = GetPrefab("Virus");
        _squareInstance = new List <GameObject>();
        _virusInstances = new Dictionary <Vector2Int, GameObject>();
    }
Example #6
0
    public override void Init(PositionProvider pp)
    {
        _pp = pp;

        ReceivePrefab("ActionQueue");

        _queueOriginPos = new Vector2(pp.Middle.x - pp.MapSize.x * 1.2f, pp.Middle.y + pp.MapSize.y * 0.6f);
        _index          = 0;
        _actionsSize    = DEFAULT_ACTION_SIZE;
    }
    public EnvironmentPositionHelper(PositionProvider pp)
    {
        Dictionary <Placeholder, Vector2> tempPositions = new Dictionary <Placeholder, Vector2> {
            { Placeholder.EAST, pp.GetSidePointRelativeToMiddle(PositionProvider.Side.X) },
            { Placeholder.NORTH, pp.GetSidePointRelativeToMiddle(PositionProvider.Side.Y) },
            { Placeholder.WEST, pp.GetSidePointRelativeToMiddle(PositionProvider.Side.X, true) },
            { Placeholder.SOUTH, pp.GetSidePointRelativeToMiddle(PositionProvider.Side.Y, true) }
        };

        AddOffset(pp, tempPositions);
    }
Example #8
0
        public void FixedUpdate()
        {
            var     prevPosition = transform.position;
            Vector2 offset       = Motion.GetOffset();

            transform.position += (Vector3)offset;

            //update angle
            if (FaceDirection)
            {
                gameObject.transform.eulerAngles = Vector3.forward * (PositionProvider.AngleBetween(prevPosition, transform.position));
            }
        }
Example #9
0
        protected override void OnGenerate(GenerateEventArgs e)
        {
            var offset = CopiedMotion.GetOffset();

            //update position
            Vector2 prevPosition = Target.transform.position;

            Target.transform.position += (Vector3)offset;

            //update angle
            if (FaceDirection)
            {
                Target.gameObject.transform.eulerAngles = Vector3.forward * (PositionProvider.AngleBetween(prevPosition, Target.transform.position));
            }
        }
Example #10
0
    public void Start(Map mapInfos)
    {
        PositionProvider pp;

        Loaded    = true;
        _mapInfos = mapInfos;
        _turn     = 0;
        Finished  = false;
        _lives    = mapInfos.Lives;
        _board.PassThroughVirus = mapInfos.passThroughtVirus;

        pp = new PositionProvider(new Vector2(0, 0), new Vector2Int(mapInfos.Rows, mapInfos.Cols), 1); // tmp

        _board.Init(pp);
        _environment.Init(pp);
        _actionQueue.Init(pp);

        _actionQueue.SetMaxAction(_lives);

        /*LINK GRAPHIC AND MAP*/

        _board.SetMap(mapInfos.Data);

        /*SPELL*/

        _spellManager = new SpellManager();
        _spellManager.Add(InputAction.Spell.ACCELERATION, new Spell(InputAction.Spell.ACCELERATION, Spell.ReloadType.COOLDOWN, mapInfos.AccelerationCD, false));
        _spellManager.Add(InputAction.Spell.DELETE_VIRUS, new Spell(InputAction.Spell.DELETE_VIRUS, Spell.ReloadType.USAGE, mapInfos.SprayUses, true));
        _spellManager.AttachDisplay(InputAction.Spell.ACCELERATION, "AccelerationSpell");
        _spellManager.AttachDisplay(InputAction.Spell.DELETE_VIRUS, "AntivirusSpraySpell");

        /*DRAW*/

        _board.Draw();
        _environment.Draw();
        _actionQueue.Draw();

        /*CAMERA*/

        PositionCamera(pp);

        /*DISPLAY*/

        _displayManager = new DisplayManager();
        _displayManager.AddText("LivesText", "Lives");
        _displayManager.Texts["Lives"].Update(_lives.ToString());
    }
Example #11
0
            public override void seek(PositionProvider index)
            {
                seek((long)index.getNext());
                long uncompressedBytes = (long)index.getNext();

                if (uncompressedBytes != 0)
                {
                    readHeader();
                    uncompressed.position(uncompressed.position() +
                                          (int)uncompressedBytes);
                }
                else if (uncompressed != null)
                {
                    // mark the uncompressed buffer as done
                    uncompressed.position(uncompressed.limit());
                }
            }
    public override void Init(PositionProvider pp)
    {
        _pp = pp;

        ReceivePrefab("Environment");

        _positionHelper = new EnvironmentPositionHelper(pp);
        _rotationHelper = new EnvironmentRotationHelper();

        _viruses = new List <EnvironmentVirus>()
        {
            new EnvironmentVirus(EnvironmentVirus.Type.INSTALLER, GetPrefab("Installer")),
            new EnvironmentVirus(EnvironmentVirus.Type.CORONA, GetPrefab("Corona")),
            new EnvironmentVirus(EnvironmentVirus.Type.FLU, GetPrefab("Flu")),
            new EnvironmentVirus(EnvironmentVirus.Type.PLAGUE, GetPrefab("Plague"))
        };
        _virusesInstances = new List <GameObject>();
    }
        public void seek(PositionProvider index)
        {
            input.seek(index);
            int consumed = (int)index.getNext();

            if (consumed > 8)
            {
                throw new ArgumentException("Seek past end of byte at " +
                                            consumed + " in " + input);
            }
            else if (consumed != 0)
            {
                readByte();
                bitsLeft = 8 - consumed;
            }
            else
            {
                bitsLeft = 0;
            }
        }
Example #14
0
        public void seek(PositionProvider index)
        {
            input.seek(index);
            int consumed = (int)index.getNext();

            if (consumed != 0)
            {
                // a loop is required for cases where we break the run into two parts
                while (consumed > 0)
                {
                    readValues(false);
                    used      = consumed;
                    consumed -= numLiterals;
                }
            }
            else
            {
                used        = 0;
                numLiterals = 0;
            }
        }
Example #15
0
 private static PointF GetTextPosition(TextOrientation textOrientation, Anchor anchor, SizeF imgSize, SizeF textSize, SizeF marginSize)
 {
     PositionProvider positionProvider = PositionProviderMap[(textOrientation, anchor)];
Example #16
0
 public abstract void seek(PositionProvider index);
Example #17
0
 public override void seek(PositionProvider index)
 {
     seek((long)index.getNext());
 }
 public void Setup()
 {
     _provider = new PositionProvider();
 }
Example #19
0
 public static List <CustomerEntity> GetCustomersByUserPermission(
     PositionProvider <CustomerEntity> source, Guid userId)
 {
     // query source and return results
 }
Example #20
0
 public override void seek(PositionProvider index)
 {
     seek((long)index.getNext());
     long uncompressedBytes = (long)index.getNext();
     if (uncompressedBytes != 0)
     {
         readHeader();
         uncompressed.position(uncompressed.position() +
                               (int)uncompressedBytes);
     }
     else if (uncompressed != null)
     {
         // mark the uncompressed buffer as done
         uncompressed.position(uncompressed.limit());
     }
 }
Example #21
0
 public override void seek(PositionProvider index)
 {
     seek((long)index.getNext());
 }
	private void Awake()
	{
		m_cameraRig = GetComponentInChildren<OVRCameraRig>();
		m_positionProvider = GetComponent<PositionProvider>();
	}
 public abstract void Init(PositionProvider pp);
            public void seek(PositionProvider index)
            {
                if (present != null)
                {
                    if (_isFileCompressed)
                    {
                        index.getNext();
                    }
                    reader.getPresent().seek(index);
                }

                if (_isDictionaryEncoding)
                {
                    // DICTIONARY encoding

                    // data stream could be empty stream or already reached end of stream before present stream.
                    // This can happen if all values in stream are nulls or last row group values are all null.
                    if (_dataStream.available() > 0)
                    {
                        if (_isFileCompressed)
                        {
                            index.getNext();
                        }
                        ((StringDictionaryTreeReader)reader).getReader().seek(index);
                    }
                }
                else
                {
                    // DIRECT encoding

                    // data stream could be empty stream or already reached end of stream before present stream.
                    // This can happen if all values in stream are nulls or last row group values are all null.
                    if (_dataStream.available() > 0)
                    {
                        if (_isFileCompressed)
                        {
                            index.getNext();
                        }
                        ((StringDirectTreeReader)reader).getStream().seek(index);
                    }

                    if (_lengthStream.available() > 0)
                    {
                        if (_isFileCompressed)
                        {
                            index.getNext();
                        }
                        ((StringDirectTreeReader)reader).getLengths().seek(index);
                    }
                }
            }
 public void seek(PositionProvider index)
 {
     input.seek(index);
     int consumed = (int)index.getNext();
     if (consumed != 0)
     {
         // a loop is required for cases where we break the run into two
         // parts
         while (consumed > 0)
         {
             numLiterals = 0;
             readValues(false);
             used = consumed;
             consumed -= numLiterals;
         }
     }
     else
     {
         used = 0;
         numLiterals = 0;
     }
 }
Example #26
0
 public abstract void seek(PositionProvider index);
 public void seek(PositionProvider index)
 {
     input.seek(index);
     int consumed = (int)index.getNext();
     if (consumed > 8)
     {
         throw new ArgumentException("Seek past end of byte at " +
             consumed + " in " + input);
     }
     else if (consumed != 0)
     {
         readByte();
         bitsLeft = 8 - consumed;
     }
     else
     {
         bitsLeft = 0;
     }
 }
Example #28
0
 // Start is called before the first frame update
 void Start()
 {
     PositionProvider.UpdateBoundaries();
     PositionProvider.SetUpPossiblePositions(Orientation.VERTICAL);
 }
Example #29
0
        private void StartEpoch(IEnumerable <IGenome> genomes)
        {
            /*const int mutations = 1;
             *
             * var positionProvider = new PositionProvider(obstacles, mapSize);
             * var factory = new BeetleBotFactory(positionProvider, genomeProducer);
             *
             * var list = new List<IGenome>(genomes);
             * DoEpochStarted(new EpochStartedEventArgs(Epoch,new ReadOnlyCollection<IGenome>(list)));
             *
             * foreach (var genome in genomes)
             * {
             *  Debug.WriteLine($"Genome: mutations: {genome.Mutations.Count}");
             *
             *  var alpha = factory.CreateBeetleBot(genome);
             *
             *  bots = bots.Add(alpha);
             *  Scene.Children.Add(alpha);
             *
             *  for (var count = 0; count < (NestedBotsCount - mutations); count++)
             *  {
             *      var child = factory.CreateBeetleBot(alpha.Genome);
             *
             *      bots = bots.Add(child);
             *      Scene.Children.Add(child);
             *  }
             *
             *  for(var count = 0; count < mutations; count++)
             *  {
             *      var mutatedGenome = genomeProducer.MutateGenome(alpha.Genome);
             *      var child = factory.CreateBeetleBot(mutatedGenome);
             *
             *      bots = bots.Add(child);
             *      Scene.Children.Add(child);
             *  }
             * }
             *
             * UpdateFoodAmount();*/

            const int mutations = 1;

            var positionProvider = new PositionProvider(obstacles, mapSize);
            var factory          = new BeetleBotFactory(positionProvider, genomeProducer);

            var list = new List <IGenome>(genomes);

            DoEpochStarted(new EpochStartedEventArgs(Epoch, new ReadOnlyCollection <IGenome>(list)));

            foreach (var genome in genomes)
            {
                Debug.WriteLine($"Genome: mutations: {genome.Mutations.Count}");

                var alpha = factory.CreateBeetleBot(genome);

                bots = bots.Add(alpha);
                Scene.Children.Add(alpha);

                break;
            }

            UpdateFoodAmount();
        }