示例#1
0
 public void shoot(Vector2 end)
 {
     bulletPath.ClearPoints();
     bulletPath.AddPoint(ZERO);
     bulletPath.AddPoint(end);
     particles2D.Position = end;
     bulletAnimationPlayer.Play("Shoot");
 }
示例#2
0
    [Signal] public delegate void ordersDone(); //Orden completada ejecutados


    ////////////////////////////////////////////  METODOS
    public override void _Ready()
    {
        spPropietarioIndicator = GetNode("spColorPlayer") as Sprite;
        tmZone       = GetNode("TmZone") as TileMap;
        line2D       = GetNode("Line2D") as Line2D;
        baseNode     = GetNode("base") as Node2D;
        animation    = GetNode("base/AnimationPlayer") as AnimationPlayer;
        lblHitPoints = GetNode("lblHitPoints") as Label;
        hpBarr       = GetNode("BarHp") as Control;
        crLevelHp    = GetNode("BarHp/crLevel") as ColorRect;
        crMaxSize    = crLevelHp.RectSize.x;

        //init idle
        animation.CurrentAnimation = "Idle";
        animation.PlaybackSpeed    = (1.9f + (float)GD.RandRange(0.0f, 0.2f));

        //anim scale
        initScale = baseNode.Scale;

        //line
        line2D.Visible = true;
        line2D.ClearPoints();

        //Color player actual

        //ready
        movePoints = maxMovePoints;
        hp         = hpMax;
    }
示例#3
0
 public void clearZones()
 {
     if (line2D != null)
     {
         line2D.ClearPoints();
     }
     if (tmZone != null)
     {
         tmZone.Clear();
     }
     if (firezone != null)
     {
         firezone = new Vector2[0];
         Update();
     }
 }
示例#4
0
    public override void _Process(float delta)
    {
        float ropeNotUsed = ropeLength - p1.Position.DistanceTo(p2.Position);


        base._Process(delta);
        ropeDraw.ClearPoints();
        ropeDraw.AddPoint(p1.Position);

        for (int i = 1; i < ropePoints; i++)
        {
            float lerpVal = (float)i / (float)ropePoints;

            //	GD.Print("Lerp val : " + lerpVal);
            //	GD.Print("From " + i + " /" + ropePoints);
            Vector2 tempPoint = vec2Lerp(p2.Position, p1.Position, lerpVal);
            if (lerpVal >= 0.5f)
            {
                tempPoint.y += ropeNotUsed * -(lerpVal - 1) * lerpVal;
                //GD.Print("Adjusted Lerp val : " + (-(lerpVal - 1)));
            }
            else
            {
                tempPoint.y += ropeNotUsed * lerpVal * -(lerpVal - 1);
            }
            ////GD.Print("Temp point loc : " + tempPoint);
            ropeDraw.AddPoint(tempPoint);
        }

        ropeDraw.AddPoint(p2.Position);
    }
示例#5
0
    private void UpdateZap()
    {
        const int signCost = 50;

        int sign = Mathf.Sign(velocity.x);

        if (sign == 0)
        {
            sign = lastMoveSign;
        }
        else
        {
            lastMoveSign = sign;
        }

        protonLine.ClearPoints();
        closest = null;

        // A proton is only reachable if it's in range of the circle's area + any number
        float closestDist = Mathf.Pi * ZapDistance * ZapDistance + 0.69420f;

        foreach (Proton body in protonField.GetOverlappingAreas())
        {
            float dist = GlobalPosition.DistanceTo(body.GlobalPosition);

            // prioritize protons in the movement direction
            Vector2 dir = GlobalPosition.DirectionTo(body.GlobalPosition);
            if (dir.x * sign > 0)
            {
                dist -= signCost;
            }

            if (Mathf.Abs(dist) < closestDist && body != prevProton)
            {
                protonRay.CastTo = ToLocal(body.GlobalPosition);
                if (protonRay.IsColliding())
                {
                    continue;
                }
                closestDist = dist;
                closest     = body;
            }
        }
    }
