Exemple #1
0
        void Start()
        {
            SpiderString  = Resources.Load <GameObject>("Prefabs/Misc/Spider_String");
            _stateMachine = new SpiderStateMachine(this);

            var spiderBase       = transform.FindChild("Spider_Base");
            var spiderConnection = transform.FindChild("Spider_Connection");

            var spiderLineRenderer = GetComponent <LineRenderer>();

            spiderLineRenderer.SetPosition(0, spiderBase.position);
            spiderLineRenderer.SetPosition(1, spiderConnection.position);

            var castRayDown = Physics2D.Raycast(transform.position, transform.up, GlobalConst.BigNumber,
                                                1 << LayerMask.NameToLayer("TerrainLayerMask"));

            if (castRayDown)
            {
                var distance = castRayDown.point - (Vector2)transform.position;

                spiderBase.transform.position = spiderBase.transform.position + transform.up * distance.magnitude / 4;
            }
        }
 public SpiderAttackState(SpiderStateMachine stateMachine)
 {
     _stateMachine = stateMachine;
     _timeCounter  = 0f;
 }
 public SpiderIdleState(SpiderStateMachine spiderState)
 {
     this._stateMachine = spiderState;
     _timeCounter       = 0f;
 }