示例#1
0
 void FireOneBarrel(int sign, GameObject barrel)
 {
     if (ComSat.RateLimit())
     {
         barrel.SendMessage("Fire");
     }
     ComSat.SpawnEntity(entity, projectilePrefab,
                        entity.position, entity.rotation + turretRotation,
                        (Entity ent) => {
         var proj = ent.gameObject.GetComponent <Projectile>();
         if (proj != null && ComSat.EntityExists(combatVehicle.target))
         {
             proj.target = combatVehicle.target;
         }
     });
 }
示例#2
0
    void TickUpdate()
    {
        ComSat.Trace(this, "TickUpdate");
        if (ComSat.EntityExists(target))
        {
            var dir         = target.position - entity.position;     // also vector to dest.
            var targetAngle = DVector2.ToAngle(dir);
            var baseAngle   = Utility.CalculateNewAngle(entity.rotation, targetAngle, DReal.Radians(turnSpeed));
            entity.rotation = baseAngle;
        }
        entity.velocity = DVector2.FromAngle(entity.rotation) * speed;
        DVector2 newPosition = entity.position + entity.velocity * ComSat.tickRate;

        // FIXME: this should do something to account for hitting fast-moving projectiles.
        DVector2 hitPosition;
        Entity   hit = ComSat.LineCast(entity.position, newPosition, out hitPosition, entity.team);

        if (hit != null && (!hit.hitOnlyIfTargetted || hit == target))
        {
            hit.Damage((int)ComputeDamage());

            var position = new Vector3((float)hitPosition.y, 0, (float)hitPosition.x);
            var rotation = Quaternion.AngleAxis((float)entity.rotation, Vector3.up);
            if (impactPrefab != null && ComSat.RateLimit())
            {
                ObjectPool.Instantiate(impactPrefab, position, rotation);
            }

            //if(trail) {
            //        trail.transform.parent = null;
            //        trail.autodestruct = true;
            //        trail = null;
            //}

            if (!penetrates || speed < minPenetrationSpeed)
            {
                ComSat.DestroyEntity(entity, DestroyReason.HitTarget);
                return;
            }
            else
            {
                speed -= penetrationSpeedReduction;
            }
        }
    }
示例#3
0
    void Fire()
    {
        if (fireDelayTime > 0)
        {
            return;
        }
        // Fire left.
        fireDelayTime = barrelRecycleTime;

        if (ComSat.RateLimit())
        {
            barrel.SendMessage("Fire");
        }
        ComSat.SpawnEntity(entity, combatVehicle.projectilePrefab,
                           entity.position, entity.rotation + turretRotation,
                           (Entity ent) => {
            var proj = ent.gameObject.GetComponent <Projectile>();
            if (proj != null && ComSat.EntityExists(combatVehicle.target))
            {
                proj.target = combatVehicle.target;
            }
        });
    }