Esempio n. 1
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        RequestPathEvent.RegisterListener(GetPath);

        nav2D = GetNode <Navigation2D>("../Nav2D");
        //Get the ti;e map and the naviation map here
    }
Esempio n. 2
0
 private void Awake()
 {
     nav    = GetComponent <Navigation2D>();
     pos1  += transform.position;
     pos2  += transform.position;
     inView = false;
 }
Esempio n. 3
0
 public Move(Mob ownerMob, Mob targetMob) : base(ownerMob, targetMob, "Move")
 {
     OwnerMob      = ownerMob;
     TargetMob     = targetMob;
     NavigationMap = OwnerMob.GetNode <Navigation2D>("/root/Game/NavigationMap");
     DebugPathLine = OwnerMob.GetNode <Line2D>("/root/Game/UI/DebugPathLine");
 }
Esempio n. 4
0
    public override void _Ready()
    {
        navmesh = GetNode("NavMesh") as Navigation2D;
        tempBar = 0;

        spawnerCount = GetNode("Spawners").GetChildren().Length;
        GD.Print(spawnerCount);
    }
Esempio n. 5
0
    } = 48;                                                                //Allowable distance from player 0 on spawn

    public override void _Ready()
    {
        nav = (Navigation2D)GetNodeOrNull("Navigation2D");
        MapLoader.GetCurrentMap(true);

        //Called here due to timing issues w the MapLoader class
        MapLoader.FocusCameraAtEntry();

        GM.AddPartyToMap(this);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Navigation2D navigation2d = (Navigation2D)target;

        if (GUILayout.Button("Generate"))
        {
            navigation2d.GenererateNavGrid();
        }
    }
Esempio n. 7
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this);
         Debug.Log("Multiples instances of Navigation2D");
         return;
     }
     instance = this;
     GenererateNavGrid();
 }
Esempio n. 8
0
    public override void _Ready()
    {
        base._Ready();

        _timer       = GetNode <Timer>("Game/Timer");
        _spawner     = GetNode <Position2D>("Game/Spawner");
        _targer      = GetNode <Position2D>("Game/Target");
        _enemies     = GetNode <Node>("Game/Map");
        _navigagtion = GetNode <Navigation2D>("Game/Map/Navigation2D");

        _timer.Connect("timeout", this, nameof(OnSpawn));
    }
Esempio n. 9
0
    public override void _Ready()
    {
        this.currentHealth = this.maxHealth;
        this.nav           = GetTree().Root.GetNode <Navigation2D>("Main/Game/Navigation2D");
        this.player        = GetTree().Root.GetNode <KinematicBody2D>("Main/Game/Player");

        pathTicker = new Timer();
        // Add timer as a child to properly dispose of it when the enemy dies.
        this.AddChild(pathTicker);
        pathTicker.WaitTime = pathTickInterval;
        pathTicker.Connect("timeout", this, nameof(FindPath));
        pathTicker.Start();
    }
Esempio n. 10
0
        public override void _Ready()
        {
            Instance = this;

            EntitiesLayer      = GetNode <YSort>("Entities");
            EffectsLayer       = GetNode <YSort>("Effects");
            FloatersLayer      = GetNode <Node>("Floaters");
            Camera             = GetNode <Camera2D>("Camera2D");
            _resourcePreloader = GetNode <ResourcePreloader>("ResourcePreloader");
            _navigation        = GetNode <Navigation2D>("Navigation2D");

            UpdateNavigationMesh();
        }
Esempio n. 11
0
        public override void _Ready()
        {
            base._Ready();
            _destinations = Global.Destinations;
            _navigation2D = Global.GlobalNavigation2D;
            foreach (Position2D position2 in _destinations.GetChildren())
            {
                _possibleDestinations.Add(position2.GlobalPosition);
            }
//            _possible_destinations = new Array<Node>(_destinations.GetChildren()).ToList();
//            _possible_destinations = (from node2d in GetChildren().Cast<Node2D>() select node2d.Position).ToList();
            MakePath();
        }
