Exemple #1
0
    public EffectCollision(Player a, Player b, Map m)
        : base(m)
    {
        position     = a.Position + (b.Position - a.Position) * 0.5f;
        lineRotation = TKMath.GetAngle(a.Position, b.Position);
        rotation     = lineRotation + 45;

        m.AddEffect(new EffectRing(position, 4f, 0.7f, Color.White, m));

        spikeMesh = new Mesh();
        lineMesh  = new Mesh();

        spikeMesh.Vertices2 = new Vector2[] {
            new Vector2(-0.5f, 0f),
            new Vector2(-0.3f, 0.5f),
            new Vector2(-0.3f, -0.5f),
            new Vector2(0.5f, 0f)
        };

        lineMesh.Vertices2 = new Vector2[] {
            new Vector2(0, 0.5f),
            new Vector2(-0.4f, 0f),
            new Vector2(0.4f, 0f),
            new Vector2(0, -0.5f)
        };
    }
Exemple #2
0
    public EffectLine(Vector2 pos1, Vector2 pos2, float startWidth, float endWidth, float duration, Color c, Map m)
        : base(m)
    {
        origin = pos1;
        target = pos2;

        this.startWidth = startWidth;
        this.endWidth   = endWidth;

        mesh = new Mesh(mesh.Vertices = new Vector3[] {
            new Vector3(-0.5f, -0.5f * startWidth, 0f),
            new Vector3(-0.5f, 0.5f * startWidth, 0f),
            new Vector3(0.5f, -0.5f * endWidth, 0f),
            new Vector3(0.5f, 0.5f * endWidth, 0f)
        });

        mesh.Color = c;
        mesh.Reset();

        Vector2 lenVector = target - origin;

        mesh.Translate(origin);
        mesh.RotateZ(TKMath.GetAngle(lenVector));
        mesh.Scale(new Vector2(lenVector.Length, 1));
        mesh.Translate(0.5f, 0);

        effectTimer = new Timer(duration, false);
    }
Exemple #3
0
 public TowerBullet(Actor owner, int id, Vector2 position, Vector2 target, Map map)
     : base(owner, id, position, map)
 {
     size     = new Vector2(0.8f, 0.8f);
     velocity = (target - position).Normalized() * 60f;
     angle    = TKMath.GetAngle(velocity);
 }
Exemple #4
0
    public override void Draw()
    {
        base.Draw();

        CTFFlag flag = Map.flags[Team.id];

        if ((!flag.IsInBase || flag.holder != null) && IsLocalPlayer)
        {
            Vector2 flagPosition = flag.holder == null ? flag.Position : flag.holder.Position;
            float   dis          = (flagPosition - Position).Length;
            Color   c            = Team.Color;
            c.A = MathHelper.Clamp((dis - 7f) / 2f, 0, 1);

            arrowMesh.Color = c;

            arrowMesh.Reset();

            arrowMesh.Translate(position);
            arrowMesh.Rotate(TKMath.GetAngle(flagPosition - position));
            arrowMesh.Translate(Math.Min(7f, (flagPosition - position).Length), 0f);
            arrowMesh.Scale(0.7f);

            arrowMesh.Draw();
        }
    }
Exemple #5
0
    public override void Hit(Actor a)
    {
        hitActor = a;

        a.Hit(Damage, TKMath.GetAngle(velocity), this, 50f);
        Hit(a.Position);
    }
Exemple #6
0
    public override void Logic()
    {
        if (effectTimer.IsDone)
        {
            Remove();
        }

        effectTimer.Logic();

        Color c = defaultColor;

        c.A          = (1f - effectTimer.PercentageDone);
        sprite.Color = c;

        sprite.SetTransform(position, size, TKMath.GetAngle(velocity));

        if (!active)
        {
            return;
        }

        base.Logic();

        velocity.Y -= Stats.defaultStats.Gravity * Game.delta;
        position   += velocity * Game.delta;

        if (map.GetCollision(position, new Vector2(0.01f, 0.01f)))
        {
            active   = false;
            velocity = Vector2.Zero;
        }
    }
