public void Init(ActorParts actorParts, ActorParts.MuscleGroup muscleGroup) { this.actorParts = actorParts; attachedMuscleGroup = muscleGroup; // If currentProp has been assigned, it will be picked up AS IS, presuming it is already linked with the joints and held in the right position. // To pick up the prop from ground, assign it after Awake, for example in Start. if (currentProp != null) { currentProp.StartPickedUp(this); } muscles = new Muscle[] { actorParts.puppet.muscles[15], actorParts.puppet.muscles[16] }; System.Array.Resize(ref actorParts.puppet.muscles, actorParts.puppet.muscles.Length - 2); defaultLocalPos = muscles[0].target.localPosition; defaultLocalEular = muscles[0].target.localEulerAngles; bladeDetector = muscles[1].transform.gameObject.AddComponent <BladeDetector>(); bladeDetector.enabled = false; bladeDetector.init(this); foreach (var m in muscles) { m.transform.gameObject.SetActive(false); } // 事件绑定 MessageManager.AddListener("OnStabIn", OnStabIn, transform); }
public void Init(ActorParts ap) { rigidTran = ap.rigidRoot; //TODO 技能的学习 skills = ap.GetLearnableSkill(); if (equipedSkill == null) { equipedSkill = new Skill[9]; } skillZone = new SkillZone(ap); }
// 需要玩家的 ActorParts public SkillZone(ActorParts ap) { sideLength = ap.GetMuscleGroup("RightHand").muscleLength; skillZones = new Vector2[9]; padding = 0.2f * sideLength; float xFactor = -2.5f; float yFactor = 2.5f; for (int i = 0; i < 3; i++) { yFactor -= 1; for (int j = 0; j < 3; j++) { xFactor += 1; Vector2 orgPoint = new Vector2(xFactor * sideLength, yFactor * sideLength); int offsetx = j - 1; int offsety = 1 - i; skillZones[i * 3 + j] = new Vector2(orgPoint.x + offsetx * padding, orgPoint.y + offsety * padding); } xFactor = -2.5f; } }
static public void AddParts(string name, Transform parts) { Debug.Log ("AddParts Name : " + name.ToString() ); if (parts == null) return; ActorParts actorParts; if (dicActorParts.ContainsKey(name)) { actorParts = dicActorParts[name]; } else { actorParts = new ActorParts(); actorParts.name = name; dicActorParts[name] = actorParts; } bool exists = false; foreach (Transform form in actorParts.parts) { if (form == parts) { exists = true; break; } } if (!exists) { actorParts.parts.Add(parts); } }
public override void Init() { puppet = GetComponentInChildren <PuppetMaster>(); if (!puppet.initiated) { puppet.Initiate(); } actorController.Init(this); actorParts = actorController.GetActorParts(); Global.Tranverse(actorParts.puppetRoot, EnableCols); if (controlling) { cameraHandler.am = this; var gm = GetGM(); gm.AddEvent("Move", (InputManager.Value2)actorController.Move); gm.AddEvent("View", (InputManager.Value2)actorController.View); gm.AddEvent("Defence", (InputManager.Bool1)actorController.Defence); gm.AddEvent("Attack", (InputManager.Bool1)actorController.Attack); gm.AddEvent("View", (InputManager.Value2)cameraHandler.View); gm.AddEvent("AdRange", (InputManager.Value1)actorController.AdRange); gm.AddEvent("Run", (InputManager.Bool1)actorController.Run); gm.AddEvent("Dodge", (InputManager.Value0)actorController.Dodge); gm.AddEvent("Jump", (InputManager.Value1)actorController.Jump); gm.AddEvent("PickDrop", (InputManager.Bool1)actorController.PickDrop); gm.AddEvent("Skill", (InputManager.Value0)actorController.Skill); } else { } state = gameObject.GetComponent <StateController>(); if (state == null) { state = gameObject.AddComponent <StateController>(); } state.Init(this); if (skillController == null) { skillController = gameObject.AddComponent <SkillController>(); } skillController.Init(actorParts); // SubManager初始化 battleMng = GetComponent <SubBattleManager>(); if (battleMng == null) { battleMng = gameObject.AddComponent <SubBattleManager>(); } effectMng = GetComponent <SubEffectManager>(); if (effectMng == null) { effectMng = gameObject.AddComponent <SubEffectManager>(); } battleMng.Init(); effectMng.Init(); LateInit(); // 测试代码位置 // TODO 删除 test代码 Test(); }