Exemple #1
0
    void CreateDieExplosion()
    {
        Random  rng      = new Random();
        Vector2 position = TKMath.GetAngleVector((float)rng.NextDouble() * 360f) * ((float)rng.NextDouble() * size.X * 0.5f);

        EffectExplosion.CreateExplosion(Position + position, 0.8f, Map);
    }
Exemple #2
0
    public EffectPlayerHit(Player p, float dir, float size, Map m)
        : base(m)
    {
        size = MathHelper.Clamp(size, 0.2f, 2f);

        tileset = new Tileset(p.playerTileset);

        mesh         = new Mesh(p.sprite.Mesh.Vertices, p.sprite.Mesh.UV);
        mesh.Tileset = p.playerTileset;

        mesh.Reset();

        mesh.Translate(p.Position);
        mesh.Scale(p.Size);
        mesh.Scale(2f);

        mesh.Scale(p.dir, 1);

        mesh.FillColor = true;

        EffectCone.CreateBloodCone(p.Position, dir, 45f, (int)(20 * size), map);
        EffectCone.CreateBloodCone(p.Position, dir, 360f, (int)(10 * size), map);

        /*
         * Random rng = new Random();
         * Vector2 ringPos = new Vector2((float)rng.NextDouble() - 0.5f,
         *      (float)rng.NextDouble() - 0.5f);
         * map.AddEffect(new EffectRing(p.position + ringPos, 2f + 2f * size, 0.7f, Color.White, map));
         *///NO RING PLZ

        Vector2 spikeDir = TKMath.GetAngleVector(dir) * 2 * size;

        map.AddEffect(new EffectSpike(p.Position - spikeDir, p.Position + spikeDir,
                                      2f * size, 0.4f, Color.White, map));
    }
Exemple #3
0
    public EffectEnemyHit(SYCreep enemy, float dir, float size, Map m)
        : base(m)
    {
        size = MathHelper.Clamp(size, 0.2f, 2f);

        mesh = new Mesh(enemy.sprite.Mesh.Vertices, enemy.sprite.Mesh.UV);

        mesh.FillColor = true;
        mesh.Texture   = enemy.sprite.Texture;

        mesh.ModelMatrix = enemy.sprite.Mesh.ModelMatrix;
        mesh.Scale(1.2f);

        /*
         * Random rng = new Random();
         * Vector2 ringPos = new Vector2((float)rng.NextDouble() - 0.5f,
         *      (float)rng.NextDouble() - 0.5f);
         * map.AddEffect(new EffectRing(enemy.position + ringPos, 2f + 2f * size, 0.7f, Color.White, map));
         *///NO RING PLZ

        Vector2 spikeDir = TKMath.GetAngleVector(dir) * 2 * size;

        map.AddEffect(new EffectSpike(enemy.Position - spikeDir, enemy.Position + spikeDir,
                                      2f * size, 0.4f, Color.White, map));
        map.AddEffect(new EffectImpactQuad(enemy.Position, size, map));
    }
Exemple #4
0
    public override Projectile CreateProjectile(Vector2 target)
    {
        float dir = TKMath.GetAngle(owner.Position, target);

        dir = dir + (float)(rng.NextDouble() - 0.5) * 5f;

        target = owner.Position + TKMath.GetAngleVector(dir);

        return(new Bullet(owner, owner.Position, target, damage, map));
    }
Exemple #5
0
    public void DropAt(Vector2 pos)
    {
        float angle = (float)rng.NextDouble() * 360f;
        float velo  = 15f + (float)rng.NextDouble() * 15f;

        Position = pos;
        velocity = TKMath.GetAngleVector(angle) * velo;

        SendExistanceToPlayer(Map.playerList);
    }
Exemple #6
0
    void Shoot()
    {
        float   dir       = TKMath.GetAngle(Position, target.Position) + (float)(rng.NextDouble() - 0.5f) * 20f;
        Vector2 targetPos = Position + TKMath.GetAngleVector(dir);

        Projectile p = new SlowBullet(this, Position, targetPos, ProjectileDamage, Map);

        velocity = (targetPos - Position) * -1 * Recoil;
        SendPositionToPlayer(Map.playerList);
        SendShootToPlayer(targetPos, p, Map.playerList);
    }
Exemple #7
0
    public virtual void Hit(float dmg, float dir, Actor a, float force = 0)
    {
        Hit(dmg);
        if (force != 0)
        {
            velocity = TKMath.GetAngleVector(dir) * force;
        }

        if (!IsAlive)
        {
            KilledBy(a);
        }
    }
Exemple #8
0
    void Shoot()
    {
        if (target == null)
        {
            return;
        }

        Vector2    dirVec = TKMath.GetAngleVector(aimDir);
        Projectile p      = new TowerBullet(this, TurretPosition + dirVec * 1.2f, TurretPosition + dirVec * 5f, 2f, Map);

        SendShootToPlayer(TurretPosition + dirVec * 5f, p, Map.playerList);
        ammo--;
    }
