Esempio n. 1
0
    void Update()
    {
        if (GameManager.IsDedicatedServer)
        {
            return;
        }

        if (entityVehicle == null || entityVehicle.player == null)
        {
            InitController();
            return;
        }
        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        //if (GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || entityVehicle.uiforPlayer.windowManager.IsModalWindowOpen())
        if (GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || uiforPlayer.windowManager.IsModalWindowOpen())
        {
            return;
        }

        if (!entityVehicle.hasDriver)
        {
            return;
        }

        if (!(entityVehicle.HasGun() || entityVehicle.HasExplosiveLauncher()))
        {
            return;
        }

        if (Input.GetMouseButton(0) && Time.time - gunShootDelay > lastGunShoot)
        {
            //DebugMsg("Left-click");
            ShootProjectile(entityVehicle.gunLauncher, "vehicleGun", "Weapons/Ranged/AK47/ak47_fire_start", true);
            lastGunShoot = Time.time;
        }
        if (Input.GetMouseButton(1) && Time.time - missileShootDelay > lastMissileShoot)
        {
            //DebugMsg("Right-click");
            ShootProjectile(entityVehicle.missileLauncher, "vehicleExplosiveLauncher", "Weapons/Ranged/M136/m136_fire", false);
            lastMissileShoot = Time.time;
        }
    }
Esempio n. 2
0
    public void OnGUI()
    {
        if (GameManager.IsDedicatedServer)
        {
            return;
        }

        LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityVehicle.player);

        //if (!Event.current.type.Equals(EventType.Repaint) || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || entityVehicle.uiforPlayer.windowManager.IsModalWindowOpen())
        if (!Event.current.type.Equals(EventType.Repaint) || GameManager.Instance.IsPaused() || GameManager.Instance.m_GUIConsole.isInputActive || uiforPlayer.windowManager.IsModalWindowOpen())
        {
            return;
        }

        if (entityVehicle == null || entityVehicle.player == null)
        {
            InitController();
            return;
        }

        if (entityVehicle.player.movementInput.bAltCameraMove || entityVehicle.player.IsDead() || !entityVehicle.hasDriver || !(entityVehicle.HasGun() || entityVehicle.HasExplosiveLauncher()))
        {
            return;
        }

        DrawCrosshair();
    }
