示例#1
0
 public void SetAllTilesInactive()
 {
     foreach (BaseTile CurrentTile in GameObject.FindObjectsOfType <BaseTile>())
     {
         CurrentTile.SetTileActive(false);
     }
 }
示例#2
0
        void GameTick()
        {
            HexTile nextTile = CurrentTile.Neighbour(Dir);

            if (!nextTile || nextTile.Terrain == TerrainType.rock || IsColliding(nextTile))
            {
                Debug.Log("GAME OVER!");
                OnGameOver();
                return;
            }

            for (int i = tail.Count - 1; i >= 0; i--)
            {
                Worm w  = tail[i];
                Worm wn = (i == 0) ? this : tail[i - 1];
                w.Dir         = wn.Dir;
                w.CurrentTile = wn.CurrentTile;
            }


            CurrentTile = nextTile;
            if (IsTarget(CurrentTile))
            {
                ConsumeTarget();
                SetTarget();
            }
            tickCount++;
        }
示例#3
0
    /// <summary>
    /// Sets the initial position and the bot settings of the cubot
    /// </summary>
    /// <param name="initialPlotTile"></param>
    /// <param name="initialOrientation"></param>
    public void SetUp(LevelDescriptor configuration, List <PlotTile> tilesInScene)
    {
        this.tilesInScene  = tilesInScene;
        CurrentOrientation = configuration.CharacterInitialOrientation;
        Vector3    cubotExtents             = this.GetComponent <Renderer>().bounds.extents;
        Vector3Int cubotPlotInitialPosition = configuration.CharacterStartPointInPlot;

        PlotTile initialPlotTile = tilesInScene.Where(t => t.PlotPosition == cubotPlotInitialPosition).First();

        float   rotY = (int)CurrentOrientation;
        Vector3 initialPlotTileExtents = initialPlotTile.GetComponent <Renderer>().bounds.extents;

        //Cubot must be over an initial plot tile, so we are going to position it
        Vector3 initialPosition = initialPlotTile.transform.position;

        initialPosition.y += cubotExtents.y + initialPlotTileExtents.y;

        Vector3 cubotInitialRotation = new Vector3(0, rotY, 0);

        this.transform.position = initialPosition;
        this.transform.rotation = Quaternion.Euler(cubotInitialRotation);

        Speed = configuration.CharacterSpeed;

        CurrentTile = initialPlotTile;
        CurrentTile.Step();
    }
示例#4
0
        /** Moves party forward one square in the direction they are facing, if not blocked by a wall */
        public void Move(Direction direction)
        {
            if (Selected.Paralized)
            {
                return;
            }

            // open a door if we move through it.
            var door = getDoor(LocationX, LocationY, direction);

            if (door != null)
            {
                openDoor(door);
            }

            var perceivedWallWeWillMoveThrough = PerceivedTile.getWallRecord(direction);
            var actualWallWeWillMoveThrough    = CurrentTile.getWallRecord(direction);

            if (perceivedWallWeWillMoveThrough != actualWallWeWillMoveThrough)
            {
                PerceivedTile.setWallRecord(direction.Sector, actualWallWeWillMoveThrough);
                CoM.Instance.RefreshMapTile(LocationX, LocationY);
            }

            if (CanMove(direction))
            {
                SetLocation(LocationX + direction.DX, LocationY + direction.DY);
            }
        }
    public override void MoveInDirection(Vector3Int direction)
    {
        Level grid = GameController.Instance.Level;
        Tile  tile = grid.GetTileForPosition(transform.position + direction - Vector3Int.up);

        if (tile != null)
        {
            Debug.Log("move onto tile");
            if (tile.IsFree())
            {
                if (CurrentTile != null)
                {
                    CurrentTile.ReleaseUnit();
                }
                tile.AssignUnit(this);
                CurrentTile = tile;

                neighbours = base.CurrentTile.GetNeighbours();

                for (int i = 0; i < neighbours.Length; i++)
                {
                    if (neighbours[i].Unit == null)
                    {
                        continue;
                    }
                    if (neighbours[i].Unit.type == Type.Player)
                    {
                        continue;
                    }

                    if (neighbours[i].Unit.type == Unit.Type.Particle)
                    {
                        if (neighbours[i].Unit.GetComponent <Particles>().particleType == particleType)
                        {
                            fuseParticle = neighbours[i].Unit.GetComponent <Particles>();
                        }
                    }
                }

                if (fuseParticle != null)
                {
                    StartCoroutine(MoveToPosition(tile.Position, EvolveParticle));
                }
                else
                {
                    StartCoroutine(MoveToPosition(tile.Position));
                }
            }
        }
        else
        {
            if (CurrentTile != null)
            {
                CurrentTile.ReleaseUnit();
            }
            //LookAtPosition(CurrentTile.Position - direction);
            StartCoroutine(MoveToPosition(CurrentTile.Position + direction, BecomeTile));
            CurrentTile = null;
        }
    }