Esempio n. 12
0
    public void Init(int mapIndex)
    {
        if (mapIndex == 1)
        {
            this.navigation2D = (Navigation2D)FireSnakeMapScene.Instance();
            AddChild(navigation2D);

            startingPosition      = new Vector2[2];
            startingPositionCount = 2;
            startingPosition[0]   = new Vector2(3008, 0);
            startingPosition[1]   = new Vector2(3008, -128);

            weaponUpgradeTileIndex = 20;
            shieldTileIndex        = 21;
            floorTileIndex         = 22;
        }
        else if (mapIndex == 2)
        {
            this.navigation2D = (Navigation2D)MountainMapScene.Instance();
            AddChild(navigation2D);

            startingPosition      = new Vector2[3];
            startingPositionCount = 3;
            startingPosition[0]   = new Vector2(-1408, 1664);
            startingPosition[1]   = new Vector2(-64, 1664);
            startingPosition[2]   = new Vector2(1152, 1664);

            weaponUpgradeTileIndex = 17;
            shieldTileIndex        = 18;
            floorTileIndex         = 19;
        }
        else
        {
            this.navigation2D = (Navigation2D)ThePitMapScene.Instance();
            AddChild(navigation2D);

            startingPosition      = new Vector2[4];
            startingPositionCount = 4;
            startingPosition[0]   = new Vector2(2100, 0);
            startingPosition[1]   = new Vector2(-2100, 0);
            startingPosition[2]   = new Vector2(0, 2100);
            startingPosition[3]   = new Vector2(0, -2100);

            weaponUpgradeTileIndex = 20;
            shieldTileIndex        = 21;
            floorTileIndex         = 22;
        }
        this.tileMap = navigation2D.GetNode <TileMap>("TileMap");
    }
    /* INPUT MANAGEMENT */
    public static void MapClick(Vector2 location, Navigation2D nav = null)
    {
        foreach (PlayerCharacter pc in _lcm.Selected)
        {
            pc.AttackTarget = null;

            if (nav != null)
            {
                pc.AddToPath(nav.GetSimplePath(pc.Position, location), Input.IsActionPressed("modify"));
            }
            else
            {
                pc.AddToPath(new Vector2[] { location }, Input.IsActionPressed("modify"));
            }
        }
    }
Esempio n. 14
0
        private void UpdatePath()
        {
            if (_navigation2D == null)
            {
                if (GameManager.Instance.SceneManager.CurrentLevel != null)
                {
                    _navigation2D = GameManager.Instance.SceneManager.CurrentLevel.Navigation2D;
                }
                else
                {
                    return;
                }
            }

            _path = _navigation2D.GetSimplePath(Position, GameManager.Instance.Player.Position).ToList();
        }
    public override void _Ready()
    {
        var redGoal      = GetNode <Area2D>("RedGoal");
        var blueGoal     = GetNode <Area2D>("BlueGoal");
        var blueBallDrop = GetNode <Area2D>("BlueBallDrop");
        var redBallDrop  = GetNode <Area2D>("RedBallDrop");

        BlueBallDropSpawnPoint = GetNode <Position2D>("BlueBallDrop/SpawnPoint");
        RedBallDropSpawnPoint  = GetNode <Position2D>("RedBallDrop/SpawnPoint");
        RedScorePosition       = GetNode <Position2D>("Positions/RedScorePosition");
        RedPickupPosition      = GetNode <Position2D>("Positions/RedPickupPosition");
        RedNavigation          = GetNode <Navigation2D>("RedNav");

        blueGoal.Connect("body_entered", this, nameof(OnBlueGoalBodyEntered));
        redGoal.Connect("body_entered", this, nameof(OnRedGoalBodyEntered));
        blueBallDrop.Connect("body_entered", this, nameof(OnBlueBallDropBodyEntered));
        redBallDrop.Connect("body_entered", this, nameof(OnRedBallDropBodyEntered));
    }
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        GD.Print("doing ready on " + this.Name);
        floor = GetNode("Navigation2D/TileMap") as TileMap;

        pathmaker = GetNode("Navigation2D") as Navigation2D;
        Vector2 startPoint = pathmaker.GetClosestPoint(new Vector2(25, 25));
        Vector2 endPoint   = pathmaker.GetClosestPoint(new Vector2(350, 25));

        //var difDemoPath = pathmaker.GetSimplePath(startPoint,endPoint, true) as Godot.Collections.Array<Vector2>;
        Vector2[] demoPath = pathmaker.GetSimplePath(startPoint, endPoint, true);
        GD.Print(demoPath.ToString());
        foreach (var point in demoPath)
        {
            GD.Print("raw points: " + point);
            GD.Print("tilepoints: " + floor.WorldToMap(point));
        }
        base._Ready();
    }