Exemple #7
0
    public override void Hit()
    {
        EffectCone.CreateSmokeCone(position, TKMath.GetAngle(velocity), 0.4f + 0.6f * charge, 0.8f, 3, 1, Map);
        Map.AddEffect(new EffectRing(position, 1.6f + charge * 1.5f, 0.5f + 0.5f * charge, Color.White, Map));

        base.Hit();
    }
        public override void Enable(Vector2 pos)
        {
            startAngle   = TKMath.GetAngle(pos - Origin);
            rotateOrigin = Origin;

            base.Enable(pos);
        }
Exemple #9
0
    public void DrawArrow()
    {
        ShadowPosition current   = CurrentPosition;
        float          direction = TKMath.GetAngle(player.Position, current.position),
                       distance  = MathHelper.Clamp((player.Position - current.position).Length, 0f, 6f) / 20f;

        Color c = player.Color;

        c.A = 0.4f;

        circleMesh.Color = c;
        arrowMesh.Color  = c;

        #region Circle
        GL.Enable(EnableCap.StencilTest);

        GL.StencilMask(0xff);
        GL.Clear(ClearBufferMask.StencilBufferBit);

        GL.StencilFunc(StencilFunction.Never, 1, 0xff);
        GL.StencilOp(StencilOp.Replace, StencilOp.Keep, StencilOp.Keep);

        circleMesh.Reset();
        circleMesh.Translate(player.Position);
        circleMesh.RotateZ(direction);
        circleMesh.Translate(-distance, 0f);
        circleMesh.Scale(2.2f - distance * 1.5f);

        circleMesh.Draw();

        GL.StencilFunc(StencilFunction.Notequal, 1, 0xff);
        GL.StencilOp(StencilOp.Incr, StencilOp.Keep, StencilOp.Incr);

        circleMesh.Reset();
        circleMesh.Translate(player.Position);
        circleMesh.Scale(2f);

        circleMesh.RotateZ(direction);

        circleMesh.Draw();

        #endregion
        distance = distance * 3f - 0.5f;

        GL.StencilFunc(StencilFunction.Notequal, 1, 0xff);

        if (distance > 0)
        {
            arrowMesh.Reset();
            arrowMesh.Translate(player.Position);
            arrowMesh.RotateZ(direction);
            arrowMesh.Translate(0.9f, 0);
            arrowMesh.Scale(distance, 0.5f);

            arrowMesh.Draw();
        }

        GL.Disable(EnableCap.StencilTest);
    }
Exemple #10
0
    public override void Logic()
    {
        SearchTarget();

        if (target != null)
        {
            if (!target.IsAlive || !TargetInArea(target))
            {
                SetTarget(null);
            }
            else
            {
                float targetDir = TKMath.GetAngle(TurretPosition, target.Position);

                float dif = targetDir - aimDir;

                while (dif > 180)
                {
                    dif -= 360;
                }
                while (dif < -180)
                {
                    dif += 360;
                }

                aimDir += dif * TurnSpeed * Game.delta;
                aimDir  = TKMath.Mod(aimDir, -180, 180);

                if (ammo <= 0)
                {
                    reloadTimer.Logic();

                    if (reloadTimer.IsDone)
                    {
                        ammo = MaxAmmo;
                        reloadTimer.Reset();
                    }
                }
                else
                {
                    shootTimer.Logic();

                    if (shootTimer.IsDone)
                    {
                        if (!Map.RayTraceCollision(TurretPosition, target.Position, Vector2.Zero))
                        {
                            Shoot();
                            shootTimer.Reset();
                        }
                    }
                }
            }
        }
        else
        {
            aimDir += 25f * Game.delta;
        }
    }
Exemple #11
0
    public void HitArea(Vector2 position)
    {
        List <Actor> actors = Map.GetActorRadius <Actor>(position, 2f, hitActor);

        foreach (Actor a in actors)
        {
            a.Hit(Damage / 2, TKMath.GetAngle(position, a.Position), owner, 25f);
        }
    }
Exemple #12
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 #13
0
 public override void Draw()
 {
     if (!Active)
     {
         return;
     }
     sprite.Draw(position,
                 size * new Vector2(1f + velocity.Length / 20f, 1f - velocity.Length / 60f),
                 TKMath.GetAngle(velocity));
 }
