public void SelectTag() { if (OnceMode && Sold) { return; } // Debug.Log("Select " + tileUnitData.unitName); // Game.Instance.PickupUnit = tileUnitData; // UnitShop.Instance.HideShop(); ActionUnitData data = (ActionUnitData)tileUnitData; if (!IsSlotRemain()) { MainMenuControl.Instance.ShowUserMessage(UserMessageManager.MES_SLOT_FULL, 1f); return; } if (Game.Instance.RoundManager.GoldAccount.Amount >= data.gold) { Game.Instance.RoundManager.GoldAccount.ApplyDeduct(data.gold); Game.Instance.SpawnPrepareUnit(tileUnitData); if (OnceMode) { Sold = true; UnitModel.SetActive(false); UnitName.text = TEMPLATE_SOLD; } } else { MainMenuControl.Instance.ShowUserMessage(UserMessageManager.MES_GOLD_INVALID, 1f); } }
private void RefreshActionUnits() { // initialize action units if (ActionUnitCount == 0) { ActionUnitCount = VisageTrackerNative._getActionUnitCount(); ActionUnits = new ActionUnitData[ActionUnitCount]; for (int actionUnitIndex = 0; actionUnitIndex < ActionUnitCount; actionUnitIndex++) { string name = Marshal.PtrToStringAnsi(VisageTrackerNative._getActionUnitName(actionUnitIndex)); bool used = VisageTrackerNative._getActionUnitUsed(actionUnitIndex); ActionUnitData actionUnitData = new ActionUnitData(actionUnitIndex, name, used); ActionUnits [actionUnitIndex] = actionUnitData; } } // get action unit values if (ActionUnitCount > 0) { float[] values = new float[ActionUnitCount]; VisageTrackerNative._getActionUnitValues(values); for (int actionUnitIndex = 0; actionUnitIndex < ActionUnitCount; actionUnitIndex++) { ActionUnits [actionUnitIndex].Value = values [actionUnitIndex]; } } }
public bool StartRound(int mainGroup) { UserGroup = mainGroup; Events.InvokeOnAction(EVENT_SPAWN_ENEMY); if (SpawnEnemy != null) { SpawnEnemy.Invoke(this); } else { if (EnemySource == RoundEnemy.Mirror) { Game.Instance.MirrorSpawn(); } } BattleUnits = ActionUnitManger.Instance.GetAll().Where(x => !x.TilePos.PrepareTile).ToList(); ApplyBuff(); StartData = BattleUnits.Select(a => a.CurrentStatus).ToList(); MainUnits = BattleUnits.Where(a => a.Group == mainGroup).ToList(); MainUnits.ForEach(a => { a.IsRealDestroy = false; ActionUnitData newData = new ActionUnitData(); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(a.CurrentStatus), newData); a.SavedStatus = newData; a.SavedStatus.position = a.transform.localPosition; }); return(StartRound()); }
// a quick fix for some false movements detected during tracking private void FixFalseMovement() { // fix for: false rotation while smiling smile_left = Tracker.GetActionUnit("au_lip_stretcher_left"); smile_right = Tracker.GetActionUnit("au_lip_stretcher_right"); rotationFixScale = Mathf.Clamp01((Tracker.Rotation.x + 17f) / 34f); if (smile_left != null && smile_left.Value > 0) { Tracker.Rotation.x -= falseRotationValue * smile_left.Value * rotationFixScale; } if (smile_right != null && smile_right.Value > 0) { Tracker.Rotation.x -= falseRotationValue * smile_right.Value * rotationFixScale; } // fix for: false translation while raising eyebrows brow_left = Tracker.GetActionUnit("au_left_outer_brow_raiser"); brow_right = Tracker.GetActionUnit("au_right_outer_brow_raiser"); Tracker.Translation.z += falseTranslationValue * Mathf.Clamp01((brow_left.Value + brow_right.Value - 0.1f) / 0.3f); }
private void ShowUnitTag(ActionUnitData data) { GameObject tag = Instantiate(UnitTagTemplate, gameObject.transform, false); AllUnitTags.Add(tag); UnitTag ScriptTag = tag.transform.GetComponent <UnitTag>(); ScriptTag.tileUnitData = data; ScriptTag.SpawnCharacter(); }
public void CalculateStatusStat() { ActionUnitData newData = (ActionUnitData)ScriptableObject.CreateInstance(typeof(ActionUnitData)); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(((ActionUnitData)tileUnitData).GetActualStatus()), newData); OriginStatus = newData; newData = (ActionUnitData)ScriptableObject.CreateInstance(typeof(ActionUnitData)); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(((ActionUnitData)tileUnitData).GetActualStatus()), newData); CurrentStatus = newData; }
public bool RemoveBuff(ActionUnit unit) { if (Buff.ActualStat == null) { return(false); } Debug.Log("Remove Buff " + unit.Group + "/" + Buff.Effect + "/" + Buff.ActualStat + "/" + Buff.Percent); float amount = 0; ActionUnitData baseStat = (ActionUnitData)unit.tileUnitData; switch (Buff.ActualStat) { case StatAffect.Health: amount = (Buff.Effect == EffectType.Increase ? 1 : -1) * baseStat.baseHealth * Buff.Percent / 100; unit.OriginStatus.baseHealth -= amount; if (Buff.Effect == EffectType.Increase) { if (unit.CurrentStatus.baseHealth > 0) { unit.CurrentStatus.baseHealth = ((unit.CurrentStatus.baseHealth - amount) <= 0) ? 1 : (unit.CurrentStatus.baseHealth - amount); } } else { if (unit.CurrentStatus.baseHealth < unit.OriginStatus.baseHealth) { unit.CurrentStatus.baseHealth = ((unit.CurrentStatus.baseHealth - amount) > unit.OriginStatus.baseHealth) ? unit.OriginStatus.baseHealth : (unit.CurrentStatus.baseHealth - amount); } } break; case StatAffect.Damage: amount = (Buff.Effect == EffectType.Increase ? 1 : -1) * baseStat.baseAttack * Buff.Percent / 100; unit.OriginStatus.baseAttack -= amount; unit.CurrentStatus.baseAttack -= amount; break; case StatAffect.AtkRate: amount = (Buff.Effect == EffectType.Increase ? -1 : 1) * baseStat.baseAttackRate * Buff.Percent / 100; unit.OriginStatus.baseAttackRate -= amount; unit.CurrentStatus.baseAttackRate -= amount; break; default: break; } AffectUnit.Remove(unit); return(true); }
public override float GetSellPriceUnit(ActionUnit sellUnit) { ActionUnitData data = (ActionUnitData)sellUnit.tileUnitData; int level = data.Level; while (data.PrevLevel != null) { data = (ActionUnitData)data.PrevLevel; } float price = (level == 1 ? 0.8f : 1f) * (level == 2 ? 2.5f : 1f) * (level == 3 ? 7.5f : 1f) * data.gold; return(price); }
private bool PerformLevelUpUnit(ActionUnit unit, List <ActionUnit> materials) { Debug.Log("UnitLevelManager level up"); ActionUnitData newStatus = (ActionUnitData)ScriptableObject.CreateInstance(typeof(ActionUnitData)); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(unit.CurrentStatus.NextLevel), newStatus); unit.tileUnitData = newStatus; unit.CalculateStatusStat(); materials.ForEach(x => Game.Instance.DestroyUnit(x)); ValidLevelUpUnit(unit, true); return(true); }
private void ScanInfo(bool isFull) { if (isFull) { OriginTotalHealth1 = 0f; OriginTotalHealth2 = 0f; } CurTotalHealth1 = 0f; CurTotalHealth2 = 0f; AvgDmg1 = 0f; AvgDmg2 = 0f; Remain1 = 0f; Remain2 = 0f; CurrentUnit = 0f; MaxUnit = Game.Instance.Profile.GameModeCtrl.GetMaxSpawn(); // List<ActionUnit> units = ActionUnitManger.Instance.GetAll(); ActionUnitData data = null; ActionUnitData curData = null; foreach (ActionUnit unit in ActionUnitManger.Instance.GetAll().Where(x => !x.TilePos.PrepareTile)) { if (isFull) { data = (ActionUnitData)unit.OriginStatus; } curData = (ActionUnitData)unit.CurrentStatus; if (unit.Group == 0) { if (isFull) { OriginTotalHealth1 += data.baseHealth; } CurTotalHealth1 += curData.baseHealth; AvgDmg1 = (AvgDmg1 * Remain1 + curData.baseAttack / curData.baseAttackRate) / (Remain1 + 1); Remain1 += 1; CurrentUnit++; } else { if (isFull) { OriginTotalHealth2 += data.baseHealth; } CurTotalHealth2 += curData.baseHealth; AvgDmg2 = (AvgDmg2 * Remain2 + curData.baseAttack / curData.baseAttackRate) / (Remain2 + 1); Remain2 += 1; } } }
private Slider CalculateSlider() { Transform slider = gameObject.transform.Find("Canvas/Slider"); Slider uiSlider = slider.gameObject.GetComponent <Slider>(); slider.position = Camera.main.WorldToScreenPoint(gameObject.transform.position); // ActionUnitData origin = (ActionUnitData)_host.tileUnitData; ActionUnitData origin = (ActionUnitData)_host.OriginStatus; ActionUnitData current = _host.CurrentStatus; uiSlider.value = (current.baseHealth >= 0 ? uiSlider.maxValue * current.baseHealth / origin.baseHealth : uiSlider.minValue); return(uiSlider); }
public void SpawnCharacter() { if (tileUnitData && characterPrefabParent) { ActionUnitData data = (ActionUnitData)tileUnitData; _attackRate = data.baseAttackRate; GameObject spawned = Instantiate(tileUnitData.characterPrefab, characterPrefabParent, false); // characterPrefabParent.transform.ChangeLayersRecursively(gameObject.layer); spawned.transform.localScale = new Vector3(40f, 40f, 40f); spawned.transform.localRotation = Quaternion.Euler(0f, spawned.transform.localRotation.eulerAngles.y + 180f, 0f); // Text name = gameObject.transform.("Text").GetComponent<Text>(); // name.text = data.unitName; UnitName.text = string.Format(TEMPLATE_TAG_NAME, data.unitName, data.gold); _animator = GetComponentInChildren <Animator>(); } }
public void ShowUnitInfo() { if (CanControlUnit) { ActionUnitData originData = (ActionUnitData)FocusUnit.OriginStatus; ActionUnitData curData = (ActionUnitData)FocusUnit.CurrentStatus; string infoText = ""; infoText = string.Format(TEMPLATE_DISPLAY_DATA, "Name", originData.unitName) + "\r\n" + string.Format(TEMPLATE_DISPLAY_DATA, "Health", string.Format("{0}/{1}", curData.baseHealth, originData.baseHealth)) + "\r\n" + string.Format(TEMPLATE_DISPLAY_DATA, "Damage", string.Format("{0}/{1}", curData.baseAttack, originData.baseAttack)) + "\r\n" + string.Format(TEMPLATE_DISPLAY_DATA, "Range", string.Format("{0}/{1}", curData.baseAttackRange, originData.baseAttackRange)) + "\r\n" + string.Format(TEMPLATE_DISPLAY_DATA, "Rate", string.Format("{0}/{1}", curData.baseAttackRate, originData.baseAttackRate)); for (int i = 0; i < FocusUnit.Buffed.Count; i++) { if (FocusUnit.Buffed[i]) { Buff b = FocusUnit.Buffs[i].Buff; infoText += "\r\n" + string.Format(TEMPLATE_DISPLAY_BUFF, b.Effect, b.Percent + "%", b.ActualStat); } } TextInfo.text = infoText; // Health.text = string.Format(TEMPLATE_DISPLAY_DATA, "Health", // string.Format("{0}/{1}", curData.baseHealth, originData.baseHealth)); // Damage.text = string.Format(TEMPLATE_DISPLAY_DATA, "Damage", // string.Format("{0}/{1}", curData.baseAttack, originData.baseAttack)); // AttackRange.text = string.Format(TEMPLATE_DISPLAY_DATA, "Range", // string.Format("{0}/{1}", curData.baseAttackRange, originData.baseAttackRange)); // AttackRate.text = string.Format(TEMPLATE_DISPLAY_DATA, "Rate", // string.Format("{0}/{1}", curData.baseAttackRate, originData.baseAttackRate)); } }
void Update() { if (Tracker == null) { return; } if (!Initialized) { data = Tracker.GetActionUnit(ActionUnitName); } else { Value = data.Value; NormalizedValue = (data.Value - Limits.x) / (Limits.y - Limits.x); NormalizedValue = Mathf.Clamp01(NormalizedValue); if (Inverted) { NormalizedValue = 1f - NormalizedValue; } // push back normalized history for (int i = 1; i < FilterWindowSize; i++) { normalizedValueHistory[i - 1] = normalizedValueHistory[i]; } // add normalized value to history normalizedValueHistory[FilterWindowSize - 1] = NormalizedValue; // filter value FilteredValue = Filter(NormalizedValue); // apply to all targets foreach (ActionUnitBindingTarget target in Targets) { if (target.BlendshapeIndex >= 0 && target.Weight >= 0f) { target.Renderer.SetBlendShapeWeight(target.BlendshapeIndex, FilteredValue * Weight * target.Weight * 100f); } } } }
public bool ApplyBuff(ActionUnit unit) { //this method usually cann by Action Unit to self buff // if (AffectUnit.Count > 0) return false; Buff.ActualStat = Buff.Stat; if (Buff.Stat == StatAffect.Random) { Buff.ActualStat = RandomStatAffect(); } // if (Buff.Target != TargetType.Custom) // { // if (Game.Instance.RoundManager.Round.RoundNumber < 5) // { // Buff.Percent = 20 - 2 * Game.Instance.RoundManager.Round.RoundNumber; // } // else // { // Buff.Percent = 2 * (Game.Instance.RoundManager.Round.RoundNumber - 5); // } // } Debug.Log("Apply Buff " + unit.Group + "/" + Buff.Effect + "/" + Buff.ActualStat + "/" + Buff.Percent); float amount = 0; ActionUnitData baseStat = (ActionUnitData)unit.tileUnitData; switch (Buff.ActualStat) { case StatAffect.Health: amount = (Buff.Effect == EffectType.Increase ? 1 : -1) * baseStat.baseHealth * Buff.Percent / 100; unit.OriginStatus.baseHealth += amount; if (Buff.Effect == EffectType.Increase) { if (unit.CurrentStatus.baseHealth < unit.OriginStatus.baseHealth) { unit.CurrentStatus.baseHealth = ((unit.CurrentStatus.baseHealth + amount) > unit.OriginStatus.baseHealth) ? unit.OriginStatus.baseHealth : (unit.CurrentStatus.baseHealth + amount); } } else { if (unit.CurrentStatus.baseHealth > 0) { unit.CurrentStatus.baseHealth = ((unit.CurrentStatus.baseHealth + amount) <= 0) ? 1 : (unit.CurrentStatus.baseHealth + amount); } } break; case StatAffect.Damage: amount = (Buff.Effect == EffectType.Increase ? 1 : -1) * baseStat.baseAttack * Buff.Percent / 100; unit.OriginStatus.baseAttack += amount; unit.CurrentStatus.baseAttack += amount; break; case StatAffect.AtkRate: amount = (Buff.Effect == EffectType.Increase ? -1 : 1) * baseStat.baseAttackRate * Buff.Percent / 100; unit.OriginStatus.baseAttackRate += amount; unit.CurrentStatus.baseAttackRate += amount; break; default: break; } AffectUnit.Add(unit); return(true); }