예제 #1
0
    public void NewBiome(Biome biome, int minutesPassed)
    {
        if (_playerCharacter.GetTotalWeight() > _playerCharacter.WeightLimit)
        {
            minutesPassed *= 2;
        }
        Journey.UpdateTime(minutesPassed);
        _playerCharacter.RegenerationFromMinutes(minutesPassed);
        var remainingCards = GameObject.FindGameObjectsWithTag(Constants.TagGrabbableCard);

        foreach (var card in remainingCards)
        {
            Destroy(card);
        }
        _avoidBhv.EnableButton();
        Journey.CurrentBiomeChoice = 0;
        Journey.Step  = 1;
        Journey.Biome = biome;
        Instantiator.NewRandomCard(1, Journey.Day, Journey.Biome, _playerCharacter);
        _currentCard = GameObject.Find("Card1");
        Instantiator.PopText(Helper.TimeFromMinutes(minutesPassed), (Vector2)_currentCard.transform.position + new Vector2(0.0f, 1.6f), TextType.Normal);
        //backCard.GetComponent<CardBhv>().BringToFront();
        _avoidBhv.EndActionDelegate   = _currentCard.GetComponent <CardBhv>().Avoid;
        _ventureBhv.EndActionDelegate = _currentCard.GetComponent <CardBhv>().Venture;
        Instantiator.NewRandomCard(0, Journey.Day, Journey.Biome, _playerCharacter);
        UpdateDisplayJourneyAndCharacterStats();
    }
예제 #2
0
    IEnumerator SpawnEnemy()
    {
        if (campingFeature == null)
        {
            campingFeature = GetComponent <CampingFeature>();
        }
        Transform spawnTile     = campingFeature.GetSpawnTile();
        Material  tileMat       = spawnTile.GetComponent <Renderer>().material;
        Color     initialColour = tileMat.color;

        float spawnTimer = 0;

        while (spawnTimer < spawnDelay)
        {
            tileMat.color = Color.Lerp(initialColour, flashColour, Mathf.PingPong(spawnTimer * tileFlashSpeed, 1));
            spawnTimer   += Time.deltaTime;
            yield return(null);
        }
        if (instantiator == null)
        {
            instantiator = FindObjectOfType <Instantiator>();
        }
        GameObject instance = instantiator.Instantiate(spawnable, spawnTile.position + Vector3.up);

        Spawned(instance);
    }
