Inheritance: MonoBehaviour
    private void onHorizontalMovement(float val)
    {
        if (val < 0f && currentOrientation == FollowCamera.TargetOrientation.RIGHT)
        {
            currentOrientation = FollowCamera.TargetOrientation.LEFT;
            FollowCamera.ChangeDirection(currentOrientation);

            transform.rotation = Quaternion.LookRotation(Vector3.back, Vector3.up);
            if (OnDirectionChanged != null)
            {
                OnDirectionChanged.Invoke(val);
            }
        }
        else if (0f < val && currentOrientation == FollowCamera.TargetOrientation.LEFT)
        {
            currentOrientation = FollowCamera.TargetOrientation.RIGHT;
            FollowCamera.ChangeDirection(currentOrientation);

            transform.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up);

            if (OnDirectionChanged != null)
            {
                OnDirectionChanged.Invoke(val);
            }
        }
    }
Exemple #2
0
    public IEnumerator DrawCard(Player forPlayer)
    {
        if (m_CardsQueue.Count == 0)
        {
            yield break;
        }

        FollowCamera.Push(transform);
        yield return(new WaitForCamera());

        var definition = PeekCard();
        var card       = SpawnCard(definition);

        var cardIdx = m_CardsQueue[0];

        m_CardsQueue.RemoveAt(0);
        m_CardsQueue.Add(cardIdx);

        yield return(card.Show());

        yield return(definition.Activate(card, forPlayer));

        Destroy(card.gameObject);

        FollowCamera.Pop();
    }
	//Unity Callbacks
	void Start()
	{
		m_Player = gameObject.GetComponent<Actor>();
		m_PlayerRigidBody = GetComponent<Rigidbody>();

		m_Camera = m_Player.m_Camera;
	}
    protected void Awake()
    {
        if(sInstance != null)
        {
            Destroy(gameObject);
            return;
        }

        sInstance = this;

        if (mDungeon == null)
        {
            mDungeon = FindObjectOfType<Dungeon>();
        }

        if (mFollowCamera == null)
        {
            mFollowCamera = FindObjectOfType<FollowCamera>();
        }

        if(mFader == null)
        {
            mFader = FindObjectOfType<Fader>();
        }

        GameObject goalObj = SpawnPrefab(mGoalPrefab);
        mGoal = goalObj.GetComponent<Goal>();
        GameObject playerObj = SpawnPrefab(GlobalData.sSelectedCharacter == SelectedCharacter.Rose ? mPlayerRosePrefab : mPlayerVuPrefab);
        mPlayer1 = playerObj.GetComponent<PlayerController>();
        mFollowCamera.Init(mPlayer1.transform);
    }
Exemple #5
0
    IEnumerator Loading()
    {
        AsyncOperation cLoadLevelAsync = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("1.GameScene");

        yield return(cLoadLevelAsync);

        UIManager.Instance.OpenUI <UI_DressRoom>(eUIType.DressRoom);

        ///게임시스템 생성
        CreateGameSystem();

        /// 캐릭터 생성
        CreateCharacter();

        ///맵 생성
        CreateMap();

        ///몬스터 생성
        CreateMonster();

        m_camera          = GameObject.FindObjectOfType <FollowCamera>();
        m_camera.m_target = IngameManager.Instance.m_myCharacter.thisTransform;

        IngameManager.Instance.m_myCharacter.AISystem.AIOn();
    }
    // private FollowCamera playerCam;

    // [SerializeField]
    // private Transform hmdPositionOffset;

    // [SerializeField]
    // private Transform hmdRotationOffset;

    public static CockpitView Create(CockpitView prefab, FollowCamera playerCam)
    {
        var cockpit = Instantiate(prefab, Vector3.zero, Quaternion.identity);
        //cockpit.playerCam = playerCam;

        return cockpit;
    }
        public void StopEvent(bool interupted = false)
        {
            //Debug.Log("Stop Cinematic");
            DialogueEvent trigger = current_event;
            current_event = null;
            current_message = null;
            talk_bubble_inst.SetActive(false);
            DialoguePanel.Get().Hide();
            DialogueZoomPanel.Get().Hide();

            if (trigger != null && trigger.camera_lock_on != null)
            {
                FollowCamera pcam = FollowCamera.Get();
                pcam.UnlockCamera();
            }

            if (trigger != null && trigger.zoomed_in)
            {
                //TheGame.Instance.UnlockGameplay();
            }

            if (!interupted && trigger != null)
            {
                trigger.TriggerEffects();
                if (OnDialogueEnd != null)
                {
                    OnDialogueEnd.Invoke(trigger);
                }
                if (trigger.OnEnd != null)
                {
                    trigger.OnEnd.Invoke();
                }
            }
        }
