Exemple #1
0
 public void _OnBulletBodyEnter(Godot.Object body)
 {
     if (body.HasMethod("HitByBullet"))
     {
         body.Call("HitByBullet");
     }
 }
Exemple #2
0
        public static int RegisterInstanceTracker(InstanceTracker tracker, Object target)
        {
            var id = (int)_gdInstance.Call("inject_instance_tracker", target);

            _gdInstance.Connect("instance_tracker_freed", tracker, InstanceTracker.OnFreedMethod);
            return(id);
        }
Exemple #3
0
    public void Plant(Node requester, Dictionary data, Godot.Object optional)
    {
        Vector3 translation = (Vector3)data[3];

        translation.y = inactiveTranslation.y;
        plantDataList.Clear();

        if (this.Call <bool>(levelManager,
                             this.GetMethodContainsEmptyBlockSlot(), translation))
        {
            Array <Spatial> laserDeviceList = availableLaserDeviceMap[data[0] as string];

            if (laserDeviceList.Count > 0)
            {
                Spatial laserDevice = laserDeviceList[0];
                laserDevice.Translation = translation;
                laserDevice.Call(this.GetMethodSetCharacter(), requester);
                laserDevice.Call(this.GetMethodSetLaserRayLevel(), data[1]);
                laserDevice.Call(this.GetMethodSetDetonateTimeLevel(), data[2]);
                laserDevice.Call(this.GetMethodPlant());

                levelManager.Call(this.GetMethodRemoveEmptyBlockSlot(), laserDevice.Translation);
                laserDeviceList.Remove(laserDevice);
                plantDataList.Add(laserDevice);
            }
        }

        optional.Call(this.GetMethodSet(), plantDataList);
    }
Exemple #4
0
 public bool Matches(Godot.Object gdObject, string methodName)
 {
     return(
         (int)gdObject.Call("get_instance_id") == objectReferenceId &&
         this.methodName.Equals(methodName)
         );
 }
        public static bool CallOrNull(this Object obj, string method, out object result, params object[] args)
        {
            var o = obj.HasMethod(method);

            result = o ? obj.Call(method, args) : null;
            return(o);
        }
    public static T Call <T>(this Godot.Object gdobj, Godot.Object caller,
                             string methodName, params object[] args)
    {
        T   response = default(T);
        int length   = args != null ? args.Length : 0;

        object[] newArgs = new object[length + 1];
        System.Array.Copy(args, 0, newArgs, 0, length);
        Optional optional = new Optional();

        newArgs[length] = optional;
        caller.Call(methodName, newArgs);

        if (!optional.IsDataReceived())
        {
            if (OS.IsDebugBuild())
            {
                StringBuilder msg = new StringBuilder(methodName);
                msg.Append("() called by ");
                msg.Append(caller.GetType().ToString()).Append(" from ");
                msg.Append(gdobj.GetType().ToString());
                msg.Append(" could not return a value!");
                GD.PushWarning(msg.ToString());
            }
        }
        else
        {
            response = optional.Get <T>();
        }

        // This fix abusive usage of Game.Objects causing a lot of memory leaks.
        optional.Free();
        return(response);
    }
Exemple #7
0
    /// <summary>
    /// Initialization
    /// </summary>
    public override void _Ready()
    {
        GDScript MyGDScript = (GDScript)GD.Load("res://API/Toast.gd");

        Godot.Object myGDScriptNode = (Godot.Object)MyGDScript.New(); // This is a Godot.Object
        myGDScriptNode.Call("displayToast");
    }