예제 #3
0
        void initIde()
        {
            var host = MefHostServices.Create(MSBuildMefHostServices.DefaultAssemblies);

            Workspace = MSBuildWorkspace.Create(host);
            Workspace.WorkspaceFailed += (sender, e) => Console.WriteLine($"Workspace error: {e.Diagnostic}");
            ProgressLogger             = new ProgressLog();
            projectCollection          = new ProjectCollection(null, new ILogger [] { new IdeLogger(this) }, ToolsetDefinitionLocations.Default)
            {
                //DefaultToolsVersion = DEFAULT_TOOLS_VERSION,
            };

            projectCollection.SetGlobalProperty("RestoreConfigFile",
                                                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget/NuGet/NuGet.Config"));

            initCommands();

            Widget go = Load(@"#ui.CrowIDE.crow");

            go.DataSource = this;

            mainDock = go.FindByName("mainDock") as DockStack;

            instFileDlg = Instantiator.CreateFromImlFragment
                              (this, "<FileDialog Caption='Open File' CurrentDirectory='{²CurrentDirectory}' SearchPattern='*.sln' OkClicked='onFileOpen'/>");
        }
예제 #4
0
        public ProfilerSystem(ProfilerSystemConfigData data) : base(data)
        {
            GameObject     obj = Instantiator.Instantiate() as GameObject;
            ProfilerUpdate p   = obj.AddComponent <ProfilerUpdate>();

            p.Initialize(this);
        }
예제 #5
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #6
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="instantiator">Instantiator which will hold desired gameobject. <see cref="T"/>
    /// must be a componenent on the Instantiator's template</param>
    /// <param name="startSize">Initial size of pool</param>
    public ObjectPool(Instantiator instantiator, int startSize)
    {
        this.instantiator = instantiator;
        pool = new List <T>();
        var objList = instantiator.InstantiateGroup(startSize);

        if (objList.Count == 0)
        {
            return;
        }

        var component = objList[0].GetComponent <T>();

        if (component == null)
        {
            Debug.LogError(
                "ObjectPool: could not find required component from Instantiator return");
            return;
        }

        foreach (var o in objList)
        {
            pool.Add(o.GetComponent <T>());
        }

        initPos = objList[0].transform.position;
        initRot = objList[0].transform.rotation;
    }
        public async Task InvokeAsync(HttpContext httpContext)
        {
            var routingResult = ControllerRouter.Route(httpContext.Request.Path.ToString());

            if (routingResult == null)
            {
                await Next(httpContext);

                return;
            }

            var instance = Instantiator.Instantiate(routingResult.Controller.Type);

            IMethodParameterProvider controllerActionParameterProvider = new MethodParameterProvider(new MethodParameterValueProvider(httpContext.Request.Query.Keys.ToDictionary(k => k, k => httpContext.Request.Query[k].First()), () => new StreamReader(httpContext.Request.Body, Encoding.UTF8).ReadToEnd()));

            var parameters = controllerActionParameterProvider.GetParameters(routingResult.Action.Method);

            var result = routingResult.Action.Method.Invoke(instance, parameters);

            if (result != null)
            {
                httpContext.Response.ContentType = "application/json";

                await httpContext.Response.WriteAsync(JsonConvert.SerializeObject(result));
            }
        }
예제 #8
0
        public static void CreateOrbitMeshes()
        {
            var starSystems = AssetDatabase.FindAssets("t:Osim.Assets.StarSystem");

            foreach (var starSystemGuid in starSystems)
            {
                var systemPath = AssetDatabase.GUIDToAssetPath(starSystemGuid);
                var systemDir  = Path.GetDirectoryName(systemPath);
                if (systemDir == null)
                {
                    continue;
                }
                var starSystem = (Assets.StarSystem)AssetDatabase.LoadAssetAtPath(systemPath, typeof(Assets.StarSystem));
                foreach (var planet in starSystem.planets)
                {
                    var planetPath = AssetDatabase.GetAssetPath(planet);
                    var planetDir  = Path.GetDirectoryName(planetPath);
                    if (planetDir == null)
                    {
                        continue;
                    }
                    int period        = (int)planet.orbit.period;
                    var points        = new Vector3[period];
                    var orbitFunction = Instantiator.CreateOrbitFunction(planet.orbit.function);
                    for (int i = 0; i < period; ++i)
                    {
                        points[i] = orbitFunction(planet.orbit.startTime + i).ToVector3(starSystem.scale);
                    }
                    var mesh = LoadOrCreateAsset <Mesh>(Path.Combine(planetDir, planet.name + "OrbitMesh.mesh"));
                    CreateOrbitMesh(mesh, points);
                    EditorUtility.SetDirty(mesh);
                }
            }
        }
예제 #9
0
    static void Main(string[] args)
    {
        var instance = Instantiator.Instantiate();

        Referent.Refer(instance);
        Console.ReadLine();
    }
예제 #10
0
    public virtual void RunAway()
    {
        Instantiator.NewPopupYesNo(Constants.YesNoTitle,
                                   "You have " + PlayerBhv.Character.RunAwayPercent + "% chance of running away.\nDo you risk it?"
                                   , Constants.Cancel, "Risk it!", OnRiskRunningAway);

        object OnRiskRunningAway(bool result)
        {
            if (result)
            {
                var rand = Random.Range(0, 100);
                if (rand < PlayerBhv.Character.RunAwayPercent)
                {
                    PlayerPrefsHelper.SaveCharacter(Constants.PpPlayer, PlayerBhv.Character);
                    Instantiator.NewOverBlend(OverBlendType.StartLoadMidActionEnd, "RUNNING AWAY", 2.0f, TransitionRunAway, reverse: true);
                    object TransitionRunAway(bool transResult)
                    {
                        NavigationService.LoadPreviousScene(OnRootPreviousScene);
                        return(transResult);
                    }
                }
                else
                {
                    Instantiator.NewSnack("Your attempt to flee fails");
                    PassTurn();
                }
            }
            return(result);
        }
    }
예제 #11
0
    private void DisplayStat()
    {
        var    stat               = Constants.LastEndActionClickedName;
        int    statId             = (int)Soul.GetFieldValue(stat + "_Id");
        int    statLevel          = (int)Soul.GetFieldValue(stat + "_Level");
        int    statAdd            = (int)Soul.GetFieldValue(stat + "_Add");
        string statName           = Soul.SoulStatsNames[statId];
        string statDescription    = Soul.SoulStatsDescriptions[statId];
        string statUnit           = Soul.SoulStatsUnit[statId];
        var    fullTitle          = statName + (statLevel > 0 ? "  " + statLevel.ToString() : string.Empty);
        var    currentDescription = statDescription + MakeContent("Current:", " +" + (statAdd * statLevel) + " " + statUnit);

        //Plural
        if (statUnit.Length > 3 && statUnit[0] != '<') //Check '<' because of custom materials
        {
            if (statAdd * statLevel > 1)
            {
                currentDescription += "s";
            }
        }
        Instantiator.NewPopupYesNo(fullTitle, currentDescription, null, "Ok", AfterDisplayStat);

        object AfterDisplayStat(bool result)
        {
            return(result);
        }
    }
예제 #12
0
        public static object Call(Type interfaceType)
        {
            var callerProvider = BusRouters.GetProviderToCallInternalInstance(interfaceType);

            if (queryClients.Count > 0)
            {
                if (queryClients.Keys.Contains(interfaceType))
                {
                    //Not a local call so apply cache layer at Bus level
                    var providerCacheType = Discovery.GetImplementationType(interfaceType, iCacheProviderType, false);
                    if (providerCacheType != null)
                    {
                        var methodSetNextProvider = TypeAnalyzer.GetMethodDetail(providerCacheType, nameof(BaseLayerProvider <IBaseProvider> .SetNextProvider)).MethodInfo;
                        if (methodSetNextProvider != null)
                        {
                            var providerCache = Instantiator.GetSingleInstance($"{providerCacheType.FullName}_Bus.Call_Cache", () =>
                            {
                                var instance = Instantiator.CreateInstance(providerCacheType);
                                methodSetNextProvider.Invoke(instance, new object[] { callerProvider });
                                return(instance);
                            });

                            return(providerCache);
                        }
                    }
                }
            }

            return(callerProvider);
        }
예제 #13
0
    /*
     * TouchPanel 1
     * ------------
     * Erzeugen von Kreisen an Kontakt 0
     * und Echtzeitskallierung bei halten
     */
    void OneFinger()
    {
        switch (tapCount)
        {
        case 1:
            //Figur inititalisieren
            Vector2 touchpos  = Input.GetTouch(0).position;
            Vector3 createpos = Camera.main.ScreenToWorldPoint(new Vector3(touchpos.x, touchpos.y, 0));

            GameObject i;
            switch (shapeType)
            {
            // Circle
            case 0: i = dashedLine ? circleDashed : circle; break;

            // Half circle
            case 1: i = circleHalfDashed; break;

            // Triangle
            case 2: i = dashedLine ? triangleDashed : triangle; break;

            // Rectangle
            default: i = box; break;
            }
            Instantiator.scale(i, new Vector3(createpos.x, createpos.y, 0));
            break;

        case 2:
            shapeType += 1;
            shapeType %= 4;
            //Figur initialisieren & strichelung wechseln
            break;
        }
    }
예제 #14
0
        public static T Inject <T>()
        {
            T            instance     = default(T);
            Type         key          = typeof(T);
            Type         type         = null;
            Instantiator instanciator = null;


            object value;

            if (instances.TryGetValue(key, out value))
            {
                instance = (T)value;
            }
            else if (instanciators.TryGetValue(key, out instanciator))
            {
                instance = (T)(object)instanciator();
            }
            else if (types.TryGetValue(key, out type))
            {
                instance = (T)Activator.CreateInstance(type);
            }
            else
            {
                throw Error.Create(HttpStatusCode.InternalServerError, "Dependency injection error: The type ({0}) you try to instanciate is not registered", key.Name);
            }

            return(instance);
        }
예제 #15
0
 private void GainLoot()
 {
     if (_loot != null && _loot.Count > 0)
     {
         var itemsNames = "";
         foreach (var item in _loot)
         {
             itemsNames += "\n" + item.GetNameWithColor();
         }
         Instantiator.NewPopupYesNo("Loot", "You looted:" + itemsNames, string.Empty, "Ok", OnPositiveOutcome);
     }
     else
     {
         Instantiator.NewPopupYesNo("Loot", "No items were in a good enough shape in order to be looted...", string.Empty, "Oh...", OnPositiveOutcome);
     }
     object OnPositiveOutcome(bool result)
     {
         if (_loot != null && _loot.Count > 0)
         {
             PlayerBhv.Character.AddToInventory(_loot, OnLootGained);
         }
         else
         {
             OnLootGained(false);
         }
         return(result);
     }
 }
예제 #16
0
        public void CanInstanstiateClassWithoutDefaultCtr()
        {
            var expectedType = typeof(SampleAssembly.ClassWithoutDefaultCtr);
            var obj          = Instantiator.InstanstiateClass(typeof(SampleAssembly.ClassWithoutDefaultCtr));

            Assert.AreEqual(expectedType, obj.GetType());
        }
예제 #17
0
 public override void Initialize(Instantiator instantiator, GameObject wall)
 {
     if (!photonView.isMine)
     {
         return;
     }
     base.Initialize(instantiator, wall);
 }
예제 #18
0
 private void OnSceneGUI()
 {
     instan          = target as Instantiator;
     handleTransform = instan.transform;
     handleRotation  = Tools.pivotRotation == PivotRotation.Local ?
                       handleTransform.rotation : Quaternion.identity;
     DrawSceneHandle("Instantiate Position", ref instan.instantiatePosition, ref isInstanPosSelected);
 }
예제 #19
0
        public object CreateView()
        {
            var createdPrefab = Instantiator.InstantiatePrefab(PrefabTemplate);

            createdPrefab.transform.position = Vector3.zero;
            createdPrefab.transform.rotation = Quaternion.identity;
            return(createdPrefab);
        }
예제 #20
0
 protected virtual void SetPrivates()
 {
     Application.targetFrameRate = 60;
     NavigationService.TrySetCurrentRootScene(SceneManager.GetActiveScene().name);
     Instantiator = GetComponent <Instantiator>();
     Soul         = PlayerPrefsHelper.GetSoul();
     Journey      = PlayerPrefsHelper.GetJourney();
 }
예제 #21
0
    public void OnPlayerCharacterClick()
    {
        int orderId   = int.Parse(Constants.LastEndActionClickedName.Substring(Helper.CharacterAfterString(Constants.LastEndActionClickedName, "FrameCharacter")));
        var character = GetCharacterBhvFromOrderId(orderId).Character;

        //ShowCharacterLifeName(character);
        Instantiator.NewPopupCharacterStats(character, null);
    }
예제 #22
0
    public void Init(int chunkOffsetX, int chunkOffsetY, Transform tilemap, TileType[,] tiles, GameObject[,] gameobjects, int viewStartXIndex, int viewStartYIndex,
                     GameObject testPrefab)
    {
        // Debug.Log("x: " + viewStartXIndex);
        TilemapTilesView = new View <TileType>(tiles, viewStartXIndex, viewStartYIndex, CHUNK_SIZE); // 0 1 2    // SETVIEW;
        GameObjectView   = new View <GameObject>(gameobjects, viewStartXIndex, viewStartYIndex, CHUNK_SIZE);

        offsetX = chunkOffsetX;
        offsetY = chunkOffsetY;

        chunkOffsetX *= CHUNK_SIZE;
        chunkOffsetY *= CHUNK_SIZE;

        GameObject parent = new GameObject("Chunk(" + offsetX + "," + offsetY + ")");

        parent.transform.parent = tilemap;

        for (int y = 0; y < CHUNK_SIZE; y++)
        {
            for (int x = 0; x < CHUNK_SIZE; x++)
            {
                TilemapTilesView[y, x] = TileType.Invalid;


    #if false
                // GameObject tileObject = TileMap.Instantiate(testPrefab);  // new GameObject("(" + y + "," + x + ")");
                GameObject tileObject = Instantiator.instantiateGo(testPrefab);
    #else
                GameObject tileObject = new GameObject("(" + y + "," + x + ")");
    #endif

                tileObject.transform.parent   = parent.transform;
                tileObject.transform.position = new Vector3(x + chunkOffsetX, y + chunkOffsetY, 0);
                tileObject.layer = 9;

                GameObjectView[y, x] = tileObject;

    #if false
                /* SpriteRenderer spriteRenderer = */
                tileObject.GetComponent <SpriteRenderer>().sortingLayerName = "TileMap";
                tileObject.GetComponent <BoxCollider2D>().enabled           = false;
                // var anim = tileObject.AddComponent<Animator>();
    #else
                var sr = tileObject.AddComponent <SpriteRenderer>();
                sr.sortingLayerName = "TileMap";
                var bc = tileObject.AddComponent <BoxCollider2D>();
                bc.enabled = false;

                // test
                var anime = tileObject.AddComponent <TileAnime>();
                anime.enabled = false;
#endif
            }
        }

        _parent = new GameObject("Chunk " + offsetX + ", " + offsetY);
        _parent.transform.parent = tilemap;
    }
예제 #23
0
    public void UpdateIcon(bool down, string key = null, InputType type = InputType.Tap)
    {
        if (!enabled)
        {
            return;
        }
        if (_framesDown < _minFramesDown)
        {
            ++_framesDown;
            down = true;
        }

        if (down)
        {
            if (!_isDown)
            {
                _framesDown = 0;
            }
            _isDown          = true;
            _mainIcon.sprite = IconDown;
        }
        else
        {
            _isDown          = false;
            _mainIcon.sprite = IconUp;
        }

        if (key != null)
        {
            var position = _singleTapSpawn.position;
            if (type == InputType.CustomTap)
            {
                position = _customTapSpawn.position;
            }
            else if (type == InputType.Held)
            {
                position = _heldSpawn.position;
            }
            else if (type == InputType.CustomHeld)
            {
                position = _timeHeldSpawn.position;
            }
            if (key == "_")
            {
                position += new Vector3(0.0f, -0.25f, 0.0f);
                Instantiator.PopNoShadowText(key.ToLower(), position + new Vector3(0.0f, 1.5f, 0.0f), distance: 2.0f, startFadingDistancePercent: 0.50f);
            }
            else if (key != string.Empty)
            {
                if (key.ToLower() == "noname")
                {
                    key = "none";
                }
                Instantiator.PopText(key.ToLower(), position + new Vector3(0.0f, 1.5f, 0.0f), distance: 2.0f, startFadingDistancePercent: 0.50f);
            }
        }
    }
예제 #24
0
 public void GoToNextScene()
 {
     //_soul = PlayerPrefsHelper.GetSoul();
     PlayerPrefsHelper.SaveSoul(Soul);
     //DEBUG CREATION
     //Instantiator.NewOverBlend(OverBlendType.StartLoadMidActionEnd, "YOUR NEW BODY AWAITS", 2.0f, OnToRaceChoiceScene);
     //DEBUG SELECTION
     Instantiator.NewOverBlend(OverBlendType.StartLoadMidActionEnd, "YOUR NEW BODY AWAITS", 2.0f, OnToCharacterSelectionScene);
 }
예제 #25
0
        public sealed override T Rent(bool initialize = false)
        {
            var instance = Instantiator.Instantiate();

            {
                instance.PoolManager = PoolManager;
            }
            return(instance);
        }
예제 #26
0
    private void SetButtons()
    {
        GameObject.Find("ButtonPause").GetComponent <ButtonBhv>().EndActionDelegate     = Pause;
        GameObject.Find("CharacterButton").GetComponent <ButtonBhv>().EndActionDelegate = ShowCharacterStats;
        GameObject.Find("ButtonInventory").GetComponent <ButtonBhv>().EndActionDelegate = ShowInventory;
        if (Constants.CardsInCache == true)
        {
            LoadCurrentCards();
        }
        else
        {
            if (Journey.Step > Journey.Biome.Steps) //Just '<' because it instantiates one in advance
            {
                //++Journey.CurrentBiomeChoice;
                Instantiator.NewCardBiome(1, Journey.Day, Journey.Biome, Journey.CurrentBiomeChoice, Journey.Biome.Destinations, _playerCharacter);
                if (Journey.Biome.Destinations > 1 && Journey.CurrentBiomeChoice < Journey.Biome.Destinations)
                {
                    //++Journey.CurrentBiomeChoice;
                    Instantiator.NewCardBiome(0, Journey.Day, Journey.Biome, Journey.CurrentBiomeChoice + 1, Journey.Biome.Destinations, _playerCharacter);
                }
                else
                {
                    _avoidBhv.DisableButton();
                }
            }
            else
            {
                Instantiator.NewRandomCard(1, Journey.Day, Journey.Biome, _playerCharacter);
                if (Journey.Step < Journey.Biome.Steps)
                {
                    Instantiator.NewRandomCard(0, Journey.Day, Journey.Biome, _playerCharacter);
                }
                else
                {
                    Instantiator.NewCardBiome(0, Journey.Day, Journey.Biome, Journey.CurrentBiomeChoice, Journey.Biome.Destinations, _playerCharacter);
                }
            }
        }
        _currentCard = GameObject.Find("Card1");
        _avoidBhv.EndActionDelegate            = _currentCard.GetComponent <CardBhv>().Avoid;
        _ventureBhv.EndActionDelegate          = _currentCard.GetComponent <CardBhv>().Venture;
        PauseMenu.Buttons[0].EndActionDelegate = Resume;
        PauseMenu.TextMeshes[0].text           = "Resume";
        PauseMenu.Buttons[1].EndActionDelegate = GiveUp;
        PauseMenu.TextMeshes[1].text           = "Give Up";
        PauseMenu.Buttons[2].EndActionDelegate = GoToSoul;
        PauseMenu.TextMeshes[2].text           = "Soul";
        PauseMenu.Buttons[3].EndActionDelegate = Settings;
        PauseMenu.TextMeshes[3].text           = "Settings";
        PauseMenu.Buttons[4].EndActionDelegate = Exit;
        PauseMenu.TextMeshes[4].text           = "Exit";

        if (!Soul.HasAtLeastOneLeveledStat())
        {
            PauseMenu.Buttons[2].DisableButton();
        }
    }
예제 #27
0
 private void GameStart()
 {
     _gridBhv.ResetAllCellsDisplay();
     _gridBhv.ResetAllCellsVisited();
     _gridBhv.SpawnOpponent(OpponentBhvs);
     _gridBhv.SpawnPlayer();
     IsWaitingStart = false;
     Instantiator.NewOverTitle(_map.Name, "Sprites/MapTitle_0", null, Direction.Left);
 }
예제 #28
0
    private void AddAction()
    {
        var    stat               = Constants.LastEndActionClickedName.Substring(Helper.CharacterAfterString(Constants.LastEndActionClickedName, "Add"));
        int    statId             = (int)Soul.GetFieldValue(stat + "_Id");
        int    statLevel          = (int)Soul.GetFieldValue(stat + "_Level");
        int    statMax            = (int)Soul.GetFieldValue(stat + "_Max");
        int    statAdd            = (int)Soul.GetFieldValue(stat + "_Add");
        int    statPrice          = (int)Soul.GetFieldValue(stat + "_Price");
        string statName           = Soul.SoulStatsNames[statId];
        string statDescription    = Soul.SoulStatsDescriptions[statId];
        string statUnit           = Soul.SoulStatsUnit[statId];
        var    fullTitle          = statName + (statLevel > 0 ? "  " + statLevel.ToString() : string.Empty);
        var    currentDescription = statDescription + MakeContent("Current:", " +" + (statAdd * statLevel) + " " + statUnit);
        var    currentPrice       = statPrice * (statLevel + 1);
        var    negative           = "Cancel";
        var    positive           = "<material=\"LongOrange\">" + currentPrice.ToString() + "</material>";

        if (statLevel == statMax || Soul.Xp < currentPrice)
        {
            negative = null;
            positive = "Back";
        }
        var nextDescription = string.Empty;

        if (statLevel != statMax)
        {
            nextDescription += MakeContent("Next:", " +" + (statAdd * (statLevel + 1)) + " " + statUnit);
        }
        //Plural
        if (statUnit.Length > 3 && statUnit[0] != '<') //Check '<' because of custom materials
        {
            if (statAdd * statLevel > 1)
            {
                currentDescription += "s";
            }
            if (statAdd * (statLevel + 1) > 1 && nextDescription != string.Empty)
            {
                nextDescription += "s";
            }
        }
        Instantiator.NewPopupYesNo(fullTitle, currentDescription + nextDescription, negative, positive, AfterAddAction);

        object AfterAddAction(bool result)
        {
            if (result == false || statLevel == statMax || Soul.Xp < currentPrice)
            {
                return(result);
            }
            Soul.Xp -= currentPrice;
            var levelFieldInfo = Soul.GetType().GetField(stat + "_Level");

            levelFieldInfo.SetValue(Soul, statLevel + 1);
            UpdateTreeDisplay();
            return(result);
        }
    }
예제 #29
0
        public object Instantiate(object id)
        {
            object result = Instantiator.Instantiate(id);

            if (id != null)
            {
                SetIdentifier(result, id);
            }
            return(result);
        }
        /// <summary>
        /// Creates a new instance of the prefab.
        /// </summary>
        public T Create()
        {
            if (CurrentObject != null)
            {
                throw new Exception("You can only instantiate one object");
            }

            CurrentObject = Instantiator.InstantiateObject(_prefab);
            return(CurrentObject);
        }
        public void should_delegate_instantiation_to_provided_lambda()
        {
            var o = new object();
            var instantiator = new Instantiator(o);

            var container = new Container(x => x.For<object>().Use(instantiator.Get));
            var instance = container.Get<object>();

            instance.Should().NotBeNull();
            instantiator.Executed.Should().BeTrue();
        }
예제 #32
0
        public override object GetInstance(Type contractType, InjectContext context)
        {
            if (_instantiator == null)
            {
                _instantiator = _container.Resolve<Instantiator>();
            }

            var obj = _instantiator.Instantiate(GetTypeToInstantiate(contractType));
            Assert.That(obj != null);
            return obj;
        }
예제 #33
0
        public object GetInstance(Type contractType)
        {
            if (!_hasInstance)
            {
                if (_instantiator == null)
                {
                    _instantiator = _container.Resolve<Instantiator>();
                }

                _instance = _instantiator.Instantiate(GetTypeToInstantiate(contractType));
                Assert.That(_instance != null);
                _hasInstance = true;
            }

            return _instance;
        }
예제 #34
0
        public void CreatesInstanceResolvingConstructorParamsViaInjector()
        {
            Instantiator instantiator;
            TestClassWithConstructorWithDependency instance;
            ITestDependency dependency;
            IDivineInjector injector;

            Scenario()
                .Given(dependency = AMock<ITestDependency>().Instance)
                .Given(injector = AMock<IDivineInjector>()
                    .WhereMethod(i => i.IsBound(typeof(ITestDependency))).Returns(true)
                    .WhereMethod(i => i.Get(typeof(ITestDependency))).Returns(dependency)
                    .Instance)
                .Given(instantiator = new Instantiator(injector))

                .When(instance = instantiator.Create<TestClassWithConstructorWithDependency>())

                .Then(instance, Is(AnInstance.NotNull<TestClassWithConstructorWithDependency>()))
                .Then(instance.Dependency, Is(AnInstance.SameAs(dependency)));
        }
예제 #35
0
        public void CreatesInstanceUsingFirstConstructorThatCanBeInjected()
        {
            Instantiator instantiator;
            TestClassWithAnUninjectableConstructor instance;
            ITestDependency dependency;
            IDivineInjector injector;

            Scenario()
                .Given(dependency = AMock<ITestDependency>().Instance)
                .Given(injector = AMock<IDivineInjector>()
                    .WhereMethod(i => i.IsBound(typeof(ITestDependency))).Returns(true)
                    .WhereMethod(i => i.IsBound(typeof(string))).Returns(false)
                    .WhereMethod(i => i.Get(typeof(ITestDependency))).Returns(dependency)
                    .Instance)
                .Given(instantiator = new Instantiator(injector))

                .When(instance = instantiator.Create<TestClassWithAnUninjectableConstructor>())

                .Then(instance, Is(AnInstance.NotNull<TestClassWithAnUninjectableConstructor>()))
                .Then(instance.Dependency, Is(AnInstance.SameAs(dependency)));
        }
예제 #36
0
        public void CreatesInstanceUsingConstructorWithFewestNumberOfParameters()
        {
            Instantiator instantiator;
            TestClassWithTwoConstructorsWithDependencies instance;
            ITestDependency dependency;
            IDivineInjector injector;

            Scenario()
                .Given(dependency = AMock<ITestDependency>().Instance)
                .Given(injector = AMock<IDivineInjector>()
                    .WhereMethod(i => i.IsBound(typeof(ITestDependency))).Returns(true)
                    .WhereMethod(i => i.IsBound(typeof(ITestSecondDependency))).Returns(false)
                    .WhereMethod(i => i.Get(typeof(ITestDependency))).Returns(dependency)
                    .Instance)
                .Given(instantiator = new Instantiator(injector))

                .When(instance = instantiator.Create<TestClassWithTwoConstructorsWithDependencies>())

                .Then(instance, Is(AnInstance.NotNull<TestClassWithTwoConstructorsWithDependencies>()))
                .Then(instance.Dependency, Is(AnInstance.SameAs(dependency)));
        }
예제 #37
0
 public PlaneShiftFactory(Instantiator instantiator)
 {
     this.instantiator = instantiator;
 }
예제 #38
0
        public void CreateThrowsExceptionInCaseNoInjectableConstructorsFound()
        {
            Instantiator instantiator;
            ITestDependency dependency;
            IDivineInjector injector;
            Exception exception;

            Scenario()
                .Given(dependency = AMock<ITestDependency>().Instance)
                .Given(injector = AMock<IDivineInjector>()
                    .WhereMethod(i => i.IsBound(typeof(ITestSecondDependency))).Returns(false)
                    .WhereMethod(i => i.IsBound(typeof(string))).Returns(false)
                    .Instance)
                .Given(instantiator = new Instantiator(injector))

                .When(exception = CaughtException(() => instantiator.Create<TestClassThatCannotBeInjected>()))

                .Then(exception,
                    Is(AnException.Of().Type<BindingException>()
                        .Message("Cannot create DivineInject.Test.TestClassThatCannotBeInjected, could not find an injectable constructor because the following types are not injectable: System.String, DivineInject.Test.ITestSecondDependency")));
        }
예제 #39
0
        public void CreatesInstanceUsingNoArgConstructor()
        {
            Instantiator instantiator;
            object instance;

            Scenario()
                .Given(instantiator = new Instantiator(AMock<IDivineInjector>().Instance))

                .When(instance = instantiator.Create<TestClassWithNoArgConstructor>())

                .Then((TestClassWithNoArgConstructor)instance, Is(AnInstance.NotNull<TestClassWithNoArgConstructor>()));
        }
예제 #40
0
 public ProjectileFactory(Instantiator instantiator)
 {
     this.instantiator = instantiator;
 }
예제 #41
0
 public ShipStateFactory(Instantiator instantiator)
 {
     _instantiator = instantiator;
 }
예제 #42
0
 public AbilityFactory(Instantiator instantiator)
 {
     this.instantiator = instantiator;
 }