Example #1
0
    public void AddSpawnColorsData(string side = "none")
    {
        GD.Randomize();

        if (side == "none")
        {
            for (int i = 0; i < 2; i++)
            {
                int rand = (int)GD.RandRange(0, colorsData.Count);
                spawnColorsData.Add(colorsData[rand]);
                colorsData.Remove(colorsData[rand]);
            }
        }
        else if (side == "Left" && waveCount == 1)
        {
            for (int i = 0; i < 2; i++)
            {
                int rand = (int)GD.RandRange(0, colorsData.Count);
                spawnColorsData_Left.Add(colorsData[rand]);
                colorsData.Remove(colorsData[rand]);
            }
        }
        else if (side == "Right" && waveCount == 1)
        {
            for (int i = 0; i < 2; i++)
            {
                int rand = (int)GD.RandRange(0, colorsData.Count);
                spawnColorsData_Right.Add(colorsData[rand]);
                colorsData.Remove(colorsData[rand]);
            }
        }
        else if (waveCount == 3)
        {
            int rand1 = (int)GD.RandRange(0, colorsData.Count);
            spawnColorsData_Left.Add(colorsData[rand1]);
            colorsData.Remove(colorsData[rand1]);

            int rand2 = (int)GD.RandRange(0, colorsData.Count);
            spawnColorsData_Right.Add(colorsData[rand2]);
            colorsData.Remove(colorsData[rand2]);
        }

        // GD.Print("colors_data : " + colorsData);
        // GD.Print("spawn_colors_data_left " + spawnColorsData_Left);
        // GD.Print("spawn_colors_data_right " + spawnColorsData_Right);
    }
Example #2
0
    // Unequip weapon at given index
    public void UnequipItem(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        int itemIndex = GetEquipItemIndex(weaponOrder, weaponIndex);

        _agent.UnequipWeapon(weaponOrder, weaponIndex);
        _equipmentIndex.Remove((int)weaponOrder + "_" + weaponIndex);
        _usedIndex.Remove(itemIndex);

        EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex);
        EmitSignal(nameof(InventoryChangeSignal));
    }
Example #3
0
    private bool RandomConverse()                                           // Just going to make this select a target at random for now.
    {
        Godot.Collections.Array pawns = GetTree().GetNodesInGroup("Pawns"); //get a list of all pawns
        pawns.Remove(this);                                                 //remove self from said list
        // Make the just the first pawn left, if there is at least one left, the conversation target.

        return(true);

        Area2D EvaluateConverseOptions(string[] groups)
        {
            return(new Area2D());
        }
    }
Example #4
0
    public void OnCollisorExit(Area2D area)
    {
        if (tower != null && area != null && area.Owner != null)
        {
            if (tower.canShoot && targetEnemy != null && area.Owner.GetGroups().Contains("Enemy"))
            {
                EmitSignal("idleHit", enemiesInRange);
            }

            if (enemiesInRange.Contains((Enemy)area.Owner))
            {
                enemiesInRange.Remove((Enemy)area.Owner);
            }
        }

        if (enemiesInRange.Count <= 0)
        {
            onSpot = false;
        }
        checkArray();
    }
Example #5
0
    public override void _Control(float delta)
    {
        Godot.Collections.Array removeIndices = new Godot.Collections.Array();

        int index = 0;

        // Check vaild members
        foreach (Tank member in members)
        {
            if (!IsInstanceValid(member))
            {
                removeIndices.Add(index);
            }
            index++;
        }

        foreach (int removeIndex in removeIndices)
        {
            members.Remove(removeIndex);
        }

        // Set the accel
        acceleration = new Vector2();

        // Validate if target is available or is freed up (maybe no longer in scene)
        if (target != null && !IsInstanceValid(target))
        {
            target = null;
        }

        if (targetPaths != null && targetPaths.Count == 0)
        {
            targetPaths = null;
        }

        // Execute next path when target is not empty
        if (targetPaths != null && target == null)
        {
            Vector2 targetPoint = (Vector2)targetPaths[0];

            Vector2 targetDir  = (targetPoint - GlobalPosition).Normalized();
            Vector2 currentDir = (new Vector2(1, 0)).Rotated(GlobalRotation);

            GlobalRotation = currentDir.LinearInterpolate(targetDir, TurretSpeed * delta).Angle();

            if (GlobalPosition.DistanceTo(targetPoint) < PATHRADIUS)
            {
                targetPaths.RemoveAt(0);

                if (targetPaths.Count == 0)
                {
                    targetPaths = null;
                }

                slowDownBoostTrail();
            }
            else
            {
                Velocity = targetDir * MaxSpeed;

                flock();
                Velocity += acceleration;
                MoveAndSlide(Velocity);

                speedUpBoostTrail();
            }
        }

        if (target != null)
        {
            Vector2 targetDir  = (target.GlobalPosition - GlobalPosition).Normalized();
            Vector2 currentDir = (new Vector2(1, 0)).Rotated(GlobalRotation);

            GlobalRotation = currentDir.LinearInterpolate(targetDir, TurretSpeed * delta).Angle();
            if (targetDir.Dot(currentDir) > 0.9)
            {
                isPrimaryWeapon = true;
            }
            else
            {
                isPrimaryWeapon   = false;
                isSecondaryWeapon = false;
            }
        }
        else
        {
            isPrimaryWeapon   = false;
            isSecondaryWeapon = false;
        }

        if (target == null && targetPaths == null)
        {
            calculatePath();
        }
    }