Esempio n. 17
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        buildObstacles();

        random     = new RandomNumberGenerator();
        gameStates = (GameStates)GetNode("/root/GAMESTATES");

        Navigation2D navigation2D = (Navigation2D)GetNode("Navigation2D");

        Input.SetCustomMouseCursor(GD.Load("res://assets/ui/blue_cross.png"), Input.CursorShape.Arrow, new Vector2(16, 16));
        //  AudioManager audioManager = (AudioManager)GetNode("/root/AUDIOMANAGER");
        //  audioManager.playMusic(musicClip);

        // After receiving and fully decoding a new snapshot, apply it to the game world
        this.Connect(nameof(SnapshotReceivedSignal), this, nameof(applySnapshot));

        network = (Network)GetNode("/root/NETWORK");
        network.Connect("DisconnectedSignal", this, nameof(onDisconnected));

        if (GetTree().IsNetworkServer())
        {
            network.Connect("PlayerRemovedSignal", this, "onPlayerRemoved");
        }

        // Spawn the players
        if (GetTree().IsNetworkServer())
        {
            aStarSolver = new RaycastAStar();
            spwanPlayer(convertToString(network.gamestateNetworkPlayer, 1));
            // The amount doesn't matter because it will be calculated in the function body
            syncBots(-1);
        }
        else
        {
            RpcId(1, nameof(spwanPlayer), convertToString(network.gamestateNetworkPlayer, -1));
        }
    }
Esempio n. 18
0
 public virtual void Awake()
 {
     nav  = GetComponent <Navigation2D>();
     anim = GetComponent <Animator>();
 }
Esempio n. 19
0
File: Enemy.cs Progetto: exts/ld44
        /**
         * We used this to get the paths from a navigation2d and then tell it where we wanted it to go.
         * Nav2D path finding is a little wonky because it ignores objects and it's best that you do something like
         * custom points for added padding. I'm sure custom coding could make this much nicer
         */
        public void old_SetPaths(Navigation2D nav, Vector2 dest)
        {
            var paths = nav.GetSimplePath(Position, dest, false);

            _paths = paths.Skip(1).Take(paths.Length - 1).ToArray();
        }
Esempio n. 20
0
    public override void _Ready()
    {
        // Called every time the node is added to the scene.
        // Initialization here
        updateHud();
        _navigation2D = GetNode <Navigation2D>("VBoxContainer/Screenbox/Ship/Navigation2D");
        //// generate character sprite nodes ////
        //base._Ready();
        var navnode    = (Node2D)GetNode("VBoxContainer/Screenbox/Ship/Navigation2D/NavigationPolygonInstance/Node2D");
        var burnButton = (Button)GetNode("VBoxContainer/HBoxContainer/VBoxContainer2/LaunchButton");

        burnButton.Connect("pressed", this, nameof(_BurnEngines));
        var buildingsButton = (Button)GetNode("VBoxContainer/HBoxContainer/VBoxContainer2/ViewBuildings");

        buildingsButton.Connect("pressed", this, nameof(_ViewBuildings));
        Texture spritetex = ResourceLoader.Load("res://char.png") as Texture;

        if (spritetex != null)
        {
            // Sprite[] _sprite = new Sprite[numChars]; // Create a new sprite!
            Area2D[] _spParent = new Area2D[numChars]; // Create a new sprite!
            Button[] _texbut   = new Button[numChars]; // Create a new sprite!
            int      i         = 0;
            Vector2  position  = new Vector2();
            Vector2  size      = new Vector2();
            size.x = 8;
            size.y = 8;
            var but = (Button)GetNode("VBoxContainer/Screenbox/Ship/Navigation2D/NavigationPolygonInstance/Node2D/CharButton");
            foreach (var c in gs.ship.Characters)
            {
                if (!c.hired)
                {
                    continue;
                }
                _spParent[i] = new Area2D();
                navnode.AddChild(_spParent[i]);
                //_spParent[i].
                _texbut[i] = new Button();
                // _sprite[i] = new Sprite();
                // _texbut[i].AddChild(_sprite[i]);
                _spParent[i].AddChild(_texbut[i]); // Add it as a child of this node.
                // CollisionShape2D _c2D = new CollisionShape2D();
                //_c2D.Scale = size;
                position.x = c.pos_x;
                position.y = c.pos_y;
                // _sprite[i].SetTexture(spritetex);
                _spParent[i].SetGlobalPosition(position);
                _spParent[i].SetPosition(position);
                _spParent[i].SetName("char_" + i);
                //GD.Print(_spParent[i].Position.x + " " + _spParent[i].Position.y);
                _texbut[i].SetName("but_" + i);
                _texbut[i].SetSize(size);
                _texbut[i].SetButtonIcon(spritetex);
                _texbut[i].Connect("pressed", this, nameof(_ClickedChar), new Godot.Collections.Array()
                {
                    i
                });
                //_spParent[i]._InputEvent(this,@event,i);
                moveNode[i] = true;
                i           = i + 1;
            }
        }
        _timer = new Timer();
        AddChild(_timer);
        _timer.Connect("timeout", this, "onTimerTimeout");
        _timer.SetWaitTime(1);
        _timer.SetOneShot(false);
        _timer.Start();
    }
 public override void _Ready()
 {
     navigation2D = GetNode <Navigation2D>("Navigation2D");
     player       = GetNode <Player>("Player");
     line2D       = GetNode <Line2D>("Line2D");
 }
