Exemple #1
0
    public void Initialize(AnimalData data)
    {
        animalData = data;

        ResourceController resourceController = Resolver.Instance.GetController <ResourceController>();

        Animator anim = GetComponent <Animator>();
        RuntimeAnimatorController  animController     = anim.runtimeAnimatorController;
        AnimatorOverrideController overrideController = new AnimatorOverrideController();

        overrideController.runtimeAnimatorController = animController;
        overrideController["Transform_Placeholder"]  = resourceController.GetAnimation(animalData.transform_animation);
        overrideController["Happy_Placeholder"]      = resourceController.GetAnimation(animalData.happy_animation);
        overrideController["Run_Placeholder"]        = resourceController.GetAnimation(animalData.run_animation);
        anim.runtimeAnimatorController = overrideController;

        anim.SetTrigger("transform");

        Invoke("StartMovement", delayBeforeMovement);
    }
Exemple #2
0
    public void Initialize(AnimalData animal)
    {
        animalData = animal;

        ResourceController resourceController = Resolver.Instance.GetController <ResourceController>();

        //TODO: what happens to this logic when an animal is recycled?
        anim = GetComponent <Animator>();
        RuntimeAnimatorController  animController     = anim.runtimeAnimatorController;
        AnimatorOverrideController overrideController = new AnimatorOverrideController();

        overrideController.runtimeAnimatorController = animController;
        overrideController["Run_Placeholder"]        = resourceController.GetAnimation(animalData.run_animation);
        overrideController["Hit_Placeholder"]        = resourceController.GetAnimation(animalData.hit_animation);
        overrideController["Special_Placeholder"]    = resourceController.GetAnimation(animalData.special_animation);
        clip = resourceController.GetAnimation(animalData.run_animation);
        anim.runtimeAnimatorController = overrideController;

        currentHealth = animalData.health * HealthMultiplier;

        animalBehavior = AnimalBehaviorLocator.Instance.GetBehavior(animalData.behavior);
        animalBehavior.Initialize(animalData, this);
    }