示例#1
0
 public static void SendSignal(string name, params object[] vars)
 {
     if (events.ContainsKey(name) == true)
     {
         events[name].Invoke(vars);
     }
 }
示例#2
0
    public int GetEquipItemIndex(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        int index = -1;

        if (_equipmentIndex.ContainsKey((int)weaponOrder + "_" + weaponIndex))
        {
            index = _equipmentIndex[(int)weaponOrder + "_" + weaponIndex];
        }

        return(index);
    }
示例#3
0
 public void updateNotify()
 {
     if (_allowedMaterials.ContainsKey(_currentMaterial) && isEnable)
     {
         EmitSignal(nameof(ColorChanged));
     }
 }
 public void ClosePort(RoadConnectorSide side_from, RoadConnectorSide side_to)
 {
     if (!connectedPorts.ContainsKey(side_from.GetPath()))
     {
         connectedPorts.Add(side_from.GetPath(), side_to.GetPath());
     }
 }
示例#5
0
    private void _onObstacleDestroy(String obstacleName)
    {
        if (GetTree().NetworkPeer == null || GetTree().IsNetworkServer())
        {
            if (_obstacles.ContainsKey(obstacleName))
            {
                _obstacles.Remove(obstacleName);
            }

            _obstaclesDestroyed.Add(obstacleName);

            destroyObstacle(obstacleName);

            Rpc(nameof(destroyObstacle), obstacleName);
        }
    }
示例#6
0
    public override void _Process(float delta)
    {
        if (footStepTimer <= 0)
        {
            if ((Vector3)player.Get("direction") != Vector3.Zero && feet.IsColliding())
            {
                // Get collided body group name
                Godot.Collections.Array collidedGroups = ((Node)feet.GetCollider()).GetGroups();

                foreach (String group in collidedGroups)
                {
                    if (footStepList.ContainsKey(group))
                    {
                        Node footStepNode = footStepList[group];
                        if (footStepNode.GetChildCount() > 0)
                        {
                            // Play audio
                            int randomIndex           = (int)GD.RandRange(0, footStepNode.GetChildCount() - 1);
                            AudioStreamPlayer3D audio = (AudioStreamPlayer3D)footStepNode.GetChild(randomIndex);
                            audio.Play();

                            // Sync player speed with audio loop
                            footStepTimer = (1 - (0.06f * (float)player.Get("normalSpeed")));
                            break;
                        }
                    }
                }
            }
        }
        else
        {
            footStepTimer -= delta;
        }
    }
示例#7
0
//*-------------------------------------------------------------------------*//

    #region GODOT METHODS

    #endregion

//*-------------------------------------------------------------------------*//

    #region INTERFACE IMPLEMENTATION

    public void Enter_State(Godot.Collections.Dictionary <string, object> pParam)
    {
        if (pParam.ContainsKey("target_global_position"))
        {
            _target_GlobalPosition = (Vector2)pParam["target_global_position"];
        }

        if (pParam.ContainsKey("velocity"))
        {
            _velocity = (Vector2)pParam["velocity"];
        }

        if (pParam.ContainsKey("velocity_multiplier"))
        {
            _velocity_multiplier = (float)pParam["velocity_multiplier"];
        }
    }
示例#8
0
    public void AddAgent(Agent agent)
    {
        if (!_agents.ContainsKey(agent.GetUnitName()))
        {
            Sprite agentMarker = (Sprite)_agentMarker.Duplicate();
            agentMarker.Name = agent.GetUnitName() + "_marker";

            agentMarker.Modulate = Team.TeamColor[(int)agent.GetCurrentTeam()];

            _grid.AddChild(agentMarker);

            // Add agent to dictonary
            _agents.Add(agent.GetUnitName(), agent);

            // Add marker to dictionary
            _agentMarkers.Add(agent.GetUnitName(), agentMarker);
        }
    }
