Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        if (UI_Targeting == null)
            UI_Targeting = GetComponentInChildren<TargetingUI>();

        if (UI_SpaceStation == null)
            UI_SpaceStation = GetComponentInChildren<SpaceStationUI>();

        allInterfaces.Add(UI_Targeting);
        allInterfaces.Add(UI_SpaceStation);
        foreach (UIBase uis in allInterfaces)
        {
            uis.SetManager(this);
        }
    }
Exemplo n.º 2
0
        public static bool Prefix(TargetingUI __instance, GameObject gameObject, ref bool __result)
        {
            Identifiable.Id id = Identifiable.GetId(gameObject);
            if (id == Identifiable.Id.NONE)
            {
                __result = false;
                return(false);
            }

            foreach ((Predicate <Identifiable.Id>, (Func <Identifiable.Id, MessageBundle, string>, Func <Identifiable.Id, MessageBundle, string>))kvp in TargetingRegistry.customTargetingInfo)
            {
                if (kvp.Item1.Invoke(id))
                {
                    __result = true;
                    __instance.nameText.text = kvp.Item2.Item1 == null?Identifiable.GetName(id) : kvp.Item2.Item1.Invoke(id, __instance.uiBundle);

                    __instance.infoText.text = kvp.Item2.Item2 == null?__instance.GetIdentifiableInfoText(id) : kvp.Item2.Item2.Invoke(id, __instance.uiBundle);

                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
    protected void AcquireTargetingSystem()
    {
        if (owner is PlayerShip)
        {
            shipTargetingSystem = owner.gameObject.GetComponent<TargetingSystem>();
            shipTargetingSystem.weapons.Add(this);
            control = ControlMode.PLAYER;

            // Add weapon to GRID.
            UI_Targeting = shipTargetingSystem.GetUI();
            UI_Weapon = GameObject.Instantiate(UI_Targeting.UIOBJECT_WEAPON) as GameObject;
            UI_Weapon.name = "WeaponsUI";

            Debug.Log(UI_Weapon.transform.GetChild(0).name);
            Debug.Log(UI_Weapon.transform.GetChild(1).name);
            Debug.Log(UI_Weapon.transform.GetChild(2).name);

            UI_weaponLabel = UI_Weapon.transform.FindChild("UILabel").GetComponent<UILabel>();
            UI_reloadSprite = UI_Weapon.transform.FindChild("UIReadyToFire").GetComponent<UISprite>();
            UI_weaponSprite = UI_Weapon.transform.FindChild("UIWeaponSprite").GetComponent<UISprite>();
            UI_selectedSprite = UI_Weapon.transform.FindChild("UISelected").GetComponent<UISprite>();
            UI_SelectWeapon = UI_Weapon.transform.FindChild("UIWeaponSprite").GetComponent<UIButton>();

            // Allows changing weapon and setting targets by left / right clicking.
            EventDelegate SelectDelegate = new EventDelegate(this, "SelectWeapon");
            UI_SelectWeapon.onClick.Add(SelectDelegate);
            SelectDelegate = new EventDelegate(this, "SetTarget");
            UI_SelectWeapon.onClick.Add(SelectDelegate);

            UI_selectedSprite.enabled = false;

            //UI_AutoFire.onClick += SwitchModes;
        //			UIEventListener.Get(UI_AutoFire.gameObject).onClick += SwitchModes;
        //
            UI_Weapon.transform.parent = UI_Targeting.weaponGrid.transform;
            UI_Weapon.transform.localPosition = Vector3.zero;
            UI_Weapon.transform.localScale = new Vector3(1,1,1);
            UI_Targeting.weaponGrid.mReposition = true;
            UI_Targeting.weaponGrid.enabled = true;
        }
        else
            control = ControlMode.AI;
    }