void Start() { hero = transform; rb = GetComponent <Rigidbody>(); liftVector = new Vector3(0, 2.0f, 0); hMove = GetComponent <HeroMotor> () as HeroMotor; hPhys = GetComponent <HeroPhysic> () as HeroPhysic; hCam = GetComponent <HeroCamera> () as HeroCamera; hClimb = GetComponent <HeroClimb> () as HeroClimb; if (hCam.cam) { cam = hCam.cam; } bones = GetComponentsInChildren <Transform> () as Transform[]; foreach (Transform t in bones) { if (t.name == "root") { rootB = t; } } // FX GameObject gO = (GameObject)Resources.Load("FX_WaterSurf"); surfSplash = (GameObject)Instantiate(gO, hero.position, Quaternion.identity); surfSplash.active = false; }
private void onEvent(string evt, object data) { switch (evt) { case Events.EVENT_INPUT_JUMP: mAnimCtl.startJump(); break; case Events.EVENT_INPUT_SCREEN_CLICK: mAnimCtl.startRun((Vector3)data); break; case Events.EVENT_SELECT_HERO: string selectName = (string)data; Debug.Log("select hero selectName = " + selectName); this.getUtil().SelectedHeroName = selectName; if (selectName.Equals(this.gameObject.name)) { mapEvent(Events.EVENT_INPUT_JUMP, onEvent); mapEvent(Events.EVENT_INPUT_SCREEN_CLICK, onEvent); mCamera = this.gameObject.AddComponent<HeroCamera>(); //让gameObject检查同步 HeroSync.init(); GlobalObject.getComponent<HeroSync>().registerSync(gameObject.name, gameObject); } Debug.Log("before onEvent break"); break; default: break; } }
private void onEvent(string evt, object data) { switch (evt) { case Events.EVENT_INPUT_JUMP: mAnimCtl.startJump(); break; case Events.EVENT_INPUT_SCREEN_CLICK: mAnimCtl.startRun((Vector3)data); break; case Events.EVENT_SELECT_HERO: string selectName = (string)data; Debug.Log("select hero selectName = " + selectName); this.getUtil().SelectedHeroName = selectName; if (selectName.Equals(this.gameObject.name)) { mapEvent(Events.EVENT_INPUT_JUMP, onEvent); mapEvent(Events.EVENT_INPUT_SCREEN_CLICK, onEvent); mCamera = this.gameObject.AddComponent <HeroCamera>(); //让gameObject检查同步 HeroSync.init(); GlobalObject.getComponent <HeroSync>().registerSync(gameObject.name, gameObject); } Debug.Log("before onEvent break"); break; default: break; } }
void Start() { resetMovement(); heroAvatar = GetComponent <HeroAvatar> (); characterController = GetComponent <CharacterController>(); camera = GetComponentInChildren <Camera>(true); heroCamera = GetComponent <HeroCamera> (); heroManager = GetComponent <HeroManager> (); heroActionMap = new Dictionary <MovementAction, VoidFunc> { { MovementAction.MinusX, MinusX }, { MovementAction.MinusY, MinusY }, { MovementAction.MinusZ, MinusZ }, { MovementAction.PlusX, PlusX }, { MovementAction.PlusY, PlusY }, { MovementAction.PlusZ, PlusZ }, { MovementAction.MinusYRotate, MinusYRotate }, { MovementAction.PlusYRotate, PlusYRotate }, { MovementAction.ChangeCameraAngle, ChangeCameraAngle }, { MovementAction.ChangeHeroAngle, ChangeHeroAngle }, { MovementAction.ToggleRunWalk, ToggleRunWalk } }; }
void Start() { hero = transform; rb = rigidbody; liftVector = new Vector3 (0, 2.0f, 0); hMove = GetComponent <HeroMotor> () as HeroMotor; hPhys = GetComponent <HeroPhysic> () as HeroPhysic; hCam = GetComponent <HeroCamera> () as HeroCamera; hClimb = GetComponent <HeroClimb> () as HeroClimb; if (hCam.cam) cam = hCam.cam; bones = GetComponentsInChildren <Transform> () as Transform[]; foreach (Transform t in bones) { if (t.name == "root") rootB = t; } // FX GameObject gO = (GameObject)Resources.Load( "FX_WaterSurf" ); surfSplash = (GameObject)Instantiate (gO, hero.position, Quaternion.identity); surfSplash.active = false; }