示例#6
0
    private void UpdateDirection()
    {
        if (NextTile == null)
        {
            //  default face to player
            _characterDirection = CharacterDirection.South;
        }
        else
        {
            if (NextTile == CurrentTile.GetNorthTile())
            {
                _characterDirection = CharacterDirection.North;
            }
            else if (NextTile == CurrentTile.GetSouthTile())
            {
                _characterDirection = CharacterDirection.South;
            }
            else if (NextTile == CurrentTile.GetWestTile())
            {
                _characterDirection = CharacterDirection.West;
            }
            else
            {
                _characterDirection = CharacterDirection.East;
            }
        }

        new CharacterUpdatedEvent {
            Character = this, Direction = _characterDirection
        }.Publish();
    }
示例#7
0
    public void Remove(bool reorder = true)
    {
        if (Removing)
        {
            logger.Log("Attempting to remove an object already being removed");
            return;
        }
        Removing = true;

        UrbAgentManager.UnregisterAgent(this);

        CurrentTile?.OnAgentLeave(this, reorder);

        CurrentMap = null;
        if (TotalAgents > 0)
        {
            TotalAgents--;
        }

        if (Debug.developerConsoleVisible)
        {
            logger.Log(LogType.Log, "Remove entity, destroying game object", context: this);
        }
        Destroy(gameObject);
    }
示例#8
0
 /// <summary>
 /// moves the player forwards or backwards on the board
 /// </summary>
 /// <param name="positions"></param>
 public void MoveTo(int positions)
 {
     if (!IsInJail)
     {
         if (positions < 0)
         {
             for (int i = positions; i < 0; i++)
             {
                 CurrentTile = CurrentTile.PreviousTile;
             }
         }
         else
         {
             for (int i = 0; i < positions; i++)
             {
                 CurrentTile = CurrentTile.NextTile;
                 if (CurrentTile.Equals(CurrentGame.Start))
                 {
                     Money += 200;
                 }
             }
         }
     }
     CurrentTile.DoAction(this);
 }
示例#9
0
        protected override Direction GetNextDirection()
        {
            var desiredDirection = Game.Navigator.GetDirections(CurrentTile);

            return(!CurrentTile.Neighbour(desiredDirection).Info.IsPassable
                ? Direction.Unknown
                : desiredDirection);
        }
示例#10
0
文件: menu.cs 项目: Klegy/uninfe
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            CurrentTile.Style = (MetroFramework.MetroColorStyle)Convert.ToInt16(e.ClickedItem.Tag);
            CurrentTile.Refresh();

            uninfeDummy.xmlParams.WriteValue(Name + "\\" + CurrentTile.Name, "color", (int)CurrentTile.Style);

            CurrentTile = null;
        }
示例#11
0
        public void SetDestination(Tile tile)
        {
            if (CurrentTile.IsNeighbour(tile, true) == false)
            {
                Debug.Log("Character::SetDestination -- Our destination Tile isn't actually our neighbour.");
            }

            DestinationTile = tile;
        }
