Exemplo n.º 1
0
 IEnumerator CountingDown()
 {
     countingDownUI.enabled = true;
     for (int i = 0; i < 5; i++)
     {
         countingDownUI.sprite = countingDownSprites[i];
         yield return(new WaitForSeconds(1));
     }
     countingDownUI.enabled = false;
     isCapturing            = true;
     experienceState        = ExperienceState.Idle;
 }
Exemplo n.º 2
0
 void ChangeState(ExperienceState newState)
 {
     experienceState = newState;
 }
Exemplo n.º 3
0
    void Update()
    {
        if (handModelManager.leapProvider)
        {
            Frame frame = handModelManager.leapProvider.CurrentFrame;

            if (Input.GetKeyDown(KeyCode.Space) && experienceState == ExperienceState.Idle)
            {
                typeBox_white.SetActive(false);
                typeBox_blue.SetActive(true);
                experienceState = ExperienceState.Chatting;
            }
            else if (Input.GetKeyDown(KeyCode.Space) && experienceState == ExperienceState.Chatting)
            {
                typeBox_white.SetActive(true);
                typeBox_blue.SetActive(false);
                experienceState = ExperienceState.Idle;
            }
            else if (Input.GetKeyDown(KeyCode.Backspace) /* && experienceState == ExperienceState.Chatting*/)
            {
                RemoveWordsMark(Sign.Hello, Sign.My, Sign.Name, Sign.Sana, Sign.What, Sign.Your, Sign.Nice, Sign.Meet, Sign.You, Sign.How, Sign.Good);
            }
            else if (Input.GetKeyDown(KeyCode.R) && experienceState == ExperienceState.Idle)
            {
                StartCoroutine(CountingDown());
                experienceState = ExperienceState.Recording;
            }



            if (frame.Hands.Count > 0)
            {
                var         calibration = GetDeltaRotMaterix();
                List <Hand> hands       = frame.Hands;
                foreach (var hand in hands)
                {
                    if (hand.IsLeft)
                    {
                        //Debug.Log(experienceState.ToString());
                        if (GetGesture(hand, Quote.l_Dirs, calibration) && experienceState == ExperienceState.Idle)
                        {
                            typeBox_white.SetActive(false);
                            typeBox_blue.SetActive(true);
                            experienceState = ExperienceState.Chatting;
                        }

                        if (Input.GetKeyDown(KeyCode.Alpha2) || isCapturing)
                        {
                            captured_L_Dirs = new Vector3[6];

                            Debug.Log("Capturing left hand...");
                            Capture(hand, out captured_L_Dirs);
                        }
                    }

                    if (hand.IsRight)
                    {
                        if (GetGesture(hand, Quote.r_Dirs, calibration) && experienceState == ExperienceState.Chatting)
                        {
                            typeBox_white.SetActive(true);
                            typeBox_blue.SetActive(false);
                            experienceState = ExperienceState.Idle;
                        }

                        switch (experienceState)
                        {
                        case ExperienceState.Chatting:
                            Translate(hand, calibration);
                            break;

                        case ExperienceState.Recording:
                            break;

                        case ExperienceState.Idle:
                            DetectSentencesAndPlay();
                            break;

                        default:
                            break;
                        }


                        if (Input.GetKeyDown(KeyCode.Alpha1) || isCapturing)
                        {
                            captured_R_Dirs = new Vector3[6];
                            Debug.Log("Capturing left hand...");
                            Capture(hand, out captured_R_Dirs);
                        }
                    }
                }
            }
        }

        if (isCapturing)
        {
            gestureBase[highlightedSentence] = new GestureData(captured_R_Dirs, captured_L_Dirs, false);
        }

        var typeBoxText = "";

        foreach (var gesture in gestureBase)
        {
            if (gesture.Value.isMarked)
            {
                typeBoxText += gesture.Key.ToString() + ", ";
            }
        }
        typeBox.text = typeBoxText;

        isCapturing     = false;
        captured_L_Dirs = captured_R_Dirs = null;
    }
        // Token: 0x06000C55 RID: 3157 RVA: 0x00056FE4 File Offset: 0x000551E4
        private void UpdateDynamicDataForUnit(Entity entity)
        {
            UnitState unitState = ShipbreakersMain.CurrentSimFrame.FindObject <UnitState>(entity);

            if (unitState == null)
            {
                return;
            }
            if (this.mSelectedEntity.IsValid())
            {
                if (this.mLastUnitState == unitState)
                {
                    return;
                }
                if (this.mSettings.UnitHealthValueLabel == null || this.mSettings.UnitHealthBar == null || this.mSettings.UnitArmorValueLabel == null || this.mSettings.UnitFireRateLabel == null || this.mSettings.UnitDamageValueLabel == null || this.mSettings.SpeedValueLabel == null || this.mSettings.UnitShortDescriptionValueLabel == null)
                {
                    Log.Warn(Log.Channel.UI, "Information Panel: An information label was not configured correctly.  Check Unity Config.   Skipping Info Panel Update", new object[0]);
                    return;
                }
                string typeID = unitState.TypeID;
                bool   flag   = this.mLastUnitState == null || this.mLastUnitState.EntityID != this.mSelectedEntity;
                ExperienceViewAttributes entityTypeAttributes = ShipbreakersMain.GetEntityTypeAttributes <ExperienceViewAttributes>(typeID);
                if (entityTypeAttributes != null)
                {
                    ExperienceState experienceState = ShipbreakersMain.CurrentSimFrame.FindObject <ExperienceState>(entity);
                    if (experienceState != null && experienceState.Level > 0 && (flag || this.mLastExperienceState == null || this.mLastExperienceState.Level != experienceState.Level))
                    {
                        if (!string.IsNullOrEmpty(experienceState.NameSuffix))
                        {
                            RankViewAttributes rankViewAttributes = entityTypeAttributes.RankViews[experienceState.Level];
                            this.mTempLocalizationFormatObjects[0]             = rankViewAttributes.ShortRankName;
                            this.mTempLocalizationFormatObjects[1]             = experienceState.NameSuffix;
                            this.mSettings.UnitShortDescriptionValueLabel.text = this.mSettings.UnitLevelFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan);
                        }
                        this.mLastExperienceState = experienceState;
                    }
                }
                if (flag || unitState.OwnerCommander != this.mLastUnitState.OwnerCommander)
                {
                    Commander commanderFromID = this.mCommanderManager.GetCommanderFromID(unitState.OwnerCommander);
                    CommanderDirectorAttributes commanderDirectorFromID = this.mCommanderManager.GetCommanderDirectorFromID(unitState.OwnerCommander);
                    this.mTempLocalizationFormatObjects[0] = ((commanderFromID != null) ? SharedLocIDConstants.GetLocalizedCommanderName(commanderDirectorFromID.PlayerType, commanderFromID.Name, commanderDirectorFromID.AIDifficulty) : string.Empty);
                    this.mTempLocalizationFormatObjects[1] = null;
                    this.mSettings.PlayerNameLabel.text    = this.mSettings.PlayerNameLocID.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan);
                }
                UnitAttributes typeAttributes = this.mSelectedEntity.GetTypeAttributes <UnitAttributes>();
                if (typeAttributes == null)
                {
                    Log.Warn(Log.Channel.UI, "Information Panel: Attribute data was missing for unit type {0}. Skipping info panel update", new object[]
                    {
                        this.mSelectedEntity.ToFriendlyString()
                    });
                    return;
                }
                UnitAttributes entityTypeAttributes2 = ShipbreakersMain.GetEntityTypeAttributes <UnitAttributes>(typeID);
                if (entityTypeAttributes2 == null)
                {
                    Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base UnitAttributes for entity type {0}", new object[]
                    {
                        typeID
                    });
                }
                if (flag || unitState.Hitpoints != this.mLastUnitState.Hitpoints)
                {
                    this.mTempLocalizationFormatObjects[0]   = unitState.Hitpoints;
                    this.mTempLocalizationFormatObjects[1]   = unitState.MaxHitpoints;
                    this.mSettings.UnitHealthValueLabel.text = ((unitState.MaxHitpoints > 0) ? this.mSettings.UnitHealthFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan) : string.Empty);
                    this.mSettings.UnitHealthBar.value       = ((unitState.MaxHitpoints > 0) ? ((float)unitState.Hitpoints / (float)unitState.MaxHitpoints) : 0f);
                    int buffComparison = 0;
                    if (entityTypeAttributes2 != null)
                    {
                        buffComparison = unitState.MaxHitpoints.CompareTo(entityTypeAttributes2.MaxHealth);
                    }
                    this.mSettings.UnitHealthValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison);
                }
                this.mSelectedEntity.GetTypeAttributes <UnitMovementAttributes>();
                int num = Fixed64.IntValue(unitState.MaxSpeed);
                if (flag || num != Fixed64.IntValue(this.mLastUnitState.MaxSpeed))
                {
                    this.mTempLocalizationFormatObjects[0] = num;
                    this.mTempLocalizationFormatObjects[1] = null;
                    this.mSettings.SpeedValueLabel.text    = this.mSettings.UnitSpeedFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan);
                    int buffComparison2 = 0;
                    UnitMovementAttributes entityTypeAttributes3  = ShipbreakersMain.GetEntityTypeAttributes <UnitMovementAttributes>(typeID);
                    UnitDynamicsAttributes unitDynamicsAttributes = (entityTypeAttributes3 != null) ? entityTypeAttributes3.Dynamics : null;
                    if (unitDynamicsAttributes != null)
                    {
                        buffComparison2 = unitState.MaxSpeed.CompareTo(unitDynamicsAttributes.MaxSpeed);
                    }
                    else
                    {
                        Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base UnitDynamicsAttributes for entity type {0}", new object[]
                        {
                            typeID
                        });
                    }
                    this.mSettings.SpeedValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison2);
                }
                int buffComparison3 = 0;
                // MOD
                int baseDamagePerRound   = 0;
                int damagePacketsPerShot = 1;
                // MOD
                if (!typeAttributes.WeaponLoadout.IsNullOrEmpty <WeaponBinding>())
                {
                    WeaponBinding weaponBinding = typeAttributes.WeaponLoadout[0];
                    if (weaponBinding != null)
                    {
                        // MOD
                        damagePacketsPerShot = weaponBinding.Weapon.DamagePacketsPerShot;
                        baseDamagePerRound   = Fixed64.IntValue(weaponBinding.Weapon.BaseDamagePerRound);
                        WeaponAttributes entityTypeAttributes4 = ShipbreakersMain.GetEntityTypeAttributes <WeaponAttributes>(typeID, weaponBinding.Weapon.Name);
                        if (entityTypeAttributes4 != null)
                        {
                            buffComparison3 = baseDamagePerRound.CompareTo(Fixed64.IntValue(entityTypeAttributes4.BaseDamagePerRound));
                        }
                        else
                        {
                            Log.Error(Log.Channel.Data | Log.Channel.UI, "Failed to find base WeaponAttributes with name {0} for entity type {1}", new object[]
                            {
                                weaponBinding.Weapon.Name,
                                typeID
                            });
                        }
                        // MOD
                    }
                    else
                    {
                        Log.Error(Log.Channel.Data | Log.Channel.UI, "First WeaponBinding in WeaponLoadout for unit type {0} is null! Unable to determine damage to show on info panel", new object[]
                        {
                            typeID
                        });
                    }
                }
                // MOD
                if (flag || this.mLastWeaponDamageValue != baseDamagePerRound || this.mLastWeaponPacketsValue != damagePacketsPerShot)
                {
                    this.mSettings.UnitDamageValueLabel.text = damagePacketsPerShot != 1 ? string.Format("{0} | {1}", baseDamagePerRound, damagePacketsPerShot) : string.Format("{0}", baseDamagePerRound);
                    this.mLastWeaponDamageValue  = baseDamagePerRound;
                    this.mLastWeaponPacketsValue = damagePacketsPerShot;
                    this.mSettings.UnitDamageValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison3);
                }
                // MOD
                if (flag || this.mLastUnitArmourValue != typeAttributes.Armour)
                {
                    this.mTempLocalizationFormatObjects[0]  = typeAttributes.Armour;
                    this.mTempLocalizationFormatObjects[1]  = null;
                    this.mSettings.UnitArmorValueLabel.text = this.mSettings.UnitArmorFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan);
                    this.mLastUnitArmourValue = typeAttributes.Armour;
                    int buffComparison4 = 0;
                    if (entityTypeAttributes2 != null)
                    {
                        buffComparison4 = typeAttributes.Armour.CompareTo(entityTypeAttributes2.Armour);
                    }
                    this.mSettings.UnitArmorValueLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison4);
                }
                if (flag || this.mLastFireRateDisplay != typeAttributes.FireRateDisplay)
                {
                    this.mTempLocalizationFormatObjects[0] = InformationPanelController.InformationPanelSettings.FireRateLocIDs[typeAttributes.FireRateDisplay];
                    this.mTempLocalizationFormatObjects[1] = null;
                    this.mSettings.UnitFireRateLabel.text  = this.mSettings.UnitFireRateFormat.TokenFormat(this.mTempLocalizationFormatObjects, this.mLocMan);
                    this.mLastFireRateDisplay = typeAttributes.FireRateDisplay;
                    int buffComparison5 = 0;
                    if (entityTypeAttributes2 != null)
                    {
                        buffComparison5 = typeAttributes.FireRateDisplay.CompareTo(entityTypeAttributes2.FireRateDisplay);
                    }
                    this.mSettings.UnitFireRateLabel.color = this.mUnitInteractionAttributes.BuffInfo.BuffColor(buffComparison5);
                }
                this.mLastUnitState = unitState;
            }
        }