/* * private BlockBase[,] LoadGrid(Texture2D source, int x, int y) { * BlockBase[,] blocks = new BlockBase[50,30]; * for (int dx = 0; dx < 50; dx++) * { * for (int dy = 0; dy < 30; dy++) * { * Color32 pixel = source.GetPixel(x*50+dx, y*30+dy); * blocks[dx,dy] = CreateBlockBase(pixel); * } * } * return blocks; * }*/ private bool CreateBlockBase(Color32 pixel, int x, int y, bool themeBool) { BlockEnum block = (BlockEnum)pixel.r; if ((int)block == 255) { block = BlockEnum.Air; } switch (block) { case (BlockEnum.Air): if (!themeBool) { _level.ChangeThemeint((pixel.g / 10)); if (!(SceneManager.GetActiveScene().name == "Editor")) { AudioScript.Instance.ChangeAudioClip((pixel.g / 10) + 2); } themeBool = true; } return(themeBool); case (BlockEnum.Powerup): block.NewBlock(Powerup[pixel.g]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); case (BlockEnum.Object): ObjectEnum objet = (ObjectEnum)pixel.g; switch (objet) { case (ObjectEnum.Tapis): block.NewBlock(Tapis[((pixel.b == 180) ? 0 : 1)]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); case (ObjectEnum.Jumper): block.NewBlock(Bumper[((pixel.b == 180) ? 0 : 1)]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); case (ObjectEnum.Monsters): block.NewBlock(Monsters[pixel.b]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); case (ObjectEnum.KeyBlock): block.NewBlock(KeyBlock[((pixel.b == 100) ? 1 : 0)]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); default: block.NewBlock(Object[(int)objet]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); } default: block.NewBlock(Block[(int)block]).SpawnTiles(x % 50, y % 30, _level.GridManagers[Mathf.FloorToInt(x / 50), Mathf.FloorToInt(y / 30)], ColorPicker.neutral); return(themeBool); } }
private void Update() { if ((_actor._currentTarget._blockEnum != BlockEnum.None && Vector3.Distance(_actor._currentTarget.transform.position, _actor.transform.position) < _targetRange) || Vector3.Distance(_actor._currentTarget.transform.position, _actor.transform.position) < _weapon._range) { if (!_crosshairManager._isActive) { _crosshairManager.ToggleState(true); } if (_targetStance != _actor._currentTarget._blockEnum) { _targetStance = _actor._currentTarget._blockEnum; StopAllCoroutines(); StartCoroutine(SwitchBlockDirection(_targetStance, Random.Range(0, _reactionTime))); if ((_targetStance != BlockEnum.Bottom && PercentChance(_attackChance)) || (_targetStance == BlockEnum.Bottom && PercentChance(_bashChance))) { _actor._attack.MeleeAttack(_weapon, _crosshairManager); } } _actor._blockEnum = _crosshairManager.GetBlockDirection(0, 0, this.transform); return; } if (_crosshairManager._isActive) { _crosshairManager.ToggleState(false); } _actor._blockEnum = BlockEnum.None; }
private Chunk fillChunkWithBlock(Chunk _Chunk, BlockEnum _BlockEnum) { for (int x = 0; x < _Chunk.Size.X; x++) { for (int y = 0; y < _Chunk.Size.Y; y++) { Block var_Block = new Block((int)_Chunk.Position.X + x * Block.BlockSize, (int)_Chunk.Position.Y + y * Block.BlockSize, _BlockEnum, _Chunk); if (!_Chunk.setBlockAtPosition(x, y, var_Block)) { Logger.Logger.LogErr("RegionFactory->fillChunkWithBlock(...) : Platzierung nicht möglich!"); } else { if (Configuration.Configuration.isHost || Configuration.Configuration.isSinglePlayer) { } else { var_Block.requestFromServer(); } } } } return(_Chunk); }
// Returns the edgestates associated with a certain block type public static EdgeStates GetEdgeStates(BlockEnum block) { EdgeStates result = new EdgeStates(false); // Creates a new set of edges that are all closed if ((int)block - 8 >= 0) { result.U = EdgeState.Open; block -= 8; } if ((int)block - 4 >= 0) { result.R = EdgeState.Open; block -= 4; } if ((int)block - 2 >= 0) { result.D = EdgeState.Open; block -= 2; } if ((int)block - 1 >= 0) { result.L = EdgeState.Open; block -= 1; } return(result); }
private void Update() { if (_lastblockEnum != _blockEnum) { _lastblockEnum = _blockEnum; _animator.Play("Block" + _blockEnum); } }
public TeleportBlock(Vector3 _Position, BlockEnum _BlockEnum, Chunk.Chunk _ParentChunk, Vector3 _Destination, int _DimensionId) : base((int)_Position.X, (int)_Position.Y, _BlockEnum, _ParentChunk) { this.destinationLocation = _Destination; this.dimensionId = _DimensionId; this.allowedFlags = new List <Searchflag>(); this.allowedFlags.Add(new PlayerObjectFlag()); }
public Room(int depth, BlockEnum blockType, Random rnd) { arrayWidth = (int)Math.Pow(3, depth); arrayHeight = (int)Math.Pow(3, depth); this.blockType = blockType; this.depth = depth; this.rnd = rnd; this.finalBlockArray = new BlockEnum[arrayWidth, arrayHeight]; this.edgeStatesArray = new EdgeStates[arrayWidth, arrayHeight]; initEdgeArray(); }
private void setupLevelToDraw() { Grid = new BlockEnum[50, 30]; GridObject = new BlockBase[50, 30]; if (SceneManager.GetActiveScene().name == "Editor") { LineRenderer = GetComponent <LineRenderer>(); LineRenderer.SetPosition(0, GridToPosition2(0, 0)); LineRenderer.SetPosition(1, GridToPosition2(0, Grid.GetLength(1))); LineRenderer.SetPosition(2, GridToPosition2(Grid.GetLength(0), Grid.GetLength(1))); LineRenderer.SetPosition(3, GridToPosition2(Grid.GetLength(0), 0)); } }
public Block (BlockEnum blockType, EdgeStates[,] omniBlockArray, int x, int y, int depth, Random rnd) { this.rnd = rnd; this.blockType = blockType; this.subWidth = 3; this.subHeight = 3; this.omniEdgeArray = omniBlockArray; edgeStatesArray = new EdgeStates[subWidth, subHeight]; finalBlockArray = new BlockEnum[subWidth, subHeight]; InitEdgeStatesArray(); InitFinalBlockArray(); HandleDepth(x, y, depth - 1); }
public Block(int _PosX, int _PosY, BlockEnum _BlockEnum, Chunk.Chunk _ParentChunk) : base() { this.layer = new BlockEnum[Enum.GetValues(typeof(BlockLayerEnum)).Length]; this.layer[0] = _BlockEnum; this.objects = new List <Object.Object>(); this.Position = new Vector3(_PosX, _PosY, 0); this.Parent = _ParentChunk; this.objectsPreEnviorment = new List <Object.Object>(); this.isWalkAble = true; this.height = 0; this.Size = new Vector3(Block.BlockSize, Block.BlockSize, 0); }
public Block(int _PosX, int _PosY, BlockEnum _BlockEnum, Chunk.Chunk _ParentChunk) : base() { this.layer = new BlockEnum[Enum.GetValues(typeof(BlockLayerEnum)).Length]; this.layer[0] = _BlockEnum; this.objects = new List<Object.Object>(); this.Position = new Vector3(_PosX, _PosY, 0); this.Parent = _ParentChunk; objectsPreEnviorment = new List<Object.Object>(); this.isWalkAble = true; this.height = 0; this.Size = new Vector3(Block.BlockSize, Block.BlockSize, 0); }
public static BlockBase NewBlock(this BlockEnum block, TileGameObject prefab) { switch (block) { case BlockEnum.Ground: return(new BlockGround(prefab)); case BlockEnum.Spike: return(new BlockSpike(prefab)); case BlockEnum.Powerup: return(new BlockPowerup(prefab)); case BlockEnum.Checkpoint: return(new CheckpointBlock(prefab)); case BlockEnum.Warp: return(new WarpBlock(prefab)); case BlockEnum.End: return(new EndBlock(prefab)); case BlockEnum.Player: return(new PlayerBlock(prefab)); case BlockEnum.Trinket: return(new TrinketBlock(prefab)); case BlockEnum.Object: switch (((CBD_Object)prefab.Data).ObjectType) { case ObjectEnum.Jumper: return(new JumperBlock(prefab)); case ObjectEnum.Tapis: return(new BlockTapis(prefab)); case ObjectEnum.SandBlock: return(new SandBlock(prefab)); case ObjectEnum.Key: return(new KeyBlockEditor(prefab)); case ObjectEnum.KeyBlock: return(new KeyblockBlock(prefab)); case ObjectEnum.Platform: return(new PlatformBlock(prefab)); case ObjectEnum.Monsters: return(new BlockMonster(prefab)); case ObjectEnum.PlatformX: return(new PlatformXYBlock(prefab)); case ObjectEnum.PlatformY: return(new PlatformXYBlock(prefab)); default: return(null); } default: return(null); } }
public void CollorIndicator(BlockEnum blockEnum) { switch (blockEnum) { case BlockEnum.None: _image.color = Controls.Instance._blockColor; return; case BlockEnum.Top: case BlockEnum.Left: case BlockEnum.Right: _image.color = Controls.Instance._attackColor; return; case BlockEnum.Bottom: _image.color = Controls.Instance._bashColor; return; } }
public void ToggleState(bool state) { _backGround.SetActive(state); _isActive = state; if (state) { _image = _bottom; _image.transform.localScale *= _selectedIncreaseSize; _image.color = Controls.Instance._blockColor; _blockEnum = BlockEnum.Bottom; _indicator.transform.position = transform.position; } else { _image.transform.localScale = Vector3.one; _image.color = Color.white; _blockEnum = BlockEnum.None; } }
private void FindDirection(float x, float y) { if (_isLocked) { return; } float largest = 0; _image.transform.localScale = Vector3.one; _image.color = Color.white; if (y > 0 && y > largest) //top { _image = _top; largest = y; _blockEnum = BlockEnum.Top; } if (x > 0 && x > largest) //right { _image = _right; largest = x; _blockEnum = BlockEnum.Right; } if (x < 0 && Mathf.Abs(x) > largest) //left { _image = _left; largest = Mathf.Abs(x); _blockEnum = BlockEnum.Left; } if (y < 0 && Mathf.Abs(y) > largest) //bottom { _image = _bottom; largest = Mathf.Abs(y); _blockEnum = BlockEnum.Bottom; } _image.transform.localScale *= _selectedIncreaseSize; _image.color = Controls.Instance._blockColor; }
public void drawBlock(GraphicsDevice _GraphicsDevice, SpriteBatch _SpriteBatch) { Vector2 var_DrawPosition = new Vector2(this.Position.X, this.Position.Y); Color var_Color = Color.White; if (Setting.Setting.debugMode) { if (this.objects.Count > 0) { var_Color = Color.Green; } else { var_Color = this.drawColor; } } String var_RegionType = ((Region.Region) this.Parent.Parent).RegionEnum.ToString(); String var_TexturePath = "Region/" + var_RegionType + "/" + var_RegionType; /*for(int i = 0; i < this.height; i++) * { * _SpriteBatch.Draw(Ressourcen.RessourcenManager.ressourcenManager.Texture["Region/" + var_RegionType + "/Block/" + "Wall"], var_DrawPosition - new Vector2(0, BlockSize * i), var_Color); * }*/ BlockLayerEnum var_Layer = BlockLayerEnum.Layer1; while ((int)var_Layer < this.layer.Length) { BlockEnum var_Enum = this.layer[(int)var_Layer]; if (var_Enum != BlockEnum.Nothing) { _SpriteBatch.Draw(Ressourcen.RessourcenManager.ressourcenManager.Texture[var_TexturePath], var_DrawPosition, new Rectangle((int)(var_Enum - 1) * BlockSize, (int)(var_Layer) * BlockSize, BlockSize, BlockSize), var_Color); } var_Layer += 1; } }
private IEnumerator SwitchBlockDirection(BlockEnum blockEnum, float switchTime) { yield return(new WaitForSeconds(switchTime)); switch (blockEnum) { case BlockEnum.Top: _actor._blockEnum = _crosshairManager.GetBlockDirection(0, 1, this.transform); break; case BlockEnum.Left: _actor._blockEnum = _crosshairManager.GetBlockDirection(1, 0, this.transform); break; case BlockEnum.Right: _actor._blockEnum = _crosshairManager.GetBlockDirection(-1, 0, this.transform); break; case BlockEnum.Bottom: _actor._blockEnum = _crosshairManager.GetBlockDirection(0, -1, this.transform); break; } }
public void TakeDamage(float _damage, BlockEnum blockDirection) { switch (_blockEnum) { case BlockEnum.None: _health -= _damage; break; case BlockEnum.Top: if (blockDirection == BlockEnum.Top) { _damage = _damage - _combatBehavior._weapon._blockResistance; if (_damage < 0) { _damage = 0; } } _health -= _damage; break; case BlockEnum.Left: if (blockDirection == BlockEnum.Right) { _damage = _damage - _combatBehavior._weapon._blockResistance; if (_damage < 0) { _damage = 0; } } _health -= _damage; break; case BlockEnum.Right: if (blockDirection == BlockEnum.Left) { _damage = _damage - _combatBehavior._weapon._blockResistance; if (_damage < 0) { _damage = 0; } } _health -= _damage; break; case BlockEnum.Bottom: if (_combatBehavior._weapon._canBlocksArrows) { _damage = _damage - _combatBehavior._weapon._blockResistance; if (_damage < 0) { _damage = 0; } } _health -= _damage; break; } if (_health <= 0) { Die(); } }
public BlockBase(TileGameObject prefab) { _prefab = prefab; _block = prefab.Block; }
private Chunk fillChunkWithBlock(Chunk _Chunk, BlockEnum _BlockEnum) { for(int x = 0; x < _Chunk.Size.X; x++) { for(int y = 0; y < _Chunk.Size.Y; y++) { Block var_Block = new Block((int)_Chunk.Position.X + x * Block.BlockSize, (int)_Chunk.Position.Y + y * Block.BlockSize, _BlockEnum, _Chunk); if (!_Chunk.setBlockAtPosition(x, y, var_Block)) { Logger.Logger.LogErr("RegionFactory->fillChunkWithBlock(...) : Platzierung nicht möglich!"); } else { if (Configuration.Configuration.isHost) { } else { var_Block.requestFromServer(); } } } } return _Chunk; }
public BlockTypeReturnData(BlockEnum pEnum, bool pAnimated) { BlockType = pEnum; Animated = pAnimated; }
public BlockTypeReturnData(BlockEnum pEnum) { BlockType = pEnum; }
public static string GetName(this BlockEnum block) => Enum.GetName(block.GetType(), block);