예제 #1
0
        public void AnnexHex(Hex hex)
        {
            //Check if already owns this
            if (hexList.Contains(hex))
            {
                return;
            }

            if (hex.getOwner() != null)
            {
                hex.getOwner().CedeHex(hex);
            }

            hexList.Add(hex);
            hex.setOwner(this);
            CalculateBorders();
        }
예제 #2
0
        private void TweenToNewLocation(GameTime gameTime)
        {
            //Face direction of new tile
            this.rotation = Core.Maths.GetRotationFromVec3(this.position, currentWaypoint.position);

            Vector3 normal = currentWaypoint.position - position;

            normal.Normalize();

            position += normal * (float)gameTime.ElapsedGameTime.TotalSeconds * Clock.timeCompression * currentWaypoint.hexData.GetMovementModifier();

            if (Vector3.Distance(currentWaypoint.position, position) < 0.2f)
            {
                //If we have reached our destination
                if (waypoints.Count() == waypoints.IndexOf(currentWaypoint) + 1)
                {
                    //Were there!
                    this.position = hexMovingTo.position;
                    hex           = hexMovingTo;
                    hexMovingTo   = null;
                    waypoints.Clear();
                    currentWaypoint = null;

                    //Check if we should be sieging
                    if (hex.getOwner() == null || hex.getOwner() != this.owner)
                    {
                        StartCapture();
                    }
                }
                else
                {
                    //Else keep on moving
                    currentWaypoint = waypoints[waypoints.IndexOf(currentWaypoint) + 1];
                    this.hex        = currentWaypoint;
                }
            }
        }