Defines a object with a lifespan, sounds and damage for the collision of physical bodies, and management of influences.
Inheritance: MapObject
Exemple #1
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnRelatedEntityDelete(Entity)"/></summary>
        protected override void OnRelatedEntityDelete( Entity entity )
        {
            base.OnRelatedEntityDelete( entity );

            if( targetTask == entity )
                targetTask = null;

            //remove deleted weapon
            Weapon weapon = entity as Weapon;
            if( weapon != null )
                unitWeapons.Remove( weapon );
        }
 public AttackTask( Weapon weapon, Dynamic target )
 {
     this.weapon = weapon;
     this.targetPosition = new Vec3( float.NaN, float.NaN, float.NaN );
     this.targetEntity = target;
 }
 //
 public AttackTask( Weapon weapon, Vec3 target )
 {
     this.weapon = weapon;
     this.targetPosition = target;
     this.targetEntity = null;
 }
        void DoAttackTask( Weapon weapon, Dynamic target )
        {
            AttackTask task = attackTasks.Find( delegate( AttackTask t )
            {
                return t.Weapon == weapon;
            } );

            if( task != null && task.TargetEntity == target )
                return;

            if( task != null )
                ResetAttackTask( task );

            task = new AttackTask( weapon, target );
            AddRelationship( target );
            attackTasks.Add( task );
        }
        void ControlledObject_Damage( Dynamic entity, MapObject prejudicial, Vec3 pos, float damage )
        {
            if( generalTaskType != GeneralTaskTypes.Battle && prejudicial != null )
            {
                Unit sourceUnit = null;

                Bullet bullet = prejudicial as Bullet;
                if( bullet != null )
                    sourceUnit = bullet.SourceUnit;
                Explosion explosion = prejudicial as Explosion;
                if( explosion != null )
                    sourceUnit = explosion.SourceUnit;

                if( sourceUnit != null )
                {
                    Intellect unitIntellect = sourceUnit.Intellect as Intellect;
                    if( unitIntellect != null && unitIntellect.Faction != Faction )
                    {
                        //do battle task
                        DoGeneralTask( GeneralTaskTypes.Battle, null );

                        //move to enemy
                        DoMoveTask( sourceUnit.Position );

                        //notify allies
                        NotifyAlliesOnEnemy( sourceUnit.Position );
                    }
                }
            }
        }
Exemple #6
0
 public Task( Types type, Dynamic entity )
 {
     this.type = type;
     this.position = new Vec3( float.NaN, float.NaN, float.NaN );
     this.entityType = null;
     this.entity = entity;
 }
Exemple #7
0
 public Task( Types type, Vec3 position, DynamicType entityType )
 {
     this.type = type;
     this.position = position;
     this.entityType = entityType;
     this.entity = null;
 }
Exemple #8
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnRelatedEntityDelete(Entity)"/></summary>
        protected override void OnRelatedEntityDelete( Entity entity )
        {
            base.OnRelatedEntityDelete( entity );

            if( taskMove.Dynamic == entity )
                taskMove.dynamic = null;
            if( taskAttack == entity )
                taskAttack = null;
            if( forceTaskMove.Dynamic == entity )
                forceTaskMove.dynamic = null;
            if( forceTaskAttack == entity )
                ForceTaskAttack = null;
        }
Exemple #9
0
 public Task( Types type )
 {
     this.type = type;
     this.position = new Vec3( float.NaN, float.NaN, float.NaN );
     this.entityType = null;
     this.entity = null;
 }
 void GamePlacard_Damage( Dynamic entity, MapObject prejudicial, Vec3 pos, float damage )
 {
     if( gameTime == 0 )
         GameStart();
 }
Exemple #11
0
 public DamageItem( Dynamic dynamic, Vec3 position, float damage )
 {
     this.dynamic = dynamic;
     this.position = position;
     this.damage = damage;
 }
Exemple #12
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnRelatedEntityDelete(Entity)"/></summary>
        protected override void OnRelatedEntityDelete( Entity entity )
        {
            base.OnRelatedEntityDelete( entity );

            if( sourceUnit == entity )
                sourceUnit = null;
            if( reasonObject == entity )
                reasonObject = null;
        }
Exemple #13
0
 public TaskMoveValue( Dynamic dynamic )
 {
     this.position = new Vec3( float.NaN, float.NaN, float.NaN );
     this.dynamic = dynamic;
 }
Exemple #14
0
 public TaskMoveValue( Vec3 position )
 {
     this.position = position;
     this.dynamic = null;
 }
        void CopyInfluencesToObject( Dynamic destination )
        {
            foreach( Entity child in Children )
            {
                if( child.IsSetDeleted )
                    continue;

                Influence influence = child as Influence;
                if( influence == null )
                    continue;

                Influence i = (Influence)Entities.Instance.Create( influence.Type, destination );
                i.RemainingTime = influence.RemainingTime;
                i.PostCreate();
            }
        }
        void UpdateTask()
        {
            Unit newTarget = null;
            float newTargetPriority = 0;

            //find target
            {
                float radius = ControlledObject.ViewRadius;

                Map.Instance.GetObjects( new Sphere( ControlledObject.Position, radius ),
                    GameFilterGroups.UnitFilterGroup, delegate( MapObject mapObject )
                {
                    Unit obj = (Unit)mapObject;

                    //check by distance
                    Vec3 diff = obj.Position - ControlledObject.Position;
                    float objDistance = diff.LengthFast();
                    if( objDistance > radius )
                        return;

                    float priority = GetAttackObjectPriority( obj );
                    if( priority != 0 && priority > newTargetPriority )
                    {
                        newTarget = obj;
                        newTargetPriority = priority;
                    }
                } );
            }

            //update targetTask
            if( newTarget != targetTask )
            {
                if( targetTask != null )
                    RemoveRelationship( targetTask );
                targetTask = newTarget;
                if( targetTask != null )
                    AddRelationship( targetTask );
            }
        }
Exemple #17
0
 public Task( Types type, Vec3 position )
 {
     this.type = type;
     this.position = position;
     this.entityType = null;
     this.entity = null;
 }