Exemple #8
0
 void Start()
 {
     //魔法管理
     magicMaster  = FindObjectOfType <MagicMaster>();
     targetCursor = FindObjectOfType <TargetCursor>();
     camera       = FindObjectOfType <FollowCamera>();
 }
    /**
     * @brief       게임에 접속한 모든 클라이언트에 플레이어를 생성합니다.
     */
    private void CreatePlayer()
    {
        if (startingList.Count <= 0)
        {
            Debug.LogError("No start position information");
        }

        // 진영 정보로 스폰 위치를 받음
        Vector3 _starting = startingList[(int)teamInfo].position;

        // 플레이어 캐릭터 생성
        GameObject playerObject = PhotonNetwork.Instantiate(GameManager._instance.GetPlayerAssetName(), _starting, Quaternion.identity, 0);

        // 카메라를 모두 가져옴 (main Camera 및 UI Camera)
        int length = Camera.allCamerasCount;

        Camera[] cameras = Camera.allCameras;

        // 카메라에 타겟을 지정해줌
        for (int i = 0; i < length; i++)
        {
            FollowCamera _followCamera = cameras[i].GetComponent <FollowCamera>();
            _followCamera.SetTarget(playerObject, teamInfo);
        }

        // blue 팀일 경우
        if (teamInfo == ETeamInfo._Blue)
        {
            // 캐릭터의 방향을 반전 시킴 (위쪽에서 아래 방향으로 내려 와야 하기 때문)
            Vector3 direction = startingList[(int)teamInfo].forward;
            playerObject.transform.forward = direction;
        }
    }
Exemple #10
0
    public override void Enter()
    {
        SceneManager.LoadScene("scene1");
        fleetManager = owner.GetComponent <FleetManager>();

        // Get VideoManager
        videoManager = GameObject.Find("VideoManager").GetComponent <VideoManager>();

        // Set the first 3 ships to attack
        for (int i = 0; i < fleetManager.ships.Count && i < 3; i++)
        {
            Boid ship = fleetManager.ships[i];
            ship.GetComponent <StateMachine>().ChangeState(new AttackState(fleetManager.borg));
            ship.maxSpeed = Random.Range(20.0f, 30.0f);
            ship.StartCoroutine(ship.ChangeSpeed());
        }

        // Change Camera Target
        FollowCamera mainCamera = Camera.main.GetComponent <FollowCamera>();

        mainCamera.target = fleetManager.GetComponent <GameObject>();

        videoPlayed = false;

        fleetManager.audioSource.Stop();
        fleetManager.audioSource.clip = fleetManager.battleMusic;
        fleetManager.audioSource.loop = true;
        fleetManager.audioSource.Play();

        //foreach (Ship ship in fleetManager.shipComp) {
        //    ship.audioSource.loop = true;
        //    ship.audioSource.clip = fleetManager.flybySound;
        //    ship.audioSource.Play();
        //}
    }
Exemple #11
0
    protected void Awake()
    {
        if (sInstance != null)
        {
            Destroy(gameObject);
            return;
        }

        sInstance = this;

        if (mDungeon == null)
        {
            mDungeon = FindObjectOfType <Dungeon>();
        }

        if (mFollowCamera == null)
        {
            mFollowCamera = FindObjectOfType <FollowCamera>();
        }

        if (mFader == null)
        {
            mFader = FindObjectOfType <Fader>();
        }

        GameObject goalObj = SpawnPrefab(mGoalPrefab);

        mGoal = goalObj.GetComponent <Goal>();
        GameObject playerObj = SpawnPrefab(GlobalData.sSelectedCharacter == SelectedCharacter.Rose ? mPlayerRosePrefab : mPlayerVuPrefab);

        mPlayer1 = playerObj.GetComponent <PlayerController>();
        mFollowCamera.Init(mPlayer1.transform);
    }
