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); }
//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) }); }
private void Awake() { Instance = this; spritePool = GetComponent <SpritePool>(); colliderPool = GetComponent <ColliderPool>(); generators[0] = new LinearGenerator(this, enemyPrefabs); Pathfinder = new FloorPathfinder(this); }
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); }
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); } }
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); }
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>(); }
//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 }); }
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); }
//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); } }
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(); }
//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); }
//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); }
//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); }
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>(); }
void Awake() { instance = this; }