Esempio n. 22
0
 public override void _Ready()
 {
     base._Ready();
     navigator = this.GetChild <Navigation2D>();
 }
    public override void _Ready()
    {
        //Viewport.

        wavePauseTimer = GetNode <Timer>("WavePauseTimer");

        wave = LoadWave(waveCount - 1);


        //ASSIGN WORLD GRID
        worldGrid = FindNode("WorldGrid") as TileMap;

        //LOAD TOWER SCENE
        towerScenes.Add("Tower", (PackedScene)ResourceLoader.Load("res://Scenes/Towers/Tower.tscn"));
        towerCosts.Add("Tower", 40);
        towerScenes.Add("Shoot", (PackedScene)ResourceLoader.Load("res://Scenes/Towers/Shoot.tscn"));
        towerCosts.Add("Shoot", 40);
        towerScenes.Add("Mortar", (PackedScene)ResourceLoader.Load("res://Scenes/Towers/Mortar.tscn"));
        towerCosts.Add("Mortar", 50);
        towerScenes.Add("Shotgun", (PackedScene)ResourceLoader.Load("res://Scenes/Towers/Shotgun.tscn"));
        towerCosts.Add("Shotgun", 60);

        //LOAD ENEMY SCENE
        enemyScenes.Add("Enemy", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/Enemy.tscn"));
        enemyScenes.Add("EnemyBig", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/EnemyBig.tscn"));
        enemyScenes.Add("Goblin", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/Goblin.tscn"));
        enemyScenes.Add("Elephant", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/Elephant.tscn"));
        enemyScenes.Add("Fast", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/Fast.tscn"));
        enemyScenes.Add("Carriage", (PackedScene)ResourceLoader.Load("res://Scenes/Enemies/Carriage.tscn"));

        //PATH FINDING
        debugLine        = FindNode("DebugLine") as Line2D;
        debugLineSnapped = FindNode("DebugLineSnapped") as Line2D;
        nav2d            = GetNode <Navigation2D>("Navigation2D");
        spawn            = GetNode <Node2D>("Spawn");
        goal             = GetNode <Node2D>("ParasitNiklas");
        path             = nav2d.GetSimplePath(spawn.GetGlobalPosition(), goal.GetGlobalPosition(), false);
        debugLine.Points = path;

        bDL = FindNode("bDL") as Line2D;

        //ALIGN PATH TO GRID
        GD.Print(path.Length);
        path = PathSnapToGrid(path);
        GD.Print(path.Length);
        debugLineSnapped.Points = path;


        money = GetTree().GetRoot().GetNode("World").FindNode("Money") as Label;
        GD.Print(money.GetName());

        health = GetTree().GetRoot().GetNode("World").FindNode("Health") as Label;
        GD.Print(health.GetName());

        EarnMoney(100);
        UpdateHealth(1000);

        Tuple <Vector2, int> tuple = BackTrackPath(path, worldGrid.MapToWorld(new Vector2(8, 6)), 24, 3);

        GD.Print("btpi: ", tuple.Item2);
    }
Esempio n. 24
0
 public override void _Ready()
 {
     PlayerToken = (WorldMapToken)GetNodeOrNull("Player");
     navigation  = (Navigation2D)GetNode("Navigation2D");
 }
Esempio n. 25
0
 public void giveNavigation2D(Navigation2D navigation2D)
 {
     this.navigation2D = navigation2D;
 }
Esempio n. 26
0
 public override void _Ready()
 {
     AnimationTree = GetNode <AnimationTree>("AnimationTree");
     AnimationMode = (AnimationNodeStateMachinePlayback)AnimationTree.Get("parameters/playback");
     _navigation2D = GetNode <Navigation2D>("/root/Map/Game/Navigation2D");
 }
Esempio n. 27
0
 public override void _Ready()
 {
     Navigation2D         = GetNode <Navigation2D>("Navigation2D");
     _ySort               = GetNode <YSort>("YSort");
     _playerSpawnPosition = GetNode <Node2D>("PlayerSpawn").GlobalPosition;
 }