Exemplo n.º 1
0
        public void CreateFoodRandomTile()
        {
            var nextTile = default(ent);

            do
            {
                nextTile = GetTile(Random.Range(1, 25), Random.Range(1, 14));
            }while (nextTile.componentTile().tag != Tags.Empty);
            nextTile.componentTile().tag = Tags.Food;
        }
Exemplo n.º 2
0
    public static void CreateObjects(Layer Layer)
    {
        var prefab = Box.Load <GameObject>("MonoPoint");

        for (int i = 0, length = SIZE; i < length; i++)
        {
            var     entity = Layer.Entity.Create(prefab);
            ref var eBench = ref entity.Set <ComponentBench>();
            eBench.transform          = entity.transform;
            eBench.position           = new Vector3(Random.Range(-100f, 100f), Random.Range(-100f, 100f), Random.Range(-100f, 100f));
            entity.transform.position = eBench.position;
        }
Exemplo n.º 3
0
        protected override void OnAwake()
        {
            var prefab = Box.Load <GameObject>("MonoPoint");

            for (int i = 0, length = CountInput.CountEntities; i < length; i++)
            {
                var     entity = Entity.Create(prefab);
                ref var eBench = ref entity.Set <ComponentBench>();
                eBench.transform = entity.transform;
                eBench.position  = new Vector3(Random.Range(-100f, 100f), Random.Range(-100f, 100f), Random.Range(-100f, 100f));
                entity.transform.localPosition = eBench.position;
            }
Exemplo n.º 4
0
        private void RenderDamages(AttackData attackData)
        {
            var target = attackData.Target;

            // TODO: add normal positioning
            foreach (var damageType in (DamageType[])Enum.GetValues(typeof(DamageType)))
            {
                var damage = attackData.GetDamage(damageType);

                if (damage == 0)
                {
                    continue;
                }

                ref var text = ref target.layer.GetBuffer <SegmentDamageText>().Add();

                var randomRange = Random.Range(-0.5f, 0.5f);
                text.source = target.layer.Obj.Create(Pool.Entities, "Prefabs/UI/DamageText",
                                                      new Vector3(randomRange, 0, 0) + target.transform.position + Vector3.up * 2);
                text.source.GetComponentInChildren <TextMeshPro>().text  = damage.ToString();
                text.source.GetComponentInChildren <TextMeshPro>().color = DamageTypeColor[(int)damageType];
                text.startTime = Time.time;
            }
Exemplo n.º 5
0
            public static void Board(int columns = 10, int rows = 10)
            {
                List <Vector2> allPos = new List <Vector2>(columns * rows);

                var boardHolder = LayerGame.Obj.Create("Prefabs/Obj Board");

                for (int x = 0; x <= columns; x++)
                {
                    for (int y = 0; y <= rows; y++)
                    {
                        if (x == 0 || x == columns || y == 0 || y == rows)
                        {
                            LayerGame.Obj.Create(Prefab.OuterWalls.Random(), boardHolder, new Vector3(x, y, 0f));
                        }
                        else
                        {
                            LayerGame.Obj.Create(Prefab.Floors.Random(), boardHolder, new Vector3(x, y, 0f));

                            if (!(x == 1 || x == columns - 1 || y == 1 || y == rows - 1))
                            {
                                allPos.Add(new Vector2(x, y));
                            }
                        }
                    }
                }

                Create.Player();

                LayerGame.Actor.Create(Prefab.Exit, Models.Exit, new Vector3(rows - 1, columns - 1));

                CreateEntityAtRandom(Prefab.Wall, Models.Wall, ref Database.Walls, 5, 10);

                int enemyCount = (int)Mathf.Log(DataLocal.level, 2f);

                CreateActorAtRandom(Prefab.Enemies, enemyCount, enemyCount);

                CreateEntityAtRandom(Prefab.Food, Models.Food, ref Database.Foods, 2, 5);

                Camera.main.transform.position = new Vector3(rows / 2, columns / 2, -100);

                void CreateEntityAtRandom(GameObject go, ModelComposer model, ref Sprite[] tileArray, int minimum, int maximum)
                {
                    int objectCount = Random.Range(minimum, maximum + 1);

                    for (int i = 0; i < objectCount; i++)
                    {
                        var randomPosition = allPos.Random();
                        allPos.Remove(randomPosition);

                        var entity  = LayerGame.Entity.Create(go, model, randomPosition, true);
                        var cObject = entity.ComponentObject();
                        cObject.renderer.sprite = tileArray.Random();
                    }
                }

                void CreateActorAtRandom(GameObject[] go, int minimum, int maximum)
                {
                    int objectCount = Random.Range(minimum, maximum + 1);

                    for (int i = 0; i < objectCount; i++)
                    {
                        var randomPosition = allPos.Random();
                        allPos.Remove(randomPosition);

                        LayerGame.Actor.Create(go.Random(), randomPosition, true);
                    }
                }
            }