private SphereCollider _item_Colloder; //技能碰撞框 public Dash(GameResource.HumanNature nature) { _human = nature.Human; _up_Speed = nature.Run_Speed * 1.5f; _Ani = nature.Human_Ani; _nature = HumanManager.Nature; }
public Jump(GameResource.HumanNature nature) { _nature = nature; _y_Speed = nature.Run_Speed; _human = nature.Human; _human_Ani = nature.Human_Ani; _jump_Bool = false; _jump_Frames = 27; _spring_Jump_Frames = _jump_Frames - 3; _preprocessing_Frames = 5; _x_Wall_Inside_Left = _nature.Left_Wall_Inside + _nature.Human_Height * (0.5f - _nature.Off_Set); _x_Wall_Inside_Right = _nature.Right_Wall_Inside - _nature.Human_Height * (0.5f - _nature.Off_Set); _fruit_Collider_Transform = _human.GetComponentInChildren <FruitCollider>().transform; float n = nature.Jump_Speed / nature.Run_Speed; _direction_Right = Vector3.right * n + Vector3.up; _direction_Left = Vector3.left * n + Vector3.up; foreach (HumanSkill i in nature.Skill_List) { if (i == HumanSkill.DoubleJump) { _jump_Bool = true; } } }
public DeadFunction(GameResource.HumanNature nature, Transform ob) { _nature = nature; _collider = ob; _human_Mesh = GameObject.FindGameObjectWithTag("Player").GetComponent <SkinnedMeshRenderer>(); _wall_Mesh = ob.GetComponent <SpriteRenderer>(); }
public Revise(GameResource.HumanNature nature) { _camera = nature.Main_Camera; _human_Ani = nature.Human_Ani; _human = nature.Human; _difference = nature.Difference_Y; _revise_Time = 0.5f; }
void InitializeStateMachines(StateMachine <HumanState> state_Machines, GameResource.HumanNature nature) { state_Machines.AddState(HumanState.Run, new Run(nature)); state_Machines.AddState(HumanState.Jump, new Jump(nature)); state_Machines.AddState(HumanState.Slowdown, new Slowdown(nature)); state_Machines.AddState(HumanState.Revise, new Revise(nature)); state_Machines.AddState(HumanState.Stop, new Stop(nature)); state_Machines.AddState(HumanState.Dead, new Dead(nature)); }
void Start() { _nature = HumanManager.Nature; _human = _nature.HumanManager_Script; _time = 0; _time_Bool = false; _default_Position = transform.localPosition; _default_Rotation = transform.localEulerAngles; }
//死亡状态的赋值方法 void DeadExecute(GameResource.HumanNature nature) { if (ItemColliction.DeadDash.IsRun()) { return; } //摄像机震动 CameraShake.Is_Shake_Camera = true; nature.HumanManager_Script.CurrentState = HumanState.Dead; }
void OnDestroy() { //清空购买道具的数组 BuyTheItems.Buy_Items_List.Clear(); BuyTheItems.dead_Dash_Bool = false; BuyTheItems.start_Dash_Bool = false; //释放对象,清理内存 _state_Data.Clear(); _item_Data.Clear(); _nature = default(GameResource.HumanNature); }
public Slowdown(GameResource.HumanNature nature) { _y_Speed = nature.Slow_Speed; _human = nature.Human; _human_Ani = nature.Human_Ani; if (nature.Slow_Speed <= 0) { Debug.Log("奔跑速度不能为0或为负!"); return; } }
public Run(GameResource.HumanNature nature) { _nature = nature; _y_Speed = nature.Run_Speed; _human = nature.Human; _human_Ani = nature.Human_Ani; if (nature.Run_Speed <= 0) { Debug.Log("奔跑速度不能为0或为负!"); return; } }
//判断,获取墙体内侧x坐标 float JudgeX(WallMark mark, GameResource.HumanNature nature, float off_Set) { switch (mark) { case WallMark.Left: return(nature.Left_Wide_Wall_Inside); case WallMark.Right: return(nature.Right_Wide_Wall_Inside); default: Debug.Log("mark值有问题"); return(10000); } }
// Use this for initialization void Start() { _nature = HumanManager.Nature; _move_Speed = _nature.Run_Speed; if (_move_Speed <= 0) { Debug.Log("移动速度不能为0或为负!"); return; } _end_Point = _nature.End_Point; _human_Render = GameObject.FindGameObjectWithTag("Player").GetComponent <SkinnedMeshRenderer>(); _success_Bool = true; GameEnd = false; }
void WallExecute(GameResource.HumanNature nature, Transform wall) { if (Time.timeSinceLevelLoad <= 0.5f) { return; } HumanState state = nature.HumanManager_Script.CurrentState; //计算人物在墙内侧的x轴坐标 float x = JudgeX(HumanManager.WallMark, nature, nature.Off_Set); if (x == 10000) { Debug.Log("获取墙内侧坐标失败!"); return; } switch (state) { case HumanState.Run: case HumanState.Revise: case HumanState.Slowdown: state = HumanState.Stop; break; case HumanState.Jump: HumanPosition(nature.Human, x); if (Ice.Is_Jump_Before) { state = HumanState.Slowdown; } else { state = HumanState.Revise; } break; } Ice.Is_Jump_Before = false; nature.HumanManager_Script.CurrentState = state; if (Jump._preprocessing_Bool) { Jump.Preprocessing(); } }
IEnumerator SpringFunction(GameResource.HumanNature nature, Transform spring) { //HumanState state = HumanState.Stop; //register_State(state, state_Machines, nature, item); bool temp_Bool = JudgeState(nature, spring); nature.Human_Ani.SetInteger(StaticParameter.Ani_Key_HumanState, 7); Animator ani = spring.GetComponent <Animator>(); //判定是否播放弹簧动画 if (temp_Bool) { //调整人物角度 switch (HumanManager.WallMark) { case WallMark.Left: _nature.Human.eulerAngles = Vector3.up * 180; break; case WallMark.Right: _nature.Human.eulerAngles = Vector3.zero; break; } ani.SetBool(StaticParameter.Ani_Key_OnOff, true); } else { if (ItemColliction.SuperMan.IsRun()) { //摄像机震动 CameraShake.Is_Shake_Camera = true; ani.SetBool(StaticParameter.Ani_Key_Broke, true); } } yield return(new WaitForSeconds(0.17f)); if (temp_Bool) { GameResource.HumanNature._follow_Spring.is_Start = false; SpringExecute(_nature, _collider); } ani.SetBool(StaticParameter.Ani_Key_OnOff, false); ani.SetBool(StaticParameter.Ani_Key_Broke, false); //AColliderMethod method = new Spring(register_State, state_Machines, nature, spring, item); //method.OnExecute(); }
/// <summary> /// 人物碰撞管理器(因为碰撞物体不同,所以每碰撞一次,创建一次方法类对象) /// </summary> /// <param name="register_State"></param> /// <param name="state_Machines"></param> /// <param name="nature"></param> /// <param name="sth"></param> /// <param name="item"></param> void ColliderManager(GameResource.HumanNature nature, Transform sth) { AColliderMethod method = null; switch (sth.gameObject.layer) { case MyTags.Wide_Wall_Collider_Layer: //墙体碰撞方法实例 method = new Wall(nature, sth); break; case MyTags.Ice_Layer: method = new Ice(nature, sth); break; case MyTags.Spring_Layer: //弹簧碰撞方法实例 method = new Spring(nature, sth); break; case MyTags.Obstacle_Layer: case MyTags.Missile_Layer: case MyTags.Sword_Layer: //致死机关碰撞方法实例 method = new DeadFunction(nature, sth); break; case MyTags.Fruit_Layer: method = new Fruit(sth); break; case MyTags.Chest_Layer: method = new Chest(sth); break; case MyTags.Toturial_Layer: method = new Toturial(sth); break; } if (method != null) { method.OnExecute(); } }
//判断人物自身技能(这里只判断人物双倍分数技能) void JudgeSkill(GameResource.HumanNature nature, Material double_Material) { foreach (HumanSkill i in nature.Skill_List) { if (i == HumanSkill.DoubleGold) { MeshRenderer render = transform.GetComponent <MeshRenderer>(); if (double_Material) { render.material = _double_Material; } else { Debug.Log(name + "少个材质"); } } } }
//重置人物状态和位置,并给人物跟随弹簧移动的参数结构体赋值 void SetHumanPosition(GameResource.HumanNature nature, Transform spring, SkinnedMeshRenderer spring_Renderer) { if (ItemColliction.SuperMan.IsRun()) { nature.Human.position = Vector3.right * nature.Human.position.x + Vector3.up * (spring.position.y - 0.4f) + Vector3.forward * nature.Human.position.z; } else { nature.Human.position = Vector3.right * nature.Human.position.x + Vector3.up * spring.position.y + Vector3.forward * nature.Human.position.z; } //给结构体赋值 GameResource.HumanNature._follow_Spring.is_Start = true; GameResource.HumanNature._follow_Spring.spring_Renderer = spring_Renderer; nature.HumanManager_Script.CurrentState = HumanState.Stop; }
//计算加速运动时的加速度 float CalculateSpeed(int frames, ref float off_Set, GameResource.HumanNature nature) { float base_Speed = nature.Run_Speed * 0.4f;//减速后的最低速度 float distance_Y = nature.Run_Speed * (frames + 8) - base_Speed * frames; float num = 0; for (int i = 0; i < frames; i++) { num += i; } off_Set = distance_Y / num;//速度的递减量 float speed_Max = off_Set * frames + base_Speed; return(speed_Max); }
void Start() { _default_Position = transform.localPosition; _default_Rotation = transform.localEulerAngles; Ice.Is_Jump_Before = false; Ice.IsOnIce = false; WideWallColliderBefore = null; _nature = HumanManager.Nature; _human = _nature.Human_Script; ItemColliderManager skill_Manager = _human.transform.GetComponentInChildren <ItemColliderManager>(); StaticParameter.JudgeNull("_human", _human); StaticParameter.JudgeNull("skill_Manager", skill_Manager); _item_Collider = skill_Manager.gameObject; _item_Collider.SetActive(false); _effect = (GameObject)StaticParameter.LoadObject("GameEffect", "effect"); _protect_Broke_Mobel = (GameObject)StaticParameter.LoadObject("Other", "ProtectBroke"); }
void SpringExecute(GameResource.HumanNature nature, Transform spring) { //播放音效 MyAudio.PlayAudio(StaticParameter.s_Spring, false, StaticParameter.s_Spring_Volume); HumanState state = HumanState.Jump; if (spring.tag.Contains(MyTags.Left_Tag)) { HumanManager.WallMark = WallMark.Right; } else { HumanManager.WallMark = WallMark.Left; } HumanManager.JumpMark = JumpMark.SpeedUp; //改变跳跃类型 nature.HumanManager_Script.CurrentState = state; }
void MoveToDashPosition(GameResource.HumanNature nature) { Vector3 center = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth * 0.5f, Camera.main.pixelHeight * 0.25f, nature.Human.position.z - Camera.main.transform.position.z)); if (MyCamera.GameEnd) { nature.Human.position = new Vector3(center.x, nature.Human.position.y, nature.Human.position.z); _human.DOMoveY(_human.position.y + 12, 0.5f); _human.DOPlay(); } else { float duration = 0.5f; int frams = (int)(60 * duration); Vector3 temp; if (BuyTheItems.start_Dash_Bool) { temp = Vector3.right * center.x + Vector3.up * (center.y + (frams - 6) * _up_Speed) + Vector3.forward * nature.Human.position.z; } else { if (MyKeys.Pause_Game && !GameUIManager.Is_Resurgence) { temp = Vector3.right * center.x + Vector3.up * center.y + Vector3.forward * nature.Human.position.z; } else { temp = Vector3.right * center.x + Vector3.up * (center.y + frams * _up_Speed) + Vector3.forward * nature.Human.position.z; } } nature.Human.DOMove(temp, duration).SetEase(Ease.Linear).SetId("Dash").OnComplete(() => { DOTween.Kill("Dash"); }); DOTween.Play("Dash"); } }
void WallExecute(GameResource.HumanNature nature, Transform wall) { if (Time.time == 0.0f) { return; } if (IsOnIce) { return; } if (_nature.HumanManager_Script.CurrentState == HumanState.Jump) { Is_Jump_Before = true; } else { Is_Jump_Before = false; _nature.HumanManager_Script.CurrentState = HumanState.Slowdown; } IsOnIce = true; }
//判断碰撞弹簧后的状态 bool JudgeState(GameResource.HumanNature nature, Transform spring) { bool temp; SkinnedMeshRenderer spring_Renderer = spring.GetComponentInChildren <SkinnedMeshRenderer>(); if (nature.HumanManager_Script.CurrentState == HumanState.Jump)//nature.Human_Mesh.bounds.center.y > spring_Renderer.bounds.min.y&& { //可以发动弹簧 temp = true; //重置人物状态和位置,并给人物跟随弹簧移动的参数结构体赋值 SetHumanPosition(nature, spring, spring_Renderer); } else { if (nature.Human_Mesh.bounds.center.y >= spring_Renderer.bounds.min.y - 0.2f && nature.Human_Mesh.bounds.center.y <= spring_Renderer.bounds.max.y + 0.2f && IsJump) { temp = true; SetHumanPosition(nature, spring, spring_Renderer); IsJump = false; } else { //不能发动弹簧 temp = false; if (!ItemColliction.SuperMan.IsRun()) { nature.HumanManager_Script.CurrentState = HumanState.Stop; } } } return(temp); }
void Awake() { GameObject hero = null; switch (MyKeys.CurrentSelectedHero) { case MyKeys.CurrentHero.GuiYuZi: hero = StaticParameter.LoadObject("Ninja", "GuiYuZi") as GameObject; break; case MyKeys.CurrentHero.CiShen: hero = StaticParameter.LoadObject("Ninja", "CiShen") as GameObject; break; case MyKeys.CurrentHero.YuZi: hero = StaticParameter.LoadObject("Ninja", "Yuzi") as GameObject; break; case MyKeys.CurrentHero.ShouSi: hero = StaticParameter.LoadObject("Ninja", "Shousi") as GameObject; break; } Instantiate(hero); //if (SceneManager.GetActiveScene().name.Contains("Endless")) //{ // copy.transform.position = new Vector3(-4.2f, -25.3f, 1.06f); //} //初始化人物属性对象 _nature = new GameResource.HumanNature(1); //初始化行为数据 _state_Data = new BehaviourData(); _item_Data = new ItemColliction(); }
public Null(GameResource.HumanNature nature) { }
public Magnet(GameResource.HumanNature nature) { _human = nature.Human; _nature = nature; }
public SuperMan(GameResource.HumanNature nature) { _human = nature.Human; _nature = nature; }
private float[] _time;//每一块起始颜色的数值 public Protect(GameResource.HumanNature nature) { _nature = nature; }
public Double(GameResource.HumanNature nature) { _nature = nature; _human = nature.Human; }
public Wall(GameResource.HumanNature nature, Transform wall) { _nature = nature; _collider = wall; _human_Mesh = GameObject.FindGameObjectWithTag("Player").GetComponent <SkinnedMeshRenderer>(); }