void IEcsRunSystem.Run() { foreach (var s in spawns) { ref var spawn = ref spawns.Get1(s); var hits = Physics2D.CircleCastAll(spawn.pos, 1.58f, Vector2.zero); bool isIntersection = false; //=========================================== spawn.view.captureValue = spawn.captureValue; //=========================================== List <TeamNum> intersectTeams = new List <TeamNum>(); int idx = 0; foreach (var hit in hits) { idx++; if (!hit.transform.GetComponent <Player>()) { continue; } isIntersection = true; //Находим сущности игроков исходя из имеющихся view игроков в пересечении foreach (var p in players) { ref var player = ref players.Get1(p); var playerIsFound = hit.transform.GetComponent <Player>() == player.view; if (playerIsFound) { intersectTeams.Add(player.teamNum); intersectTeams = intersectTeams.Distinct().ToList(); } } if (idx < hits.Length) { continue; } foreach (var p in players) { ref var player = ref players.Get1(p); var playerIsFound = hit.transform.GetComponent <Player>() == player.view; if (playerIsFound) { //Debug.Log($"{teams[player.teamNum]} -+-+-- Тип спауна {spawn.spawnType} -+-+-+ Тима {player.teamNum}"); //Debug.Log($"{intersectTeams.Count} - каунт хуянт {idx}"); ref var spawnEntity = ref spawns.GetEntity(s); if (spawnEntity.Has <CrossCaptureTag>()) { if (intersectTeams.Count > 1) { continue; } else { spawnEntity.Del <CrossCaptureTag>(); var col = spawn.view.GetCurColor(spawn.spawnType); ChangeColor(ref spawn, col, col); } } if (intersectTeams.Count > 1) { spawnEntity.Get <CrossCaptureTag>(); continue; } if (teams[player.teamNum] == spawn.spawnType) { //Debug.Log($"{teams[player.teamNum]} ^^^^ {spawn.spawnType}"); if (spawn.captureValue < 1) { spawn.captureValue += Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } else { continue; } } //Debug.Log($"{teams[player.teamNum]} -+-+-- {spawn.spawnType}"); if (spawn.captureValue > 0 && spawn.spawnType != SpawnType.Neutral && teams[player.teamNum] != spawn.spawnType) { spawn.captureValue -= Time.deltaTime * captureSpeed; Color32 cur = spawn.view.GetCurColor(spawn.spawnType); Color32 tar = Color.white; ChangeColor(ref spawn, tar, cur); } if (spawn.captureValue <= 0 && spawn.spawnType != SpawnType.Neutral) { spawn.spawnType = SpawnType.Neutral; spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } if (spawn.captureValue < 1 && spawn.spawnType == SpawnType.Neutral) { if (spawn.lastCaptureColor == Color.white || spawn.lastCaptureColor == spawn.view.GetCurColor(teams[player.teamNum])) { spawn.captureValue += Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); if (spawn.captureValue >= 1 && teams[player.teamNum] != spawn.spawnType) { spawn.spawnType = teams[player.teamNum]; //spawn.lastCaptureColor = spawn.view.GetCurColor(teams[player.teamNum]); } } else { spawn.captureValue -= Time.deltaTime * captureSpeed; Color32 cur = Color.white; Color32 tar = spawn.lastCaptureColor;//view.GetCurColor(teams[player.teamNum]); ChangeColor(ref spawn, cur, tar); if (spawn.captureValue <= 0) { spawn.lastCaptureColor = Color.white; } } } }
void IEcsRunSystem.Run() { foreach (var i in _mobsChangeHealth) { ref var mob = ref _mobsChangeHealth.GetEntity(i); ref var powerGameDesignCurrent = ref _mobsChangeHealth.Get1(i);
public void Run() { foreach (var i in _items) { ref var ent = ref _items.GetEntity(i); ref var uObject = ref _items.Get1(i);
public void Run() { foreach (var i in _filter) { ref var entity = ref _filter.GetEntity(i); ref InstantiateComponent component = ref entity.Get <InstantiateComponent>();
void IEcsRunSystem.Run() { foreach (var i in _mobs) { ref var mob = ref _mobs.GetEntity(i); ref var powerGameDesignBase = ref _mobs.Get1(i);
public void Run() { foreach (int i in _mapRegionCreationFilter) { ref var entity = ref _mapRegionCreationFilter.GetEntity(i); ref var mapRegionCreation = ref _mapRegionCreationFilter.Get1(i);
public void Run() { foreach (var i in _playerMovementFilter) { ref var entity = ref _playerMovementFilter.GetEntity(i); ref var player = ref _playerMovementFilter.Get1(i);
public void Run() { foreach (var id in aiFilter) { ref var entity = ref aiFilter.GetEntity(id); ref var brain = ref aiFilter.Get2(id);
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var gun = ref _filter.GetEntity(i); ref var ammo = ref _filter.Get1(i);
public void Run() { foreach (var i in _players) { ref var ent = ref _players.GetEntity(i); ref var player = ref _players.Get1(i);
void IEcsRunSystem.Run() { foreach (var snakeIdx in _snakeFilter) { ref var snakeEntity = ref _snakeFilter.GetEntity(snakeIdx); ref var snake = ref _snakeFilter.Get1(snakeIdx);
public void Run() { foreach (var i in _addedPlayer) { var id = i; var playerComponent = _addedPlayer.Get1(id); playerComponent.PlayerBehaviour.OnHit += () => PlayerBehaviourOnOnHit(_addedPlayer.GetEntity(id)); } if (_localPlayer.IsEmpty()) { return; } ref var input = ref _localPlayer.Get2(0);
void IEcsRunSystem.Run() { foreach (var i in _filter) { ref var bullet = ref _filter.GetEntity(i); ref var bulletHealthCurrent = ref bullet.Get <HealthCurrentComponent>().Value;
void IEcsRunSystem.Run() { if (!_checkFilter.IsEmpty()) { GameObject touchSquare = _checkFilter.Get1(0).obj; Direction moveDirection = touchSquare.GetComponent <SquareScript>().SquareDirection; Vector2Int touchPos = new Vector2Int((int)touchSquare.transform.position.x / Const.CellSizePx, (int)touchSquare.transform.position.y / -Const.CellSizePx); Vector2Int moveDirectionInt = Const.DirToVecI(moveDirection); _checkFilter.GetEntity(0).Destroy(); if (!CheckMove(touchPos, moveDirectionInt)) { EcsEntity ent = _world.NewEntity(); ent.Get <WaitForTochComponent>(); EcsEntity ent4 = _world.NewEntity(); SoundFxComponent ss = new SoundFxComponent(); ss.Fx = SoundFx.SquareMoveError; ent4.Get <SoundFxComponent>() = ss; return; } List <GameObject> SquaresToMove = new List <GameObject>(); SquaresToMove.Add(_globalData.GameField[touchPos.x, touchPos.y].Obj); Vector2Int npos = touchPos; do { npos = npos + moveDirectionInt; if (npos.x < 0 || npos.x >= Const.MapSize || npos.y < 0 || npos.y >= Const.MapSize) { break; } if (_globalData.GameField[npos.x, npos.y].Obj is null) { break; } SquaresToMove.Add(_globalData.GameField[npos.x, npos.y].Obj); } while (true); SquaresToMove.Reverse(); SaveUndo(); EcsEntity ent1 = _world.NewEntity(); ent1.Get <MoveComponent>().SquaresToMove = SquaresToMove; ent1.Get <MoveComponent>().Direction = moveDirection; Vector3 moveDirectionF = Const.DirToVecF(moveDirection); List <Vector3> dstPos = new List <Vector3>(); List <Vector2Int> srcPosInt = new List <Vector2Int>(); List <Vector2Int> dstPosInt = new List <Vector2Int>(); foreach (GameObject o in SquaresToMove) { Vector3 dst = o.transform.position + moveDirectionF * Const.CellSizePx; dstPos.Add(dst); Vector2Int di = new Vector2Int((int)dst.x / Const.CellSizePx, (int)dst.y / -Const.CellSizePx); dstPosInt.Add(di); Vector2Int si = new Vector2Int((int)o.transform.position.x / Const.CellSizePx, (int)o.transform.position.y / -Const.CellSizePx); srcPosInt.Add(si); } ent1.Get <MoveComponent>().DstPos = dstPos; ent1.Get <MoveComponent>().SrcPosInts = srcPosInt; ent1.Get <MoveComponent>().DstPosInts = dstPosInt; EcsEntity ent3 = _world.NewEntity(); SoundFxComponent s = new SoundFxComponent(); s.Fx = SoundFx.SquareMove; ent3.Get <SoundFxComponent>() = s; } }