public override Interaction CheckForPromotion()
    {
        Ray        ray = new Ray(Player.GetInstance().MainCamera.transform.position, Player.GetInstance().MainCamera.transform.forward);
        RaycastHit hit;

        Debug.DrawRay(ray.origin, ray.direction, Color.red);
        _hasHit = Physics.SphereCast(ray, 0.05f, out hit, 1000.0f, 1 << LayerMaskManager.Get(Layer.Verse),
                                     QueryTriggerInteraction.Collide);

        if (_hasHit)
        {
            if (_selectedGameObject != null && _selectedGameObject.GetInstanceID() != hit.collider.gameObject.GetInstanceID())
            {
                HideFeedback();
            }
            _selectedGameObject = hit.collider.gameObject;
            _selectedVerse      = _selectedGameObject.GetComponent <VerseInfoComponent>().Info;
            ShowFeedback();
        }
        else
        {
            HideFeedback();
            _selectedGameObject = null;
        }
        return(this);
    }
示例#2
0
        public void Awake()
        {
            if (_instance == null)
            {
                _instance = this;
                DontDestroyOnLoad(gameObject);

                // TODO All of this should be GENERATED HERE instead of adquired by using GetComponent<>()
                CharMovement           = GetComponent <CharacterMovement>();
                CharController         = GetComponent <CharacterController>();
                MainCamera             = GetComponentInChildren <Camera>();
                Animator               = GetComponent <Animator>();
                _collider              = GetComponent <CapsuleCollider>();
                _layerMaskAllButPlayer = ~(1 << LayerMaskManager.Get(Layer.Player));
                _shovel          = GetComponentInChildren <ShovelMovementComponent>();
                Look             = new Look(gameObject);
                CameraController = gameObject.AddComponent <CameraController>();

                Camera landmarkCamera = GameObject.Find("LandmarkCamera").GetComponent <Camera>();
                CameraController.Init(MainCamera, landmarkCamera);
            }
            else
            {
                Debug.LogWarning("Player singleton instance destroyed!");
                Destroy(gameObject);
            }
        }
 public override void HideFeedback()
 {
     _mark.enabled = true;
     foreach (MeshRenderer r in _model.GetComponentsInChildren <MeshRenderer>())
     {
         r.gameObject.layer = LayerMaskManager.Get(Layer.Landmark);
     }
 }
 public override void ShowFeedback()
 {
     _mark.enabled = false;
     foreach (MeshRenderer r in _model.GetComponentsInChildren <MeshRenderer>())
     {
         r.gameObject.layer = LayerMaskManager.Get(Layer.Outline);
     }
 }
示例#5
0
 private void BaseInit()
 {
     _iconGameObject = new GameObject("_marker");
     _iconGameObject.transform.parent = transform;
     _iconGameObject.transform.LocalReset();
     _iconGameObject.layer = LayerMaskManager.Get(Layer.DrawFront);
     _icon = _iconGameObject.AddComponent <SpriteRenderer>();
 }
示例#6
0
        public void Start()
        {
            int player = 1 << LayerMaskManager.Get(Layer.Player);

            _layerMaskAllButPlayer = ~player;
            _collider     = GetComponent <CapsuleCollider>();
            _charMovement = GetComponent <CharacterMovement>();
        }
 public override void DoInteraction()
 {
     AudioController.GetInstance().PlayPickupCoffin();
     _coffin.transform.parent = _slot;
     _coffin.transform.LocalReset();
     _coffin.layer = LayerMaskManager.Get(Layer.Landmark);
     _coffin.GetComponent <Collider>().enabled = true;
     Player.GetInstance().CurrentState = new WalkRunState();
 }
