Example #1
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        FlowerAnimationState currState = animator.GetComponent <Plant>().GetCurrentState();

        animator.SetTrigger(Enum.GetName(typeof(FlowerAnimationState), (int)currState));
        Debug.Log(Enum.GetName(typeof(FlowerAnimationState), (int)currState));
    }
Example #2
0
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (lastUpdateTime + updateTime > Time.time)
        {
            return;
        }
        else
        {
            Plant currentFlower = animator.GetComponent <Plant>();
            float progression   = currentFlower.GetProgression();
            if (progression >= 1 || progression < 0)
            {
                currentFlower.SwitchToNextState();
                FlowerAnimationState currState = animator.GetComponent <Plant>().GetCurrentState();
                animator.SetTrigger(Enum.GetName(typeof(FlowerAnimationState), (int)currState));
            }
            else
            {
                currentFlower.Fall(progression);
                animator.SetFloat("Progression", progression);
            }

            lastUpdateTime = Time.time;
        }
    }
Example #3
0
    public PlantLocalData(PlantFormData data)
    {
        InitialTime = DateTime.Now;

        PlantName   = data.plantName;
        Description = data.description;

        Rotation = Util.RandomRange(-150f, -30f);

        PlantFormType  = data.plantFormType;
        FlowerFormType = data.flowerFormType;

        PetalPrefab     = data.PetalPrefab;
        PistilPrefab    = data.PistilPrefab;
        BudPrefab       = data.BudPrefab;
        LeafPrefab      = data.LeafPrefab;
        SproutParticles = data.SproutParticles;

        CurrentAnimationState = FlowerAnimationState.Sprout;
        LastStateChangedTime  = InitialTime;
        AnimationDurationList = new List <float>()
        {
            data.SproutAnimationDuration,
            data.GrowAniamtionDuration,
            data.BloomAnimationDuration,
            data.FallAnimationDuration,
            data.RebloomAnimationDuration
        };
        AnimationCycleTime = data.BloomAnimationDuration + data.FallAnimationDuration + data.RebloomAnimationDuration;

        MainStem = DistributeMainStemLocalData(data.SproutPathData, data.StemPathData, data.StemColorData);
        Flower   = DistributeFlowerLocalData(data.PetalData, data.PetalColorData);
        Petals   = DistributePetalLocalData(Flower, data.PetalData);
        Leaves   = DistributeLeafLocalData(data.leafGrowRelation, data.SproutLeafData, data.GrownLeafData, data.LeafColorData);

        Debug.Log("PlantLocalData Constructed");
    }
Example #4
0
 public void SetAnimationState(FlowerAnimationState state)
 {
     _d.CurrentAnimationState = state;
     _d.LastStateChangedTime  = DateTime.Now;
 }