public virtual void ElementReaction(Element element) { if (elementComponent) { switch (element) { case Element.Fire: if (iceParticle != null) { GridFunctionUtility.CreateParticleAt(fireParticle, this); } break; case Element.Ice: if (iceParticle != null) { GridFunctionUtility.CreateParticleAt(iceParticle, this); } break; default: break; } elementComponent.OnHitElement(element); eElementReaction.Invoke(element); } }
public IEnumerator SpawnEnemy() { Vector2Int yRange = GridFunctionUtility.GetPlayerChessyRange(); yRange.x = Mathf.Max(0, yRange.x - spawnDistance); yRange.y = Mathf.Min(GridManager.instance.size.y - 1, yRange.y + spawnDistance); int cntNum = AIManager.instance.AIs.Count; foreach (CAICompoment t in AIManager.instance.AIs) { if (t.actor.elementComponent.state == ElementState.Frozen) { cntNum--; } } int maxEnemyNum = maxEnemyOverNum + GridManager.instance.GetPlayerActiveChesses().Count; int spawnnum = Mathf.Min(num, maxEnemyNum - cntNum); for (int i = 0; i < spawnnum; i++) { Vector2Int targetLocation = GetValidLocation(yRange); GridManager.instance.InstansiateChessAt(ChooseRandomEnemy(), targetLocation); GameObject t = UIManager.instance.CreateFloorHUD(targetLocation, Color.yellow); UIManager.instance.eRefreshFloorHUD.Invoke(); yield return(1f); Destroy(t); } yield return(0.5f); }
IEnumerator PreEnvironmentTurn() { Vector2Int yRange = GridFunctionUtility.GetPlayerChessyRange(); yRange.x = Mathf.Max(0, yRange.x - stormAroundDistance); yRange.y = Mathf.Min(GridManager.instance.size.y - 1, yRange.y + stormAroundDistance); for (int i = 0; i < stormNum; i++) { Vector2Int location; do { location = GridFunctionUtility.GetRandomLocation(yRange); }while (stormLocation.Contains(location)); stormLocation.Add(location); } foreach (var location in stormLocation) { GameObject t = GridFunctionUtility.CreateParticleAt(prefabStorm, location); Material mat = t.GetComponent <MeshRenderer>().material; Color color = mat.GetColor("_Color"); mat.SetColor("_Color", Color.yellow); stormParticle.Add(t); yield return(new WaitForSeconds(1f)); mat.SetColor("_Color", color); } GameManager.instance.EnvironmentPreTurnEnd(); }
public IEnumerator PostTurnAIExcute() { foreach (var AI in AIs) { AI.PerformSkill(); yield return(null);//技能释放完成后继续执行 } StartCoroutine(GridFunctionUtility.InvokeAfter(GameManager.instance.AIPostTurnEnd, 1f)); }
protected override bool SetCondition <T1>(T1 pa) { if (!GridFunctionUtility.InRange(GetRange(), pa.location)) { Debug.Log("OutRange"); return(false); } return(true); }
Vector2Int GetValidLocation(Vector2Int yRange) { Vector2Int t = new Vector2Int(); do { t = GridFunctionUtility.GetRandomLocation(yRange); } while (!GridManager.instance.CheckTransitability(t)); return(t); }
public void DieImmediately() { Debug.Log("Chess:" + gameObject + "Die"); gameObject.SetActive(false); if (deathParticle != null) { GridFunctionUtility.CreateParticleAt(deathParticle, this); } Destroy(gameObject); }
public virtual void Enter() { if (prefabEnterParticle != null && !disableParticle) { GridFunctionUtility.CreateParticleAt(prefabEnterParticle, owner); } if (prefabPersistentParticle != null) { persistentParticle = GridFunctionUtility.CreateParticleAt(prefabPersistentParticle, owner); persistentParticle.transform.parent = owner.render.transform; } }
public void FreezeFoot() { if (freezeFoot) { return; } if (prefabFreezenFootVFX != null) { freezenFootVFX = GridFunctionUtility.CreateParticleAt(prefabFreezenFootVFX, this); } freezeFoot = true; }
/// <summary> /// 显示技能范围 /// </summary> public void PrepareSkill() { if (target != null) { (actor as GChess).FaceToward((target.location - actor.location).Normalized()); floorHUD = new FloorHUD(GetSkill().GetAffectRange, new Color(1, 0, 0, 0.8f)); } else { Debug.Log("Target Miss"); } StartCoroutine(GridFunctionUtility.InvokeAfter(AIManager.instance.MoveNext, 0.5f)); }
public virtual void Exit() { if (prefabExitParticle != null) { GridFunctionUtility.CreateParticleAt(prefabExitParticle, owner); } if (persistentParticle != null) { persistentParticle.GetComponent <ParticleSystem>().Stop(); Destroy(persistentParticle, 10); persistentParticle = null; } }
/// <summary> /// 释放技能 /// </summary> public void PerformSkill() { if (floorHUD != null) { floorHUD.Release(); floorHUD = null; } if (target != null) { AIChess.skill.Perform(); } StartCoroutine(GridFunctionUtility.InvokeAfter(AIManager.instance.MoveNext, 1f)); }
public void Warm() { if (warm) { return; } if (prefabWarmVFX != null) { warmVFX = GridFunctionUtility.CreateParticleAt(prefabWarmVFX, this); warmVFX.transform.parent = render.transform; } warm = true; }
public void DeactiveFreezeFoot() { if (!freezeFoot) { return; } eFreezeFootBroken.Invoke(); freezeFoot = false; Destroy(freezenFootVFX); if (prefabFreezenFootBrokenVFX != null) { GridFunctionUtility.CreateParticleAt(prefabFreezenFootBrokenVFX, this); } freezenFootVFX = null; }
/// <summary> /// 实施移动,并调用AISkill.Decide /// </summary> public void PerformMove() { if (AIChess.location == desination) { StartCoroutine(GridFunctionUtility.InvokeAfter(MoveComplete, 0.5f)); } else { AIChess.moveComponent.eFinishPath.AddListener(MoveComplete); if (target != null) { AIChess.MoveTo(desination); AIChess.skill.Decide(target); } } }
virtual public bool RequestMove(Vector2Int[] pathArr) { if (state != MoveState.Idle) { return(false); } else { path = new Queue <Vector2Int>(); foreach (var location in pathArr) { if (location == actor.location) { continue; } path.Enqueue(location); } if (path.Count == 0) { StartCoroutine(GridFunctionUtility.InvokeAfter(eFinishPath.Invoke, 1f)); return(false); } else { string s = System.String.Empty; Vector2Int[] t = path.ToArray(); foreach (var p in t) { s += p.ToString(); } Debug.Log("The Path is" + s); } state = MoveState.Moving; curTargetPosition = GridManager.instance.GetChessPosition3D(path.Dequeue()); return(true); } }
protected void AIPostTurnStart() { Debug.Log("GameState:AIPostTurnStart"); StartCoroutine(GridFunctionUtility.InvokeNextFrame(AIManager.instance.PostTurn)); }