Exemplo n.º 1
0
        private void HandleItemCollection(LevelImp level)
        {
            ItemImp item;

            if (!level.MayCollectItem(this, out item))
            {
                return;
            }
            switch (item.Type)
            {
            case ItemType.AdditionalBomb:
                PlacableBombCount++;
                CurrentPlacableBombCount++;
                break;

            case ItemType.AdditionalFireRange:
                BombExplosionRange++;
                break;

            case ItemType.AdditionalSpeed:
                Speed += SpeedIncrease;
                break;

            case ItemType.Punish:
                HandleCollectionPunish();
                break;

            case ItemType.MaxRangeBomb:
                ActiveBombType = BombType.MaxRange;
                break;
            }
            CollectedItems.Add(item.Type);
            item.Collect();
        }
Exemplo n.º 2
0
 private void HandlePlaceBomb(LevelImp level)
 {
     if (_punishedType == PunishedType.AutoDrop || (FigureController != null && FigureController.ActionDone))
     {
         PlaceBomb(level);
     }
 }
Exemplo n.º 3
0
        public void Update(LevelImp level, float elapsed)
        {
            if (!IsAlive)
            {
                return;
            }

            if (_punishedType != PunishedType.None)
            {
                _punishedTime += elapsed;
                if (_punishedTime >= PunishedDuration)
                {
                    _punishedType = PunishedType.None;
                }
            }

            FigureController?.Update(elapsed);

            Move(level, elapsed);
            HandleItemCollection(level);
            HandleHitByFire(level);
            HandlePlaceBomb(level);

            FigureController?.Reset();
        }
Exemplo n.º 4
0
 private void HandleHitByFire(LevelImp level)
 {
     if (level.HitByFire(this))
     {
         Die(Position);
         level.ProvideItemsOf(this);
     }
 }
Exemplo n.º 5
0
        private FigureImp CreateComputerFigure(LevelImp level)
        {
            var comFigureController = new ComFigureController(level);
            var figure = new FigureImp(Id)
            {
                FigureController = comFigureController
            };

            comFigureController.Figure = figure;
            return(figure);
        }
Exemplo n.º 6
0
        private void HandlePrepareMatch()
        {
            _currentLevel = new LevelImp(_matchTimeSeconds);
            _currentLevel.GenerateLevel(_levelAssetPath);
            foreach (var member in _members.Where(m => m.Type != MemberType.Watcher))
            {
                _currentLevel.AddFigure(member.SpawnFigure(_currentLevel));
            }

            State = GameSessionState.PreparingMatchSynchronizeStart;
            RemainingStartupTime = 3;
        }
Exemplo n.º 7
0
        protected bool PlaceBomb(LevelImp level)
        {
            if (CurrentPlacableBombCount > 0)
            {
                var placedBomb = level.PlaceBomb(this);
                if (placedBomb != null)
                {
                    CurrentPlacableBombCount--;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        public FigureImp SpawnFigure(LevelImp level)
        {
            switch (Type)
            {
            case MemberType.Computer:
                return(CreateComputerFigure(level));

            case MemberType.ActivePlayer:
                return(CreatePlayerFigure());

            default:
                throw new InvalidOperationException("Watcher do not get figure");
            }
        }
Exemplo n.º 9
0
        private void Move(LevelImp level, float elapsed)
        {
            //todo: wtf?
            //float elapsed = Math.Abs(TimeStamp - 0) > 0.001
            //                    ? (float) (timeStamp - TimeStamp)
            //                    : 0;

            var tile = (TileBlockImp)level.GetData(level.GetTilePositionFromWorld(Position));

            Vector2 actualMoveDirection = _punishedType == PunishedType.InvertControls
                                              ? -FigureController.MoveDirection
                                              : FigureController.MoveDirection;

            if (FigureController != null && WalkDirection != actualMoveDirection)
            {
                WalkDirection = actualMoveDirection;
            }

            if (WalkDirection == Vector2.Zero && tile.Force == Vector2.Zero)
            {
                _animating = false;
                //TimeStamp = timeStamp;
                return;
            }

            if (!_animating)
            {
                _animating = true;
            }

            if (WalkDirection == Vector2.Zero)
            {
                _animating = false;
            }

            float moveDistance = Speed * elapsed;

            Vector2 moveStep = WalkDirection * moveDistance;

            if (moveStep == Vector2.Zero)
            {
                moveStep = tile.Force * moveDistance;
            }
            else
            {
                if (tile.Force != Vector2.Zero)
                {
                    if (tile.Force == WalkDirection)
                    {
                        moveStep *= 2;
                    }
                    else if (Math.Abs(tile.Force.X - WalkDirection.X) < 0.01f || Math.Abs(tile.Force.Y - WalkDirection.Y) < 0.01f)
                    {
                        moveStep *= 0.5f;
                    }
                    else
                    {
                        moveStep = (WalkDirection + (tile.Force / 2)) * moveDistance;
                    }
                }
            }

            Position = level.HandleCollissionsSlide(Position, moveStep);
            //TimeStamp = timeStamp;
        }