Exemple #12
0
    public MyGame(string[] tmxFileNames, int levelIndex) :
        base(SCREEN_WIDTH, SCREEN_HEIGHT, FULLSCREEN) // Create a window that's 800x600 and NOT fullscreen
    {
        GL.ClearColor(1f, 1f, 1f, 1f);

        ThisInstance = this;

        _levelFiles = tmxFileNames;

        if (_levelFiles.Length == 0)
        {
            throw new ApplicationException(
                      $"_levelFiles.Length == 0, no tmx files found in {AppDomain.CurrentDomain.DynamicDirectory}");
        }

        LoadScoreBoardData();

        _mapData = TiledMapParserExtended.MapParser.ReadMap(_levelFiles[levelIndex]);

        _map = new MapGameObject(_mapData);

        _camera = new FollowCamera(0, 0, width, height);

        _canvasDebugger = new CanvasDebugger2(width, height);

        AddChild(SoundManager.Instance);

        var hudScreenFader = new HudScreenFader();

        StartScreen();

        //var startScreen = new StartScreen();
        //AddChild(startScreen);
    }
Exemple #13
0
    // Start is called before the first frame update
    new void Start()
    {
        StatusLoad();

        base.Start();

        _type = CharacterType.Player;
        _id   = 0;
        _name = "<color=#ffff00>プレイヤー</color>";

        _itemList = new List <Item>();

        _skillAttackSlot = new SkillAttackType[4];

        UIManager.instance.GetSkillMenu().SetSkill(0, (int)SkillAttackType.ThrustAttack);
        UIManager.instance.GetSkillMenu().SetSkill(1, (int)SkillAttackType.RotaryAttack);
        UIManager.instance.GetSkillMenu().SetSkill(2, (int)SkillAttackType.HeavyAttack);
        UIManager.instance.GetSkillMenu().SetSkill(3, (int)SkillAttackType.MowDownAttack);

        _skillAttackSlot[0] = SkillAttackType.ThrustAttack;
        _skillAttackSlot[1] = SkillAttackType.RotaryAttack;
        _skillAttackSlot[2] = SkillAttackType.HeavyAttack;
        _skillAttackSlot[3] = SkillAttackType.MowDownAttack;

        _visibleRect = new Rect(2, 2, 2, 2);

        _camera = Camera.main.GetComponent <FollowCamera>();
    }
 private void Start()
 {
     // Setup
     player       = Player.instance.targeting;
     followCam    = FollowCamera.instance;
     meshRenderer = GetComponent <MeshRenderer>();
 }
Exemple #15
0
 void Start()
 {
     follow = gameObject.GetComponent <FollowCamera>();
     follow.SetTarget(point0);
     isLoad         = false;
     isChoosingHero = false;
 }