Exemple #14
0
    public Bullet(Actor a, int id, Vector2 bsize, Vector2 position, Vector2 target, Map m)
        : base(a, id, position, m)
    {
        directionVector = (target - position).Normalized();
        direction       = TKMath.GetAngle(directionVector);

        velocity = directionVector * Stats.defaultStats.BulletVelocity;

        size       = new Vector2(0.1f, 0.1f);
        bulletSize = bsize;
    }
Exemple #15
0
    public override void Logic()
    {
        //base.Logic();
        SYPlayer p = Map.GetActorAtPos <SYPlayer>(Position, Size);

        if (p != null && p.VulnerableToCreep)
        {
            p.Hit(ImpactDamage, TKMath.GetAngle(Position, p.Position), this, ImpactForce);
            p.HitByCreep();
        }
    }
Exemple #16
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 #17
0
    public void DashStep()
    {
        dashTarget.timeTraveled += Game.delta;

        Vector2 direction   = dashTarget.Direction;
        float   speedFactor = TKMath.Exp(Math.Max(0, 0.4f - dashTarget.timeTraveled * 10), 2f, 20);

        Vector2 stepSize = direction * speedFactor * stats.DashVelocity * Game.delta;

        if (stepSize.Length > (dashTarget.endPosition - Position).Length)
        {
            DashEnd();
            return;
        }

        Vector2 stepTarget = Position + stepSize;

        //Check for players
        List <Actor> actorCol = Map.RayTraceActor <Actor>(Position, stepTarget, Size * 1.8f, this);

        if (actorCol.Count > 0)
        {
            foreach (Actor a in actorCol)
            {
                if (a is Player)
                {
                    Player p = a as Player;

                    if (p.IsDashing)
                    {
                        DashEnd((Player)actorCol[0]);
                        ((Player)actorCol[0]).DashEnd(this);

                        SendDashCollisionToPlayer((Player)actorCol[0], Map.playerList);

                        return;
                    }
                    else if (!p.IsDodging && !AlliedWith(p))
                    {
                        a.Hit(p.MaxHealth, TKMath.GetAngle(direction), this);
                    }
                }
                else
                {
                    a.Hit(a.MaxHealth, TKMath.GetAngle(direction), this);
                }
            }
        }

        Position += stepSize;
    }
    public override void Draw()
    {
        mesh.Reset();

        Vector2 lenVector = target - origin;

        float w = TKMath.Exp(effectTimer.PercentageDone, 5);

        mesh.Translate(origin);
        mesh.RotateZ(TKMath.GetAngle(lenVector));
        mesh.Scale(new Vector2(lenVector.Length, w));

        mesh.Draw();
    }
Exemple #19
0
    public void DodgeStep()
    {
        dodgeTarget.timeTraveled += Game.delta;
        Vector2 dir = dodgeTarget.DirectionVector;

        float speedFactor = TKMath.Exp(Math.Max(0, 0.4f - dodgeTarget.timeTraveled * 5), 2f, 30);

        Vector2 step = dir * stats.DodgeVelocity * speedFactor * Game.delta;

        //Stepping
        if ((dodgeTarget.direction == Direction.Right || dodgeTarget.direction == Direction.Left) && Map.GetCollision(this, step))
        {
            float stepSizeFactor = stats.StepSize * step.Length;

            if (!Map.GetCollision(this, step + new Vector2(0, stepSizeFactor)))
            {
                int   accuracy     = 16;
                float currentStep  = 0;
                float testStepSize = stepSizeFactor / accuracy;

                for (int i = 0; i < accuracy; i++)
                {
                    if (Map.GetCollision(this, step + new Vector2(0, currentStep)))
                    {
                        currentStep += testStepSize;
                    }
                    else
                    {
                        break;
                    }
                }

                step.Y += currentStep;
            }
        }

        Vector2 collisionPosition;
        bool    collision = Map.RayTraceCollision(Position, Position + step, Size, out collisionPosition, this);

        step = collisionPosition - Position;

        dodgeTarget.stepLength = speedFactor;
        dodgeTarget.stepAngle  = TKMath.GetAngle(step);

        Position = collisionPosition;
        if (dodgeTarget.TargetReached(Position) || collision)
        {
            DodgeEnd();
        }
    }
