// group the buttons according to their functionality , in their 4 respective groups .
    public void groupButtons()
    {
        // branch into number keys
        if (this.Name == "oneKey" || this.Name == "oneKey2" || this.Name == "oneKey3" || this.Name == "oneKey6" || this.Name == "oneKey7" || this.Name == "oneKey8" || this.Name == "oneKey11" || this.Name == "oneKey12" || this.Name == "oneKey16" || this.Name == "oneKey17" || this.Name == "oneKey18")
        {
            // GD.Print("number keys clicked");
            sysInputs.Call(method: "numberKey", this.Name);
        }


        // operator keys
        if (this.Name == "oneKey9" || this.Name == "oneKey10" || this.Name == "oneKey15" || this.Name == "oneKey13")
        {
            // GD.Print("operator keys clicked");
            sysInputs.Call(method: "operatorKeys", this.Name);
        }


        // super keys
        if (this.Name == "oneKey14" || this.Name == "oneKey4" || this.Name == "oneKey5")
        {
            // GD.Print("super key clicked");
            sysInputs.Call(method: "superkeys", this.Name);
        }


        // extra keys.
        if (this.Name == "oneKey19" || this.Name == "oneKey20")
        {
            // GD.Print("extra keys clicked");
            sysInputs.Call(method: "extraKeys", this.Name);
        }
    }
Пример #2
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);
    }
Пример #3
0
        public void Input_PlaceTower(InputEvent @event)
        {
            if (@event is InputEventMouse)
            {
                InputEventMouse mouseEvent = (InputEventMouse)@event;
                var             ray        = new MouseRay(camera, mouseEvent.GlobalPosition);
                Vector3?        pos        = ray.PositionOnPlane(new Plane(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)));
                if (mouseEvent.ButtonMask == 1 && lastButtonMask == 0)
                {
                    if (GUITools.IsPointOnGUI(world.GetNode(new NodePath("GUI")), mouseEvent.GlobalPosition))
                    {
                        return;
                    }
                    if (pos.HasValue && pos.Value.x > 0 && pos.Value.z > 0)
                    {
                        Vector2 gPos = new Vector2(pos.Value.x, pos.Value.z);
                        gPos.x = (int)(gPos.x);
                        gPos.y = (int)(gPos.y);
                        if (Grid[(int)gPos.x, (int)gPos.y].CanPlaceOn)
                        {
                            Tile tile = (Tile)sceneTower.Instance();
                            SetTile(tile, (int)gPos.x, (int)gPos.y);
                            pathUpdaterGround.Update(GetGrid(MovementLayer.Ground), endPoints);
                        }
                    }
                }

                if (pos.HasValue)
                {
                    Vector3 iPos = new Vector3(
                        ((int)pos.Value.x),
                        ((int)pos.Value.y),
                        ((int)pos.Value.z));
                    glowTile.Translation  = iPos;
                    placeTile.Translation = iPos;
                    if (iPos.x < 0 || iPos.z < 0 || iPos.x >= Width || iPos.z >= Height)
                    {
                        glowTile.Visible = false;
                    }
                    else
                    {
                        glowTile.Visible = true;
                        Tile t = Grid[(int)iPos.x, (int)iPos.z];
                        if (t.CanPlaceOn)
                        {
                            glowTile.Call("blue");
                        }
                        else
                        {
                            glowTile.Call("red");
                        }
                    }
                }

                lastButtonMask = mouseEvent.ButtonMask;
            }
        }
Пример #4
0
 private void TryToActivateProjectile()
 {
     if (projectileList.Count > 0)
     {
         Spatial projectile = projectileList[0];
         projectile.Call(this.GetMethodTransitTo(), "active");
         projectile.Call(this.GetMethodSetDirection(), projectileDirection);
         projectileList.RemoveAt(0);
     }
 }
    private void DropLaserDevice()
    {
        Array <Spatial> deviceList = availableLaserDeviceMap["W"];

        if (deviceList.Count > 0)
        {
            Spatial ld = deviceList[0];
            ld.Translation = new Vector3(this.RandiRange(rng, -halfColumn, halfColumn),
                                         0f, this.RandiRange(rng, -halfRow, halfRow)) + dropOffset;
            ld.Call(this.GetMethodSetLaserRayLevel(), this.RandiRange(rng, 2, 5));
            ld.Call(this.GetMethodTransitTo(), "active");
            ld.Call(this.GetMethodMove(), this, Vector3.Down);
            deviceList.RemoveAt(0);
        }
    }