示例#8
0
 public override void DoInteraction()
 {
     _coffin.layer = LayerMaskManager.Get(Layer.Landmark);
     AnimationUtils.MoveSmoothlyTo(_coffin.transform, _tomb.transform.position - Vector3.up * 1.5f, 0.5f);
     AnimationUtils.LookTowardsHorizontal(_coffin.transform, _tomb.transform.right, 0.5f, () => {
         _coffin.transform.parent = _tomb.transform;
         _coffin.GetComponent <Collider>().enabled = true;
     });
     // TODO LookTowardsVertical (using arg lookDir instead of LookAtPoint)
     _tombComponent.PlayerTombTransition(new PoemState(_tombComponent), false);
     _tombComponent.HideMarker();
     _tombComponent.HideColliders();
     AudioController.GetInstance().AddMusicChannel();
 }
        public void Awake()
        {
            _mainCamera        = GetComponent <Camera>();
            _alwaysFrontCamera = new GameObject("AlwaysFrontCamera").AddComponent <Camera>();
            _alwaysFrontCamera.transform.parent        = transform;
            _alwaysFrontCamera.transform.localPosition = Vector3.zero;
            _alwaysFrontCamera.transform.eulerAngles   = Vector3.zero;
            _layerMaskDrawFront  = 1 << LayerMaskManager.Get(Layer.DrawFront);
            _layerMaskDrawFront |= 1 << LayerMaskManager.Get(Layer.Verse);

            _alwaysFrontCamera.CopyFrom(_mainCamera);
            _alwaysFrontCamera.depth       = Depth;
            _alwaysFrontCamera.clearFlags  = CameraClearFlags.Depth;
            _alwaysFrontCamera.depth       = _mainCamera.depth + 1;
            _alwaysFrontCamera.cullingMask = _layerMaskDrawFront;
        }
示例#10
0
        public override void DoInteraction()
        {
            Coffin.layer = LayerMaskManager.Get(Layer.DrawFront);
            MarkableComponent m = Coffin.GetComponent <MarkableComponent>();

            if (m != null)
            {
                m.enabled = false;
            }
            else
            {
                DebugMsg.ComponentNotFound(Debug.LogWarning, typeof(MarkableComponent));
            }
            AudioController.GetInstance().PlayPickupCoffin();
            Player.GetInstance().CurrentState = new DragCoffinState(Coffin);
        }
示例#11
0
        public CartMovementBehaviour(Transform transform, GameObject cart, SuperConfig config) : base(transform)
        {
            _cartConfig    = config.DriveCartMovement;
            _movement      = new SmoothMovementHandler(config.CartAcceleration).SetMovement();
            _cartTransform = cart.transform;
            foreach (Collider c in cart.GetComponentsInChildren <Collider>())
            {
                if (!c.isTrigger)
                {
                    c.enabled = false;
                    _disabledColliders.Add(c);
                }
            }
            _layerMaskAllButPlayer = ~(1 << LayerMaskManager.Get(Layer.Player));
            _moveBackAction        = Player.GetInstance().Actions.GetAction(PlayerAction.MoveBack);

            Utils.AnimationUtils.LookTowardsHorizontal(transform, cart.transform.forward, _cartConfig.GoInsideTimeSeconds);
            Utils.AnimationUtils.LookTowardsVertical(Player.GetInstance().MainCamera.transform, transform.position + cart.transform.forward, _cartConfig.GoInsideTimeSeconds);
            AudioController.GetInstance().PlayCart();
        }
        public VersesDisplayer(int length)
        {
            _displayMeshText = new TextMesh[length];
            _shadowMeshText  = new TextMesh[length];

            _container = new GameObject("_textMeshContainer");
            Font     font    = Resources.Load <Font>("Fonts/HammerheadRegular");
            Material fontMat = Resources.Load <Material>("Fonts/HammerheadRegularAlwaysFrontMat");

            for (int i = 0; i < _displayMeshText.Length; ++i)
            {
                GameObject child = new GameObject("_child" + i);
                child.layer            = LayerMaskManager.Get(Layer.Verse);
                child.transform.parent = _container.transform;
                child.transform.LocalReset();
                _displayMeshText[i]                      = child.AddComponent <TextMesh>();
                _displayMeshText[i].fontSize             = FontSize;
                _displayMeshText[i].transform.localScale = Vector3.one * Scale;
                _displayMeshText[i].alignment            = TextAlignment.Center;
                _displayMeshText[i].anchor               = TextAnchor.MiddleCenter;
                _displayMeshText[i].font                 = font;
                _displayMeshText[i].GetComponent <Renderer>().material       = fontMat;
                _displayMeshText[i].GetComponent <Renderer>().material.color = BaseColor;

                GameObject subchild = new GameObject("_shadow" + i);
                subchild.layer            = LayerMaskManager.Get(Layer.Verse);
                subchild.transform.parent = child.transform;
                subchild.transform.LocalReset();
                _shadowMeshText[i]                      = subchild.AddComponent <TextMesh>();
                _shadowMeshText[i].fontSize             = FontSize;
                _shadowMeshText[i].transform.localScale = Vector3.one;
                _shadowMeshText[i].offsetZ              = ShadowOffset;
                _shadowMeshText[i].alignment            = TextAlignment.Center;
                _shadowMeshText[i].anchor               = TextAnchor.MiddleCenter;
                _shadowMeshText[i].font                 = font;
                _shadowMeshText[i].GetComponent <Renderer>().material       = fontMat;
                _shadowMeshText[i].GetComponent <Renderer>().material.color = ShadowColor;

                _displayMeshText[i].gameObject.SetActive(false);
            }
        }
