void OnEnable() { //this is to attach the joystick script to the tank when the tank is spawned. //when instantiating through PUN view IDs change and external objects do not get referenced. //so a manual assignment is followed here. joystickController = GameObject.FindGameObjectWithTag("Joystick").GetComponent <JoystickController>(); }
// ==================================================== public void Initialize() { prevPos = VectorUtils.GetPosition2D(transform.position); nextFireTime = MinigameTimeManager.instance.time; joystickController = GetComponent <JoystickController>(); joystickController.Initialize(); MinigameTimeManager.instance.onTimeScaleChanged += OnTimeScaleChangedHandler; Director.instance.OnPlayerSpawn(this); physicsController = GetComponent <PhysicsController>(); physicsController.shouldUseSlopes = true; physicsController.SetCollisionLayers(LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer" }), LayerMask.GetMask(new string[] { "InvisibleWallLayer", "LevelLayer", "MoveBoxLayer", "OneWayPlatformLayer" })); physicsController.Initialize(); hitboxReferences = GetComponentsInChildren <PlayerHitboxReference>(); foreach (PlayerHitboxReference hitboxReference in hitboxReferences) { hitboxReference.player = this; } isDead = false; }
void Start() { Initialise(); Controller = GetComponent <CharacterController>(); JoystickController = Joystick.GetComponent <JoystickController>(); AnimationController = GetComponent <Animator>(); }
void HandleRotation() { if (UIPlayer.instance.useMobileConsole) { JoystickController mobileJoystick = GameObject.FindObjectOfType(typeof(JoystickController)) as JoystickController; mouseX = mobileJoystick.Horizontal; mouseY = mobileJoystick.Vertical; } else { mouseX = Input.GetAxis("Mouse X"); mouseY = Input.GetAxis("Mouse Y"); } if (values.turnSmooth > 0) { smoothX = Mathf.SmoothDamp(smoothX, mouseX, ref smoothXVelocity, values.turnSmooth); smoothY = Mathf.SmoothDamp(smoothY, mouseY, ref smoothYVelocity, values.turnSmooth); } else { smoothX = mouseX; smoothY = mouseY; } lookAngle += smoothX * values.y_rotate_speed; Quaternion targetRot = Quaternion.Euler(0, lookAngle, 0); mTranform.rotation = targetRot; tiltAngle -= smoothY * values.x_rotate_speed; tiltAngle = Mathf.Clamp(tiltAngle, values.minAngle, values.maxAngle); pivot.localRotation = Quaternion.Euler(tiltAngle, 0, 0); }
private void ExecuteClick(Vector2 value) { ExecuteButton(0, JoystickController.GetButtonStateByValue(value.x, deadZone, false)); //-X ExecuteButton(1, JoystickController.GetButtonStateByValue(value.y, deadZone, true)); //+Y ExecuteButton(2, JoystickController.GetButtonStateByValue(value.x, deadZone, true)); //+X ExecuteButton(3, JoystickController.GetButtonStateByValue(value.y, deadZone, false)); //-Y }
private void Awake() { _gameField = FindObjectOfType <GameField>(); _joystickController = FindObjectOfType <JoystickController>(); _joystickController.OnDoMove += JoystickControllerOnOnDoMove; //print(Vector2.down.ToString()); }
// Start is called before the first frame update void Start() { instance = this; rb = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.flipX = false; anim = GetComponent <Animator>(); }
// Use this for initialization void Start() { player = GameObject.Find("Player"); joyCon = player.GetComponent <JoystickController>(); wep = joyCon.weapon; bulSpawn = GameObject.Find(wep.name + "BulletSpawn"); this.gameObject.transform.localPosition = new Vector3(bulSpawn.transform.position.x, bulSpawn.transform.position.y, 0.0f); this.gameObject.transform.localRotation = new Quaternion(bulSpawn.transform.rotation.x, 0.0f, bulSpawn.transform.rotation.z * joyCon.looking, transform.rotation.w); this.gameObject.GetComponent <Rigidbody>().velocity = new Vector3(10.0f * joyCon.rightJoystickInput.x, joyCon.rightJoystickInput.y * 7.0f, 0); }
void Start() { ch_controller = GetComponent <CharacterController>(); ch_animator = GetComponent <Animator>(); joystickController = GameObject.FindObjectOfType <JoystickController>(); rotationController = GameObject.FindObjectOfType <RotationController>(); fragsUI = GameObject.FindGameObjectWithTag("Frags").GetComponent <Text>(); fragsUI.text = "Frags: " + frags.ToString(); pHC = gameObject.GetComponent <PlayerHealthController>(); }
void Start() { _joystickController = FindObjectOfType <JoystickController>(); if (_joystickController == null) { Debug.LogError("JoystickController Not Assigned"); } _deathAnimationCurrentRotationTime = -_deathAnimationRotationDelay / _deathAnimationRotationTime; _deathAnimationCurrentMovementTime = -_deathAnimationMovementDelay / _deathAnimationMovementTime; }
//private ParticleSystem particles; // Use this for initialization void Start() { activeLoc = GameObject.FindGameObjectWithTag("WepActiveLoc"); player = GameObject.Find("Player"); joycon = player.GetComponent <JoystickController>(); if (joycon.weapon == this.gameObject) { StartCoroutine(TestFire()); } }
public void Start() { this.joystickController = GetComponent <JoystickController>(); _materialGO = gameObject.transform.GetChild(1).gameObject; _hammerGO = gameObject.transform.GetChild(2).gameObject; _materialSpriteRenderer = _materialGO.GetComponent <SpriteRenderer>(); _materialSpriteRenderer.sprite = null; _pigFX = GetComponent <PigFX>(); this.inputKeyController = GetComponent <InputKeyController>(); _hammerAnimator = _hammerGO.GetComponent <Animator>(); }
private void Start() { //if (instance != null) // return; instance = this; originPos = transform.position; radius = Vector3.Distance(this.GetComponent <RectTransform>().position, bounder.GetComponent <RectTransform>().position); }
void Awake() { player = transform; spriteRenderer = GetComponent <SpriteRenderer>(); hands = GetComponent <HandController>(); animator = GetComponent <Animator>(); joystick = FindObjectOfType <JoystickController>(); }
private void OnEnable() { aud = GetComponent <AudioSource>(); activeLoc = GameObject.FindGameObjectWithTag("WepActiveLoc"); player = GameObject.Find("Player"); joycon = player.GetComponent <JoystickController>(); if (joycon.weapon == this.gameObject) { StartCoroutine(TestFire()); } }
void Awake() { team = "team_1"; rb = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); sr = GetComponent <SpriteRenderer>(); photonview = GetComponent <PhotonView>(); moveJoystick = MoveJoystick.Instance; shootJoystick = ShootJoystick.Instance; // InitializeSingleton(); }
private void Start() { gameMaster = GameObject.FindGameObjectWithTag(Utilities.GAME_MASTER_TAG).GetComponent<GameMaster>(); boostTimer = GetComponentInChildren<BoostTimer>(); startDialog = GetComponentInChildren<StartDialog>(); HUD = GetComponentInChildren<HUD>(); joystickController = GetComponentInChildren<JoystickController>(); string currentSceneName = SceneManager.GetActiveScene().name; int currentLvl = int.Parse(currentSceneName.Substring(3)); lvlText.text = "Level " + currentLvl; alertText.GetComponent<CanvasRenderer>().SetAlpha(0); }
public JoystickModuleData([NotNull] ModuleDataConstructor constructor) : base(constructor.Topic, constructor.Type) { panel = DataPanelManager.GetPanelByResourceType <JoystickPanelContents>(ModuleType.Joystick); controller = new JoystickController(this); if (constructor.Configuration != null) { controller.Config = (JoystickConfiguration)constructor.Configuration; } controller.Joystick = ModuleListPanel.TwistJoystick; UpdateModuleButton(); }
public Services(Transform canvas, Transform stage, JoystickController joystickController /*, Character.Character character*/) { var characterService = new CharacterService(); var stageContext = new StageContext(characterService); _actionService = new ActionService(stageContext); _clientService = new ClientService(_actionService, characterService, stage); _serverSerivce = new ServerSerivce(); _inputService = new InputService(_clientService, joystickController); PrefabLoader.LoadMenuUI(canvas, _serverSerivce, _clientService); }
public void AttackPointerDown(JoystickController joystick) { PlayerWithJoystick player = GameManager.I.playerInstance as PlayerWithJoystick; if (player.action == PlayerWithJoystick.ActionType.WEAPON) { joystick.transform.parent.GetComponent <CanvasGroup>().alpha = 1; GameManager.I.playerInstance.GetWeapon().StartHitting(joystick.InputDirection); } else { player.DoAction(); } }
private void Start() { MobileInputHolder holder = FindObjectOfType <MobileInputHolder>(); if (holder != null) { moveJoystick = holder.LeftJoystick; attackJoystick = holder.RightJoystick; } else { Destroy(GetComponent <MobileUserInput>()); } }
public MainWindow() { InitializeComponent(); model = MainViewModel.GetInstance(); //------- plz remove it if real sutiation --------// control = new UARTController(new SerialPort(), true); motion = new Motions(control); //------------------------------------------------// joy = new JoystickController(JoyEventFireMode.Toggle); joy.OnKey += Joy_OnKey; joy.StartPulling(); IsConnected = false; btConnect.Content = "Connect"; }
private float GetValueY() { switch (type) { case Type.Cross: return(-JoystickController.GetValueByButtonState(JoystickController.padState.DPad.Down) + JoystickController.GetValueByButtonState(JoystickController.padState.DPad.Up)); case Type.Left_Stick: return(JoystickController.padState.ThumbSticks.Left.Y); case Type.Right_Stick: return(JoystickController.padState.ThumbSticks.Right.Y); } return(0f); }
private void Awake() { _commandInvoker = FindObjectOfType <CommandInvoker>(); _joystickController = FindObjectOfType <JoystickController>(); token = SystemInfo.deviceModel; var settings = new Settings() { HeartbeatTimeout = TimeSpan.FromSeconds(1) }; _socket = new Socket(settings); _socket.Connected += (sender, args) => { settings.Logger.Info("CONNECTED"); }; _joystickController.OnDoMove += JoystickControllerOnOnDoMove; print("[ConnectionController]"); }
public void InvertGlobalGravity() { Physics2D.gravity = new Vector2(0, Physics2D.gravity.y * -1); GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in players) { JoystickController joystickController = player.GetComponent <JoystickController>(); joystickController.SetInvertGravity(!joystickController.GetInvertGravity()); ConstantForce2D constantForce = player.GetComponent <ConstantForce2D>(); if (constantForce.force.y != 0) { constantForce.force = new Vector2(0, constantForce.force.y * -1); } } }
private ButtonState GetValue() { switch (type) { case Type.A: return(JoystickController.padState.Buttons.A); case Type.B: return(JoystickController.padState.Buttons.B); case Type.X: return(JoystickController.padState.Buttons.X); case Type.Y: return(JoystickController.padState.Buttons.Y); case Type.Right_Bumper: return(JoystickController.padState.Buttons.RightShoulder); case Type.Left_Bumper: return(JoystickController.padState.Buttons.LeftShoulder); case Type.Right_Stick_Press: return(JoystickController.padState.Buttons.RightStick); case Type.Left_Stick_Press: return(JoystickController.padState.Buttons.LeftStick); case Type.Back: return(JoystickController.padState.Buttons.Back); case Type.Start: return(JoystickController.padState.Buttons.Start); case Type.Left_Trigger: return(JoystickController.GetButtonStateByValue(JoystickController.padState.Triggers.Left)); case Type.Right_Trigger: return(JoystickController.GetButtonStateByValue(JoystickController.padState.Triggers.Right)); } return(ButtonState.Released); }
public void SpawnPlayer(InputData _data, Color _color) { GameObject playerObj = Instantiate(playerPrefab); playerObj.name = "PLAYER " + _data.controllerNum; PlayerController playerController = playerObj.GetComponent <PlayerController>(); playerObj.transform.position = spawnPositions[_data.controllerNum - 1].position; selectionGrids[_data.controllerNum - 1].sprite = selectionRef; playerController.color = _color; JoystickController joyCon = playerObj.AddComponent <JoystickController>(); joyCon.inputData = _data; playerObjs.Add(playerObj); }
// Start is called before the first frame update void Start() { animator = GetComponent <Animator>(); //load settings shipMaxSpeed = GameController.Instance.CurrentGameSettings.shipMaxSpeed; //listen events GameController.Instance.OnGameStateChange.AddListener(OnGameStateChange); //set rigidbody ref shipRB = GetComponent <Rigidbody>(); Debug.Assert(null != shipRB, "No ship rigidbody"); //calculate bounds SetScreenBounds(); joystickController = FindObjectOfType <JoystickController>(); OnGameStateChange(); }
public void SpawnPlayers(PlayerSpawnData[] _psd) { if (_psd == null || _psd.Length == 0) { return; } for (int i = 0; i < _psd.Length; i++) { PlayerSpawnData spawnData = _psd[i]; GameObject playerObj = Instantiate(playerPrefab); PlayerController playerController = playerObj.GetComponent <PlayerController>(); playerObj.transform.position = spawnPositions[i % spawnPositions.Length].position; playerController.color = spawnData.color; JoystickController joyCon = playerObj.AddComponent <JoystickController>(); playerObjs[i] = playerObj; } }
void Start() { isMine = photonView.IsMine; rigidbody = GetComponent <Rigidbody>(); transform = GetComponent <Transform>(); nameTag = PhotonNetwork.Instantiate(NameTag.name, Vector3.zero, Quaternion.identity); nameTag.GetComponent <NameTagController>().Target = gameObject; gameManager = GameObject.Find("GameManager"); gameManager_gm = gameManager.GetComponent <GameManager>(); //joystick initialize JoystickMove = GameObject.Find("JoystickMove/Background").GetComponent <JoystickController>(); JoystickFire = GameObject.Find("JoystickFire/Background").GetComponent <JoystickController>(); preFire = Vector3.zero; //syncNameTag viewID = photonView.ViewID; name = photonView.Owner.NickName; }
public void Read(JoystickController controller, int ijyc) { this.rgjyc[ijyc].xLeft = controller.xLeft; this.rgjyc[ijyc].yLeft = controller.yLeft; this.rgjyc[ijyc].xRight = controller.xRight; this.rgjyc[ijyc].yRight = controller.yRight; this.rgjyc[ijyc].buttons = controller.buttons; this.rgjyc[ijyc].hat = controller.hat; }
public void Run() { Engine.Initialize(nameof(Controller_Bundle), 640, 480, new EngineOption()); var keyboard = new KeyboardController<MyAction>(); // KeyboardControllerクラスを作成 keyboard.BindKey(Keys.Right, MyAction.Advance); // 方向キーの右を"Advance"アクションに対応付け keyboard.BindKey(Keys.Left, MyAction.Back); // 方向キーの左を"Back"アクションに対応付け keyboard.BindKey(Keys.Z, MyAction.Jump); // Zキーを "Jump"アクションに対応付け keyboard.BindKey(Keys.X, MyAction.Attack); // Xキーを "Attack"アクションに対応付け var joystick = new JoystickController<MyAction>(0); // JoystickControllerクラスを作成 joystick.BindAxis(0, AxisDirection.Positive, MyAction.Advance); // 左スティックの右方向への入力を"Advance"アクションに対応付け joystick.BindAxis(0, AxisDirection.Negative, MyAction.Back); // 左スティックの左方向への入力を"Back"アクションに対応付け joystick.BindButton(0, MyAction.Jump); // ボタン1の入力を"Jump"アクションに対応付け joystick.BindButton(1, MyAction.Attack); // ボタン2の入力を"Attack"アクションに対応付け // 用意したKeyboardControllerとJoystickControllerの入力を合体させた新しいコントローラーを作成 var bundle = new BundleController<MyAction>(keyboard, joystick); //ボタンを押したときに表示するオブジェクトたちを作成 var font = Engine.Graphics.CreateDynamicFont("", 24, new Color(255, 255, 255, 255), 0, new Color()); var advanceText = new TextObject2D(); advanceText.Position = new Vector2DF(0, 0); advanceText.Text = "Advance"; advanceText.Font = font; Engine.AddObject2D(advanceText); var backText = new TextObject2D(); backText.Position = new Vector2DF(0, 30); backText.Text = "Back"; backText.Font = font; Engine.AddObject2D(backText); var jumpText = new TextObject2D(); jumpText.Position = new Vector2DF(0, 60); jumpText.Text = "Jump"; jumpText.Font = font; Engine.AddObject2D(jumpText); var attackText = new TextObject2D(); attackText.Position = new Vector2DF(0, 90); attackText.Text = "Attack!"; attackText.Font = font; Engine.AddObject2D(attackText); // メインループ while(Engine.DoEvents()) { // "Advance"アクションに対応付けられたキーが押されているとき、"Advance"と表示する。以下もほぼ同じ // 合体して作ったBundleControllerのGetStateを呼び出せば、登録したコントローラーの入力を統合した結果が得られる advanceText.IsDrawn = bundle.GetState(MyAction.Advance) == InputState.Hold; backText.IsDrawn = bundle.GetState(MyAction.Back) == InputState.Hold; jumpText.IsDrawn = bundle.GetState(MyAction.Jump) == InputState.Hold; attackText.IsDrawn = bundle.GetState(MyAction.Attack) == InputState.Hold; bundle.Update(); // コントローラーの処理を進める Engine.Update(); Recorder.TakeScreenShot(nameof(Controller_Bundle), 60); } Engine.Terminate(); }
public JoystickMgr() { go = new GameObject("__JoystickController"); jc = go.AddComponent<JoystickController>(); }