示例#12
0
        /// <summary>
        /// Performs the specified action
        /// </summary>
        /// <param name="action">The PlayerAction to perform</param>
        public void PerformAction(PlayerAction action)
        {
            if (!CanPerformAction(action))
            {
                throw new PlayerActionNotAllowedException();
            }

            CurrentTile.PerformAction(this, action);

            OnPlayerAction?.Invoke(this);
        }
示例#13
0
 private PlayingTile GenerateNewPlayingTile()
 {
     CurrentTile = Dealer.DealTile();
     CurrentTile.PositionChanged += () => RaisePropertyChanged(nameof(CurrentTilePositions));
     CurrentTile.PlaceOnBoard(Global.NB_TILES / 2, Global.NB_TILES / 2);
     for (int i = 0; i < RandomUtil.RandomWithMax(5); ++i)
     {
         CurrentTile.RotateClockwise();
     }
     return(CurrentTile);
 }
示例#14
0
        public override void Update(GameTime time)
        {
            base.Update(time);

            // If there are no more Soldiers in this stack, it will stop existing
            if (unitsAndCounts.Keys.Count == 0)
            {
                CurrentTile.SetUnit(null);
                return;
            }
        }
示例#15
0
        public void DestroySelf()
        {
            // BeforeDestroyed(this, adderObject)
            foreach (var e in GetTriggerEvents(TriggerEventType.BeforeDestroyed))
            {
                e.Invoke();
            }

            IsDestroyed = true;
            CurrentTile?.RemoveTileObject(TypeName);
            CurrentTile = null;
        }
示例#16
0
    IEnumerator FlipHexes(bool FRestart)
    {
        Background_Right.SetActive(false);
        Background_Restart.SetActive(false);
        Background_Credits.SetActive(false);

        foreach (Transform CurrentColumn in Right.transform)
        {
            foreach (Transform CurrentTile in CurrentColumn)
            {
                CurrentTile.gameObject.SetActive(true);
                CurrentTile.GetComponent <Animator>().SetTrigger("Flip");
            }
            yield return(new WaitForSeconds(0.01f));
        }

        StartCoroutine(DelayedBackground(Background_Right, true));
        //Background_Right.SetActive(true);

        if (FRestart)
        {
            FailedText.SetActive(true);
            Reason.SetActive(true);

            foreach (Transform CurrentColumn in Restart.transform)
            {
                foreach (Transform CurrentTile in CurrentColumn)
                {
                    CurrentTile.gameObject.SetActive(true);
                    CurrentTile.GetComponent <Animator>().SetTrigger("Flip");
                }
                yield return(new WaitForSeconds(0.01f));
            }

            StartCoroutine(DelayedBackground(Background_Restart, true));
            //Background_Restart.SetActive(true);
        }
        else
        {
            foreach (Transform CurrentColumn in Credits.transform)
            {
                foreach (Transform CurrentTile in CurrentColumn)
                {
                    CurrentTile.gameObject.SetActive(true);
                    CurrentTile.GetComponent <Animator>().SetTrigger("Flip");
                }
                yield return(new WaitForSeconds(0.0001f));
            }

            StartCoroutine(DelayedBackground(Background_Credits, true));
            //Background_Credits.SetActive(true);
        }
    }
示例#17
0
 public override void Explode()
 {
     CurrentTile.Left.Up.ExplodeContent();
     CurrentTile.Up.ExplodeContent();
     CurrentTile.Up.Right.ExplodeContent();
     CurrentTile.Right.ExplodeContent();
     CurrentTile.Right.Down.ExplodeContent();
     CurrentTile.Down.ExplodeContent();
     CurrentTile.Down.Left.ExplodeContent();
     CurrentTile.Left.ExplodeContent();
     CurrentTile.ExplodeContent();
 }
