Example #1
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(instance.gameObject);
     }
     instance = this;
 }
 private void Awake()
 {
     Instance     = this;
     spritePool   = GetComponent <SpritePool>();
     colliderPool = GetComponent <ColliderPool>();
     generator    = new FloorGenerator(this);
     generator.Generate(RoomCount);
 }
    public Room(int pX, int pY, SpritePool spritePool, ColliderPool colliderPool)
    {
        tiles = new Tile[Width * Height];

        Pos      = new Vec2i(pX, pY);
        WorldPos = new Vector2(pX * Width, pY * Height);

        this.spritePool = spritePool;
        collision       = new RoomCollision(this, colliderPool);
    }
Example #4
0
 //Static methods to create a GameMaterial from a specific data.
 static GameMaterial ReadData(MaterialData data)
 {
     return(new GameMaterial()
     {
         id = data.Id,
         name = data.Name,
         sprite = SpritePool.LoadSprite(data.SpriteId),
         color = new Color(data.R, data.G, data.B, data.A)
     });
 }
Example #5
0
    private void Awake()
    {
        Instance = this;

        spritePool   = GetComponent <SpritePool>();
        colliderPool = GetComponent <ColliderPool>();

        generators[0] = new LinearGenerator(this, enemyPrefabs);

        Pathfinder = new FloorPathfinder(this);
    }
Example #6
0
        public StarwarGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            laserPool = new SpritePool<LaserSprite>(graphics);
            enemyPool = new SpritePool<EnemySprite>(graphics);
            explosionPool = new SpritePool<AnimatedSprite>(graphics);
            starPool = new SpritePool<ParallaxStarSprite>(graphics);
            settings = Settings.ReadSettings();

            laserUpdateThreshold = TimeSpan.FromMilliseconds(1000.0F/settings.NumOfLasersPerSecond);
        }
Example #7
0
    void LayoutSprites(SpritePool sprites, Amount amount)
    {
        for (var i = 0; i < Random.Range(amount.Min, amount.Max + 1); ++i)
        {
            int     j         = Random.Range(0, gridPositions.Count);
            Vector3 randomPos = gridPositions[j];
            gridPositions.RemoveAt(j);

            GameObject sprite = sprites.GetRandomSprite();
            Instantiate(sprite, randomPos, Quaternion.identity);
        }
    }
Example #8
0
        public StarwarGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            laserPool             = new SpritePool <LaserSprite>(graphics);
            enemyPool             = new SpritePool <EnemySprite>(graphics);
            explosionPool         = new SpritePool <AnimatedSprite>(graphics);
            starPool = new SpritePool <ParallaxStarSprite>(graphics);
            settings = Settings.ReadSettings();

            laserUpdateThreshold = TimeSpan.FromMilliseconds(1000.0F / settings.NumOfLasersPerSecond);
        }
Example #9
0
        private void Awake()
        {
            loadedChunks = new Dictionary <Chunk, DynamicChunk>(9);

            tiles   = Resources.LoadAll <Tile>(Constants.UserData.TilesetPath);
            sprites = Resources.LoadAll <Sprite>(Constants.UserData.ItemsetPath);

            spritePool = new SpritePool(spritePrefab, 2000);

            AnimationRunner.ItemSprites = sprites;
            animationRunners            = new Dictionary <VariantObjectBase, AnimationRunner>();
        }
Example #10
0
 //Static Methods to create a Worker from a specific data.
 static Worker ReadData(WorkerData data)
 {
     return(new Worker()
     {
         id = data.Id,
         name = data.Name,
         sprite = SpritePool.LoadSprite(data.SpriteId),
         color = new Color(data.R, data.G, data.B, data.A),
         tired = data.Tired,
         talent = data.Talent,
         motivation = data.Motivation
     });
 }
Example #11
0
    public Room(int pX, int pY, SpritePool spritePool, ColliderPool colliderPool, Floor floor)
    {
        this.floor = floor;
        tiles      = new Tile[Width * Height];

        Pos      = new Vec2i(pX, pY);
        tileRect = new RectInt(pX * Width, pY * Height, Width, Height);
        WorldPos = new Vector2(tileRect.xMin, tileRect.yMin);

        this.spritePool = spritePool;

        collision = new RoomCollision(this, colliderPool);
    }
Example #12
0
 //Static Methods to create a Worker from a specific data.
 public static Piece ReadData(PieceData data)
 {
     return(new Piece()
     {
         id = data.Id,
         name = data.Name,
         onlyColor = data.IsOnlyColor,
         sprite = SpritePool.LoadSprite(data.SpriteId),
         color = new Color(data.R, data.G, data.G, data.A),
         materialsNeeded = StringToRequirements(data.Requirements),
         secondsNeeded = data.SecondsNeeded,
         quantityToCreate = data.QuantityToCreate
     });
 }
    void Awake()
    {
        spritePools = new Dictionary<Sprite, SpritePool> ();

        for (int i = 0; i < prefabs.Length; i++) {

            var newPool = new SpritePool (prefabs[i], number);

            newPool.SetOnActivate (OnActivate);
            newPool.SetOnDeactivate (OnDeactivate);

            spritePools.Add (prefabs [i], newPool);
        }
    }
