public void UpdateFromState(Monster.State state) { Sprite sprite = null; if (state == Monster.State.WANDER) { sprite = this.wanderSprite; } else if (state == Monster.State.THREATEN) { sprite = this.threatenSprite; } else if (state == Monster.State.FLEE) { sprite = this.fleeSprite; } else if (state == Monster.State.PRE_FIGHT) { sprite = this.fightSprite; } else if (state == Monster.State.POST_FIGHT) { sprite = this.postFightSprite; } else if (state == Monster.State.ENFLAMED_PANIC) { sprite = this.firePanicSprite; } else if (state == Monster.State.LURE) { sprite = this.lureSprite; } else if (state == Monster.State.MESMERIZED) { sprite = this.mesmerizeSprite; } else if (state == Monster.State.DIGESTING) { sprite = this.digestingSprite; } else if (state == Monster.State.DYING) { sprite = this.deadSprite; } this.renderer.sprite = sprite; }
public void CallMonster(Player player, Monster.State state) { CardBattle.PlayAudio("召唤"); player.CallMonster(downView.handId, state); if (current == Round.Self) { self.BattleSort(new Vector3(200f, 0), true); enemy.BattleSort(new Vector3(200f, 0), true); } else { self.BattleSort(new Vector3(200f, 0), false); enemy.BattleSort(new Vector3(200f, 0), false); } player.HandSort(); // 当前回合召唤次数减1 --callCount; }
// 召唤怪物 public void CallMonster(int index, Monster.State state) { if (battle.Count <= 5) { CardProto proto = hand[index]; if (proto.View.type == CardModel.Type.Monster) { if (isSelf) { proto.View.transform.SetParent(GameObject.Find("CardBattle/SelfBattle").transform); } else { proto.View.transform.SetParent(GameObject.Find("CardBattle/EnemyBattle").transform); } proto.View.transform.rotation = new Quaternion(); proto.View.transform.localScale = new Vector3(0.4f, 0.4f); //proto.View.transform.DOLocalMove(Vector3.zero, 0.5f); proto.View.enabled = false; //GameObject.Destroy(proto.View); hand.Remove(proto); // 创建怪物模型 Object origin = Resources.Load("Prefab/Monster"); GameObject monsterObject = GameObject.Instantiate(origin) as GameObject; // 修改怪物模型 string id = (proto.GetID() / 10 == 0 ? "0" : "") + proto.GetID().ToString(); origin = Resources.Load("Prefab/Role/" + (isSelf ? "Benefit" : "Harm") + "/" + id); if (origin == null) { origin = Resources.Load("Prefab/Role/Benefit/01"); } GameObject monsterOrigin = GameObject.Instantiate(origin, monsterObject.transform) as GameObject; monsterOrigin.name = "Monster"; monsterOrigin.transform.DOLocalMoveZ(-50, 0.5f); proto.View.monster = monsterObject; //proto.View.monster.SetActive(false); Monster monster = proto.View.monster.AddComponent <Monster>(); monster.proto = proto; monster.origin = monsterOrigin; // 攻击状态 monster.isSelf = isSelf; monster.state = state; monster.SetState(false, false); monster.SetHealth(proto.GetHealth()); monster.state = state; monster.model.value = proto.GetDefend(); monster.SetValue(monster.GetValue()); if (isSelf) { proto.View.monster.transform.SetParent(GameObject.Find("CardBattle/SelfBattle/Monsters").transform); } else { proto.View.monster.transform.SetParent(GameObject.Find("CardBattle/EnemyBattle/Monsters").transform); } proto.View.monster.transform.rotation = new Quaternion(); proto.View.monster.transform.localScale = new Vector3(1f, 1f, 1f); // 更新卡牌信息 monster.UpdateCard(); battle.Add(proto); for (int i = index; i < hand.Count; i++) { hand[i].View.handId = i; } } } else { EventManager.PostEvent(TipSystem.DataType.ShowTip, "不可召唤,战场怪物数量到达上限", isSelf ? true : false); } }