示例#18
0
    public virtual void Ondeath(float x, Skill f, Actor a = null)
    {
        OnDeath(x, f);
        if (GameManager.CurrentBattle.Foes.Contains(this))
        {
            GameManager.CurrentBattle.Foes.Remove(this);
        }
        if (GameManager.CurrentBattle.Players.Contains(this))
        {
            GameManager.CurrentBattle.Players.Remove(this);
        }

        CurrentTile.OnQuitting();

        UnityEngine.Debug.Log(this.Name + " is death");
    }
示例#19
0
        public void SetMap(Map newMap)
        {
            if (CurrentMap != null)
            {
                CurrentMap.Player = null;
            }

            if (CurrentTile != null)
            {
                CurrentTile.LeaveTile(this);
            }

            newMap.Player = this;
            CurrentTile   = newMap.GetTile(newMap.PlayerStart.X, newMap.PlayerStart.Y);
            CurrentTile.EnterTile(this);
        }
示例#20
0
    public void RandomSwitchLane()
    {
        int lane = 0;

        if (_target.CurrentLane == 0)
        {
            if (CurrentLane != 0)
            {
                return;
            }
            else
            {
                lane = CurrentTile.GetRandomLaneBut(0);
            }
        }

        SwitchLane(lane);
    }
示例#21
0
        /** Checks if party can move in given direction. */
        public bool CanMove(Direction direction)
        {
            var newField = Map.GetField(LocationX + direction.DX, LocationY + direction.DY);

            // don't allow character to move off map or into rock
            if (newField == null || newField.Rock)
            {
                return(false);
            }

            // check for wall crossing
            if (CurrentTile.getWallRecord(direction).Wall)
            {
                return(false);
            }

            return(true);
        }
示例#22
0
    private void CreateBasicGrid()
    {
        float      YStep             = Mathf.Sqrt(HexRadius * HexRadius - HexRadius * HexRadius / 4);
        float      XStep             = HexRadius - Mathf.Sqrt(HexRadius * HexRadius - YStep * YStep) / 2;
        float      OddRowPush        = 0.0F;
        int        GridCorrector     = 0;
        Vector3    GlobalCoordinates = new Vector3(0.0F, 0.0F, 0.0F);
        GameObject CurrentTile;

        System.Random Rand = new System.Random();

        for (int GridX = 0; GridX < (int)GridSize.x; GridX++)
        {
            OddRowPush = (GridX % 2 == 1) ? (YStep / 2) : 0;
            for (int GridY = GridCorrector; GridY < (int)GridSize.y + GridCorrector; GridY++)
            {
                GlobalCoordinates.x = ((GridY - GridCorrector) * YStep) + OddRowPush;
                GlobalCoordinates.y = -GridX * XStep;

                //Instantiating a tile
                CurrentTile      = (GameObject)Instantiate(DefaultTile, new Vector3(GlobalCoordinates.x, 0, GlobalCoordinates.y), Quaternion.identity);
                CurrentTile.name = "[" + GridY + "," + GridX + "]";
                CurrentTile.transform.SetParent(this.transform);
                CurrentTile.AddComponent <HexTile>();
                HexTile currentHex = CurrentTile.GetComponent <HexTile>();
                currentHex.AxialCoordinates = new Vector2(GridX, GridY);
                currentHex.Type             = (TerrainType)Rand.Next(0, 5);
                TerrainProperty terrainProp = FindProperty(currentHex);
                CurrentTile.GetComponent <Renderer>().material.color = terrainProp.DebugColor;

                if (GridX == 0 && GridY == 0)
                {
                    PlayersTile = currentHex;
                }
            }

            if (GridX % 2 == 1)
            {
                GridCorrector--;
            }
        }
    }
 //Jobs
 void UpdateJob(float time)
 {
     //If no job is assigned, look for a job
     if (this.CurrentJob == null)
     {
         if (!this.jobs.IsEmpty)
         {
             this.CurrentJob = jobs.DequeueValue();
         }
         else
         {
             //IDLE as there are no jobs
             this.CurrentJob      = new Job(this.CurrentTile, JobList.JobFunctions[(int)JobList.Jobs.Idle], 5f);
             this.adjacentJobTile = this.CurrentTile;
         }
     }
     else
     {
         //If standing on the right tile, do the job
         if (CurrentTile.Equals(this.adjacentJobTile))
         {
             //Job is performed regardless of outcome here
             if (this.CurrentJob.PerformJob(time))
             {
                 this.CurrentJob.OnCompleteJob(this.CurrentJob.Tile, this);
                 this.CurrentJob      = null;
                 this.adjacentJobTile = null;
             }
         }
         else
         {
             //If not in range and not travelling, start to travel
             if (currentPath == null)
             {
                 Tile dest = this.CurrentJob.Tile.NearestNeighbourTo(this.CurrentTile.X, this.CurrentTile.Y);
                 SetDest(dest);
                 this.adjacentJobTile = dest;
             }
             //Else the villager is travelling but not close enough yet
         }
     }
 }
