コード例 #1
0
    private void Awake()
    {
        Instance      = this;
        WeaponSubject = new WeaponSubject();
        ItemSubject   = new ItemSubject();
        newSlots      = new List <GameObject>();

        WeaponSubject.Attach(new WeaponObserver(a =>
        {
            if (a.isNewItemNotify)
            {
                var newSlot = WeaponSlot.weaponSlots.Where(slot => { return(slot.gameObject.activeSelf == false); }).First();
                if (newSlot != null)
                {
                    newSlots.Add(newSlot.gameObject);
                    newSlot.Init(a.NewItem);
                    a.isNewItemNotify = false;
                }
            }
        }));

        //WeaponSubject.Notify();

        gameObject.SetActive(false);
    }
コード例 #2
0
        //----------------------------------------------------------------------------------

        /// <summary>
        /// 20180515 SangBin :
        /// ???????? SungJun : Notify to WeaponSlots
        /// </summary>
        private void Awake()
        {
            //if (instance == null)
            //{
            //    instance = this;
            //    DontDestroyOnLoad(gameObject);
            //    weaponTypeDic.Add(1, WeaponTypeEnum.weaponType01);
            //    currentWeaponType = weaponTypeDic[1];
            //}
            //else
            //{
            //    DestroyImmediate(this);
            //}
            instance = this;
            //weaponDic.Add(0, WeaponTypeEnum.weaponType01);
            //currentWeaponType = weaponDic[0];
            //GetWeapons();
            holeSparkPS = transform.GetChild(1).gameObject.GetComponent <ParticleSystem>();

            //test
            currentWeaponType = WeaponTypeEnum.weaponType01;


            weaponSubject = ItemWindow.Instance.WeaponSubject;
            //weaponSubject.NotifyNewItem(WeaponTypeEnum.weaponType01);

            GetAmmu();
            StartCoroutine(SaveAmmuPerPeriod());
        }
コード例 #3
0
    private void CheckSelectedWeapon(WeaponSubject a)
    {
        var backgroundImage = gameObject.GetComponent <Image>();

        if (a.SelectedItem == myType)
        {
            backgroundImage.color = new Color(1.0f, 0, 0);
        }
        else
        {
            backgroundImage.color = new Color(1.0f, 1.0f, 1.0f);
        }
    }
コード例 #4
0
    private void Awake()
    {
        weaponSlots.Add(gameObject.GetComponent <WeaponSlot>());

        subject = ItemWindow.Instance.WeaponSubject;

        subject.Attach(new WeaponObserver(CheckSelectedWeapon));

        var button = gameObject.GetComponent <Button>();

        button.onClick.AddListener(() => { subject.SetCurruntWeapon(myType); });

        //subject.Notify();

        //gameObject.SetActive(false);
    }