Ejemplo n.º 1
0
    void Update()
    {
        if (generator == null)
        {
            return;
        }
        if (usingLatestConfig)
        {
            return;
        }
        if (!generator.ConfigReady)
        {
            return;
        }

        usingLatestConfig = true;

        if (newCharacterRequested)
        {
            //新角色的加载过程
            Destroy(character);
            character = generator.Generate();
            Animation a = character.GetComponent <Animation>();
            a.Play("idle1");
            a["idle1"].wrapMode   = WrapMode.Loop;
            newCharacterRequested = false;

            if (!firstCharacter)
            {
                return;
            }
            firstCharacter = false;
            if (a["walkin"] == null)
            {
                return;
            }
            a["walkin"].layer  = 1;
            a["walkin"].weight = 1;
            a.CrossFade("walkin", 0.8f);
            character.GetComponent <SkinnedMeshRenderer>().updateWhenOffscreen = true;
        }
        else
        {
            //不加载新角色,更新角色部件的过程
            character = generator.Generate(character);
            if (nonLoopingAnimationToPlay == null)
            {
                return;
            }
            Animation a = character.GetComponent <Animation>();
            a[nonLoopingAnimationToPlay].layer  = 1;
            a[nonLoopingAnimationToPlay].weight = 1;
            a.CrossFade(nonLoopingAnimationToPlay, 0.8f);
            nonLoopingAnimationToPlay = null;
        }
    }
Ejemplo n.º 2
0
    private IEnumerator GenerateCharacter()
    {
        while (!CharacterGenerator.ReadyToUse)
        {
            yield return(0);
        }

        CharacterGenerator generator = CharacterGenerator.CreateWithConfig(PlayerStats.config);

        while (!generator.ConfigReady)
        {
            yield return(0);
        }

        GameObject tempObject = generator.Generate();

        tempObject.transform.parent        = myTransform;
        tempObject.transform.localPosition = new Vector3(0, 0.5f, 0);
        tempObject.transform.localRotation = Quaternion.identity;
        tempObject.transform.localScale    = new Vector3(0.01f, 0.01f, 0.01f);

        movingTransform = tempObject.transform;
        myAnimation     = movingTransform.GetComponent <Animation>();

        AssignVariables();
    }
Ejemplo n.º 3
0
        private void StartPlaying()
        {
            areaGenerator.Generate();
            //Add Rulers
            characterGenerator.Generate(CharacterType.Ruler, Rarity.Normal,
                                        areaGenerator.GetTile(0, 0).transform,
                                        turnManager.Players[0]);

            characterGenerator.Generate(CharacterType.Ruler, Rarity.Normal,
                                        areaGenerator.GetTile(areaGenerator.GridSize - 1, areaGenerator.GridSize - 1).transform,
                                        turnManager.Players[1]);

            //Set actions for base panel
            uiManager.BasePanelUIManager.SetBuyNormal(() => BuyCharacter(Rarity.Normal));
            uiManager.BasePanelUIManager.SetBuyMagic(() => BuyCharacter(Rarity.Magic));
            uiManager.BasePanelUIManager.SetBuyRare(() => BuyCharacter(Rarity.Rare));

            uiManager.BasePanelUIManager.SetButtonValues(normalPrice, magicPrice, rarePrice);
        }
    public IEnumerator GenerateCharacter(string config)
    {
        while (!CharacterGenerator.ReadyToUse)
        {
            yield return(0);
        }

        CharacterGenerator generator = CharacterGenerator.CreateWithConfig(config);

        while (!generator.ConfigReady)
        {
            yield return(0);
        }

        GameObject tempObject = generator.Generate();

        tempObject.transform.parent        = myTransform;
        tempObject.transform.localPosition = new Vector3(0, 0.5f, 0);
        tempObject.transform.localRotation = Quaternion.identity;
        tempObject.transform.localScale    = new Vector3(0.01f, 0.01f, 0.01f);

        Transform tempTransform = tempObject.transform.Search("Bone_Rotation");

        //Adicionar os trails como filho para o bone certo
        GameObject tempSword = (GameObject)Instantiate(swordHolder, myTransform.position, Quaternion.identity);

        tempSword.transform.parent        = myTransform.Search("Bone_Hand_R");
        tempSword.transform.localPosition = Vector3.zero;
        tempSword.transform.localRotation = Quaternion.identity;
        tempSword.transform.localScale    = new Vector3(1, 1, 1);
        //------------------------------------------------

        transformReceiver.movementTransform = tempObject.transform;
        transformReceiver.boneTransform     = tempTransform;

        transformInterpolation.movementTransform = tempObject.transform;
        transformInterpolation.boneTransform     = tempTransform;
        transformInterpolation.StartReceiving();

        charAnimator.myAnimation    = GetComponentInChildren <Animation>();
        charAnimator.TorsoTransform = tempTransform;
        charAnimator.PrepareAnimations();
        //transformInterpolation

        //movingTransform = tempObject.transform;
        //myAnimation = movingTransform.GetComponent<Animation>();

        //AssignVariables();
    }
