Пример #1
0
        public Projectile(Actor sender, string tracerEffectName, string explosionEffectName)
        {
            this.sender = sender;
            renderElement = new RenderElement();
            renderElement.IndexBuffer = GFXPrimitives.SphereGeometry.Geometry.renderElement.IndexBuffer;
            renderElement.VertexBuffer = GFXPrimitives.SphereGeometry.Geometry.renderElement.VertexBuffer;
            renderElement.VertexCount = GFXPrimitives.SphereGeometry.Geometry.renderElement.VertexCount;
            renderElement.VertexDec = GFXPrimitives.SphereGeometry.Geometry.renderElement.VertexDec;
            renderElement.VertexStride = GFXPrimitives.SphereGeometry.Geometry.renderElement.VertexStride;
            renderElement.StartVertex = GFXPrimitives.SphereGeometry.Geometry.renderElement.StartVertex;
            renderElement.PrimitiveCount = GFXPrimitives.SphereGeometry.Geometry.renderElement.PrimitiveCount;

            projectileMaterial = ResourceManager.Inst.GetMaterial("GateMaterial");

            //tracerEffect = ResourceManager.Inst.GetParticleEffect(tracerEffectName);
            explosionEffect = ResourceManager.Inst.GetParticleEffect(explosionEffectName);
        }
Пример #2
0
 public override void OnUpdate()
 {
     base.OnUpdate();
     AcquireTarget();
     if (target != null)
     {
         Vector3 moveDir = (target.Transformation.GetPosition()-Transformation.GetPosition());
         float distToTarget = moveDir.Length();
         moveDir /= distToTarget;
         Move(moveDir);
         if (distToTarget <= killDistance)
         {
             target.ApplyDamage(999999);
             target = null;
             moveDirection = Vector3.Down + moveDir;
         }
     }
     else
     {
         if(this.Transformation.GetPosition().Y > -500)
             Move(moveDirection);
     }
 }
Пример #3
0
 void AcquireTarget()
 {
     if (target == null)
     {
         for (int i = 0; i < scene.Actors.Count; i++)
         {
             Actor currActor = scene.Actors[i];
             if (!currActor.IsDead())
             {
                 Vector3 actorPos = currActor.Transformation.GetPosition();
                 Vector3 terrainPos = scene.MainTerrain.Transformation.GetPosition();
                 Vector3 terrainSize = scene.MainTerrain.Transformation.GetScale()*2f;
                 float dist = Vector3.Distance(terrainPos * new Vector3(1, 0, 1), actorPos * new Vector3(1, 0, 1));
                 if (actorPos.Y < 6 && dist > terrainSize.X)
                 {
                     Transformation.SetPosition(actorPos - currActor.GetForwardVector()*speed*10.0f);
                     target = currActor;
                     new Sound3D("SeaMonster", Transformation.GetPosition());
                     break;
                 }
             }
         }
     }
 }
Пример #4
0
 void AcquireEnemy()
 {
     enemy = null;
     float minDist = float.PositiveInfinity;
     for (int i = 0; i < scene.Actors.Count; i++)
     {
         Actor currActor = scene.Actors[i];
         if (currActor.GetTeam() != this.GetTeam() && !currActor.IsDead())
         {
             float dist = Vector3.DistanceSquared(currActor.Transformation.GetPosition(), this.Transformation.GetPosition());
             if (dist < minDist)
             {
                 enemy = currActor;
                 minDist = dist;
             }
         }
     }
 }
Пример #5
0
        protected override void ResetState()
        {
            base.ResetState();
            wanderMovesCount = 0;
            // Unit configurations
            enemy = null;

            wanderPosition = Transformation.GetPosition();
            wanderStartPosition = wanderPosition;
            state = RaptorState.Wander;
        }
Пример #6
0
 public void AddActor(Actor entity)
 {
     Actors.Add(entity);
 }
Пример #7
0
 public void RemoveActor(Actor entity)
 {
     int index = Actors.IndexOf(entity);
     if (index >= 0)
         Actors.RemoveAt(index);
 }
Пример #8
0
 public void RemoveActor(Actor entity)
 {
     Actors.Remove(entity);
 }
Пример #9
0
 public CharacterBody(Actor actor)
     : base()
 {
     this.actor = actor;
 }
Пример #10
0
 void AcquireEnemy()
 {
     enemy = null;
     float minDist = float.PositiveInfinity;
     for (int i = 0; i < scene.Actors.Count; i++)
     {
         Actor currActor = scene.Actors[i];
         if (currActor.GetTeam() != this.GetTeam() && !currActor.IsDead())
         {
             float dist = Vector3.DistanceSquared(currActor.Transformation.GetPosition(), this.Transformation.GetPosition());
             if (dist < minDist)
             {
                 enemy = currActor;
                 minDist = dist;
             }
         }
     }
     if (enemy != null)
     {
         state = RaptorState.AquiredTarget;
         //Roar when they're spotted
         string attackAnim = datablock.GetAnimation(DinosaurAnimationsSimple.Roar);
         new Sound3D(datablock.RoarSoundEffect, this.Transformation.GetPosition());
         model.GetAnimationLayer().AddAnimation(attackAnim, true);
         animationDelay = ResourceManager.Inst.GetAnimation(attackAnim).EndTime;
     }
     else
         state = RaptorState.Wander;
 }
Пример #11
0
        protected override void ResetStates()
        {
            base.ResetStates();
            wanderMovesCount = 0;
            // Unit configurations
            enemy = null;

            wanderPosition = physicsState.position;
            wanderStartPosition = physicsState.position;
            state = EnemyState.Wander;
        }
Пример #12
0
 public override void ApplyDamage(Projectile projectile, Vector3 impulseVector)
 {
     Actor sender = projectile.GetSender();
     if (sender.GetTeam() != this.GetTeam() && !sender.IsDead())
     {
         if (enemy != null)
         {
             enemy = (enemy.GetHealth() <= sender.GetHealth()) ? enemy : sender;
         }
         else
         {
             enemy = sender;
         }
     }
     base.ApplyDamage(projectile, impulseVector);
 }