Exemplo n.º 1
0
        /// <summary>
        /// Creates Unit target overlays, showing players where Units are headed.
        /// </summary>
        private void CreateUnitTargetOverlays()
        {
            ForEach(obj => {
                Tile t = obj as Tile;

                // If there is a Unit on this Tile and their target is not where they are
                if (t.Occupied && t.Unit.TargetPosition != t.Unit.PositionInGrid)
                {
                    // Make a UnitTargetOverlay for this and add it to the list of overlays
                    TargetPositionOverlay uto = new TargetPositionOverlay(t.Unit);
                    unitTargets.Add(uto);
                }
            });
        }
Exemplo n.º 2
0
        public override void Update(GameTime time)
        {
            base.Update(time);

            // Updates the Unit target overlay
            unitTargets.Update(time);
            hitEffectList.Update(time);

            // Remove unitTargets that are done
            unitTargets.ForEach(obj => {
                TargetPositionOverlay uto = obj as TargetPositionOverlay;

                if (uto.Finished)
                {
                    unitTargets.RemoveChild(obj);
                }
            });

            //If we have a selected unit; if there is a path to follow, we start walking using Walk(), otherwise we move to target location
            if (walkingUnits.Count > 0)
            {
                for (int i = walkingUnits.Count - 1; i >= 0; --i)
                {
                    WalkingUnit walkingUnit = walkingUnits[i];
                    if (walkingUnit.MovingUnit.Vectors.Count > 0)
                    {
                        Walk(walkingUnit.MovingUnit, walkingUnit.MovingUnit.Vectors[0]);
                    }
                    else
                    {
                        OnUnitFinishMoving(walkingUnit);
                        walkingUnits.Remove(walkingUnit);
                    }
                }
            }
        }