Ejemplo n.º 5
0
    // Requests a new character when the required assets are loaded, starts
    // a non looping animation when changing certain pieces of clothing.
    void Update()
    {
        if (generator == null)
        {
            return;
        }
        if (usingLatestConfig)
        {
            return;
        }
        if (!generator.ConfigReady)
        {
            return;
        }

        usingLatestConfig = true;

        if (newCharacterRequested)
        {
            Destroy(character);
            character = generator.Generate();
            character.animation.Play("idle1");
            character.animation["idle1"].wrapMode = WrapMode.Loop;
            newCharacterRequested = false;

            // Start the walkin animation for the first character.
            if (!firstCharacter)
            {
                return;
            }
            firstCharacter = false;
            if (character.animation["walkin"] == null)
            {
                return;
            }

            // Set the layer to 1 so this animation takes precedence
            // while it's blended in.
            character.animation["walkin"].layer = 1;

            // Use crossfade, because it will also fade the animation
            // nicely out again, using the same fade length.
            character.animation.CrossFade("walkin", fadeLength);

            // We want the walkin animation to have full weight instantly,
            // so we overwrite the weight manually:
            character.animation["walkin"].weight = 1;

            // As the walkin animation starts outside the camera frustrum,
            // and moves the mesh outside its original bounding box,
            // updateWhenOffscreen has to be set to true for the
            // SkinnedMeshRenderer to update. This should be fixed
            // in a future version of Unity.
            character.GetComponent <SkinnedMeshRenderer>().updateWhenOffscreen = true;
        }
        else
        {
            character = generator.Generate(character);

            if (nonLoopingAnimationToPlay == null)
            {
                return;
            }

            character.animation[nonLoopingAnimationToPlay].layer = 1;
            character.animation.CrossFade(nonLoopingAnimationToPlay, fadeLength);
            nonLoopingAnimationToPlay = null;
        }
    }
Ejemplo n.º 6
0
 public void GenerateEnemy()
 {
     generator.Generate(enemyClass, atk, 0, health, speedX, speedY);
 }
Ejemplo n.º 7
0
        private static void Execute()
        {
            // Set up the configuration and generator.
            Config config = null;

            try
            {
                var configJson = File.ReadAllText("config.json");
                config = JsonConvert.DeserializeObject <Config>(configJson);
            }
            catch (FileNotFoundException) { throw new CharGenException("config.json could not be found. Please restart the program with this file present."); }
            catch (JsonReaderException jrex)
            {
                bool isPathError = jrex.Message.Contains("ckii_folder_path") || jrex.Message.Contains("mod_folder_path");

                if (isPathError)
                {
                    throw new CharGenException("config.json was not readable due to a malformed path. Please make sure to escape the paths by using \\\\ instead of a single \\.");
                }
                throw new CharGenException("config.json was not readable due to \"" + jrex.Message + "\".");
            }

            // Parse the cultures.
            var cultureLoader = new CultureLoader();

            cultureLoader.Load(cultureLoader.GetDirectory(config.ModPath));
            var culture = cultureLoader[config.Culture];

            // Make sure that the culture was correct.
            if (culture == null)
            {
                throw new CharGenException("Culture \'" + config.Culture + "\' was not found. Did you make a typo?");
            }

            var dynastyLoader = new DynastyLoader();

            dynastyLoader.Load(dynastyLoader.GetDirectory(config.ModPath));
            var dynasty = dynastyLoader[config.DynastyId.ToString()];

            // Generate some characters.
            var characterGenerator = new CharacterGenerator(new CharacterGenerator.Config()
            {
                Culture     = culture,
                Dynasty     = dynasty,
                Year        = new Range(config.MinimumYear, config.MaximumYear),
                FertileAge  = new Range(config.MinimumFertileAge, config.MaximumFertileAge),
                Age         = new Range(config.MinimumAge, config.MaximumAge),
                FirstCharId = config.FirstCharId.ToString(),
                ReligionId  = config.Religion
            });

            characterGenerator.Generate();

            // Write the characters to a file.
            var filename = dynasty.Culture.ToLower() + "_" + dynasty.Id + "_" + dynasty.Name.ToLower() + ".txt";

            characterGenerator.Write(filename);

            // Generate title history.
            var titleHistoryGenerator = new TitleHistoryGenerator(new TitleHistoryGenerator.Config()
            {
                MaximumSuccessionYear = config.MaximumSuccessionYear,
                Characters            = characterGenerator.Items
            });

            titleHistoryGenerator.Generate();
            titleHistoryGenerator.Write("titles.txt");
        }