示例#24
0
    IEnumerator ReverseHexes(bool FRestart)
    {
        if (FRestart)
        {
            FailedText.SetActive(false);
            Reason.SetActive(false);
            Background_Restart.SetActive(false);
        }

        else
        {
            for (int loop = (Credits.transform.childCount - 1); loop >= 0; loop--)
            {
                foreach (Transform CurrentTile in Credits.transform.GetChild(loop))
                {
                    CurrentTile.GetComponent <Animator>().SetTrigger("Reset");
                }
                yield return(new WaitForSeconds(0.0001f));
            }

            for (int loop = (Right.transform.childCount - 1); loop >= 0; loop--)
            {
                foreach (Transform CurrentTile in Right.transform.GetChild(loop))
                {
                    CurrentTile.GetComponent <Animator>().SetTrigger("Reset");
                }
                yield return(new WaitForSeconds(0.0001f));
            }

            Background_Credits.SetActive(false);
        }

        Background_Right.SetActive(false);

        if (!FRestart)
        {
            yield return(new WaitForSeconds(0.6f));
        }

        DisableMe();
    }
示例#25
0
    /// <summary>
    /// Make the onscreen penguin move to the destination tile
    /// </summary>
    /// <param name="destinationTile">Selected tile to move to</param>
    /// <remarks>
    /// CALLED BY: GameManager::ExecuteMove_GameWorld()
    /// </remarks>
    /// <returns>TRUE if a legal move was successfully executed</returns>
    ///
    public bool MoveTo(GameTile destinationTile)
    {
        // Make move only if this tile is in the list of legal moves compiled on Penguin click,
        //  or if it was "pre-approved" by AI on its turn
        //
        if (SetDestination(destinationTile))   // Set penguin's destination
        {
            // Change "penguin" status for tiles both departed from and arrived at
            //
            CurrentTile.RemovePenguin();
            destinationTile.PlacePenguin(this);

            OnSelectOff();   // Turn off selection as we move

            // Launch "Moving" State
            //
            IsMoving = true;
        }

        return(true);
    }
示例#26
0
    protected void CalculateDisplayInfo()
    {
        s_TickToDisplay_p.Begin();

        var massChange = Math.Abs(LastCheckedMass - Mass);

        if (massChange > MassChangeToReorder)
        {
            LastCheckedMass = Mass;
            if (CurrentTile != null)
            {
                CurrentTile.UpdateClearance();
                if (Shuffle)
                {
                    CurrentTile.VisualShuffle();
                }
            }
        }

        if (!(Time.time > NextReposition) || !(Display.Significance > UrbDisplay.FeatureSignificance))
        {
            s_TickToDisplay_p.End();
            return;
        }
        var position = transform.position;

        if (TargetLocation == position)
        {
            s_TickToDisplay_p.End();
            return;
        }
        NextReposition = Time.time + RepositionInterval;
        Vector3 Direction = (TargetLocation - position);

        position           = (Direction.magnitude > LocationThreshold) ? position + (Direction.normalized * Time.deltaTime) : TargetLocation;
        transform.position = position;

        s_TickToDisplay_p.End();
    }