示例#6
0
    public override void _Ready()
    {
        _line = (Line2D)GetNode("Line");

        _line.Gradient = _gradientColor;
        _line.ClearPoints();

        _random = new Godot.RandomNumberGenerator();

        _tween = (Tween)GetNode("Decray");

        _line.GlobalPosition = Vector2.Zero;
        _line.GlobalRotation = 0;
        _line.Width          = _width;
    }
 private void DrawGraph(Godot.Collections.Array dataArray, Line2D line, int speciesCreationTime)
 {
     if (line.Visible)
     {
         line.ClearPoints();
         for (int i = 0; i < dataArray.Count; i++)
         {
             Vector2 NewPoint;
             if (i == speciesCreationTime + 1)
             {
                 Vector2 creationPoint = (Vector2) new Vector2((i + 1) * 1350 / dataArray.Count, 520);
                 line.AddPoint(creationPoint);
             }
             if (i == 0)
             {
                 if (MaxYvalue != 0)
                 {
                     NewPoint = (Vector2) new Vector2(10, 520 - (float)dataArray[i] * 520f / MaxYvalue);
                 }
                 else
                 {
                     NewPoint = (Vector2) new Vector2(10, 520);
                 }
             }
             else
             {
                 if (MaxYvalue != 0)
                 {
                     NewPoint = (Vector2) new Vector2((i + 1) * 1350 / dataArray.Count, 520 - (float)dataArray[i] * 520f / MaxYvalue);
                 }
                 else
                 {
                     NewPoint = (Vector2) new Vector2((i + 1) * 1350 / dataArray.Count, 520);
                 }
             }
             line.AddPoint(NewPoint);
         }
     }
 }
示例#8
0
    public void Control(float delta)
    {
        _pathLine.GlobalRotation = 0;

        // If not reloading, then set to default
        if (_agent.RightWeaponAction != (int)GameStates.PlayerInput.InputAction.RELOAD)
        {
            _agent.RightWeaponAction = (int)GameStates.PlayerInput.InputAction.NOT_TRIGGER;
        }
        if (_agent.LeftWeaponAction != (int)GameStates.PlayerInput.InputAction.RELOAD)
        {
            _agent.LeftWeaponAction = (int)GameStates.PlayerInput.InputAction.NOT_TRIGGER;
        }

        Godot.Collections.Array pathPoints = null;

        switch (_currentState)
        {
        case State.PATROL:
            if (!_patrolReached)
            {
                pathPoints = _pathFinding.GetPath(GlobalPosition, _patrolLocation);

                if (pathPoints.Count > 1)
                {
                    Vector2 nextPoint = (Vector2)pathPoints[1];
                    _agent.RotateToward(nextPoint, delta);
                    _agent.MoveToward(_agent.GlobalPosition.DirectionTo(nextPoint), delta);
                    _setPathLine(pathPoints);
                }
                else
                {
                    _patrolReached = true;
                    _patrolTimer.Start();
                    _pathLine.ClearPoints();
                }
            }

            break;

        case State.ENGAGE:
            if (_targetAgent != null && IsInstanceValid(_targetAgent))
            {
                _agent.RotateToward(_targetAgent.GlobalPosition, delta);

                // Calculate rotation
                float angelToTargetAgent = _agent.GlobalPosition.DirectionTo(_targetAgent.GlobalPosition).Angle();

                // Only start fire when agent is closely faced to its target agent (around Pi / 4)
                if (Mathf.Abs(_agent.GlobalRotation - angelToTargetAgent) < 0.8f)
                {
                    _agent.RightWeaponAction = (int)GameStates.PlayerInput.InputAction.TRIGGER;
                    _agent.LeftWeaponAction  = (int)GameStates.PlayerInput.InputAction.TRIGGER;
                }

                // Chanse engaged agent closer if possible
                if (_agent.GlobalPosition.DistanceTo(_targetAgent.GlobalPosition) > 600.0f)
                {
                    _agent.MoveToward(_agent.GlobalPosition.DirectionTo(_targetAgent.GlobalPosition), delta);
                }
            }
            else
            {
                _checkTarget();
            }
            break;

        case State.ADVANCE:

            pathPoints = _pathFinding.GetPath(GlobalPosition, _nextBasePosition);

            if (pathPoints.Count > 1)
            {
                Vector2 nextPoint = (Vector2)pathPoints[1];
                _agent.RotateToward(nextPoint, delta);
                _agent.MoveToward(_agent.GlobalPosition.DirectionTo(nextPoint), delta);
                _setPathLine(pathPoints);
            }
            else
            {
                SetState(State.PATROL);
                _pathLine.ClearPoints();
            }
            break;

        default:
            break;
        }
    }