コード例 #1
0
ファイル: GameCanvas.cs プロジェクト: Vlad7/TanksStory
        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
ファイル: LifeIndicator.cs プロジェクト: Vlad7/TanksStory
        public LifeIndicator(GameObject gameObject, Int32 showtime)
        {
            TargetObject = gameObject;

            ShowTime = showtime;
            RestTime = showtime;

            //RestLife = TargetObject.Life;
        }
コード例 #3
0
ファイル: WoodBox.cs プロジェクト: Vlad7/TanksStory
        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
ファイル: CompositeObject.cs プロジェクト: Vlad7/TanksStory
        /// <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
ファイル: Camera.cs プロジェクト: Vlad7/TanksStory
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gObject"></param>
 public void TryRemoveIndicator (GameObject gObject)
 {
     LifeIndicators.RemoveAll(x => x.TargetObject == gObject);
 }
コード例 #6
0
ファイル: Camera.cs プロジェクト: Vlad7/TanksStory
        /// <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
ファイル: Camera.cs プロジェクト: Vlad7/TanksStory
 /// <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
ファイル: PrimitiveObject.cs プロジェクト: Vlad7/TanksStory
 public override bool Contains(GameObject obj)
 {
     return this.Equals(obj);
 }
コード例 #9
0
ファイル: Bullet.cs プロジェクト: Vlad7/TanksStory
 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
ファイル: CollisionManager.cs プロジェクト: Vlad7/TanksStory
 public void RegisterObject(GameObject gameObject)
 {
     //if(!chekingObjects.Contains(gameObject))
         chekingObjects.Add(gameObject);
 }
コード例 #12
0
ファイル: GameObject.cs プロジェクト: Vlad7/TanksStory
 /// <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
ファイル: CompositeObject.cs プロジェクト: Vlad7/TanksStory
        /// <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
ファイル: CompositeObject.cs プロジェクト: Vlad7/TanksStory
        /// <summary>
        /// Remove one component
        /// </summary>
        /// <param name="gObj"></param>
        public void RemoveComponent(GameObject gObj)
        {
            components.Remove(gObj);

            if (ComponentsUpdated != null)
                ComponentsUpdated(this);
        }
コード例 #15
0
ファイル: CompositeObject.cs プロジェクト: Vlad7/TanksStory
        /// <summary>
        /// Add new component
        /// </summary>
        /// <param name="gObj"></param>
        public void AddComponent(GameObject gObj)
        {
            components.Add(gObj);

            if (ComponentsUpdated != null)
                ComponentsUpdated(this);
        }
コード例 #16
0
ファイル: GameObject.cs プロジェクト: Vlad7/TanksStory
 /// <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
ファイル: BrickBlock.cs プロジェクト: Vlad7/TanksStory
        public override void Collide(GameObject gameObject, System.Windows.Vector direction, double overlap)
        {
            base.Collide(gameObject, direction, overlap);

            Damage(overlap);
        }
コード例 #18
0
ファイル: CollisionManager.cs プロジェクト: Vlad7/TanksStory
 public void UnRegisterObject(GameObject gameObject)
 {
     chekingObjects.Remove(gameObject);
 }