protected override void Initialize() { _gui = new Gui(_desktop); base.Initialize(); foreach (Blocks name in Enum.GetValues(typeof(Blocks))) { Materials.Add(name, Content.Load <Texture2D>(name.ToString())); } _virtualWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; _virtualHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _virtualWidth, _virtualHeight); _world = new World(); Player1 = new Player(0, 0, _world); _cam = new OrthographicCamera(viewportAdapter); _cam.LookAt(new Vector2(Player.X, Player.Y)); _cam.Zoom = IRestrictions.Zoom; _spriteBatch = new SpriteBatch(GraphicsDevice); _playerMouse = new PlayerMouse(Content, _spriteBatch, _cam); _inputController = new InputController(_cam, _spriteBatch, Content, this, _world, Player1, _playerMouse); WorldRenderer = new WorldRenderer(_playerMouse, _inputController, _spriteBatch, this, _world); }
private void Awake() { if (myChamp == null) { myChamp = transform.parent.gameObject; } myChampionData = myChamp.GetComponent <ChampionData>(); TheAIPath = myChamp.GetComponent <AIPath>(); TheAIDest = myChamp.GetComponent <AIDestinationSetter>(); ThePlayerMouse = myChamp.GetComponent <PlayerMouse>(); aStarTargetObj = ThePlayerMouse.myTarget; enemiesList = new List <GameObject>(); myChampBehav = myChamp.GetComponent <ChampionBehavior>(); myChampionAnimation = myChamp.GetComponent <ChampionAnimation>(); champName = PlayerData.Instance.championName; if (myChamp.transform.parent.name.Contains("Ashe")) { asheSkill = myChamp.GetComponent <AsheSkill>(); if (asheSkill != null) { isAshe = true; } } }
private void Start() { photonview = this.transform.GetChild(0).GetComponent <PhotonView>(); PlayerObj.SetActive(true); //rvocontroller = GetComponentInChildren<Pathfinding.RVO.RVOController>(); seeker = GetComponentInChildren <Pathfinding.Seeker>(); aipath = GetComponentInChildren <Pathfinding.AIPath>(); funnelmodifier = GetComponentInChildren <Pathfinding.FunnelModifier>(); aidestinatonsetter = GetComponentInChildren <Pathfinding.AIDestinationSetter>(); playermouse = GetComponentInChildren <PlayerMouse>(); rigidbody = GetComponentInChildren <Rigidbody>(); WarFog = PlayerObj.GetComponent <FogOfWarEntity>(); forminimap = transform.GetChild(2).gameObject; astar_target = transform.GetChild(1).gameObject; splatmanager = transform.GetChild(0).GetChild(0).gameObject; rigidbody.isKinematic = true; WarFog.enabled = false; if (photonView.isMine) { PlayerObj.name = gameObject.name + "_" + PhotonNetwork.player.NickName; } else { PlayerObj.name = gameObject.name + photonView.owner.NickName; } SceneManager.activeSceneChanged += SceneLoaded; DontDestroyOnLoad(this); }
// Use this for initialization void Start() { player_info = GetComponent <PlayerInfo>(); player_mouse = GetComponent <PlayerMouse>(); player_keyboard = GetComponent <PlayerKeyboard>(); zoom = 0.0f; }
public WorldRenderer(PlayerMouse playerMouse, InputController inputController, SpriteBatch spriteBatch, Main main, World world) { _playerMouse = playerMouse; _inputController = inputController; _spriteBatch = spriteBatch; _main = main; _world = world; _world.Impassable.Add(Blocks.BlockWater); _world.Impassable.Add(Blocks.BlockRoof); _world.Impassable.Add(Blocks.BlockWall); }
public void Init(int p_playerId) { if (m_mouseParent) { m_cursor = Instantiate(m_mousePrefab, m_mouseParent.transform); } else { m_cursor = Instantiate(m_mousePrefab); } m_uiCursor = Instantiate(m_uiCursorPrefab, m_uiCanvas.transform).GetComponent <UICursor>(); m_mouse = m_cursor.GetComponent <PlayerMouse>(); m_mouse.useHardwarePointerPosition = false; m_mouse.playerId = p_playerId; m_rewiredPlayer = Rewired.ReInput.players.GetPlayer(p_playerId); if (Player.m_players.Count > 0) { m_player = Player.GetPlayerFromId(p_playerId); } m_mouse.leftButton.actionName = "UIInteract1"; m_mouse.rightButton.actionName = "UIInteract3"; //m_mouse.middleButton.actionName = "UIInteract3"; m_mouse.wheel.yAxis.actionName = "UIWheelY"; float sens = (float)Game.m_options.LoadOptionInt("Sensitivity" + "_" + p_playerId, 100).GetInt() / 50f; float size = (float)Game.m_options.LoadOptionInt("CursorSize" + "_" + p_playerId, 100).GetInt() / 200f; m_mouse.pointerSpeed = sens; m_uiCursor.transform.localScale = new Vector3(size, size, size); List <PlayerMouse> mice = Game.m_rewiredEventSystem.PlayerMice; mice.Add(m_mouse); Game.m_rewiredEventSystem.PlayerMice = mice; ChangeMode(m_useUICoordinatesOnly ? CursorModes.CURSOR : CursorModes.LINE, true); m_mouse.ScreenPositionChangedEvent += OnScreenPositionChanged; m_mouse.screenPosition = new Vector2(Screen.width / 2, Screen.height / 2 + 1); string cursorSprite = Game.m_options.Get("CursorSprite", p_playerId).GetString(); Sprite sprite = SpriteUtils.LoadSpriteFromFile(Application.dataPath + "/Data/Cursors/" + cursorSprite + ".png"); if (sprite != null) { SetCursorImage(sprite); } }
void Awake() { pointer = (GameObject)GameObject.Instantiate(pointerPrefab); pointer.transform.localScale = new Vector3(spriteScale, spriteScale, spriteScale); #if UNITY_5_PLUS if (hideHardwarePointer) { Cursor.visible = false; // hide the hardware pointer } #endif // Create the Player Mouse mouse = PlayerMouse.Factory.Create(); // Set the owner mouse.playerId = playerId; // Set up Actions for each axis and button mouse.xAxis.actionName = horizontalAction; mouse.yAxis.actionName = verticalAction; mouse.wheel.yAxis.actionName = wheelAction; mouse.leftButton.actionName = leftButtonAction; mouse.rightButton.actionName = rightButtonAction; mouse.middleButton.actionName = middleButtonAction; // If you want to change joystick pointer speed mouse.pointerSpeed = 1f; // If you want to change the wheel to tick more often mouse.wheel.yAxis.repeatRate = 5; // If you want to set the screen position mouse.screenPosition = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f); // If you want to use Actions to drive the X/Y position of the mouse // instead of using the hardware cursor position // mouse.useHardwareCursorPositionForMouseInput = false; // Additionally you'd need to bind mouse X/Y to the X/Y Actions on the Player's Mouse Map. // The result of this is that the mouse pointer will no longer pop to the hardware cursor // position when you start using the mouse. You would also need to hide the mouse // pointer using Cursor.visible = false; // Subscribe to position changed event (or you could just poll for it) mouse.ScreenPositionChangedEvent += OnScreenPositionChanged; // Get the initial position OnScreenPositionChanged(mouse.screenPosition); }
private void Awake() { if (myChamp == null) { myChamp = transform.parent.gameObject; } myChampionData = myChamp.GetComponent <ChampionData>(); TheAIPath = myChamp.GetComponent <AIPath>(); TheAIDest = myChamp.GetComponent <AIDestinationSetter>(); ThePlayerMouse = myChamp.GetComponent <PlayerMouse>(); AStarTargetObj = ThePlayerMouse.myTarget; enemiesList = new List <GameObject>(); myChampBehav = myChamp.GetComponent <ChampionBehavior>(); }
public void OnAwake() { Input.OnKey += OnKey; // Load initial map Env.Console.ExecuteString("map test"); // Player mouse interaction PlayerMouse = AddComponent <PlayerMouse>(); // Create UI ui = new TestUI(Root); // Create kill plane GameObject.Instantiate <KillPlane>(Root); }
private bool AddMouse(PlayerMouse playmouse) { if (PlayerMouseList.Count == 0) { PlayerMouseList.Add(playmouse); } else { if (PlayerMouseList[PlayerMouseList.Count - 1].MouseType == playmouse.MouseType && PlayerMouseList[PlayerMouseList.Count - 1].Event == playmouse.Event) { return(false); } else { PlayerMouseList.Add(playmouse); } } return(true); }
private void Awake() { this.pointer = (GameObject)Object.Instantiate <GameObject>((M0)this.pointerPrefab); this.pointer.get_transform().set_localScale(new Vector3(this.spriteScale, this.spriteScale, this.spriteScale)); if (this.hideHardwarePointer) { Cursor.set_visible(false); } this.mouse = PlayerMouse.Factory.Create(); ((PlayerController)this.mouse).set_playerId(this.playerId); ((PlayerController.ElementWithSource) this.mouse.get_xAxis()).set_actionName(this.horizontalAction); ((PlayerController.ElementWithSource) this.mouse.get_yAxis()).set_actionName(this.verticalAction); ((PlayerController.ElementWithSource) this.mouse.get_wheel().get_yAxis()).set_actionName(this.wheelAction); ((PlayerController.ElementWithSource) this.mouse.get_leftButton()).set_actionName(this.leftButtonAction); ((PlayerController.ElementWithSource) this.mouse.get_rightButton()).set_actionName(this.rightButtonAction); ((PlayerController.ElementWithSource) this.mouse.get_middleButton()).set_actionName(this.middleButtonAction); this.mouse.set_pointerSpeed(1f); this.mouse.get_wheel().get_yAxis().set_repeatRate(5f); this.mouse.set_screenPosition(new Vector2((float)Screen.get_width() * 0.5f, (float)Screen.get_height() * 0.5f)); this.mouse.add_ScreenPositionChangedEvent(new Action <Vector2>(this.OnScreenPositionChanged)); this.OnScreenPositionChanged(this.mouse.get_screenPosition()); }
// Start is called before the first frame update void Start() { _grid = GridGenerator.Singleton; if (!_grid) { throw new MissingComponentException("Missing component: GridGenerator"); } _im = FindObjectOfType <InputManager>(); if (!_im) { throw new MissingComponentException("Missing component: InputManager"); } _pCamera = GetComponentInChildren <PlayerCamera>(); if (!_pCamera) { throw new MissingComponentException("Missing component: PlayerCamera"); } _pMouse = GetComponentInChildren <PlayerMouse>(); if (!_pMouse) { throw new MissingComponentException("Missing component: PlayerMouse"); } }
public void init() { PlayerMouse.initialize(); }
private void initPlayerControls() { player = GetComponent <Player>(); player.init(); PlayerMouse.initialize(); }
void Update() { PlayerMouse.checkForClick(); }