Example #14
0
    public void Randomize()
    {
        materials = new GameMaterial[MaterialSize];

        for (int i = 0; i < MaterialSize; i++)
        {
            materials[i] = new GameMaterial();

            materials[i].id   = "ID00" + i;
            materials[i].name = "LOREM IPSUM " + Random.Range(0, 1000);
            //materials[i].Costo = Random.Range(0, 1000);
            materials[i].color  = Random.ColorHSV();
            materials[i].sprite = SpritePool.RandomSprite();
        }

        //ToUI();
    }
Example #15
0
    //Static Method to create an ExampleXML
    public static WorkerDataList ExampleData()
    {
        WorkerDataList dl = new WorkerDataList();

        WorkerData d1 = new WorkerData()
        {
            Id         = "d1",
            Name       = "Worker1",
            Price      = 8000,
            Quantity   = 1,
            SpriteId   = SpritePool.GetId(SpritePool.RandomSprite()),
            Tired      = 0,
            Talent     = 50,
            Motivation = 0.4f,
            R          = 1,
            G          = 1,
            B          = 1,
            A          = 1
        };

        WorkerData d2 = new WorkerData()
        {
            Id         = "d2",
            Name       = "DevilWorker",
            Price      = 666,
            Quantity   = 6,
            SpriteId   = SpritePool.GetId(SpritePool.RandomSprite()),
            Tired      = 0.2f,
            Talent     = 20,
            Motivation = 0.1f,
            R          = 1,
            G          = 0,
            B          = 0,
            A          = 1
        };

        dl.workers    = new WorkerData[2];
        dl.workers[0] = d1;
        dl.workers[1] = d2;

        return(dl);
    }
Example #16
0
    //Static method to get an XML Example of the data
    public static PieceDataList ExampleData()
    {
        PieceDataList pdl = new PieceDataList();

        pdl.pieces    = new PieceData[2];
        pdl.pieces[0] = new PieceData()
        {
            Id               = "P01",
            Name             = "Piece 01",
            IsOnlyColor      = true,
            Quantity         = 0,
            SecondsNeeded    = 40,
            Requirements     = "d5 10, d3 1,",
            QuantityToCreate = 1,
            SpriteId         = SpritePool.GetId(SpritePool.RandomSprite()),
            R = 1,
            G = 1,
            B = 1,
            A = 1
        };

        pdl.pieces[1] = new PieceData()
        {
            Id               = "P02",
            Name             = "Piece 02",
            IsOnlyColor      = false,
            Quantity         = 0,
            SecondsNeeded    = 20,
            Requirements     = "d4 1, d3 1,",
            QuantityToCreate = 5,
            SpriteId         = SpritePool.GetId(SpritePool.RandomSprite()),
            R = 1,
            G = 1,
            B = 1,
            A = 1
        };

        return(pdl);
    }
Example #17
0
    //Static Method to create an ExampleXML
    public static MaterialDataList ExampleData()
    {
        MaterialDataList dl = new MaterialDataList();

        MaterialData d1 = new MaterialData()
        {
            Id       = "d1",
            Name     = "Name1",
            Price    = 900,
            Quantity = 4,
            SpriteId = SpritePool.GetId(SpritePool.RandomSprite()),
            R        = 1,
            G        = 0,
            B        = 0,
            A        = 1
        };

        MaterialData d2 = new MaterialData()
        {
            Id       = "d2",
            Name     = "Name2",
            Price    = 666,
            Quantity = 6,
            SpriteId = SpritePool.GetId(SpritePool.RandomSprite()),
            R        = 0,
            G        = 0,
            B        = 1,
            A        = 1
        };

        dl.materials    = new MaterialData[2];
        dl.materials[0] = d1;
        dl.materials[1] = d2;

        return(dl);
    }
Example #18
0
 void Start()
 {
     gameLogic  = this.GetComponentInParent <GameLogic>();
     SpritePool = GameObject.FindGameObjectWithTag("SpritePool").GetComponent <SpritePool>();
     Table      = GameObject.FindGameObjectWithTag("Table");
 }
 public DynamicChunk(SpritePool pool)
 {
     spritePool      = pool;
     loadedItems     = new List <SpriteRenderer>();
     itemHeightLevel = new Dictionary <Vector3i, float>();
 }
Example #20
0
 void Awake()
 {
     instance = this;
 }