Exemple #20
0
        public ArrowTrace(Vector2 start, Vector2 end, float startsize, float endsize, Map map)
            : base(map)
        {
            mesh = new Mesh(new Vector2[] {
                new Vector2(0, 0.5f * startsize),
                new Vector2(1, 0.5f * endsize),
                new Vector2(1, -0.5f * endsize),
                new Vector2(0, -0.5f * startsize)
            });

            mesh.Reset();

            mesh.Translate(start);
            mesh.RotateZ(TKMath.GetAngle(start, end));
            mesh.Scale((end - start).Length, 0.1f);
        }
Exemple #21
0
    public override void Hit()
    {
        Map.AddEffect(new EffectRing(position, 6f, 1.2f, Color.White, Map));
        EffectCone.CreateSmokeCone(position, TKMath.GetAngle(velocity), 1.2f, 1f, 4, 5, Map);

        Random rng = new Random();

        for (int i = 0; i < 2; i++)
        {
            float size = 0.5f + (float)rng.NextDouble() * 0.3f;
            float dir  = ((float)rng.NextDouble() - 0.5f) * 45f;

            Map.AddEffect(new EffectRockSmoke(position, TKMath.GetAngle(velocity) + 180 + dir, size, Map));
        }

        base.Hit();
    }
Exemple #22
0
            public void Logic()
            {
                Vector2 pos    = manipulator.Origin;
                Vector2 normal = manipulator.Active ? manipulator.scaleNormal : manipulator.Normal;
                float   angle  = TKMath.GetAngle(normal) - 90;

                centerButton.Position = pos;
                centerButton.Rotation = angle;
                xAxisButton.Position  = pos + normal.PerpendicularRight * Editor.camera.Position.Z * 0.1f;
                xAxisButton.Rotation  = angle - 90;
                yAxisButton.Position  = pos + normal * Editor.camera.Position.Z * 0.1f;
                yAxisButton.Rotation  = angle;

                centerButton.Logic();
                xAxisButton.Logic();
                yAxisButton.Logic();
            }
    public override void Logic()
    {
        if (effectTimer.IsDone)
        {
            Remove();
        }

        float w = TKMath.Exp(effectTimer.PercentageDone, 5);

        mesh.Reset();
        mesh.Translate(a);
        mesh.RotateZ(TKMath.GetAngle(a, b));
        mesh.Scale((b - a).Length, w);

        effectTimer.Logic();

        base.Logic();
    }
        public override void Manipulate()
        {
            float angle = TKMath.GetAngle(MouseInput.Current.Position - rotateOrigin) - startAngle;

            if (KeyboardInput.Current[Key.LControl])
            {
                angle /= 22.5f;

                angle = (float)Math.Round(angle);

                angle *= 22.5f;
            }

            foreach (Vertex v in editor.selectedList)
            {
                v.RotateTo(rotateOrigin, angle + TKMath.GetAngle(vertexOffsetList[v]));
            }

            base.Manipulate();
        }
Exemple #25
0
    public override void Logic()
    {
        if (target != null)
        {
            float targetDir = TKMath.GetAngle(TurretPosition, target.Position);

            float dif = targetDir - aimDir;

            while (dif > 180)
            {
                dif -= 360;
            }
            while (dif < -180)
            {
                dif += 360;
            }

            aimDir += dif * TurnSpeed * Game.delta;
            aimDir  = TKMath.Mod(aimDir, -180, 180);

            if (ammo <= 0)
            {
                reloadTimer.Logic();
                if (reloadTimer.IsDone)
                {
                    ammo = 5;
                }
            }
        }
        else
        {
            aimDir += 25f * Game.delta;
        }

        barrelPosition -= barrelPosition * 5f * Game.delta;

        headSprite.Rotation = aimDir;
    }
Exemple #26
0
 public override void Hit(Actor a)
 {
     a.Hit(Damage, TKMath.GetAngle(velocity), this);
 }
Exemple #27
0
        public void Rotate(Vector2 origin, float delta)
        {
            float currentAngle = TKMath.GetAngle(position - origin) + delta;

            RotateTo(origin, currentAngle);
        }
Exemple #28
0
 public virtual void Hit(Actor a)
 {
     Hit(a.Position);
     a.Hit(damage, TKMath.GetAngle(velocity), this);
 }
Exemple #29
0
 public DashTarget(Vector2 a, Vector2 b)
 {
     startPosition = a;
     endPosition   = b;
     angle         = TKMath.GetAngle(a, b);
 }