Exemple #1
0
    public void ChangeState(bool state)
    {
        if (state)
        {
            _open = true;
            Steps = 50;

            _mc.SetValueWithIndex(999, index);//delete from Matrix
            //temporaryAction
            //  Destroy(gameObject);
            //action _open
        }
        else
        {
            _open = false;
            //action Close;
        }
    }
Exemple #2
0
        public virtual void GoTo(Vector3 dir)
        {
            if (!IsFree)
            {
                return;
            }

            var newIndex = dir.normalized + Index;

            var startRot = _trans.rotation;

            _trans.LookAt(_trans.position + dir);


            if (startRot == _trans.rotation)
            {
                //walk
                //walk
                var wasValue = mc.GetValue(newIndex);
                if (newIndex.x < mc.I && newIndex.z < mc.J && newIndex.x >= 0 &&
                    newIndex.z >= 0 && wasValue != 1)
                {
                    if (wasValue == 999)
                    {
                        GameObject.Find("_CONTROLLERS_").GetComponent <LevelsController>().Finish = true;
                    }


                    var fwd = transform.TransformDirection(Vector3.forward);

                    var        ray = new Ray(_trans.position, fwd);
                    RaycastHit hit;

                    DoorScr door = null;
                    if (Physics.Raycast(ray, out hit, 1))
                    {
                        door = hit.transform.gameObject.GetComponent <DoorScr>();
                    }

                    if (door != null)
                    {
                        return;
                    }
                    mc.SetValueWithIndex(0, Index);
                    Index = newIndex;
                    mc.SetValueWithIndex(MyValue, Index);

                    _progressWalk = AntiSpeedWalking;
                    _goingTo      = dir;
                    _finalTo      = _trans.position + dir;
                    IsFree        = false;

                    var anim = gameObject.GetComponent <Animator>();
                    if (anim != null)
                    {
                        anim.SetBool("Walking", true);
                    }
                    //anim.SetInteger("State", 1);
                }
            }
            else
            {
                ///rotate
                if (Mathf.Abs(_trans.rotation.eulerAngles.y - startRot.eulerAngles.y) == 180)
                {
                    _rotateRight = false;
                    //  print("around");

                    _trans.RotateAround(_trans.position, new Vector3(0, 1, 0), 90);
                    _finalRotate = _trans.rotation;
                }
                else
                {
                    var temp = startRot.eulerAngles.y + 90;
                    if (temp >= 360)
                    {
                        temp -= 360;
                    }

                    _rotateRight = _trans.rotation.eulerAngles.y == temp;

                    _finalRotate = _trans.rotation;
                }

                _trans.rotation = startRot;
                _progressRot    = AntiSpeedRotation;
                IsFree          = false;

                var anim = gameObject.GetComponent <Animator>();
                if (anim != null)
                {
                    //anim.SetBool("Rotating", true);
                    //anim.SetBool("Right", _rotateRight);
                }
            }
        }