Пример #6
0
    private void CreateLaserDeviceInstances()
    {
        Array <Spatial> laserDeviceList;
        string          currentType;
        Spatial         container;
        Spatial         laserDevice = null;

        SCG.IEnumerator <PackedScene> it = laserDevicePSList.GetEnumerator();
        int index       = 0;
        int finalAmount = laserDeviceAmount * specialistAmount;

        while (it.MoveNext())
        {
            laserDeviceList = new Array <Spatial>();
            container       = GetChild <Spatial>(index++);

            for (int i = 0; i < finalAmount; i++)
            {
                laserDevice             = it.Current.Instance() as Spatial;
                laserDevice.Translation = inactiveTranslation;
                laserDevice.Name        = this.CreateUniqueNodeName(laserDevice);
                laserDevice.Call(this.GetMethodSetManager(), this);
                container.CallDeferred(this.GetGDMethodAddChild(), laserDevice);
                laserDeviceList.Add(laserDevice);
            }

            currentType = this.Call <string>(laserDevice, this.GetMethodGetNodeType());
            availableLaserDeviceMap.Add(currentType, laserDeviceList);
        }
    }
Пример #7
0
    private void CreateSpellInstances()
    {
        Array <Spatial> projectileList;
        string          currentType;
        Spatial         container;
        Spatial         projectile = null;

        SCG.IEnumerator <PackedScene> it = projectilePrefabList.GetEnumerator();
        int index = 0;
        int amount;

        while (it.MoveNext())
        {
            projectileList = new Array <Spatial>();
            container      = GetChild <Spatial>(index);
            amount         = projectileAmountList[index++];

            for (int i = 0; i < amount; i++)
            {
                projectile             = it.Current.Instance() as Spatial;
                projectile.Translation = inactiveTranslation;
                projectile.Name        = this.CreateUniqueNodeName(projectile);
                projectile.Call(this.GetMethodSetManager(), this);
                projectileList.Add(projectile);
                container.CallDeferred(this.GetGDMethodAddChild(), projectile);
            }

            if (amount > 0)
            {
                currentType = this.Call <string>(projectile, this.GetMethodGetNodeType());
                availableProjectileMap.Add(currentType, projectileList);
            }
        }
    }
Пример #8
0
    private void HandleSpecialistDeath(Spatial specialist)
    {
        int    id  = this.Call <int>(specialist, this.GetMethodGetSpecialistId());
        string key = this.CreateString("p", (id + 1), "Deaths");

        PutGlobal(key, GetGlobal <int>(key) + 1);

        specialistAliveList.Remove(specialist);
        specialist.Call(this.GetMethodApplyItem(),
                        this.GetMethodIncreaseLives(), -1);
        specialist.Call(this.GetMethodApplyItem(),
                        this.GetMethodIncreaseSpeedLevel(), -1);
        specialist.Call(this.GetMethodApplyItem(),
                        this.GetMethodIncreaseLaserRayLevel(), -2);
        specialist.Call(this.GetMethodApplyItem(),
                        this.GetMethodIncreaseLaserDeviceAmount(), -1);
    }
Пример #9
0
 private void TryToMoveProjectile(Spatial projectile, string type)
 {
     if (projectileTypeMoveDirectionMap.ContainsKey(type))
     {
         Vector3 direction = projectileTypeMoveDirectionMap[type];
         projectile.Call(this.GetMethodMove(), skillManager, direction);
     }
 }
    private void PushObject()
    {
        Spatial c = pushRayCast.GetCollider() as Spatial;

        if (c != null)
        {
            c.Call(this.GetMethodMove(), character, GetBodyDirection());
        }
    }