示例#9
0
    public bool checkObstacles(Vector2 input)
    {
        TileMap tilemap         = (TileMap)GetNode("Navigation2D/Ground");
        Vector2 tileMapPosition = tilemap.WorldToMap(input);

        float xIndex = tileMapPosition.x;
        float yIndex = tileMapPosition.y;

        // Align to the cell deployment (2 x 2 index size)
        if (xIndex % 2 != 0)
        {
            xIndex = xIndex - 1;
        }
        if (yIndex % 2 != 0)
        {
            yIndex = yIndex - 1;
        }

        return(obstacles.ContainsKey("obstacle_" + xIndex + "_" + yIndex));
    }
示例#10
0
 private void _onDetectionZoneBodyEntered(Node body)
 {
     if (body.HasMethod(nameof(Agent.GetCurrentTeam)) && body != _agent)
     {
         // If not same team identifier, identify as target
         if (((Agent)body).GetCurrentTeam() != _agent.GetCurrentTeam())
         {
             Agent agent = (Agent)body;
             if (_targetAgent == null)
             {
                 _targetAgent = agent;
                 SetState(State.ENGAGE);
             }
             // Save as list of future target
             if (!_targetAgents.ContainsKey(agent.GetUnitName()))
             {
                 _targetAgents.Add(agent.GetUnitName(), agent.GetCurrentTeam());
             }
         }
     }
 }
示例#11
0
//*-------------------------------------------------------------------------*//

    #region INTERFACE IMPLEMENTATION

    public void Enter_State(Godot.Collections.Dictionary <string, object> pParam)
    {
        _timer.Connect("timeout", this, nameof(_on_Timer_Timeout));

        // Get the direction from Air state
        if (pParam.ContainsKey("direction"))
        {
            _direction = (Vector2)pParam["direction"];
        }

        _timer.Start();
    }
示例#12
0
//*-------------------------------------------------------------------------*//

    #region INTERFACE IMPLEMENTATION

    public void Enter_State(Godot.Collections.Dictionary <string, object> pParam)
    {
        _moveNode.Enter_State(pParam);

        // Just after starting a straight jump, allow the character to move on x axis in the air
        //      If 0.0f => the player jump, then cannot move on x axis until landing on the ground
        _moveNode.Acceleration.x = Acceleration_X;

        // To preserve the character inertia in the air
        if (pParam.ContainsKey("velocity"))
        {
            _moveNode.Velocity   = (Vector2)pParam["velocity"];     // to override the default velocity
            _moveNode.MaxSpeed.x = Mathf.Max(Mathf.Abs(_moveNode.Velocity.x), _moveNode.MaxSpeed_Default.x);
        }

        // To make the player jump
        if (pParam.ContainsKey("impulse"))
        {
            //_moveNode.Velocity += Utils.CalculateJumpVelocity(_moveNode.Velocity, _moveNode.MaxSpeed, (float)pParam["impulse"]);
            _Movement_Jump();
        }
    }
示例#13
0
    public void CreatureGet(Creature creature, int cost, string name)
    {
        PickupCreatureAudio.Play();
        if (!CreaturesCaught.ContainsKey(name))
        {
            GD.Print("Couldn't find:" + name + " setting to 1.");
            CreaturesCaught.Add(name, 1);
        }
        else
        {
            var current = CreaturesCaught[name];
            current++;

            CreaturesCaught[name] = current++;
            GD.Print("New value: " + current);

            GD.Print("Did find:" + name + " setting to " + CreaturesCaught[name]);
        }

        if (!CreaturesCost.ContainsKey(name))
        {
            CreaturesCost[name] = cost;
        }

        GD.Print("Hook retracting due to creature get!");

        HasCreature     = true;
        CurrentCreature = creature;
        var oldParent = GetParent();

        oldParent.RemoveChild(creature);

        HookLaunch.Stop(Hook);
        HookChainLaunch.Stop(this);
        Hook.AddChild(creature);
        creature.GlobalPosition = Hook.GlobalPosition;
        RetractHook();
    }