예제 #1
0
        public void InitShop()
        {
            if (_list != null && _list.Count <= 0)
            {
                foreach (var o in _list)
                {
                    GameObject.Destroy(o);
                }
            }

            _list = new List <GameObject>();
            for (int i = 0; i < 5; ++i)
            {
                GameObject gum = GameObject.Instantiate <GameObject>(_pack);
                gum.name  = "nicotine gum(Clone)";
                gum.tag   = "Untagged";
                gum.layer = 0;
                gum.transform.position = _pos[i];
                gum.transform.rotation = Quaternion.Euler(90.0f, 160.0f, 0.0f);
                gum.GetComponent <Rigidbody>().isKinematic = true;
                GumBehaviour comp = gum.AddComponent <GumBehaviour>();
                comp.ShopList = _list;
                _list.Add(gum);
            }
            GameObject.Destroy(_pack);
        }
예제 #2
0
        public override void OnLoad()
        {
            // Original
            AssetBundle ab       = LoadAssets.LoadBundle(this, "pack.unity3d");
            GameObject  original = ab.LoadAsset <GameObject>("pack.prefab");

            _pack      = GameObject.Instantiate <GameObject>(original);
            _pack.name = "nicotine gum";
            Material m = new Material(Shader.Find("Standard"));

            m.mainTexture = original.GetComponent <Renderer>().material.mainTexture;
            _pack.GetComponent <Renderer>().material = m;

            GameObject.Destroy(original);
            ab.Unload(false);

            // Load save
            GumSaveData data = GumSaveData.Deserialize <GumSaveData>(GumSaveData.SavePath);

            for (int i = 0; i < data.Pos.Count; ++i)
            {
                GameObject gum = GameObject.Instantiate <GameObject>(_pack);
                gum.transform.position = data.Pos[i];
                gum.transform.rotation = data.Rot[i];
                GumBehaviour c = gum.AddComponent <GumBehaviour>();
                c.ShopList = _list;
                c.Count    = data.GumCount[i];
                c.Activate();
                c.SetBought();
            }

            // Setup
            FatigueFsm    = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerFatigue");
            StressFsm     = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerStress");
            StressRateFsm = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerStressRate");
            DrunkFsm      = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerDrunk");
            ThirstFsm     = PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerThirst");
            InitShop();
            ConsoleCommand.Add(new GumCommand(this));

            ModConsole.Print($"[Gum] has loaded without issue");
        }