Пример #11
0
    public Spatial addCube(int cube_size)
    {
        new_cube = (PackedScene)ResourceLoader.Load("res://Cube.tscn");
        Spatial cube = (Spatial)new_cube.Instance();

        cube.Call("makeCube", cube_size, spacing_constant);
        AddChild(cube);

        return(cube);
    }
Пример #12
0
 private void TryToActivateItem()
 {
     if (itemInstanceList.Count > 0)
     {
         Spatial item = itemInstanceList[0];
         itemInstanceList.RemoveAt(0);
         item.Call(this.GetMethodTransitTo(), "active");
         item.Translation = this.Call <Vector3>(levelManager,
                                                this.GetMethodGetPositionFromRandomEmptyBlockSlot()) + itemOffset;
     }
 }
Пример #13
0
 private void AddItemToSoftBlock(Spatial softBlock)
 {
     if (itemToAddList.Count > 0)
     {
         Spatial item = itemToAddList[0];
         item.Name = this.CreateUniqueNodeName(item);
         this.AddChildToItemContainer(this, item);
         itemToAddList.RemoveAt(0);
         softBlock.Call(this.GetMethodSetItem(), item);
     }
 }
Пример #14
0
 public override void ExecuteSkill()
 {
     if (projectileList.Count > 0)
     {
         Spatial projectile = projectileList[0];
         projectile.Call(this.GetMethodPlant());
         string type = this.Call <string>(projectile, this.GetMethodGetNodeType());
         TryToRemoveEmptyBlockSlot(projectile, type);
         TryToMoveProjectile(projectile, type);
         projectileList.RemoveAt(0);
     }
 }
Пример #15
0
        private void update()
        {
            var x        = Mathf.Round(Translation.x / 2);
            var y        = Mathf.Round(Translation.y / 2);
            var cur_cell = new Vector2(x, y);

            if (!last_cell.Equals(cur_cell))
            {
                last_cell = cur_cell;
            }
            CTRL.Call("update", x, y);
        }
Пример #16
0
    public static void SetDisplay()
    {
        viewGrid.Visible        = false;
        mainDisplayRoot.Visible = true;

        topViewPlane.Visible   = false;
        frontViewPlane.Visible = false;
        sideViewPlane.Visible  = false;

        if (selectedView == 0)
        {
            viewGrid.Visible        = true;
            mainDisplayRoot.Visible = false;
            topViewPlane.Call("SetDisplayNode", topViewRoot.GetPath());
            frontViewPlane.Call("SetDisplayNode", frontViewRoot.GetPath());
            sideViewPlane.Call("SetDisplayNode", sideViewRoot.GetPath());

            topViewPlane.Visible   = true;
            frontViewPlane.Visible = true;
            sideViewPlane.Visible  = true;
        }
        else if (selectedView == 1)
        {
            topViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            topViewPlane.Visible = true;
        }
        else if (selectedView == 2)
        {
            frontViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            frontViewPlane.Visible = true;
        }
        else if (selectedView == 3)
        {
            sideViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            sideViewPlane.Visible = true;
        }
    }
Пример #17
0
    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);
    }