Exemple #16
0
    public override void Start()
    {
        base.Start();

        Anim      = GetComponentInChildren <Animator>();
        layerMask = 1 << LayerMask.NameToLayer("Kart");
        layerMask = ~layerMask;

        if (KartCamPrefab != null)
        {
            GameObject camObj = Instantiate(KartCamPrefab) as GameObject;
            if (camObj != null)
            {
                FollowCam        = camObj.GetComponent <FollowCamera>();
                FollowCam.Target = transform;
                if (isLocalPlayer)
                {
                    Camera cam = FollowCam.GetComponent <Camera>();
                    cam.enabled = true;

                    if (UI != null)
                    {
                        UI.gameObject.SetActive(true);
                    }
                }
            }
        }

        if (isLocalPlayer)
        {
            NI = GetComponent <NetworkIdentity>();
        }

        initGUIControls();
    }
    private void CreateTank()
    {
        Vector3    pos;
        Quaternion quo;

        if (PhotonNetwork.isMasterClient)
        {
            pos = new Vector3(90, 1, 0);
            quo = Quaternion.AngleAxis(-90, new Vector3(0, 1, 0));
        }
        else
        {
            pos = new Vector3(-90, 1, 0);
            quo = Quaternion.AngleAxis(90, new Vector3(0, 1, 0));
        }
        GameObject go = PhotonNetwork.Instantiate("Tank", pos, quo, 0);
        Tank       t  = go.GetComponent <Tank> ();

        FollowCamera c = go.AddComponent <FollowCamera> ();

        c.camera = Camera.main;
        if (PhotonNetwork.isMasterClient)
        {
            c.OffsetPosition = new Vector3(4, 3, 0);
        }
        else
        {
            c.OffsetPosition = new Vector3(-4, 3, 0);
        }
        c.OffsetAngle = Quaternion.AngleAxis(0, Vector3.up);
    }
    void Start()
    {
        GameObject target = Instantiate(MenuManager.SelectedCharacter, Vector3.zero, Quaternion.identity);

        followC        = camera.GetComponent <FollowCamera>();
        followC.target = target;
    }
Exemple #19
0
 // Use this for initialization
 void Start()
 {
     leaderCam         = GetComponent <LeaderCamera>();
     followCam         = GetComponent <FollowCamera>();
     leaderCam.enabled = true;
     followCam.enabled = false;
 }
Exemple #20
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            this.Services.AddService(typeof(SpriteBatch), spriteBatch);
            DiagnosticsManager.Initialize(this);
            SpriteBatchHelpers.Initialize(GraphicsDevice);
            Primitives.Initialize(GraphicsDevice);
            Billboard.Initialize(GraphicsDevice, Content.Load <Effect>("Shaders/Billboarding"));

            // TODO: use this.Content to load your game content here
            CreateSpheres();

            ship      = new Ship(this);
            followCam = new FollowCamera(camera, ship);

            lightningTexture = new LightningTexture(GraphicsDevice, 50, 100);

            #region Particles
            pSet = new ParticleSettings()
            {
                BlendState                 = BlendState.Additive,
                MaxParticles               = 10,
                Duration                   = TimeSpan.FromSeconds(0.5),
                DurationRandomness         = 0.1f,
                EmitterVelocitySensitivity = 0,
                MinVelocity                = 1f,
                MaxVelocity                = 2f,
                Gravity        = Vector3.Zero,
                EndVelocity    = 0,
                MinColor       = Color.White,
                MaxColor       = Color.White,
                MinRotateSpeed = -0.1f,
                MaxRotateSpeed = 0.1f,
                MinStartSize   = 0.25f,
                MaxStartSize   = 0.35f,
                MinEndSize     = 0.5f,
                MaxEndSize     = 0.6f
            };

            var pTex = new Texture2D(GraphicsDevice, 5, 5);
            pTex.SetData(Enumerable.Repeat(Color.FromNonPremultiplied(0, 0, 255, 125), 25).ToArray());

            var pEff = Content.Load <Effect>("Shaders/Particles");

            pSys = new ParticleSystem(this, pSet, pTex, pEff, camera);
            pEmi = new ParticleEmitter(pSys)
            {
                Position = Vector3.UnitX, ParticlesPerSecond = 10
            };
            pEmi2 = new ParticleEmitter(pSys)
            {
                Position = -Vector3.UnitX, ParticlesPerSecond = 10
            };
            //pEmi = new ParticleEmitter(pSys) { Position = Vector3.UnitY, ParticlesPerSecond = 10 };
            //pEmi = new ParticleEmitter(pSys) { Position = new Vector3(Vector2.One, 0), ParticlesPerSecond = 10 };
            #endregion

            base.LoadContent();
        }
Exemple #21
0
 // Use this for initialization
 void Start()
 {
     playerMove         = FindObjectOfType <PlayerMove>();
     playerAttack       = FindObjectOfType <PlayerAttack>();
     inputAttackCheacck = FindObjectOfType <InputAttack.InputAttackCheacck>();
     followCamera       = FindObjectOfType <FollowCamera>();
 }
    public FloatEvent OnDirectionChanged; // Acceleration direction changes

    private void Start()
    {
        currentOrientation = InitialDirection;
        FollowCamera.CameraTargetChanged(this);

        PlayerInputSender.RegisterInputAction(PInput.HORIZONTAL, PInputType.FOCUS, onHorizontalMovement);
    }
