public void Init(MonsterEx attr, Transform attach, EUnitCamp camp) { owner = attach.GetComponent <MeteorUnit>(); Info = GetComponentInChildren <UnitDebugInfo>(true); Info.SetOwner(owner); //Transform mainCanvas = GameObject.Find("Canvas").transform; //transform.SetParent(mainCanvas); transform.localScale = Vector3.one; transform.localRotation = Quaternion.identity; transform.localPosition = Vector3.zero; transform.SetAsLastSibling(); //rect.anchoredPosition3D = new Vector3(0, 40.0f, 0); //transform.localScale = Vector3.one * 0.1f;//0.07-0.03 0.07是主角与敌人距离最近时,0.03是摄像机与敌人最近时,摄像机与敌人最近时,要看得到敌人,必须距离 44左右 MonsterName.text = attr == null ? "" : attr.Name; if (camp == EUnitCamp.EUC_ENEMY) { MonsterName.color = Color.red; } else if (camp == EUnitCamp.EUC_NONE) { MonsterName.color = Color.white; } target = attach; if (owner == Main.Ins.LocalPlayer) { MonsterName.gameObject.SetActive(false); } }
public MonsterEx InitPlayer(LevelScriptBase script) { MonsterEx ret = new MonsterEx(); ret.InitPlayer(script); return(ret); }
public MonsterEx InitMon(string Script) { MonsterEx ret = new MonsterEx(); if (ret.InitMonster(Script)) { return(ret); } return(null); }
//生成指定怪物 public static MeteorUnit Spawn(string script) { MonsterEx mon = InitMon(script); GameObject objPrefab = Resources.Load("MeteorUnit") as GameObject; GameObject ins = GameObject.Instantiate(objPrefab, Vector3.zero, Quaternion.identity) as GameObject; MeteorUnit unit = ins.GetComponent <MeteorUnit>(); switch (mon.Team) { case 0: unit.Camp = EUnitCamp.EUC_KILLALL; //与所有人都是敌人 break; case 1: unit.Camp = EUnitCamp.EUC_FRIEND; //流星阵营 break; case 2: unit.Camp = EUnitCamp.EUC_ENEMY; //蝴蝶阵营 break; default: unit.Camp = EUnitCamp.EUC_NONE; //与所有人都是朋友,所有人都无法打我 break; } unit.Init(mon.Model, mon); MeteorManager.Instance.OnGenerateUnit(unit); LuaFunction onInit = ScriptMng.ins.GetFunc("OnInit"); LuaFunction OnStart = ScriptMng.ins.GetFunc("OnStart"); onInit.call(unit.InstanceId); unit.SetGround(false); if (Global.GLevelItem.wayPoint != null) { if (Global.GLevelItem.wayPoint.Count > mon.SpawnPoint) { unit.transform.position = Global.GLevelItem.wayPoint[mon.SpawnPoint].pos; } else if (Global.GLevelItem.wayPoint.Count > 0) { unit.transform.position = Global.GLevelItem.wayPoint[0].pos; } } unit.transform.rotation = new Quaternion(0, 0, 0, 1); OnStart.call(); U3D.InsertSystemMsg(unit.name + " 加入游戏"); return(unit); }
public MonsterEx InitNetPlayer(PlayerEventData player) { MonsterEx ret = new MonsterEx(); ret.HpMax = (int)Main.Ins.RoomMng.GetRoom(Main.Ins.NetWorkBattle.RoomId).hpMax; ret.hpCur = ret.HpMax; ret.AngryValue = 0; ret.Model = (int)player.model; ret.Weapon = (int)player.weapon; ret.Weapon2 = (int)0; ret.name = player.name; ret.SpawnPoint = U3D.Rand(16); ret.Speed = 1000; ret.IsPlayer = player.playerId == Main.Ins.NetWorkBattle.PlayerId; return(ret); }
public MonsterEx InitNetPlayer(PlayerEvent player) { MonsterEx ret = new MonsterEx(); ret.HpMax = (int)RoomMng.Ins.GetRoom(NetWorkBattle.Ins.RoomId).hpMax * 10; ret.hpCur = ret.HpMax; ret.AngryValue = 0; ret.Model = (int)player.model; ret.Weapon = (int)player.weapon; ret.Weapon2 = (int)0; ret.name = player.name; ret.SpawnPoint = (int)player.spawnIndex; ret.Speed = 1000; ret.IsPlayer = player.playerId == NetWorkBattle.Ins.PlayerId; return(ret); }
void Start() { //for (int i = 0; i < 20; i++) // AmbLoader.Ins.LoadCharacterAmb(i); //AmbLoader.Ins.LoadCharacterAmb(); //ActionInterrupt.Instance.Init(); //MenuResLoader.Instance.Init(); Attr = new MonsterEx(); Attr.InitPlayer(null); if (charLoader != null) { return; } UnitId %= 20; //Debug.LogError("start"); Init(UnitId < 0 ? 0:UnitId, LayerMask.NameToLayer("LocalPlayer")); }
public static void SpawnRobot(int idx) { MonsterEx mon = new MonsterEx(); mon.Weapon = weaponCode[weaponIndex % weaponCode.Length]; mon.Weapon2 = weaponCode[(weaponIndex + 1) % weaponCode.Length]; weaponIndex++; mon.IsPlayer = false; mon.name = Global.model[idx]; GameObject objPrefab = Resources.Load("MeteorUnit") as GameObject; GameObject ins = GameObject.Instantiate(objPrefab, Vector3.zero, Quaternion.identity) as GameObject; MeteorUnit unit = ins.GetComponent <MeteorUnit>(); unit.Camp = EUnitCamp.EUC_ENEMY; unit.Init(idx, mon); MeteorManager.Instance.OnGenerateUnit(unit); unit.SetGround(false); unit.transform.position = Global.GLevelItem.wayPoint.Count != 0 ? Global.GLevelItem.wayPoint[nextSpawnPoint].pos : GameObject.Find("StartPoint").transform.position; unit.transform.rotation = new Quaternion(0, 0, 0, 1); }
public static MeteorUnit InitPlayer(LevelScriptBase script) { MonsterEx mon = SceneMng.InitPlayer(script); GameObject objPrefab = Resources.Load("MeteorUnit") as GameObject; GameObject ins = GameObject.Instantiate(objPrefab, Vector3.zero, Quaternion.identity) as GameObject; MeteorUnit unit = ins.GetComponent <MeteorUnit>(); MeteorManager.Instance.LocalPlayer = unit; unit.Camp = EUnitCamp.EUC_FRIEND;//流星阵营 unit.Init(mon.Model, mon); MeteorManager.Instance.OnGenerateUnit(unit); //LuaFunction onInit = ScriptMng.ins.GetFunc("OnInit"); //LuaFunction OnStart = ScriptMng.ins.GetFunc("OnStart"); //onInit.call(unit.InstanceId); unit.SetGround(false); unit.transform.position = Global.GLevelItem.wayPoint.Count > mon.SpawnPoint ? Global.GLevelItem.wayPoint[mon.SpawnPoint].pos : GameObject.Find("StartPoint").transform.position;//等关卡脚本实现之后在设置单机出生点.PlayerEx.Instance.SpawnPoint unit.transform.eulerAngles = new Vector3(0, mon.SpawnDir, 0); //OnStart.call(); U3D.InsertSystemMsg(unit.name + " 加入游戏"); return(unit); }
public MonsterEx InitNetPlayer(PlayerSync player) { MonsterEx ret = new MonsterEx(); RoomInfo room = RoomMng.Ins.GetRoom(NetWorkBattle.Ins.RoomId); if (room == null) { Debug.LogError("创建联机玩家-找不到房间信息 房间号:" + NetWorkBattle.Ins.RoomId); } ret.HpMax = room == null ? 200 : (int)room.hpMax * 10; ret.hpCur = (int)player.hp; ret.AngryValue = (int)player.ang; ret.Model = (int)player.model; ret.Weapon = (int)player.weapon; ret.Weapon2 = (int)0; ret.name = player.name; ret.SpawnPoint = (int)player.spwanIndex; ret.Speed = 1000; ret.IsPlayer = false; return(ret); }
//其他玩家进入战场,要判断当前是否在战场 //这个玩家也可能是自己 void OnPlayerEnterLevel(PlayerEvent rsp) { //Debug.LogError(rsp.name + "进入了战场"); if (FrameReplay.Ins.Started)//一定是新角色进入. { U3D.OnCreateNetPlayer(rsp); } else { //进来的玩家是自己,加载场景 if (rsp.playerId == NetWorkBattle.Ins.PlayerId) { //战斗场景已经存在 if (Main.Ins.GameBattleEx != null) { //重新设置主角的模型和阵营,原来的模型还在 MonsterEx mon = Main.Ins.LocalPlayer.Attr; mon.Weapon = (int)rsp.weapon; mon.Model = (int)rsp.model; Main.Ins.LocalPlayer.Camp = (EUnitCamp)rsp.camp; Main.Ins.LocalPlayer.Init((int)rsp.model, mon, true); //重设 Main.Ins.LocalPlayer.ResetPosition(); Main.Ins.GameBattleEx.NetGameStart(); return; } FrameSyncLocal.Ins.OnSelfEnterLevel(rsp); NetWorkBattle.Ins.Load(); } else { //自己还没有进入战场,看到别人进入战场的信息 U3D.InsertSystemMsg(U3D.GetCampEnterLevelStr((EUnitCamp)rsp.camp, rsp.name)); FrameSyncLocal.Ins.OnPlayerEnterLevel(rsp); } } }
//生成指定怪物,这个是从脚本入口来的,是正式关卡中生成NPC的 public MeteorUnit Spawn(string script) { MonsterEx mon = InitMon(script); GameObject objPrefab = Resources.Load("MeteorUnit") as GameObject; GameObject ins = GameObject.Instantiate(objPrefab, Vector3.zero, Quaternion.identity) as GameObject; MeteorUnit unit = ins.GetComponent <MeteorUnit>(); switch (mon.Team) { case 0: unit.Camp = EUnitCamp.EUC_KILLALL; //与所有人都是敌人 break; case 1: unit.Camp = EUnitCamp.EUC_FRIEND; //流星阵营 break; case 2: unit.Camp = EUnitCamp.EUC_ENEMY; //蝴蝶阵营 break; default: unit.Camp = EUnitCamp.EUC_NONE; //与所有人都是朋友,所有人都无法打我 break; } unit.Init(mon.Model, mon); UnitTopState unitTopState = new UnitTopState(unit); Main.Ins.EnterState(unitTopState); Main.Ins.MeteorManager.OnGenerateUnit(unit); LuaFunction onInit = mon.sState["OnInit"] as LuaFunction; onInit.call(mon.sState, unit.InstanceId); unit.SetGround(false); if (Main.Ins.CombatData.GLevelMode <= LevelMode.SinglePlayerTask) { if (Main.Ins.CombatData.wayPoints.Count != 0) { unit.transform.position = Main.Ins.CombatData.wayPoints.Count > mon.SpawnPoint ? Main.Ins.CombatData.wayPoints[mon.SpawnPoint].pos : Main.Ins.CombatData.wayPoints[0].pos;//等关卡脚本实现之后在设置单机出生点.PlayerEx.Instance.SpawnPoint } } else if (Main.Ins.CombatData.GLevelMode == LevelMode.CreateWorld) { if (Main.Ins.CombatData.GGameMode == GameMode.Normal) { unit.transform.position = Main.Ins.CombatData.wayPoints.Count > mon.SpawnPoint ? Main.Ins.CombatData.wayPoints[mon.SpawnPoint].pos : Main.Ins.CombatData.wayPoints[0].pos;//等关卡脚本实现之后在设置单机出生点.PlayerEx.Instance.SpawnPoint } else if (Main.Ins.CombatData.GGameMode == GameMode.MENGZHU) { //16个点 unit.transform.position = Main.Ins.CombatData.GLevelSpawn[Main.Ins.CombatData.SpawnIndex]; Main.Ins.CombatData.SpawnIndex++; Main.Ins.CombatData.SpawnIndex %= 16; } else if (Main.Ins.CombatData.GGameMode == GameMode.ANSHA || Main.Ins.CombatData.GGameMode == GameMode.SIDOU) { //2个队伍8个点. if (unit.Camp == EUnitCamp.EUC_FRIEND) { unit.transform.position = Main.Ins.CombatData.GCampASpawn[Main.Ins.CombatData.CampASpawnIndex]; Main.Ins.CombatData.CampASpawnIndex++; Main.Ins.CombatData.CampASpawnIndex %= 8; } else if (unit.Camp == EUnitCamp.EUC_ENEMY) { unit.transform.position = Main.Ins.CombatData.GCampASpawn[Main.Ins.CombatData.CampBSpawnIndex]; Main.Ins.CombatData.CampBSpawnIndex++; Main.Ins.CombatData.CampBSpawnIndex %= 8; } } } unit.transform.rotation = new Quaternion(0, 0, 0, 1); U3D.InsertSystemMsg(U3D.GetCampEnterLevelStr(unit)); mon.OnStart(); return(unit); }