Exemple #9
0
    public virtual void Hit(float dmg, float dir, Projectile proj, float force = 0)
    {
        Hit(dmg);
        if (force != 0)
        {
            velocity = TKMath.GetAngleVector(dir) * force;
        }

        if (!IsAlive)
        {
            KilledBy(proj.Owner);
        }
    }
Exemple #10
0
    public EffectRockSmoke(Vector2 position, float direction, float size, Map m)
        : base(m)
    {
        this.position = position;
        position     += velocity * Game.delta * 4;

        smokeSize  = (float)rng.NextDouble() * 0.5f + 0.5f;
        smokeSize *= size;

        velocity = TKMath.GetAngleVector(direction) * 25 * smokeSize;

        effectTimer.Reset(smokeSize);
    }
    public EffectSmoke(Vector2 position, float size, float time, float floatDirection, float velocity, Color color, Map m)
        : base(m)
    {
        this.position = position;

        this.color = color;
        direction  = TKMath.GetAngleVector(floatDirection);
        speed      = velocity;
        smokeSize  = size;

        sprite = new Sprite(Art.Load("Res/circlebig.png"));

        smokeTimer.Reset(time);

        Logic();
    }
    public static void CreateBloodCone(Vector2 position, float direction, float spread, int nmbr, Map map)
    {
        //Splatters
        for (int i = 0; i < nmbr; i++)
        {
            Vector2 pos = new Vector2(
                ((float)rng.NextDouble()) * 2f - 1f,
                ((float)rng.NextDouble()) * 2f - 1f) * 0.4f;

            float dir   = ((float)rng.NextDouble() - .5f) * spread + direction;
            float size  = 0.4f - ((float)rng.NextDouble() * .3f);
            float color = 0.8f - ((float)rng.NextDouble() * 0.3f);
            float velo  = 10f + (30f - size * 3f) * (float)rng.NextDouble();

            map.AddEffect(new EffectBlood(position + pos, size, TKMath.GetAngleVector(dir) * velo, map));
        }
    }
Exemple #13
0
    void GenerateMesh(int resolution)
    {
        Vector2[] vectors = new Vector2[resolution];

        for (int i = 0; i < resolution; i++)
        {
            float angle = i / (float)resolution * 360f;
            vectors[i] = TKMath.GetAngleVector(angle);
        }

        mesh.GetAttribute <Vector2>("position").Data = vectors;

        crossMesh.GetAttribute <Vector2>("position").Data = new Vector2[]
        {
            new Vector2(-0.2f, 0f),
            new Vector2(0.2f, 0f),
            new Vector2(0f, 0.2f),
            new Vector2(0f, -0.2f)
        };
    }
Exemple #14
0
    public void Drop()
    {
        if (holder == null)
        {
            return;
        }

        base.Position = holder.Position + new Vector2(0, 2f);
        velocity      = TKMath.GetAngleVector(90 + ((float)Map.rng.NextDouble() - 0.5f) * 2 * 70f) * 10f;
        holder        = null;

        MessageBuffer msg = new MessageBuffer();

        msg.WriteShort((short)Protocol.MapArgument);
        msg.WriteShort((short)Protocol_CTF.FlagDropped);
        msg.WriteByte(ownerID);

        msg.WriteVector(base.Position);
        msg.WriteVector(velocity);

        Map.SendToAllPlayers(msg);
    }
Exemple #15
0
    public void Logic()
    {
        List <Vector2> vectorList = new List <Vector2>(10);
        float          angle      = progress * fillAngle,
                       part = fillAngle / 8;

        vectorList.Add(new Vector2(0, 0));
        vectorList.Add(TKMath.GetAngleVector(startAngle));

        for (int i = 0; i < 9; i++)
        {
            if (Math.Abs(angle) > Math.Abs(part * i))
            {
                vectorList.Add(TKMath.PolarPointVector(part * i + startAngle, 4));
            }
            else
            {
                vectorList.Add(TKMath.PolarPointVector(angle + startAngle, 4));
                break;
            }
        }

        stencilMesh.Vertices2 = vectorList.ToArray();
    }
Exemple #16
0
        public void RotateTo(Vector2 origin, float angle)
        {
            float distance = (position - origin).Length;

            position = origin + TKMath.GetAngleVector(angle) * distance;
        }
Exemple #17
0
 public void Drop()
 {
     position = holder.Position + new Vector2(0, 2f);
     velocity = TKMath.GetAngleVector(90 + ((float)Map.rng.NextDouble() - 0.5f) * 70f) * 20f;
     holder   = null;
 }