Exemple #23
0
    internal void AddUnit(MsgAddUnit_S2C config)
    {
        GameObject go = new GameObject("unit_" + config.id.ToString());

        go.transform.position = new Vector3(config.posx, 0, config.posy);
        if (config.isController == 1)
        {
            FollowCamera camera = Camera.main.GetComponent <FollowCamera>();
            if (camera == null)
            {
                camera = Camera.main.gameObject.AddComponent <FollowCamera>();
            }
            camera.m_target = go.transform;
            go.AddComponent <Controller>();
        }
        Unit unit = go.AddComponent <Unit>();

        m_units.Add(config.id, unit);
        unit.ID                 = config.id;
        unit.camp               = config.camp;
        unit.isController       = config.isController == 1;
        unit.transform.position = new Vector3(config.posx, 0, config.posy);
        CapsuleCollider collider = unit.gameObject.AddComponent <CapsuleCollider>();

        collider.radius          = 3;
        collider.height          = 2;
        collider.center          = new Vector3(0, 1, 0);
        unit.fsm.blackboard.unit = unit;
        unit.fsm.AttachFactory(m_unitFsmStateFactory);
        unit.fsm.Transition((int)UnitFSM.State.ID.Idle);
        unit.ChangeModel(config.look);
    }
    public override IEnumerator PlayInternal(CinematicDirector player)
    {
        float        seconds          = 0f;
        FollowCamera cameraController = Camera.main.GetComponent <FollowCamera>();

        while (seconds < mSeconds)
        {
            Vector3 offset = cameraController.animationOffset;
            offset.x = Mathf.Sin(seconds * mSpeed * 2f * 3.1415f) * mIntensity;
            offset.y = Mathf.Sin(seconds * mSpeed * 2f * 3.1415f * 0.25f) * mIntensity;

            cameraController.animationOffset = offset;
            seconds += Time.deltaTime;
            yield return(null);
        }

        while (cameraController.animationOffset.magnitude > 0.1f)
        {
            cameraController.animationOffset *= 0.5f;
            yield return(null);
        }

        cameraController.animationOffset = Vector3.zero;

        yield break;
    }
Exemple #25
0
 void Awake()
 {
     PAS       = GetComponent <playerAudioScr>();
     followCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <FollowCamera>();
     rb        = GetComponent <Rigidbody2D>();
     jumpVec   = new Vector2(0, jumpForce);
 }
Exemple #26
0
    //Unity Callbacks
    void Start()
    {
        m_Player          = gameObject.GetComponent <Actor>();
        m_PlayerRigidBody = GetComponent <Rigidbody>();

        m_Camera = m_Player.m_Camera;
    }
Exemple #27
0
    void Start()
    {
        _instance = this;

        TheCamera.transform.localPosition = new Vector3(0, 0, -FloorDistance);
        transform.rotation = Quaternion.Euler(FloorRotation);
    }
 void OnDeath()
 {
     if (transform.position.y < -5)
     {
         //fell out of world
     }
     else
     {
         FollowCamera camera = RoadTileManager.checkpoint.FollowCamera;
         if (Vector3.Distance(transform.position, camera.target.transform.position) > camera.CullDistance)
         {
             // Culled
         }
         else if (RoadTileManager.bMainMenu)
         {
             // Main Menu screen
         }
         else
         {
             Killcount.AddKill();
             if (Killcount.GetKills() % 10 == 0)
             {
                 Currency.AddCurrency();
             }
         }
     }
 }
Exemple #29
0
 private void Start()
 {
     _followCamera = FindObjectOfType <FollowCamera>();
     _animator     = GetComponent <Animator>();
     _random       = new Random();
     _random.InitState();
 }
