示例#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();
        }
示例#2
0
 private void HandlePlaceBomb(LevelImp level)
 {
     if (_punishedType == PunishedType.AutoDrop || (FigureController != null && FigureController.ActionDone))
     {
         PlaceBomb(level);
     }
 }
示例#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();
        }
示例#4
0
 private void HandleHitByFire(LevelImp level)
 {
     if (level.HitByFire(this))
     {
         Die(Position);
         level.ProvideItemsOf(this);
     }
 }
        private FigureImp CreateComputerFigure(LevelImp level)
        {
            var comFigureController = new ComFigureController(level);
            var figure = new FigureImp(Id)
            {
                FigureController = comFigureController
            };

            comFigureController.Figure = figure;
            return(figure);
        }
示例#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;
        }
示例#7
0
        protected bool PlaceBomb(LevelImp level)
        {
            if (CurrentPlacableBombCount > 0)
            {
                var placedBomb = level.PlaceBomb(this);
                if (placedBomb != null)
                {
                    CurrentPlacableBombCount--;
                    return(true);
                }
            }

            return(false);
        }
        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");
            }
        }
示例#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;
        }