示例#27
0
文件: Piece.cs 项目: Kiwin/LudOOP
        /// <summary>
        /// Moves the piece a set amount of steps
        /// </summary>
        /// <param name="steps">the amount of steps to move</param>
        public void Move(int steps)
        {
            // kind of misleading, is only used with the onmove event to
            Tile previousTile = CurrentTile;

            // Determines whether the piece is moving backwards or forwards
            bool isMovingForward = steps > 0;

            // sets an absolute value to the amount of steps
            steps = Math.Abs(steps);

            // "steps" once for every 1 in steps (moves the piece whatever many times it needs)
            for (int i = 0; i < steps; i++)
            {
                bool isLastStep = (i == steps - 1);
                LastTile = CurrentTile;
                CurrentTile.onPieceLeave(this, isMovingForward, isLastStep);
                if (CurrentTile != LastTile)
                {
                    CurrentTile.onPieceEnter(this, isMovingForward, isLastStep);
                }
            }
            OnMove(this, previousTile, CurrentTile);
        }
示例#28
0
文件: Form1.cs 项目: dkxce/PlitkaCalc
        public void CalcTiles(Zones.TPolygon BoxRect, SizeF TileSize, double Gap)
        {
            Hashtable ht = new Hashtable();

            double tmpH = BoxRect.Height + TileSize.Height * 2;
            double tmpW = BoxRect.Width + TileSize.Width * 2;

            List <Zones.TPolygon> TotalTiles = new List <Zones.TPolygon>();

            if (Angle45.Checked)
            {
                double step_xy = Math.Sqrt(Math.Pow((double)TileSize.Width + Gap, 2.0) + Math.Pow((double)TileSize.Height + Gap, 2.0));

                double y = 0;// TileSize.Height;
                while (y < tmpH)
                {
                    double x = 0;// TileSize.Width;
                    while (x < tmpW)
                    {
                        Zones.TPolygon pl;
                        pl = GetPlitka45(new PointF((float)x, (float)y), TileSize);
                        if (Zones.PolygonInPolygon(pl, BoxRect))
                        {
                            TotalTiles.Add(pl);
                        }
                        pl = GetPlitka45(new PointF(
                                             (float)(x - step_xy / 2.0),
                                             (float)(y + step_xy / 2.0)), TileSize);
                        if (Zones.PolygonInPolygon(pl, BoxRect))
                        {
                            TotalTiles.Add(pl);
                        }
                        x += TileSize.Width * (double)Math.Sqrt(2) + Gap;
                    }
                    ;
                    y += TileSize.Width * (double)Math.Sqrt(2) + Gap;
                }
                ;
            }
            ;

            if (Angle90.Checked)
            {
                double y = 0;// TileSize.Height;
                while (y < tmpH)
                {
                    double x = 0;// TileSize.Width;
                    while (x < tmpW)
                    {
                        Zones.TPolygon pl = GetPlitka90(new PointF((float)x, (float)y), TileSize);
                        if (Zones.PolygonInPolygon(pl, BoxRect))
                        {
                            TotalTiles.Add(pl);
                        }
                        x += TileSize.Width + Gap;
                    }
                    ;
                    y += TileSize.Height + Gap;
                }
                ;
            }
            ;

            Bitmap   b = null;
            Graphics g = null;

            if (!NoDraw.Checked)
            {
                b = new Bitmap((int)(BoxRect.Width + TileSize.Width * 2), (int)(BoxRect.Height + TileSize.Height * 2));
                g = Graphics.FromImage(b);
            }
            ;

            int        count_Black     = 0;
            int        count_Red       = 0;
            int        count_Green     = 0;
            AreasCount ac_red          = new AreasCount();
            AreasCount ac_green        = new AreasCount();
            double     DefaultTileArea = (new Zones.TPolygon(new Zones.TPoint(0, 0), TileSize)).Area;
            int        tCo             = 0;

            foreach (Zones.TPolygon CurrentTile in TotalTiles)
            {
                CurrentTile.Title = tCo++;
                Pen pen = new Pen(new SolidBrush(Color.Gray));
                if (!NoDraw.Checked)
                {
                    CurrentTile.Draw(g, pen, (int)TileSize.Width, (int)TileSize.Height);
                }
                Zones.TPolygon poly = CalcOutOfBoundsPoly(CurrentTile, BoxRect);
                if (poly != null)                             // выходит за границы
                {
                    if (poly.Area <= (DefaultTileArea / 2.0)) // меньше половины плитки
                    {
                        ac_green[poly.Area]++;
                        count_Green++;
                        pen        = new Pen(new SolidBrush(Color.Green));
                        poly.Title = CurrentTile.Title;
                        if (!NoDraw.Checked)
                        {
                            poly.Draw(g, pen, (int)TileSize.Width, (int)TileSize.Height);
                        }
                    }
                    else if (poly.Area >= (DefaultTileArea * 0.85)) // Плитка полностью входит площадь
                    {
                        count_Black++;
                        pen = new Pen(new SolidBrush(Color.Black));
                        if (!NoDraw.Checked)
                        {
                            CurrentTile.Draw(g, pen, (int)TileSize.Width, (int)TileSize.Height);
                        }
                    }
                    else // больше половины плитки
                    {
                        ac_red[poly.Area]++;
                        count_Red++;
                        pen = new Pen(new SolidBrush(Color.Red));
                        if (!NoDraw.Checked)
                        {
                            CurrentTile.Draw(g, pen, (int)TileSize.Width, (int)TileSize.Height);
                        }
                    };
                }
                ;
            }
            ;

            SolidBrush br = new SolidBrush(Color.FromArgb(80, Color.Navy));

            if (!NoDraw.Checked)
            {
                BoxRect.Draw(g, new Pen(new SolidBrush(Color.FromArgb(255, Color.Black))), (int)TileSize.Width, (int)TileSize.Height);
                pictureBox1.Image = b;
                pictureBox1.Image.Save(GetCurrentDir() + @"\Calced.bmp");
            }
            ;

            textBox9.Text  = "Черных: " + count_Black.ToString() + "\r\n";
            textBox9.Text += "   " + DefaultTileArea.ToString() + ": " + count_Black.ToString() + "\r\n";
            textBox9.Text += "Красных: " + count_Red.ToString() + "\r\n";
            foreach (double d in ac_red.Areas)
            {
                textBox9.Text += "   " + d.ToString() + ": " + ac_red[d].ToString() + "\r\n";
            }
            textBox9.Text += "Зеленых: " + count_Green.ToString() + "\r\n";
            foreach (double d in ac_green.Areas)
            {
                textBox9.Text += "   " + d.ToString() + ": " + ac_green[d].ToString() + "\r\n";
            }
        }