Exemple #30
0
 private void Start()
 {
     _boxCollider2D         = GetComponent <BoxCollider2D>();
     _boxCollider2D.enabled = false;
     _followCamera          = FindObjectOfType <FollowCamera>();
     _animator = GetComponent <Animator>();
 }
        public void StartEvent(DialogueEvent dialogue_event)
        {

            if (current_event != dialogue_event)
            {
                StopEvent(true);
                //Debug.Log("Start Cinematic: " + cinematic_trigger.gameObject.name);
                current_event = dialogue_event;
                current_message = null;
                dialogue_index = -1;
                cinematic_timer = 0f;
                dialogue_timer = 0f;
                interact_timer = 0f;

                if (current_event.camera_lock_on != null)
                {
                    FollowCamera pcam = FollowCamera.Get();
                    pcam.LockCameraOn(current_event.camera_lock_on);
                }

                if (OnDialogueStart != null)
                {
                    OnDialogueStart.Invoke(dialogue_event);
                }
                if (dialogue_event.OnStart != null)
                {
                    dialogue_event.OnStart.Invoke();
                }
            }
        }
Exemple #32
0
    public void AssignCamera(GameObject target)
    {
        Debug.Log("Targeting " + target.ToString() + " with main camera");
        FollowCamera camera = GameObject.FindGameObjectWithTag(Tags.MainCamera).GetComponent <FollowCamera>();

        camera.target = target;
    }
Exemple #33
0
    private IEnumerator TurnRountine()
    {
        FollowCamera.Push(currentPlayer.gameObject.transform);
        yield return(currentPlayer.BeginTurn());

        FollowCamera.Pop();
    }
Exemple #34
0
	public override void EnterState(FSMTransition transition) {
		base.EnterState(transition);

		_followCam = Camera.main.GetComponent<FollowCamera>();
		_originalDistance = _followCam.Distance;

		_light = (Light)GameObject.Find("Directional Light").GetComponent<Light>();
		_originalLightIntensity = _light.intensity;

		SilenceMonks();
		SilenceMusic();
	}
    private void CheckSpaceClicks(FollowCamera spaceCam)
    {
        /* GUI blocks clicking on empty space - including brackets, which are
         * buttons */
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (Input.GetButtonDown("turn"))
        {
            clickOffTargetTime = Time.time;
        }
        else if (Input.GetButtonUp("turn"))
        {
            var player = PlayerShip.LocalPlayer;

            if (player && Time.time - clickOffTargetTime < FollowCamera.UI_DRAG_DELAY)
            {
                /* the select button was un-pressed, but no bracket was under the cursor
                    (they block raycasts). do a world raycast to see if we hit any 3d objects*/
                var mousePos = Input.mousePosition;
                var mouseRay = spaceCam.Camera.ScreenPointToRay(new Vector3(mousePos.x, mousePos.y, 0));
                RaycastHit mouseHit;
                if (Physics.Raycast(mouseRay, out mouseHit))
                {
                    for (int bracket = 0; bracket < brackets.Count; ++bracket)
                    {
                        if (brackets[bracket].Target.transform == mouseHit.transform)
                        {
                            brackets[bracket].SetPlayerTarget();
                            break;
                        }
                    }
                }
                else
                {
                    player.Ship.Target = null;
                }
            }
        }
    }
Exemple #36
0
 public void Start()
 {
     _RTSCamera = this.GetComponentInChildren<RTSCamera>();
     activeCamera = _RTSCamera.camera;
     _followCamera = this.GetComponentInChildren<FollowCamera>();
     _followCamera.gameObject.SetActive(false);
     _player = this.GetComponent<Player>();
 }
