示例#1
0
        public void Kill()
        {
            if (this.PowerLevel >= rand.NextDouble())
            {
                // We survive! WOO!
                return;
            }

            // We die! NOO!
            this.isDead = true;
            SoundsController.playSound("Celldeath", this.position);
            UnitController.MarkUnitAsDead(this);
        }
        override protected bool stopMovingIfGoalIsReached()
        {
            // If we are reasonably close to baseEntity.
            float   distance = float.MaxValue;
            Vector2 here     = position;
            Vector2 there    = targetPosition;

            Vector2.Distance(ref here, ref there, out distance);

            if (distance == 0.0f)
            {
                if (MissionEntity != null)
                {
                    // If this is an enemy! KILL IT! OMG
                    if (MissionEntity.owner != this.owner)
                    {
                        if (MissionEntity is Unit && !((Unit)MissionEntity).isDead)
                        {
                            this.Kill();
                            ((Unit)MissionEntity).Kill();
                            SoundsController.playSound("Celldeath", this.position);
                        }
                    }

                    MissionEntity = null;
                }
            }
            if (MissionEntity == null || MissionEntity is Unit && ((Unit)MissionEntity).isDead)
            {
                this.Kill();
                SoundsController.playSound("Celldeath", this.position);
                return(true);
            }

            return(false);
        }