Exemple #8
0
//  // Called every frame. 'delta' is the elapsed time since the previous frame.
//  public override void _Process(float delta)
//  {
//
//  }
    /// <summary>
    /// Sets the viewport's camera to the perspective specified by the button press id
    /// passed by the button connection signal.
    /// </summary>
    /// <param name = "id">The PerspectiveTypeEmun value for the camera perspective associated with the toolbar button</param>
    ///
    private void toolbarChangePerspective(int id)
    {
        currentPerspective = (PerspectiveType)id;
        Node tmp = this.GetNode("../Viewport/Camera/CameraObj");

        GD.Print(tmp.Name);
        GD.Print(tmp.GetType());
        Godot.Camera tmp2 = (Godot.Camera)tmp;

        Godot.Camera subCam  = (Godot.Camera)GetNode("../Viewport/Camera/CameraObj");
        Script       gdClass = ResourceLoader.Load("res://src/CameraObj.gd") as Script;
        Object       gdCam   = new Object();

        gdCam = (Godot.Object)gdClass.Call("new");
        gdCam.SetScript(gdClass);


        switch (currentPerspective)
        {
        case PerspectiveType.Front:

            //GD.Print(subCam.GetClass() + subCam.GetFilename());

            Vector3 newLook = new Vector3(5, 1, 0);
            subCam.LookAtFromPosition(newLook, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            gdCam.Call("_update_mouselook");
            gdCam.Call("_update_movement");
            break;

        case PerspectiveType.Back:
            //subCam = GetNode<Camera>("../Viewport/Camera/CameraObj");
            newLook = new Vector3(-5, 1, 0);
            subCam.LookAtFromPosition(newLook, new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            gdCam.Call("_update_mouselook");
            gdCam.Call("_update_movement");
            break;

        case PerspectiveType.Orthogonal:
            //subCam = GetNode<Camera>("../Viewport/Camera/CameraObj");
            subCam.SetOrthogonal(3, 1, 10);
            gdCam.Call("_update_mouselook");
            gdCam.Call("_update_movement");
            break;

        case PerspectiveType.NOrthogonal:
            subCam.Projection = 0;
            gdCam.Call("_update_mouselook");
            gdCam.Call("_update_movement");
            break;

        default:
            GD.Print("Unrecognized Menu Item");
            break;
        }
    }
Exemple #9
0
 public void IsValidDataMap(Dictionary dataMap,
                            Array keyList, string gameMode, Godot.Object optional)
 {
     if (ContainsAllKeys(dataMap, keyList))
     {
         optional.Call(this.GetMethodSet(),
                       GetGameplayAC(dataMap, gameMode).Equals(dataMap["ac"] as string));
     }
 }
 public static bool TryCall(this Object obj, string method, params object[] args)
 {
     if (!obj.HasMethod(method))
     {
         return(false);
     }
     obj.Call(method, args);
     return(true);
 }
Exemple #11
0
    public void Get(string key, Godot.Object optional)
    {
        object value;

        if (globalDataMap.TryGetValue(key, out value))
        {
            optional.Call(this.GetMethodSet(), value);
        }
    }
Exemple #12
0
        public static Dictionary WasEmitted(Object emitter, string signal, string context)
        {
            var passed = $"Signal {signal} was emitted from {emitter}";
            var failed = $"Signal {signal} was not emitted from {emitter}";

            var watcher = (Reference)emitter.Call("get_meta", "watcher");
            var success = (int)watcher.Call("get_emit_count", signal) > 0;
            var result  = success ? passed : failed;

            return(Result(success, passed, result, context));
        }
Exemple #13
0
    /// <summary>
    /// Handles the logic whenever the Logout button is pressed
    /// </summary>
    private void _on_LogoutBtn_pressed()
    {
        GDScript fb     = (GDScript)GD.Load("res://API/Facebook.gd");
        GDScript google = (GDScript)GD.Load("res://API/Google.gd");

        if (Global.GoogleLoggedIn)
        {
            Godot.Object googleScript = (Godot.Object)google.New(); // This is a Godot.Object
            googleScript.Call("google_connect");
            googleScript.Call("google_disconnect");
        }
        else if (Global.FbLoggedIn)
        {
            Godot.Object fbScript = (Godot.Object)fb.New(); // This is a Godot.Object
            fbScript.Call("facebook_connect");
            fbScript.Call("logout");
        }

        GetTree().ChangeScene("res://Presentation/Login/Login.tscn");
    }
Exemple #14
0
    public void GetAllAsList(Godot.Object optional)
    {
        Array list = new Array();

        SCG.IEnumerator <SCG.KeyValuePair <string, object> > it =
            globalDataMap.GetEnumerator();

        while (it.MoveNext())
        {
            list.Add(it.Current.Value);
        }

        optional.Call(this.GetMethodSet(), list);
    }
Exemple #15
0
    public void GetGameplayDataMap(string gameMode, Godot.Object optional)
    {
        Dictionary dataMap = Get1PGameplayDataMap(gameMode);

        if (dataMap == null)
        {
            dataMap = Get2PGameplayDataMap(gameMode);
        }

        if (dataMap != null)
        {
            optional.Call(this.GetMethodSet(), dataMap);
        }
    }
Exemple #16
0
    public void GetLastGameplayDataMap(Godot.Object optional)
    {
        Dictionary dataMap = this.Call <Dictionary>(jsonSerializer,
                                                    this.GetMethodLoad(), GetFilePath(), true);

        if (dataMap.Contains("gameMode") && dataMap.Contains("ac"))
        {
            string checkAC = GetGameplayAC(dataMap, dataMap["gameMode"] as string);

            if (checkAC.Equals(dataMap["ac"] as string))
            {
                optional.Call(this.GetMethodSet(), dataMap);
            }
        }
    }
    public void Request(Node requester, string type, Godot.Object optional)
    {
        Array <Spatial> projectileList = availableProjectileMap[type];

        projectileDataList.Clear();

        if (projectileList.Count > 0)
        {
            Spatial projectile = projectileList[0];
            projectile.Call(this.GetMethodSetCharacter(), requester);
            projectileList.Remove(projectile);
            projectileDataList.Add(projectile);
        }

        optional.Call(this.GetMethodSet(), projectileDataList);
    }
    public void dispara()
    {
        try {
            Jugador jugador = (Jugador)GetNode("Jugador");

            // efecto del disparo
            jugador.disparaArma();

            Spatial Cabeza    = (Spatial)jugador.GetNode("Cabeza");
            Camera  objcamera = (Camera)Cabeza.GetNode("Camera");
            RayCast ray       = (RayCast)objcamera.GetNode("RayCast");

            if (ray.Enabled && ray.IsColliding())
            {
                Godot.Object objetivo = (Godot.Object)ray.GetCollider();

                Vector3 vectorimpacto = ray.GetCollisionPoint();

                // si el impacto lo recibe un objeto preparado para recibir balas
                if (objetivo.HasMethod("recibeBala"))
                {
                    // calculamos la direccion del impacto
                    Vector3 inicio    = ray.Translation;
                    Vector3 vectordir = vectorimpacto - inicio;

                    objetivo.Call("recibeBala", vectordir);
                }

                // pintamos el impacto de la bala

                // debug con cajas en vez de impacto

                poneCajaEscenario(vectorimpacto);

                /*
                 * PackedScene objeto = (PackedScene)ResourceLoader.Load("res://objetos/mini/ImpactoBalaPared.tscn");
                 * //  objetos.mini.ImpactoBalaPared efecto = (objetos.mini.ImpactoBalaPared)objeto.Instance();
                 * ImpactoBalaPared efecto = (ImpactoBalaPared)objeto.Instance();
                 * AddChild(efecto);
                 * efecto.haceEfecto(vectorimpacto);
                 */
            }
        }
        catch (Exception ex) {
        }
    }
Exemple #19
0
    public void observe_variable(string variable_name, Godot.Object gd_object, string method_name)
    {
        if (story == null)
        {
            PushNullStoryError();
            return;
        }

        try
        {
            var instanceId = (int)gd_object.Call("get_instance_id");
            var funcRef    = GD.FuncRef(gd_object, method_name);

            Ink.Runtime.Story.VariableObserver lambda = (string variableName, object value) => {
                funcRef.CallFuncv(new Godot.Collections.Array()
                {
                    variableName, value
                });
            };

            var functionReference = new FunctionReference(instanceId, method_name, lambda);

            if (observers.TryGetValue(variable_name, out List <FunctionReference> referenceList))
            {
                referenceList.Append(functionReference);
            }
            else
            {
                observers[variable_name] = new List <FunctionReference> ()
                {
                    functionReference
                };
            }

            story.ObserveVariable(variable_name, lambda);
        }
        catch (Exception e)
        {
            HandleException(e);
        }
    }
Exemple #20
0
    public void bind_external_function(
        string func_name,
        Godot.Object gd_object,
        string method_name,
        bool lookahead_safe)
    {
        if (story == null)
        {
            PushNullStoryError();
            return;
        }

        try
        {
            story.BindExternalFunctionGeneral(
                func_name,
                (object[] args) => gd_object.Call(method_name, args),
                lookahead_safe);
        }
        catch (Exception e)
        {
            HandleException(e);
        }
    }
Exemple #21
0
 public void IsInactive(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), projectileAction.Inactive);
 }
Exemple #22
0
 public void GetNodeType(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), projectileType);
 }
Exemple #23
0
 public void GetGameplayRankingMap(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), rankedGameplayDataMap);
 }
Exemple #24
0
 public void Load(string filePath, bool notNull, Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), Load(filePath, notNull));
 }
 public void IsDead(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), enemyStatus.Dead);
 }
 public void Move(Vector3 direction, Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), enemyAction.Move(direction));
 }
 public void CanExecuteSkill(Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(), enemySkill.CanExecuteSkill());
 }
 public void ExecuteSkill(Vector3 direction, string animationName, Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(),
                   enemyAction.ExecuteSkill(direction, animationName));
 }
 public void ExecuteSkill(Vector3 direction, Godot.Object optional)
 {
     optional.Call(this.GetMethodSet(),
                   enemyAction.ExecuteSkill(direction));
 }
Exemple #30
0
 public void Get(Godot.Object signalData)
 {
     signalData.Call(this.GetMethodSet(), activeCheatCodeMap);
 }