public MonsterEx InitPlayer(LevelScriptBase script) { MonsterEx ret = new MonsterEx(); ret.InitPlayer(script); return(ret); }
//只加载地图/地图物件.要令所有客户端初始化完毕后状态一致,然后用指令播放器,播放帧指令. //如果是单机,就使用帧播放 void OnLoadFinishedEx(LevelDatas.LevelDatas lev) { Main.Ins.SoundManager.Enable(true); LevelScriptBase script = GetLevelScript(lev.LevelScript); if (script == null) { UnityEngine.Debug.LogError(string.Format("level script is null levId:{0}, levScript:{1}", lev.ID, lev.LevelScript)); return; } Main.Ins.CombatData.GScript = script; script.OnLoad(); //加载场景配置数据 Main.Ins.SceneMng.OnEnterLevel(); GameObject battleRoot = new GameObject("GameBattle"); Main.Ins.GameBattleEx = battleRoot.AddComponent <GameBattleEx>(); //等脚本设置好物件的状态后,根据状态决定是否生成受击盒,攻击盒等. Main.Ins.GameBattleEx.Init(script); FrameReplay.Instance.OnBattleStart(); //寻路 PathHelper.Ins.StartCalc(); //如果是录制模式-完毕后不要打开战斗UI if (Main.Ins.CombatData.Replay) { Main.Ins.EnterState(Main.Ins.ReplayState); } else { Main.Ins.EnterState(Main.Ins.FightState); } }
//场景初始化调用,或者爆出物品,待物品落地时调用 public void OnStart(LevelScriptBase script = null) { initializeY = transform.position.y; if (curve == null) { Keyframe[] ks = new Keyframe[2]; ks[0] = new Keyframe(0, -1); ks[1] = new Keyframe(1, 1); curve = new AnimationCurve(ks); //curve. } curve.postWrapMode = WrapMode.PingPong; curve.preWrapMode = WrapMode.PingPong; //自转+高度转 if (!property.names.ContainsKey("machine") && gameObject.activeSelf && !billBoard) { StartCoroutine(yMove()); } if (script != null) { MethodOnAttack = script.GetType().GetMethod(gameObject.name + "_OnAttack"); MethodOnIdle = script.GetType().GetMethod(gameObject.name + "_OnIdle"); } if (MethodOnAttack != null || OnAttackCallBack != null) { RefreshCollision(); } }
public static void OnLoadFinishedSingle(int level) { Application.targetFrameRate = GameStateMgr.Ins.gameStatus.TargetFrame; DlcMng.Ins.Init(); LevelData lev = DataMgr.Ins.GetLevelData(level); LevelScriptBase script = GetLevelScript(lev.LevelScript); if (script == null) { UnityEngine.Debug.LogError(string.Format("level script is null levId:{0}, levScript:{1}", lev.Id, lev.LevelScript)); return; } CombatData.Ins.GLevelItem = lev; CombatData.Ins.GLevelMode = LevelMode.SinglePlayerTask; CombatData.Ins.GGameMode = GameMode.Normal; CombatData.Ins.GScript = script; CombatData.Ins.wayPoints = CombatData.GetWayPoint(CombatData.Ins.GLevelItem); //加载场景配置数据 SceneMng.Ins.OnEnterLevel(); GameObject battleRoot = new GameObject("GameBattle"); Main.Ins.GameBattleEx = battleRoot.AddComponent <GameBattleEx>(); //等脚本设置好物件的状态后,根据状态决定是否生成受击盒,攻击盒等. Main.Ins.GameBattleEx.Init(script); FrameReplay.Ins.OnBattleStart(); PathHelper.Ins.StartCalc(); FightState.State.Open(); }
public void Init(Level lev, LevelScriptBase script) { lev_script = script; //updateFn = ScriptMng.ins.GetFunc("OnUpdate"); if (script != null) { time = script.GetRoundTime() * 60; } timeClock = 0.0f; //注册所有场景物件的受击框 SceneItemAgent[] sceneObjs = FindObjectsOfType <SceneItemAgent>(); //上一局如果暂停了,新局开始都恢复 Resume(); if (lev_script != null) { lev_script.Scene_OnLoad(); lev_script.Scene_OnInit(); lev_script.OnStart(); } for (int i = 0; i < sceneObjs.Length; i++) { sceneObjs[i].OnStart(lev_script); RegisterCollision(sceneObjs[i]); } U3D.InsertSystemMsg("新回合开始计时"); }
public void OnEnterLevel(LevelScriptBase levelScript, string sceneItems) { if (levelScript == null) { return; } if (Loader.Instance != null) { Loader.Instance.LoadFixedScene(sceneItems); Loader.Instance.LoadDynamicTrigger(sceneItems); } else { Debug.LogError("Loader not exist"); } //Main.Instance.CombatData.wayPoints = CombatData.Ins.GLevelSpawn = new Vector3[16]; CombatData.Ins.GCampASpawn = new Vector3[8]; CombatData.Ins.GCampBSpawn = new Vector3[8]; for (int i = 0; i < 16; i++) { GameObject obj = NodeHelper.Find(string.Format("D_user{0:d2}", i + 1), Loader.Instance.gameObject); CombatData.Ins.GLevelSpawn[i] = obj == null ? Vector3.zero : obj.transform.position; } for (int i = 0; i < 8; i++) { GameObject objA = NodeHelper.Find(string.Format("D_teamA{0:d2}", i + 1), Loader.Instance.gameObject); CombatData.Ins.GCampASpawn[i] = objA == null ? Vector3.zero :objA.transform.position; GameObject objB = NodeHelper.Find(string.Format("D_teamB{0:d2}", i + 1), Loader.Instance.gameObject); CombatData.Ins.GCampBSpawn[i] = objB == null ? Vector3.zero : objB.transform.position; } }
//只加载地图/地图物件.要令所有客户端初始化完毕后状态一致,然后用指令播放器,播放帧指令. //如果是单机,就使用帧播放 void OnLoadFinishedEx(LevelData lev) { SoundManager.Ins.Enable(true); LevelScriptBase script = GetLevelScript(lev.LevelScript); if (script == null) { UnityEngine.Debug.LogError(string.Format("level script is null levId:{0}, levScript:{1}", lev.Id, lev.LevelScript)); return; } CombatData.Ins.GScript = script; //加载场景配置数据 SceneMng.Ins.OnEnterLevel(); GameObject battleRoot = new GameObject("GameBattle"); Main.Ins.GameBattleEx = battleRoot.AddComponent <GameBattleEx>(); //等脚本设置好物件的状态后,根据状态决定是否生成受击盒,攻击盒等. Main.Ins.GameBattleEx.Init(script); FrameReplay.Ins.OnBattleStart(); //寻路-单机时有效 if (CombatData.Ins.GLevelMode <= LevelMode.CreateWorld) { PathHelper.Ins.StartCalc(); } //如果是录制模式-完毕后不要打开战斗UI //if (CombatData.Ins.Replay) // Main.Ins.EnterState(Main.Ins.ReplayState); //else FightState.State.Open(); }
public void InitPlayer(LevelScriptBase script) { Team = 1; IsPlayer = true; Speed = 1000; if (script == null) { name = "孟星魂"; SpawnPoint = 0; SpawnDir = 0; Weapon = 51; Weapon2 = 47; HpMax = hpCur = 1000; } else { name = script.GetPlayerName(); Model = script.GetPlayerModel(); SpawnPoint = script.GetPlayerSpawn(); SpawnDir = script.GetPlayerSpawnDir();//一个Z轴朝内,一个Z轴朝外,角度自己来换吧。 Weapon = (int)(double)script.GetPlayerWeapon(); Weapon2 = (int)(double)script.GetPlayerWeapon2(); HpMax = hpCur = (int)(double)script.GetPlayerMaxHp(); if (HpMax == 0) { hpCur = HpMax = 1000; } } View = 50; AngryValue = 0; IsDead = false; }
public void OnEnterLevel(LevelScriptBase levelScript, string sceneItems) { if (levelScript == null) { return; } if (Loader.Instance != null) { Loader.Instance.LoadFixedScene(sceneItems); Loader.Instance.LoadDynamicTrigger(sceneItems); } else { Debug.LogError("Loader not exist"); } //Main.Instance.CombatData.wayPoints = Main.Ins.CombatData.GLevelSpawn = new Vector3[16]; Main.Ins.CombatData.GCampASpawn = new Vector3[8]; Main.Ins.CombatData.GCampBSpawn = new Vector3[8]; for (int i = 0; i < 16; i++) { GameObject obj = NodeHelper.Find(string.Format("D_user{0:d2}", i + 1), Loader.Instance.gameObject); Main.Ins.CombatData.GLevelSpawn[i] = obj == null ? Vector3.zero : obj.transform.position; } for (int i = 0; i < 8; i++) { GameObject objA = NodeHelper.Find(string.Format("D_teamA{0:d2}", i + 1), Loader.Instance.gameObject); Main.Ins.CombatData.GCampASpawn[i] = objA == null ? Vector3.zero :objA.transform.position; GameObject objB = NodeHelper.Find(string.Format("D_teamB{0:d2}", i + 1), Loader.Instance.gameObject); Main.Ins.CombatData.GCampBSpawn[i] = objB == null ? Vector3.zero : objB.transform.position; } if (Main.Ins.CombatData.GLevelMode == LevelMode.MultiplyPlayer) { return; } //GameObject objWayPoint = new GameObject("wayPoint"); //objWayPoint.transform.position = Vector3.zero; //objWayPoint.transform.rotation = Quaternion.identity; //objWayPoint.transform.localScale = Vector3.one; //objWayPoint.layer = LayerMask.NameToLayer("WayPoint"); //for (int i = 0; i < Main.Ins.CombatData.wayPoints.Count; i++) //{ // GameObject wayPoint = new GameObject(string.Format("WayPoint{0}", i)); // wayPoint.tag = "WayPoint"; // wayPoint.transform.SetParent(objWayPoint.transform); // wayPoint.transform.position = Main.Ins.CombatData.wayPoints[i].pos; // wayPoint.layer = objWayPoint.layer; // wayPoint.transform.rotation = Quaternion.identity; // wayPoint.transform.localScale = Vector3.one; // BoxCollider box = wayPoint.AddComponent<BoxCollider>(); // box.isTrigger = true; // box.size = Vector3.one * (Main.Ins.CombatData.wayPoints[i].size); // box.center = Vector3.zero; //} }
void OnLoadFinishedEx(Level lev) { LevelScriptBase script = GetLevelScript(lev.goodList); //设置主角属性 U3D.InitPlayer(script);; //先创建一个相机 GameObject camera = GameObject.Instantiate(Resources.Load("CameraEx")) as GameObject; camera.name = "CameraEx"; //角色摄像机跟随者着角色. CameraFollow followCamera = GameObject.Find("CameraEx").GetComponent <CameraFollow>(); followCamera.Init(); //摄像机完毕后 SceneMng.OnLoad();// SoundManager.Instance.Enable(true); //加载场景配置数据 SceneMng.OnEnterLevel(lev.ID);//原版功能不加载其他存档数据. //把音频侦听移到角色 AudioListener listen = Startup.ins.gameObject.GetComponent <AudioListener>(); if (listen != null) { DestroyImmediate(listen); } MeteorManager.Instance.LocalPlayer.gameObject.AddComponent <AudioListener>(); FightWnd.Instance.Open(); if (!string.IsNullOrEmpty(lev.BgmName)) { SoundManager.Instance.PlayMusic(lev.BgmName); } //这个脚本暂时未调通,先放着 //ScriptMng.ins.CallScript(lev.goodList);//负责关卡内物件的属性,及攻击收击逻辑等 //等脚本设置好物件的状态后,根据状态决定是否生成受击盒,攻击盒等. GameBattleEx.Instance.Init(lev, script); //除了主角的所有角色,开始输出,选择阵营, 进入战场 for (int i = 0; i < MeteorManager.Instance.UnitInfos.Count; i++) { if (MeteorManager.Instance.UnitInfos[i] == MeteorManager.Instance.LocalPlayer) { continue; } MeteorUnit unitLog = MeteorManager.Instance.UnitInfos[i]; U3D.InsertSystemMsg(GetCampStr(unitLog)); } }
//场景初始化调用,或者爆出物品,待物品落地时调用 public void OnStart(LevelScriptBase script = null) { initializeY = transform.position.y; //自转+高度转 if (!property.names.ContainsKey("machine") && !billBoard) { if (curve == null) { Keyframe[] ks = new Keyframe[2]; ks[0] = new Keyframe(0, -1); ks[1] = new Keyframe(1, 1); curve = new AnimationCurve(ks); } curve.postWrapMode = WrapMode.PingPong; curve.preWrapMode = WrapMode.PingPong; animate = true; } if (script != null) { MethodOnAttack = script.GetType().GetMethod(gameObject.name + "_OnAttack"); MethodOnIdle = script.GetType().GetMethod(gameObject.name + "_OnIdle"); OnTouch = Main.Ins.CombatData.GScriptType.GetMethod(name + "_OnTouch", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (OnTouch == null) { System.Type typeParent = Main.Ins.CombatData.GScriptType.BaseType; while (typeParent != null && OnTouch == null) { OnTouch = typeParent.GetMethod(name + "_OnTouch", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); typeParent = typeParent.BaseType; } } OnPickUp = Main.Ins.CombatData.GScriptType.GetMethod(name + "_OnPickUp", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (OnPickUp == null) { System.Type typeParent = Main.Ins.CombatData.GScriptType.BaseType; while (typeParent != null && OnPickUp == null) { OnPickUp = typeParent.GetMethod(name + "_OnPickUp", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); typeParent = typeParent.BaseType; } } } if (MethodOnAttack != null || OnAttackCallBack != null) { RefreshCollision(); } }
void ApplyDamage() { bool prevdestroyed = destroyed; float currentHealth = GetComponent <DamageableComponent>().health; destroyed = currentHealth <= 0.0f; if (currentHealth < previousHealth && isPlayer && currentHealth > 0.0f) { hitSource.clip = hitSound; hitSource.pitch = 0.95f + (Random.value * 0.1f); hitSource.Play(); } if (!prevdestroyed && destroyed) { firePrefabInstance = Instantiate(firePrefab); firePrefabInstance.transform.parent = transform; firePrefabInstance.transform.localPosition = firePosition; forceDownTimer.Start(); if (team == AirplaneTeam.Enemy) { LevelScriptBase levelscript = GameObject.FindWithTag("Level Script").GetComponent <LevelScriptBase>(); switch (type) { case AirplaneType.Interceptor: levelscript.interceptorkills++; break; case AirplaneType.Bomber: levelscript.bomberkills++; break; case AirplaneType.Boss: levelscript.bosskills++; break; } } } previousHealth = currentHealth; }
void OnEnterLevel() { if (select != null) { CombatData.Ins.MainWeapon = GameStateMgr.Ins.gameStatus.Single.Weapon0; CombatData.Ins.SubWeapon = GameStateMgr.Ins.gameStatus.Single.Weapon1; CombatData.Ins.PlayerLife = GameStateMgr.Ins.gameStatus.Single.Life; CombatData.Ins.PlayerModel = GameStateMgr.Ins.gameStatus.Single.Model; CombatData.Ins.RoundTime = GameStateMgr.Ins.gameStatus.Single.RoundTime; CombatData.Ins.MaxPlayer = GameStateMgr.Ins.gameStatus.Single.MaxPlayer; bool isPluginLevel = true; List <LevelData> all = DataMgr.Ins.GetLevelDatas(); for (var i = 0; i < all.Count; i++) { if (all[i] == select) { isPluginLevel = false; break; } } if (isPluginLevel) { CombatData.Ins.Chapter = DlcMng.Ins.FindChapterByLevel(select); GameStateMgr.Ins.gameStatus.ChapterTemplate = CombatData.Ins.Chapter.ChapterId; GameStateMgr.Ins.gameStatus.Single.LevelTemplate = select.Id; } else { GameStateMgr.Ins.gameStatus.ChapterTemplate = 0; GameStateMgr.Ins.gameStatus.Single.LevelTemplate = select.Id; CombatData.Ins.Chapter = null; } LevelScriptBase script = LevelHelper.GetLevelScript(select.LevelScript); if (script == null) { U3D.PopupTip(string.Format("关卡脚本为空 关卡ID:{0}, 关卡脚本:{1}", select.Id, select.LevelScript)); return; } U3D.LoadLevel(select, LevelMode.CreateWorld, (GameMode)GameStateMgr.Ins.gameStatus.Single.Mode); } }
public void InitPlayer(LevelScriptBase script) { Team = 1; IsPlayer = true; Speed = 1000; if (script == null) { name = StringUtils.DefaultPlayer; SpawnPoint = 0; SpawnDir = 0; Weapon = 51; Weapon2 = 47; HpMax = hpCur = 10000; } else { name = script.GetPlayerName(); Model = script.GetPlayerModel(); SpawnPoint = script.GetPlayerSpawn(); SpawnDir = script.GetPlayerSpawnDir();//一个Z轴朝内,一个Z轴朝外,角度自己来换吧。 Weapon = (int)(double)script.GetPlayerWeapon(); Weapon2 = (int)(double)script.GetPlayerWeapon2(); HpMax = hpCur = (int)(double)script.GetPlayerMaxHp(); if (HpMax == 0) { hpCur = HpMax = 1000; } if (CombatData.Ins.GLevelMode == LevelMode.CreateWorld) { HpMax = hpCur = 10 * CombatData.Ins.PlayerLife; Weapon = U3D.GetWeaponByType(CombatData.Ins.MainWeapon); Weapon2 = U3D.GetWeaponByType(CombatData.Ins.SubWeapon); Model = CombatData.Ins.PlayerModel; name = DataMgr.Ins.GetModelDatas()[Model].Name; } } View = 500; AngryValue = 0; IsDead = false; }
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); }