示例#29
0
        /** Updates the explored map to reveal the tile the party is standing on. */
        private void updateExploredMap()
        {
            var origionalValue = PerceivedTile.Value;

            bool secretDiscovered = false;

            if (PerceivedTile != null)
            {
                var character = PerceptionCharacter;

                PerceivedTile.Explored   = true;
                PerceivedTile.Water      = CurrentTile.Water;
                PerceivedTile.Pit        = CurrentTile.Pit;
                PerceivedTile.StairsUp   = CurrentTile.StairsUp;
                PerceivedTile.StairsDown = CurrentTile.StairsDown;
                PerceivedTile.Teleporter = CurrentTile.Teleporter;
                PerceivedTile.Dirt       = CurrentTile.Dirt;
                PerceivedTile.Rock       = CurrentTile.Rock;
                PerceivedTile.Chute      = CurrentTile.Chute;
                PerceivedTile.Grass      = CurrentTile.Grass;

                bool blind = false;
                if (!blind)
                {
                    // copy walls, but leave secrets alone
                    for (int lp = 0; lp < 4; lp++)
                    {
                        WallRecord wall                = new WallRecord();
                        var        actualWallRecord    = CurrentTile.getWallRecord(lp);
                        var        perceivedWallRecord = PerceivedTile.getWallRecord(lp);

                        if (actualWallRecord.Secret)
                        {
                            wall.Type = perceivedWallRecord.Secret ? WallType.Secret : WallType.Wall;
                        }
                        else
                        {
                            wall.Type = actualWallRecord.Type;
                        }

                        if (actualWallRecord.Secret && !perceivedWallRecord.Secret)
                        {
                            if (GameRules.PerceptionRoll(character, 15 + (Depth * 5)))
                            {
                                CoM.PostMessage("{0} discovered a secret door.", CoM.Format(character));
                                SoundManager.Play("OLDFX_FOUND");
                                wall.Type        = WallType.Secret;
                                secretDiscovered = true;
                            }
                        }

                        PerceivedTile.setWallRecord(lp, wall);
                    }
                }

                if (PerceivedTile.GroundValue != CurrentTile.GroundValue)
                {
                    // roll to see if we detect the difference or not
                    if (GameRules.PerceptionRoll(character, 10 + (Depth * 2)))
                    {
                        detectSquare(PerceivedTile, CurrentTile, "{0} detected that the party is standing on {1} square.", character);
                    }
                    else
                    {
                        if (GameRules.PerceptionRoll(character, (Depth)))
                        {
                            CoM.PostMessage("{0} detects something strange about this place.", CoM.Format(character));
                        }
                    }
                }
            }

            bool tileChanged = origionalValue != PerceivedTile.Value || secretDiscovered;

            if (CoM.GraphicsLoaded && tileChanged)
            {
                CoM.Instance.RefreshMapTile(LocationX, LocationY);
            }
        }