Esempio n. 3
0
    public void OnDriverOn()
    {
        //InitController();

        if (entityVehicle != null && entityVehicle.player != null && entityVehicle.hudStatBar != null)
        {
            string        msg = "VehicleWeapons.OnDriverOn: hudStatBarWinGroup children controllers:\n";
            XUiController hudStatBarWinGroup = entityVehicle.hudStatBar.WindowGroup.Controller;
            foreach (XUiController controller in hudStatBarWinGroup.Children)
            {
                msg += ("- " + controller.ToString() + " | type = " + controller.GetType() + " | viewComponent ID = " + controller.viewComponent.ID + " | viewComponent type = " + controller.viewComponent.GetType().ToString() + "\n");
                if (controller.viewComponent.ID == "HUDRightStatBars")
                {
                    msg += "  Components:\n";
                    Transform[] transforms = controller.viewComponent.UiTransform.gameObject.GetComponentsInChildren <Transform>(true);
                    foreach (Transform transform in transforms)
                    {
                        msg += ("\t- " + transform.gameObject.name + " | " + transform.GetType() + "\n");

                        if (transform.name == "hudVehicleWeaponsAmmo")
                        {
                            vehicleAmmoUIRoot = transform.gameObject;
                            vehicleAmmoUIRoot.SetActive(true);
                        }

                        if (transform.name == "vehicleHealthIcon")
                        {
                            UISprite[] vehicleHealthSprites = transform.gameObject.GetComponentsInChildren <UISprite>(true);
                            if (vehicleHealthSprites.Length > 0)
                            {
                                vehicleHealthSprites[0].spriteName = entityVehicle.GetMapIcon();
                                msg += ("\t\t- vehicleHealthSprite = " + vehicleHealthSprites[0].spriteName + "\n");
                            }
                        }

                        if (transform.name == "vehicleHealth")
                        {
                            UISprite[] vehicleHealthSprites = transform.gameObject.GetComponentsInChildren <UISprite>(true);
                            foreach (UISprite sprite in vehicleHealthSprites)
                            {
                                if (sprite.gameObject.name == "Icon")
                                {
                                    miniBikeDefaultSprite            = sprite;
                                    miniBikeDefaultSprite.spriteName = "";
                                }
                            }
                        }

                        if (transform.name == "hudVehicleGunAmmo")
                        {
                            //gunAmmoUIRoot = transform.gameObject;
                            //gunAmmoUIRoot.SetActive(entityVehicle.HasGun() && entityVehicle.HasGunAmmo());
                            bool        bShowGun = entityVehicle.HasGun() && entityVehicle.HasGunAmmo();
                            Component[] comps    = transform.gameObject.GetComponentsInChildren <Component>();
                            foreach (Component comp in comps)
                            {
                                if (comp.name == "BarContent" && comp.GetType() == typeof(UISprite))
                                {
                                    ((UISprite)comp).enabled = bShowGun;
                                }
                                if (comp.name == "Icon" && comp.GetType() == typeof(UISprite))
                                {
                                    msg            += ("\t\t- " + comp.gameObject.name + " | " + comp.GetType() + "\n");
                                    gunAmmoUISprite = (UISprite)comp;

                                    gunAmmoItemValue           = entityVehicle.GetWeaponAmmoType("vehicleGun");
                                    gunAmmoUISprite.spriteName = gunAmmoItemValue.ItemClass.GetIconName();
                                    gunAmmoUISprite.enabled    = bShowGun;
                                }
                                if (comp.name == "TextContent" && comp.GetType() == typeof(UILabel))
                                {
                                    msg                   += ("\t\t- " + comp.gameObject.name + " | " + comp.GetType() + "\n");
                                    gunAmmoUILabel         = (UILabel)comp;
                                    gunAmmoUILabel.text    = entityVehicle.uiforPlayer.xui.PlayerInventory.GetItemCount(gunAmmoItemValue.ItemClass.Id).ToString();
                                    gunAmmoUILabel.enabled = bShowGun;
                                }
                            }
                        }
                        if (transform.name == "hudVehicleExplosiveLauncherAmmo")
                        {
                            //explosiveAmmoUIRoot = transform.gameObject;
                            //explosiveAmmoUIRoot.SetActive(entityVehicle.HasExplosiveLauncher() && entityVehicle.HasExplosiveLauncherAmmo());
                            bool        bShowEL = entityVehicle.HasExplosiveLauncher() && entityVehicle.HasExplosiveLauncherAmmo();
                            Component[] comps   = transform.gameObject.GetComponentsInChildren <Component>();
                            foreach (Component comp in comps)
                            {
                                if (comp.name == "BarContent" && comp.GetType() == typeof(UISprite))
                                {
                                    ((UISprite)comp).enabled = bShowEL;
                                }
                                if (comp.name == "Icon" && comp.GetType() == typeof(UISprite))
                                {
                                    msg += ("\t\t- " + comp.gameObject.name + " | " + comp.GetType() + "\n");
                                    explosiveAmmoUISprite = (UISprite)comp;

                                    explosiveAmmoItemValue           = entityVehicle.GetWeaponAmmoType("vehicleExplosiveLauncher");
                                    explosiveAmmoUISprite.spriteName = explosiveAmmoItemValue.ItemClass.GetIconName();
                                    explosiveAmmoUISprite.enabled    = bShowEL;
                                }
                                if (comp.name == "TextContent" && comp.GetType() == typeof(UILabel))
                                {
                                    msg += ("\t\t- " + comp.gameObject.name + " | " + comp.GetType() + "\n");
                                    explosiveAmmoUILabel         = (UILabel)comp;
                                    explosiveAmmoUILabel.text    = entityVehicle.uiforPlayer.xui.PlayerInventory.GetItemCount(explosiveAmmoItemValue.ItemClass.Id).ToString();
                                    explosiveAmmoUILabel.enabled = bShowEL;
                                }
                            }
                        }
                    }
                }
            }
            DebugMsg(msg);
        }
    }