示例#13
0
        public void Awake()
        {
            _outlineShader                   = Shader.Find("Custom/PostOutline");
            _drawSimpleShader                = Shader.Find("Custom/DrawSimple");
            _mainCamera                      = GetComponent <Camera>();
            _outlinerCamera                  = new GameObject("CameraOutliner").AddComponent <Camera>();
            _outlinerCamera.enabled          = false;
            _outlinerCamera.transform.parent = transform;
            _outlinerCamera.transform.LocalReset();
            _layerMaskOnlyOutline = 1 << LayerMaskManager.Get(Layer.Outline);
            _material             = new Material(_outlineShader)
            {
                color = OutlineColor
            };
            _material.SetInt("_Thickness", Thickness);

            _outlinerCamera.CopyFrom(_mainCamera);
            _outlinerCamera.clearFlags      = CameraClearFlags.Color;        // TODO: these params should be changed based on a MainCamera listener, not per frame
            _outlinerCamera.backgroundColor = Color.black;
            _outlinerCamera.cullingMask     = _layerMaskOnlyOutline;
        }
        public CarveTerrainInteraction()
        {
            if (_digMarker == null)
            {
                _digMarker = GameObject.CreatePrimitive(PrimitiveType.Cube);
                Object.Destroy(_digMarker.GetComponent <Collider>());
                _digMarker.SetActive(false);
                _digMarker.name = "_digMarker";
                _digMarker.transform.localScale = new Vector3(4, 0.1f, 4);
                _digMarker.layer = LayerMaskManager.Get(Layer.Outline);
                _digMarker.GetComponent <MeshRenderer>().material = new Material(Shader.Find("UI/Default"));
                IconMarkerComponent icon = _digMarker.AddComponent <IconMarkerComponent>();
                icon.Init("Sprites/dig", new Color(0, 81.0f / 255.0f, 240.0f / 255.0f));
            }

            _player = Player.GetInstance();

            string     terrainName = "Terrain Volume";
            GameObject terrain     = GameObject.Find(terrainName);

            if (!terrain)
            {
                DebugMsg.GameObjectNotFound(Debug.LogError, terrainName);
            }
            else
            {
                var terrainVolume = terrain.GetComponent <TerrainVolume>();
                if (!terrainVolume)
                {
                    DebugMsg.ComponentNotFound(Debug.LogError, typeof(TerrainVolume));
                }

                _terrainCarver = terrain.GetComponent <CarveTerrainVolumeComponent>();
                if (!_terrainCarver)
                {
                    DebugMsg.ComponentNotFound(Debug.LogError, typeof(CarveTerrainVolumeComponent));
                }
            }
        }
        public override void DoInteraction()
        {
            _coffin.transform.parent = null;
            _coffin.GetComponent <Collider>().enabled = true;
            Rigidbody rb = _coffin.GetComponent <Rigidbody>();

            rb.isKinematic = false;
            _coffin.layer  = LayerMaskManager.Get(Layer.Landmark);

            MarkableComponent m = _coffin.GetComponent <MarkableComponent>();

            if (m == null)
            {
                Debug.LogWarning("Object <b>" + _coffin.gameObject.name + "</b> could not be marked. (Missing MarkableComponent!)");                 // TODO extract to Error class
            }
            else
            {
                //TODO: ADD GUARD -> enable only if not throwed into a hole
                m.enabled = true;
            }

            AudioController.GetInstance().PlayThrowCoffin();
            Player.GetInstance().CurrentState = new WalkRunState();
        }