示例#30
0
    public static void UnloadAndRequestChunks()
    {
        if (!World.IsOpen)
        {
            //World is not setup yet
            //Prevents NullReferenceException
            return;
        }

        foreach (KeyValuePair <System.Tuple <int, int>, ChunkClass> Chunk in World.Chunks.ToArray())
        {
            Vector3 ChunkPos = new Vector3(Chunk.Key.Item1, 0, Chunk.Key.Item2);
            if (ChunkPos.DistanceTo(new Vector3(Game.PossessedPlayer.Translation.x, 0, Game.PossessedPlayer.Translation.z)) <= Game.ChunkRenderDistance * (World.PlatformSize * 9))
            {
                if (Self.GetTree().IsNetworkServer())
                {
                    foreach (Tile CurrentTile in Chunk.Value.Tiles)
                    {
                        CurrentTile.Show();
                    }

                    foreach (DroppedItem Item in Chunk.Value.Items)
                    {
                        Item.Show();
                    }
                }
            }
            else
            {
                List <Tile> TilesBeingRemoved = new List <Tile>();
                foreach (Tile CurrentTile in Chunk.Value.Tiles)
                {
                    if (Self.GetTree().IsNetworkServer())
                    {
                        CurrentTile.Hide();
                    }
                    else
                    {
                        TilesBeingRemoved.Add(CurrentTile);
                    }
                }
                foreach (Tile CurrentTile in TilesBeingRemoved)
                {
                    CurrentTile.Remove(Force: true);
                }

                List <DroppedItem> ItemsBeingRemoved = new List <DroppedItem>();
                foreach (DroppedItem Item in Chunk.Value.Items)
                {
                    if (Self.GetTree().IsNetworkServer())
                    {
                        Item.Hide();
                    }
                    else
                    {
                        ItemsBeingRemoved.Add(Item);
                    }
                }
                foreach (DroppedItem Item in ItemsBeingRemoved)
                {
                    Item.Remove();
                }
            }
        }


        if (!Self.GetTree().IsNetworkServer())
        {
            World.Self.RequestChunks(Self.GetTree().GetNetworkUniqueId(), Game.PossessedPlayer.Translation, Game.ChunkRenderDistance);
        }
    }