コード例 #1
0
 public virtual void RegisterInstance(ExcersizeActivityInst inst)
 {
     this.EnsureSetup();
     inst.Body = this.Context.GetBody(inst.Avatar);
     inst.Body.EnsureSetup();
     this.Instances.Add(inst);
 }
コード例 #2
0
    void UpdateCurrentSelection()
    {
        if (this.Hand)
        {
            this.FieldOverallAlpha = this.ExcersizeSystem.Breath.UnitFadeInPct;
            return;
        }
        if (this.ChiBall)
        {
            this.FieldOverallAlpha = 1.0f;
            return;
        }
        this.ExcersizeInst = null;
        var   bestInst      = this.ExcersizeInst;
        float bestInstScore = 0.0f;

        if (this.ExcersizeSystem)
        {
            var cur          = this.ExcersizeSystem.CurrentActivity;
            var wantPause    = true;
            var overallAlpha = 1.0f;
            if (cur)
            {
                ChakraBreath chakraExcer = null;
                ChakraBreath infoChakra  = null;
                foreach (var inst in cur.Instances)
                {
                    {
                        float score = Vector3.Dot((inst.Body.SpineEnd.transform.position - Camera.main.transform.position).normalized, Camera.main.transform.forward);
                        if ((!bestInst) || (score > bestInstScore))
                        {
                            bestInst      = inst;
                            bestInstScore = score;
                        }
                    }
                    if (inst.Body == this.Body)
                    {
                        this.ExcersizeInst = inst;
                    }
                    var ce = (inst as ChakraBreath);
                    if (ce)
                    {
                        if (ce.Body == this.Body)
                        {
                            chakraExcer = ce;
                        }
                        if (ce.IsInfoAvatar)
                        {
                            infoChakra = ce;
                        }
                    }
                }
                if (this.ExcersizeInst != bestInst)
                {
                    this.ExcersizeInst = null;                     // disable the model that isn't in front of user
                }
                if (!chakraExcer)
                {
                    //this.ExcersizeInst = null; // DISABLING NON CHAKRA EXCERSIZE
                }
                if (infoChakra && infoChakra.FocusChakra)
                {
                    if (chakraExcer != infoChakra)
                    {
                        chakraExcer        = null;                  // if teacher, and info is active, hide the teacher
                        this.ExcersizeInst = null;
                    }
                }
                if ((this.ExcersizeInst))
                {
                    if ((chakraExcer && chakraExcer.CurrentChakra))
                    {
                        this.CurrentFocusChakra = chakraExcer.CurrentChakra.ChakraIndex - 1;
                        overallAlpha            = Mathf.Lerp(0.35f, 1.0f, chakraExcer.LatestBreathAlpha);               // doesn't fully fade
                    }
                    overallAlpha = this.ExcersizeSystem.Breath.UnitFadeInPct;
                    wantPause    = false;
                }
            }
            this.IsPaused          = (wantPause);
            this.FieldOverallAlpha = overallAlpha;
        }
    }