示例#16
0
 public override void ShowFeedback()
 {
     Coffin.layer = LayerMaskManager.Get(Layer.Outline);
 }
        public bool PassHeightRestrictions(Vector3 point, Vector3 normal)
        {
            RaycastHit[] hits = Physics.BoxCastAll(point + Vector3.up * 5.0f, _digMarker.transform.localScale, Vector3.down,
                                                   Quaternion.identity, 10.0f, ~(1 << LayerMaskManager.Get(Layer.Player)), QueryTriggerInteraction.Collide);
            if (hits.Length == 0)
            {
                return(true);
            }

            float maxHeight = -99;
            float minHeight = 99;

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject.tag != TagManager.Get(Tag.Terrain))
                {
                    return(false);
                }
                if (hit.distance == 0.0f)
                {
                    return(false);
                }
                if (hit.distance > maxHeight)
                {
                    maxHeight = hit.distance;
                }
                if (hit.distance < minHeight)
                {
                    minHeight = hit.distance;
                }
            }
            if (maxHeight - minHeight > 1.0f)
            {
                return(false);
            }
            return(true);
        }
        public void Init(Vector3 upperLeft, Vector3 lowerRight)
        {
            if (!_groundInstantiator)
            {
                _groundInstantiator      = Resources.Load <GameObject>("Prefabs/Ground");
                _groundInstantiator.name = "_ground";
                _groundInstantiator.SetActive(false);
            }
            if (!_groundHeapInstantiator)
            {
                _groundHeapInstantiator      = Resources.Load <GameObject>("Prefabs/GroundHeap");
                _groundHeapInstantiator.name = "_groundHeap";
                _groundHeapInstantiator.SetActive(false);
            }
            if (!_gravestoneInstantiator)
            {
                _gravestoneInstantiator      = Resources.Load <GameObject>("Prefabs/Tombstone");
                _gravestoneInstantiator.name = "_gravestone";
                _gravestoneInstantiator.SetActive(false);
            }

            _icon = gameObject.AddComponent <IconMarkerComponent>();
            _icon.Init("Sprites/bury", new Color(0, 81.0f / 255.0f, 240.0f / 255.0f));

            _ground = Object.Instantiate(_groundInstantiator);
            _ground.transform.parent = transform;
            _ground.transform.LocalReset();
            _ground.transform.localPosition = Vector3.down * 0.5f;
            _ground.SetActive(true);

            _groundHeap = Object.Instantiate(_groundHeapInstantiator);
            _groundHeap.transform.parent = transform;
            _groundHeap.transform.LocalReset();
            _groundHeap.transform.up            = Vector3.up;
            _groundHeap.transform.localPosition = new Vector3(-2, -1.25f, -3.5f);
            _groundHeap.SetActive(true);

            SphereCollider c = gameObject.AddComponent <SphereCollider>();

            c.isTrigger        = false;
            c.radius           = 2.75f;
            c.center           = new Vector3(0, 0.85f, 0);
            c.gameObject.layer = LayerMaskManager.Get(Layer.IgnoreRaycast);

            SphereCollider trigger = gameObject.AddComponent <SphereCollider>();

            trigger.isTrigger = true;
            trigger.radius    = 4.5f;

            TTomb triggerTomb = gameObject.AddComponent <TTomb>();

            triggerTomb.Init(this);

            Vector3    position = (lowerRight - upperLeft) / 2.0f + upperLeft;
            RaycastHit hit;

            Player.GetInstance().GetEyeSight(out hit);
            transform.position = position;
            transform.up       = hit.normal;

            const float offset   = 1.75f;
            Vector3     middleUp = new Vector3(lowerRight.x + offset, hit.point.y, lowerRight.z - (lowerRight.z - upperLeft.z) / 2.0f);

            _gravestone = Object.Instantiate(_gravestoneInstantiator);
            _gravestone.SetActive(true);
            _gravestone.transform.parent = transform;
            _gravestone.transform.LocalReset();
            _gravestone.transform.position       = middleUp;
            _gravestone.transform.localPosition -= Vector3.up * 3.0f;
            MiddleLow = new Vector3(upperLeft.x - offset, hit.point.y, lowerRight.z - (lowerRight.z - upperLeft.z) / 2.0f);
        }