コード例 #1
0
    void SetActive(PhxCharacterItem item, PhxClass cl, IPhxControlableInstance preview)
    {
        foreach (PhxCharacterItem it in Items)
        {
            it.SetActive(false);
        }
        item.SetActive(true);
        CurrentSelection = cl;

        foreach (PhxInstance inst in UnitPreviews)
        {
            inst.gameObject.SetActive(false);
        }
        preview.GetInstance().gameObject.SetActive(true);

        IPhxControlableInstance animPreview = preview as IPhxControlableInstance;

        if (animPreview != null)
        {
            animPreview.PlayIntroAnim();
        }
    }
コード例 #2
0
    public void Add(PhxClass cl)
    {
        if (cl.ClassType != EEntityClassType.GameObjectClass)
        {
            Debug.LogError($"Cannot add odf class '{cl.Name}' as item to character selection!");
            return;
        }

        // CSP = Char Select Preview
        IPhxControlableInstance preview = RTS.CreateInstance(cl, cl.Name + "_CSP" + nameCounter++, Vector3.zero, Quaternion.identity, false, GAME.CharSelectTransform) as IPhxControlableInstance;

        preview.Fixate();
        UnitPreviews.Add(preview);

        PhxCharacterItem item = Instantiate(ItemPrefab, ListContents);

        item.OnClicked += () =>
        {
            SetActive(item, cl, preview);
        };

        item.SetHeaderText(cl.LocalizedName);

        string detailText = "";

        PhxSoldier.ClassProperties soldier = cl as PhxSoldier.ClassProperties;
        if (soldier != null)
        {
            foreach (Dictionary <string, IPhxPropRef> section in soldier.Weapons)
            {
                if (section.TryGetValue("WeaponName", out IPhxPropRef nameVal))
                {
                    PhxProp <string> weapName  = (PhxProp <string>)nameVal;
                    PhxClass         weapClass = RTS.GetClass(weapName);
                    if (weapClass != null)
                    {
                        PhxProp <int> medalProp = weapClass.P.Get <PhxProp <int> >("MedalsTypeToUnlock");
                        if (medalProp != null && medalProp != 0)
                        {
                            // Skip medal/award weapons for display
                            continue;
                        }
                        detailText += weapClass.LocalizedName + '\n';
                    }
                }
            }
            item.SetDetailText(detailText);
        }

        Items.Add(item);

        if (CurrentSelection == null)
        {
            SetActive(item, cl, preview);
        }
        else
        {
            item.SetActive(false);
            preview.GetInstance().gameObject.SetActive(false);
        }

        ReCalcItemSize();
    }