示例#1
0
        private Visual GetIndicatorVisual(GameObject TargetObject, Vector focus, Vector viewSize)
        {
            int backWidth = GameProcess.Current_Game.gameMap.TileSize;

            int backHeight = 10;
            int fillPadding = 1;

            DrawingVisual visual = new DrawingVisual();

            double percents = TargetObject.Life;

            int fillWidth = (int)((backWidth - fillPadding) * percents / 100);

            Vector position = CalculatePositionOnCanvas(TargetObject.AbsoluteCenter, viewSize, focus);

            Point rBackPoint = new Point(position.X - backWidth / 2, position.Y - backHeight / 2 - backWidth / 2);
            Point rFillPoint = new Point(rBackPoint.X + fillPadding, rBackPoint.Y + fillPadding);

            Rect rectBack = new Rect(rBackPoint, new Size(backWidth, backHeight));
            Rect rectFill = new Rect(rFillPoint, new Size(fillWidth, backHeight - fillPadding * 2));


            using (DrawingContext dc = visual.RenderOpen())
            {
                dc.DrawRectangle(IndicatorBackBrush, IndicatorBorderPen, rectBack);
                dc.DrawRectangle(IndicatorFillBrush, IndicatorBorderPen, rectFill);
            }

            return visual;
        } 
示例#2
0
        public LifeIndicator(GameObject gameObject, Int32 showtime)
        {
            TargetObject = gameObject;

            ShowTime = showtime;
            RestTime = showtime;

            //RestLife = TargetObject.Life;
        }
示例#3
0
        public override void Collide(GameObject gameObject, System.Windows.Vector direction, double overlap)
        {
                long summWeight = gameObject.GetWeight() + this.GetWeight();

                this.LocalCenter -= direction * overlap * (gameObject.GetWeight() / summWeight);
               // MessageBox.Show("dd");

       

            Damage(overlap * 2);
        }
示例#4
0
        /// <summary>
        /// Set component by type
        /// </summary>
        /// <param name="nObj"></param>
        public void SetComponentByType(GameObject nObj)
        {
            nObj.Parent = this;

            for (int i = 0; i < components.Count; i++)
            {
                if (components[i].GetType() == nObj.GetType())
                {
                    components[i] = nObj;

                    return;
                }
            }

            this.AddComponent(nObj);

            if (ComponentsUpdated != null)
                ComponentsUpdated(this);
        }       
示例#5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gObject"></param>
 public void TryRemoveIndicator (GameObject gObject)
 {
     LifeIndicators.RemoveAll(x => x.TargetObject == gObject);
 }
示例#6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gObject"></param>
        public void IndicateLifeChange(GameObject gObject)
        {
            foreach (LifeIndicator indicator in LifeIndicators)
            {
                if (indicator.TargetObject.Equals(gObject))
                {
                    indicator.Reset();

                    return;
                }
            }

            LifeIndicators.Add(new LifeIndicator(gObject, 1000));
        }
示例#7
0
 /// <summary>
 /// This metod returns game objects to draw from map grid. When target object is in
 /// allowable sector, camera doesn't move. Otherway, it moves.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void UpdateFocus(GameObject gObject)
 {
     this.Focus = new Vector(UpdateFocusX(gObject.AbsoluteCenter.X), UpdateFocusY(gObject.AbsoluteCenter.Y));
 }
示例#8
0
 public override bool Contains(GameObject obj)
 {
     return this.Equals(obj);
 }
示例#9
0
 public override void Collide(GameObject gameObject, Vector direction, double overlap)
 {
     Crash();
     //base.Collide(gameObject, direction, overlap);
 }
示例#10
0
文件: Tank.cs 项目: Vlad7/TanksStory
        public override void Collide(GameObject gameObject, Vector direction, double overlap)
        {
            if (gameObject.Name != "bullet")
            {
                ///
                LocalCenter += direction * overlap * 1.2;
                Engine.translateSpeed = new Vector(Engine.translateSpeed.X / 2, Engine.translateSpeed.Y / 2);
                ///
            }
            else
            {

                if(this.Name.ToLower() =="player")
                    Damage(overlap * 0.1);
                else
                    Damage(overlap * 0.5);
            }
        }
示例#11
0
 public void RegisterObject(GameObject gameObject)
 {
     //if(!chekingObjects.Contains(gameObject))
         chekingObjects.Add(gameObject);
 }
示例#12
0
 /// <summary>
 /// This method check if this object contains someone primitive
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public abstract Boolean Contains(GameObject obj);
示例#13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Contains(GameObject obj)
        {
            if (this.Equals(obj)) return true;

            foreach (GameObject gObj in components)
            {
                if (gObj.Contains(obj)) return true;
            }

            return false;         
        }
示例#14
0
        /// <summary>
        /// Remove one component
        /// </summary>
        /// <param name="gObj"></param>
        public void RemoveComponent(GameObject gObj)
        {
            components.Remove(gObj);

            if (ComponentsUpdated != null)
                ComponentsUpdated(this);
        }
示例#15
0
        /// <summary>
        /// Add new component
        /// </summary>
        /// <param name="gObj"></param>
        public void AddComponent(GameObject gObj)
        {
            components.Add(gObj);

            if (ComponentsUpdated != null)
                ComponentsUpdated(this);
        }
示例#16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="direction"></param>
 /// <param name="overlap"></param>
 public virtual void Collide(GameObject gameObject, Vector direction, double overlap)
 {
     
 }
示例#17
0
        public override void Collide(GameObject gameObject, System.Windows.Vector direction, double overlap)
        {
            base.Collide(gameObject, direction, overlap);

            Damage(overlap);
        }
示例#18
0
 public void UnRegisterObject(GameObject gameObject)
 {
     chekingObjects.Remove(gameObject);
 }