Пример #18
0
    // This function sets which viewport/display to display to, as well as which view(s) is (are) visible
    public static void SetDisplay()
    {
        // Set grid view as invisible and main view as visible
        viewGrid.Visible        = false;
        mainDisplayRoot.Visible = true;

        // Set planeControl objects (in 3D view) as invisible
        topViewPlane.Visible       = false;
        frontViewPlane.Visible     = false;
        sideViewPlane.Visible      = false;
        auxiliaryViewPlane.Visible = false;

        // Set the display size to the main viewport size
        PlaneControl.SetScreenSize(LARGE_PLANE_X_SCALE, LARGE_PLANE_Y_SCALE, MAX_FOCUS);

        if (selectedView == (int)Views.ALL_VIEWS)
        {
            // If all views are visible, set the grid view to visible and main view to invisible
            viewGrid.Visible        = true;
            mainDisplayRoot.Visible = false;

            // Set the individual view display ndoes
            topViewPlane.Call("SetDisplayNode", topViewRoot.GetPath());
            frontViewPlane.Call("SetDisplayNode", frontViewRoot.GetPath());
            sideViewPlane.Call("SetDisplayNode", sideViewRoot.GetPath());
            auxiliaryViewPlane.Call("SetDisplayNode", auxiliaryViewRoot.GetPath());

            // Set all planeControl objects (in 3D view) as visible
            topViewPlane.Visible   = true;
            frontViewPlane.Visible = true;
            sideViewPlane.Visible  = true;

            // If auxiliary view is enabled for this object, make the auxiliary planeControl object visible
            if (isAuxEnabled)
            {
                auxiliaryViewPlane.Visible = true;
            }

            // If all views are selected, change the display size to the small viewport size
            PlaneControl.SetScreenSize(SMALL_PLANE_X_SCALE, SMALL_PLANE_Y_SCALE, MAX_FOCUS);
        }
        else if (selectedView == (int)Views.TOP_VIEW)
        {
            // If top view is selected, set top view display node and set 3D planeControl object as visible
            topViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            topViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.FRONT_VIEW)
        {
            // If front view is selected, set front view display node and set 3D planeControl object as visible
            frontViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            frontViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.SIDE_VIEW)
        {
            // If side view is selected, set side view display node and set 3D planeControl object as visible
            sideViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            sideViewPlane.Visible = true;
        }
        else if (selectedView == (int)Views.AUX_VIEW && isAuxEnabled)
        {
            // If auxiliary view is selected, set auxiliary view display node and set 3D planeControl object as visible
            auxiliaryViewPlane.Call("SetDisplayNode", mainDisplayRoot.GetPath());
            auxiliaryViewPlane.Visible = true;
        }
    }
Пример #19
0
    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        int result = 0;

        result = (int)HUD.Call("buttonProcess", delta);

        if (result == 0)
        {
            return;
        }
        GD.Print(result);

        if ((result >= 2) && (result <= 7))
        {
            cube_size = result;
            moveCamera(cameraMain, cube_size);
            cube = addCube(cube_size);
            GD.Print(default_rot);
            GD.Print(camera_rot);

            //cube.Call("makeAxisLines", cube_size);
            return;
        }

        if (result == 10)
        {
            cube_size   = 0;
            edge_select = new Vector3(0, 0, 0);
            //cube.Call("removeAxisLines");

            // reset camera too
            cameraMain.Translation = zero_vec;
            cameraMain.GlobalTranslate(default_loc);
            camera_rot          = default_rot;
            cameraMain.Rotation = camera_rot;
            moveCamera(cameraMain, cube_size);

            RemoveChild(cube);
            return;
        }

        if ((result >= 0x100) && (result <= 0x104))
        {
            cube.Call("removeOutline");

            if (result == 0x100)
            {
                edge_select = new Vector3(1, 0, 0);
            }
            if (result == 0x101)
            {
                edge_select = new Vector3(0, 1, 0);
            }
            if (result == 0x102)
            {
                edge_select = new Vector3(0, 0, 1);
            }

            if ((result == 0x103) && (edge_select.Length() < cube_size))
            {
                edge_select = edge_select + edge_select.Normalized();
            }
            if ((result == 0x104) && (edge_select.Length() > 1))
            {
                edge_select = edge_select - edge_select.Normalized();
            }

            cube.Call("makeOutline", cube_size, edge_select);

            HUD.Call("cubeShow");

            return;
        }

        if (result == 0x105)
        {
            RemoveChild(cube);
            cube = addCube(cube_size);
        }

        if ((result >= 0x200) && (result <= 0x201))
        {
            if (result == 0x200)
            {
                twistCube(cube, cube_size, edge_select, -1, 1);
            }
            if (result == 0x201)
            {
                twistCube(cube, cube_size, edge_select, 1, 1);
            }
            HUD.Call("cubeShow");
        }

        //twistCube(cube, cube_size, edge_select, 1, 1);
        return;
    }
Пример #20
0
 public void twistCube(Spatial cube, int size, Vector3 side_select, int direction, int times)
 {
     cube.Call("spinSide", size, side_select, direction, times);
 }