//reborn controller public void Revive() { Debug.Log(name + " Revive"); gameObject.SetActive(true); transform.position = _startPos; actionStat = ActionStat.Idle; hp = role.State.MaxHP; role.State.CurHP = role.State.MaxHP; role.State.CurMP = role.State.MaxMP; this.enabled = true; if (stateManager != null) { stateManager.enabled = true; } if (_healthBar != null) { _healthBar.gameObject.SetActive(true); } if (uiSlot != null) { uiSlot.Revive(); } //reset cooldown value_CoolDown_Skill_1 = 0; value_CoolDown_Skill_2 = 0; // StartCoroutine("CalCoolDownSkill_1"); // StartCoroutine("CalCoolDownSkill_2"); }
public IEnumerator OnDied() { actionStat = ActionStat.Dead; float timeDestroy = 0.8f; if (dead != null) { timeDestroy += GetComponent <Animation>()[dead.name].length; } SoundManager.Instance.PlayDeath(this); yield return(new WaitForSeconds(timeDestroy)); if (isMob) { Destroy(gameObject); Destroy(_healthBar.gameObject); GameplayManager.Instance.Remove(this); } else { gameObject.SetActive(false); if (_healthBar != null) { _healthBar.gameObject.SetActive(false); } if (uiSlot != null) { uiSlot.Died(); } } }
public void OnHit() { if (actionStat == ActionStat.Skill) { return; } if (actionStat != ActionStat.hit && actionStat != ActionStat.Dead) { //if (IsMyHero() && !isMob) //{ // Debug.Log(name + ": " + actionStat + " -> Hit"); //} _oldActionStat = actionStat; actionStat = ActionStat.hit; if (hit != null) { Invoke("DeHit", CalculatorTimeAnim(hit)); } else { Invoke("DeHit", 0.5f); } } }
public bool CheckActionValid(string action_id, string village_id = "") { string combineID = CombineID(action_id, village_id); ActionStat pickAction = actionStatList.Find(x => x.ID == action_id); if (pickAction.ID == null) { return(false); } if (action_id == StatFlag.ActionStat.Cure) { return(gameManager.turn_count - GetValue(action_id, village_id) > 1 && currentAP >= pickAction.apCost); } if (action_id == StatFlag.ActionStat.Quarantine) { return(GetValue(action_id, village_id) <= 0 && currentAP >= pickAction.apCost); } if (action_id == StatFlag.ActionStat.Investigate) { return(currentAP >= 2); } return(currentAP >= pickAction.apCost); }
//network event Action private void HandleAction(GameObject targetAction) { if (actionStat == ActionStat.Move || actionStat == ActionStat.Dead || actionStat == ActionStat.Skill) { return; } target = targetAction; actionStat = ActionStat.Action; }
private void HandleMove(Vector3 pos) { //if (IsMyHero() && !isMob) //{ // Debug.Log("HandleMove " + pos); //} positionWay = pos; actionStat = ActionStat.Move; }
private void DeHit() { if (actionStat != ActionStat.hit || actionStat == ActionStat.Dead) { return; } if (_oldActionStat != ActionStat.Skill) { actionStat = _oldActionStat; } else { actionStat = ActionStat.Idle; } }
public Dashboard GetDashboard(int branchId, int subordinateId, int loanProductId) { var dashboard = new Dashboard(); using (var connection = GetConnection()) using (var command = new OpenCbsCommand("GetDashboard", connection) .AsStoredProcedure() .With("@date", TimeProvider.Today) .With("@userId", User.CurrentUser.Id) .With("@subordinateId", subordinateId) .With("@branchId", branchId) .With("@loanProductId", loanProductId) .WithTimeout(200)) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var portfolioLine = new PortfolioLine { Name = reader.GetString("name"), Amount = reader.GetDecimal("amount"), Quantity = reader.GetInt("quantity"), Color = reader.GetString("color") }; dashboard.PortfolioLines.Add(portfolioLine); } reader.NextResult(); while (reader.Read()) { var stat = new ActionStat { Date = reader.GetDateTime("date"), AmountDisbursed = reader.GetDecimal("amount_disbursed"), NumberDisbursed = reader.GetInt("number_disbursed"), AmountRepaid = reader.GetDecimal("amount_repaid"), NumberRepaid = reader.GetInt("number_repaid"), }; dashboard.ActionStats.Add(stat); } } return(dashboard); }
//network event active skill private void HandleSkillCast(int curSkillIndex) { curSkillIndexSelect = curSkillIndex; if (curSkillIndexSelect == 0) { countAction = 0; actionStat = ActionStat.Action; } else if (curSkillIndexSelect == 1) { _timerAnim = 0; actionStat = ActionStat.Skill; SkillHandle = Skill_1_Cast; } else if (curSkillIndexSelect == 2) { _timerAnim = 0; actionStat = ActionStat.Skill; SkillHandle = Skill_2_Cast; } }
public void ExecuteAction(string action_id, string village_id = null) { ActionStat pickAction = actionStatList.Find(x => x.ID == action_id); if (pickAction.ID == null) { return; } string combineID = CombineID(action_id, village_id); switch (action_id) { case StatFlag.ActionStat.Quarantine: ActionDict = UtilityMethod.EditDictionary <float>(ActionDict, combineID, 1); break; case StatFlag.ActionStat.Cure: ActionDict = UtilityMethod.EditDictionary <float>(ActionDict, combineID, gameManager.turn_count); Village village = villageManager.villages.Find(x => x.ID == village_id); if (village != null) { village.Cure(); } break; case StatFlag.ActionStat.Investigate: ActionDict = UtilityMethod.EditDictionary <float>(ActionDict, combineID, 1); gameManager.techViewPresenter.gameObject.SetActive(true); break; case StatFlag.ActionStat.Lab: ActionDict = UtilityMethod.EditDictionary <float>(ActionDict, combineID, GetValue(combineID) + 1); break; } currentAP -= pickAction.apCost; gameManager.UpdateHeaderUIView(); }
void UpdateState() { //Monster state animation switch (actionStat) { case ActionStat.Idle: { if (actionStat != ActionStat.Dead) { GetComponent <Animation>().CrossFade(idle.name); if (target) { actionStat = ActionStat.Attack; } } } break; case ActionStat.Move: { if (actionStat != ActionStat.Dead) { checkDistance = (transform.position - LookAtTo(positionWay)).magnitude; if (checkDistance >= distanceAttack) { GetComponent <Animation>().CrossFade(walk.name); transform.Translate(Vector3.forward * speedMove * Time.deltaTime); } else { actionStat = ActionStat.Idle; } } } break; case ActionStat.Attack: { if (actionStat != ActionStat.Dead) { if (target != null) { checkDistance = (transform.position - LookAtTo(target.transform.position)).magnitude; if (checkDistance >= distanceAttack) { GetComponent <Animation>().CrossFade(walk.name); transform.Translate(Vector3.forward * speedMove * Time.deltaTime); } else { AttackHandle(); } } else { actionStat = ActionStat.Idle; } } } break; case ActionStat.Dead: { GetComponent <Animation>().CrossFade(dead.name); Destroy(gameObject, 2); } break; } }
void Start() { hp = maxhp; actionStat = ActionStat.Move; AttackHandle = Attack_1; }
public void OnReciveBattleSync(UserRole.RoleState roleState) { if (this == null) { return; } role.State = roleState; float damage = hp - roleState.CurHP; this.hp -= damage; //update MP from server if (this._healthBar != null) { this._healthBar.SetMP(roleState.CurMP, roleState.MaxMP); } // set die from server if (roleState.Action == RoleAction.Dead) { this.hp = 0; StartCoroutine(OnDied()); } if (damage > 0) { this.damageGet = Mathf.Abs(damage); this.TakingDamage(); if (role.Base.UserId == GameManager.GameUser.Id) { this.InitTextDamage(Color.green); } else { this.InitTextDamage(Color.red); } float curHPPercent = hp / maxhp; float l = Mathf.Lerp(2.0f / 3.0f, 0.1f, curHPPercent); if (damage > 10) { if (Random.Range(0.0f, 1.0f) <= l) { OnHit(); //Debug.Log("Hit " + curHPPercent.ToString("0.0") + " " + l); } } } else//Buff { this.damageGet = Mathf.Abs(damage); if (this.damageGet > 1) { this.InitTextDamage(Color.green, true); } } if (this.hp <= 0) { //Debug.Log("this.hp " + this.hp); actionStat = ActionStat.Dead; if (isMob) { UIBattleManager.Instance.OnMonsterIsDie(); } } else { CheckEffect(roleState); } }
//update animation , move private void UpdateActionStat() { //Hero State animation switch (actionStat) { case ActionStat.Idle: { /*if (tag == "Player" && !isAuto && typeCharacter != TypeChatacter.Healer) * { * Controller enemy; * float maxRange = distanceAction; * * maxRange = Mathf.Max(maxRange, 3); * * enemy = stateManager.FindEnemyNearest(true, maxRange); * * if (enemy != null && actionStat == ActionStat.Idle) * { * HandleAction(enemy.gameObject); * } * * }*/ oldSkillIndexSend = -1; curSkillIndexSelect = -1; GetComponent <Animation>().CrossFade(idle.name); } break; //this role move to point case ActionStat.Move: //receiver from server { oldSkillIndexSend = -1; curSkillIndexSelect = -1; countAction = float.MaxValue; checkDistance = Vector3.Distance(transform.position, LookAtTo(positionWay)); //Debug.Log(name + " move"); if (checkDistance >= 0.5f) { GetComponent <Animation>().CrossFade(walk.name); transform.Translate(Vector3.forward * speedMove * Time.deltaTime); } else { //positionWay = Vector3.zero; OnIdle(); //completed how to move tutorial UIBattleManager.Instance.OnHeroFinishedMove(this); //hanlde =default attack 1 (only mobs) ActionHandle = Action_1; } } break; //this role move to target , and attack case ActionStat.Action: //receiver from server { if (target != null) { checkDistance = (transform.position - LookAtTo(target.transform.position)).magnitude; // *0.8f; if (checkDistance >= distanceAction) { GetComponent <Animation>().CrossFade(walk.name); transform.Translate(Vector3.forward * speedMove * Time.deltaTime); //hanlde save =default Action_1 , prepare for this action ActionHandle = Action_1; } else { if (isConnectedServer() && oldSkillIndexSend != 0) { //in range attack of default skill, send active skill if (target.GetComponent <Controller>().actionStat != ActionStat.Dead) { GameplayManager.Instance.SendSkillCast(role.Id, role.RoleSkills[0].SkillId); } oldSkillIndexSend = 0; } else { //call function of hanlde ActionHandle(); } if (target.GetComponent <Controller>() != null && target.GetComponent <Controller>().hp <= 0) { target = null; } } } else //target not exist { OnIdle(); } } break; case ActionStat.Skill: //receiver from server { if (SkillHandle != null) { if (isConnectedServer()) { GameSkill curSkill = role.RoleSkills[curSkillIndexSelect].GameSkill; if (isSkillNeedTarget(curSkill)) { if (target == null) { OnIdle(); return; } checkDistance = (transform.position - LookAtTo(target.transform.position)).magnitude; // *0.8f; if (checkDistance >= curSkill.CastRange) { //Debug.Log("Ok CastRange " + curSkill.CastRange); if (GetComponent <Animation>()[action.name].normalizedTime <= 0) { GetComponent <Animation>().CrossFade(walk.name); transform.Translate(Vector3.forward * speedMove * Time.deltaTime); break; } } else { //Debug.Log("CastRange < " + curSkill.CastRange); } } } SkillHandle(); } else { actionStat = ActionStat.Idle; } } break; case ActionStat.Dead: { if (GetComponent <Animation>().IsPlaying(dead.name)) { return; } if (!GetComponent <Animation>().enabled) { GetComponent <Animation>().enabled = true; } GetComponent <Animation>().CrossFade(dead.name); this.enabled = false; } break; case ActionStat.hit: if (hit != null) { GetComponent <Animation>().CrossFade(hit.name); } break; } }
public void OnIdle() { countAction = -1; actionStat = Controller.ActionStat.Idle; }