Exemple #37
0
    void Awake()
    {
        cameraControl = Camera.main.GetComponent<CameraControl>();
        followCamera = Camera.main.GetComponent<FollowCamera>();
        instance = this;

        if (currentLevelIndex != -1)
        {
            LoadLevel(currentLevelIndex);
        }

        View();
    }
 public CockpitView CreateCockpit(FollowCamera playerCam)
 {
     return CockpitView.Create(cockpitPrefab, playerCam);
 }
 public void Start()
 {
     this.enabled = false;
     _followCamera = this.GetComponentInChildren<FollowCamera>();
 }
    // If player is walking...
    void Walking()
    {
        if (followcamera == null) {
            followcamera = FindObjectOfType<FollowCamera>();
        }

        Vector3 joyStick = Vector3.zero;
        joyStick.x = Input.GetAxisRaw("Horizontal") * joystickSpeed;
        joyStick.z = Input.GetAxisRaw("Vertical") * joystickSpeed;
        if (joyStick.magnitude > 0) {
            Debug.Log ("joystick Hori=" + joyStick.x + " Ver=" + joyStick.z);
            // カメラの向きに合わせて移動方向を回転
            if (followcamera != null) {
                joyStick = Quaternion.Euler(0, followcamera.horizontalAngle, 0) * joyStick;
            }
            Vector3 position = transform.position;
            position.x += joyStick.x;
            position.z += joyStick.z;
            SendMessage("SetDestination", position);
            //targetCursor.SetPosition(position);
        }

        if (Input.GetKeyDown("space")) {
            ChangePlayerState(PlayerState.PlayerAttacking);
        }
        if (inputManager.Clicked()) {
            Vector2 clickPos = inputManager.GetCursorPosition();
            Ray ray = Camera.main.ScreenPointToRay(clickPos);
            RaycastHit hitInfo;

            // Using Raycast
            if( Physics.Raycast( ray,out hitInfo,RayCastMaxDistance,
                               ( 1 << LayerMask.NameToLayer("Ground") ) |
                               ( 1 << LayerMask.NameToLayer("EnemyHit") ))) {
                if( hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("Ground") ) {
                    SendMessage("SetDestination",hitInfo.point);
                }

                if( hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("EnemyHit") ) {
                    Vector3 hitPoint = hitInfo.point;
                    hitPoint.y = transform.position.y;
                    float distance = Vector3.Distance( hitPoint, transform.position );

                    // Check the distance to Enemy from Player.
                    if( distance < attackRange ) {
                        this.attackTarget = hitInfo.collider.transform;
                        this.ChangePlayerState(PlayerState.PlayerAttacking);
                    }
                }
            }
        }
    }
Exemple #41
0
	void Awake() {
		instance = this;
	}
	void Awake () {
		S = this;
		camZ = this.transform.position.z;
	}
    void InitBattleManager()
    {
        armiesList.Clear ();
        enemiesList.Clear ();
        followCamera = Camera.main.GetComponent<FollowCamera>();
        BattleUIManager.GetInstance().InitTransforms();
        service.LoadData();

        Transform enemiesParent = this.transform.root.FindChild ("Enemies");

        foreach(Transform child in enemiesParent)
        {
            enemiesList.Add (child.GetComponent<EnemyBaseController> ());
        }

        InitArmies();
        InitEnemies();

        Invoke("BattleStart",0.5f);
    }
    private void UpdateModuleAimPoints(FollowCamera cam)
    {
        var loadout = ship.ModuleLoadout;

        for (int moduleIndex = 0; moduleIndex < loadout.SlotCount; ++moduleIndex)
        {
            if (loadout.IsFreeSlot(moduleIndex))
            {
                continue;
            }

            var module = loadout.GetSlot(moduleIndex);

            var hardpoint = ship.GetHardpointAt(moduleIndex);

            var aimOrigin = hardpoint.transform.position;

            var aimPoint = cam.GetWorldAimPoint(aimOrigin);

            if (aimPoint.HasValue)
            {
                module.Aim = AutoaimSnapToPredictor(aimPoint.Value, moduleIndex);
            }
            else
            {
                module.Aim = ship.transform.position + ship.transform.forward * 1000;
            }
        }
    }
    void Start()
    {
        if (GetComponent<Camera> () == null)
            throw new UnityException ("This script must be inside a camera gameobject");

        cameraControll = transform.parent.GetComponent<FollowCamera> ();
        if (cameraControll == null)
            throw new UnityException ("The GO hirarquy must fallow: Camera3DGO -> MainCamera.");

        originalDist = Vector3.Distance (cameraControll.transform.position, transform.position);
    }