当前位置: 首页>>代码示例>>C#>>正文


C# Hex.SetPlayerHab方法代码示例

本文整理汇总了C#中Hex.SetPlayerHab方法的典型用法代码示例。如果您正苦于以下问题:C# Hex.SetPlayerHab方法的具体用法?C# Hex.SetPlayerHab怎么用?C# Hex.SetPlayerHab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hex的用法示例。


在下文中一共展示了Hex.SetPlayerHab方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Expand

    public void Expand(Hex newHabitat, Hex oldHabitat)
    {
        int habIndex = habitats.IndexOf(oldHabitat);
        int colonyPop = (int)adultPopulations[habIndex] / 2;
        int cost = 3;

        if(migrationTokens >= cost && !newHabitat.localCritters.Contains(this)){
            migrationTokens -= cost;

            if (isPlayer)
            {
                CheckMigrationAnimationState(migrationTokens);
            }

            habitats.Add(newHabitat);
            adultPopulations.Add(colonyPop);
            adultPopulations[habIndex] -= colonyPop;
            cubPopulations.Add(10);
            babyPopulations.Add(5);
            newHabitat.localCritters.Add(this);
            newHabitat.localCritters.TrimExcess();

            adultPopulations[habIndex] -= colonyPop;

            BreedTokens(oldHabitat);

            AgeTokens(oldHabitat, Token.AgeGroup.Adult);
            AgeTokens(oldHabitat, Token.AgeGroup.Cub);
            AgeTokens(oldHabitat, Token.AgeGroup.Baby);

            foreach(Token token in tokenList){
                if(token.GetAge() == Token.AgeGroup.Adult && token.GetHex() == oldHabitat){
                    StopCoroutine("Wander");
                    token.SetHex(newHabitat);
                    token.gameObject.transform.SetParent(newHabitat.transform);
                    token.StartCoroutine("Wander");
                    AgeTokens(oldHabitat, Token.AgeGroup.Adult);

                    break;
                }
            }

            if(isPlayer){
                newHabitat.SetPlayerHab(true);
            }

            BreedTokens(newHabitat);
        }

        //print ("Critter# " + number + " expanded from Hex# " + habitat.GetNumber() + " to neighboring Hex# " + newHabitat.GetNumber() + ".\r\n");
    }
开发者ID:Paulgherve1,项目名称:Critters,代码行数:51,代码来源:Critter.cs

示例2: Migrate

    public void Migrate(Hex newHabitat, Hex oldHabitat)
    {
        int oldHabIndex = habitats.IndexOf(oldHabitat);
        int cost = 1;

        if(migrationTokens >= cost && !newHabitat.localCritters.Contains(this)){
            migrationTokens -= cost;

            if (isPlayer)
            {
                CheckMigrationAnimationState(migrationTokens);
            }

            habitats.Add(newHabitat);
            adultPopulations.Add(adultPopulations[oldHabIndex]);
            cubPopulations.Add(cubPopulations[oldHabIndex]);
            babyPopulations.Add(babyPopulations[oldHabIndex]);
            newHabitat.localCritters.Add(this);
            newHabitat.localCritters.TrimExcess();

            adultPopulations[oldHabIndex] = 0;
            cubPopulations[oldHabIndex] = 0;
            babyPopulations[oldHabIndex] = 0;

            Death(oldHabitat);

            tokenList.TrimExcess();

            foreach(Token token in tokenList){
                if(token.GetHex() == oldHabitat){
                    StopCoroutine("Wander");
                    token.SetHex(newHabitat);
                    token.gameObject.transform.SetParent(newHabitat.transform);
                    token.StartCoroutine("Wander");
                }
            }

            oldHabitat.localCritters.TrimExcess();

            if(isPlayer){
                oldHabitat.SetPlayerHab(false);
                newHabitat.SetPlayerHab(true);
                oldHabitat.RemoveWarnings();
            }
        }

        //print("Critter# " + number + " Migrated from Hex# " + oldHabitat + " to Hex# " + newHabitat + ".\r\n");
    }
开发者ID:Paulgherve1,项目名称:Critters,代码行数:48,代码来源:Critter.cs

示例3: Death

    //What happens when you die?
    void Death(Hex habitat)
    {
        int i = habitats.IndexOf(habitat);

        //print ("Critter#" + number + " Died out in Hex# " + habitat.GetNumber() + ".\r\n");

        StopCoroutine("Eat");
        StopCoroutine("Breed");
        StopCoroutine("Cleanup");

        UpdateStats();

        adultPopulations.RemoveAt(i);
        adultPopulations.TrimExcess();
        cubPopulations.RemoveAt(i);
        cubPopulations.TrimExcess();
        babyPopulations.RemoveAt(i);
        babyPopulations.TrimExcess();
        habitats.Remove(habitat);
        habitats.TrimExcess();
        habitat.localCritters.Remove(this);
        habitat.localCritters.TrimExcess();

        if(isPlayer){
            habitat.SetPlayerHab(false);
            habitat.RemoveWarnings();
        }

        for(int n = 0; n < tokenList.Count; n++){
            Token token = tokenList[n];

            if(token.GetHex() == habitat){
                token.Die();
            }
        }
    }
开发者ID:Paulgherve1,项目名称:Critters,代码行数:37,代码来源:Critter.cs

示例4: Generate

    //Runs Generators to create values for each species.
    public void Generate(Hex hex, bool isPlayer)
    {
        name = "Bob " + num; num++;
        GenerateSize();

        GameObject creature = Instantiate(Creature, transform.position, Quaternion.identity) as GameObject;
        critter = creature.GetComponent<Critter>();

        //Assigns generated values for each Species after being Instantiated.
        creature.name = name;
        critter.SetName (name);
        critter.SetNumber(critterCount);

        critter.SetIsPlayer(isPlayer);
        critter.SetSize(size);
        baseFoodValue = (size*size) * 10;
        critter.SetBaseFoodValue(baseFoodValue);
        critter.SetSpeed(StatGenerator());
        critter.SetSneak(StatGenerator());
        critter.SetSense(StatGenerator());
        critter.SetOffense(StatGenerator());
        critter.SetDefense(StatGenerator());
        critter.ModifyEvoPts(startEvoPts);

        critter.adultPopulations.Add(startPop);
        critter.cubPopulations.Add(startPop * .25f);
        critter.babyPopulations.Add(startPop * .25f);
        CreateCritterLists(critterCount);
        AddToLocalCritterList(critter, hex);
        critter.InitializeSlots();
        critter.ResetPreferences();
        UnlockCritterStartEvos(critter);

        if (isPlayer){
            Player player = FindObjectOfType<Player>();

            critter.SetName(player.GetCritterName());
            critter.SetTokenSprite(player.GetCritterTokenSprite());
            critter.SetTokenColor(player.GetCritterTokenColor());
            player.SetCritter(critter);
            hex.SetPlayerHab(true);

        }else if(!isPlayer){
            critter.SetTokenSprite(SelectSprite());
            critter.SetTokenColor(GenerateColor());
            critter.GenerateTokens();
        }
        critter.InitializePopsList();

        critterCount++;
    }
开发者ID:Paulgherve1,项目名称:Critters,代码行数:52,代码来源:CritterGenerator.cs


注:本文中的Hex.SetPlayerHab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。