Exemplo n.º 1
0
		///Replace the text of the statement found in brackets, with blackboard variables ToString
		public Statement BlackboardReplace(IBlackboard bb){
			var s = text;
			var i = 0;
			while ( (i = s.IndexOf('[', i)) != -1){
				var end = s.Substring(i + 1).IndexOf(']');
				var varName = s.Substring(i + 1, end);
				var output = s.Substring(i, end + 2);
				object o = null;
				if (bb != null)
					o = bb.GetValue<object>(varName);
				s = s.Replace(output, o != null? o.ToString() : "*" + varName + "*");
				i++;
			}

			return new Statement(s, audio, meta);
		}
Exemplo n.º 2
0
        ///Replace the text of the statement found in brackets, with blackboard variables ToString
        public Statement BlackboardReplace(IBlackboard bb)
        {
            var s = text;
            var i = 0;

            while ((i = s.IndexOf('[', i)) != -1)
            {
                var    end     = s.Substring(i + 1).IndexOf(']');
                var    varName = s.Substring(i + 1, end);
                var    output  = s.Substring(i, end + 2);
                object o       = null;
                if (bb != null)
                {
                    o = bb.GetValue <object>(varName);
                }
                s = s.Replace(output, o != null? o.ToString() : "*" + varName + "*");
                i++;
            }

            return(new Statement(s, audio, meta));
        }
Exemplo n.º 3
0
    public override void OnEnter()
    {
        controller.ClearVelocity();
        controller.ActiveGravity = false;

        var  target        = blackboard.GetValue <Transform> ("Target");
        var  dir           = 0;
        var  groundY       = 0f;
        var  startPosition = Owner.transform.position;
        bool leftBlocked   = false;
        bool rightBlocked  = false;

        var range = statCollection.GetStatValue(KEY_RANGE_X);

        // 传送方向选择
        var hit = Physics2D.Raycast(target.position, Vector2.left, range, LayerMask.GetMask("Platform", "Wall"));

        if (hit.transform != null)
        {
            leftBlocked = true;
        }
        hit = Physics2D.Raycast(target.position, Vector2.right, range, LayerMask.GetMask("Platform", "Wall"));
        if (hit.transform != null)
        {
            rightBlocked = true;
        }

        hit = Physics2D.Raycast(target.position, Vector2.down, range, LayerMask.GetMask("Platform", "Wall"));
        if (hit.collider != null)
        {
            groundY = hit.collider.bounds.max.y;
        }

        if (leftBlocked && !rightBlocked)
        {
            dir = 1;
        }
        else if (!leftBlocked && rightBlocked)
        {
            dir = -1;
        }
        if (dir == 0)
        {
            dir = MathUtils.RandomBool() ? 1 : -1;
        }

        // 坐标修正
        var teleportPoint = new Vector2(target.position.x + dir * range, target.position.y + height);

        if (height < 0)
        {
            teleportPoint.y = groundY;
        }
        teleportPoint = TerrainDetectionSystem.TerrainOverlapHorizontalFix(teleportPoint, boxCollider2D.size,
                                                                           boxCollider2D.offset, Owner.transform.localScale);

        // 特效
        // EffectManager.ApplySpecificEffectAt ( "Boss_08_yuandian", Owner.transform.position );

        Owner.transform.SetPosition(teleportPoint.x, teleportPoint.y);

        // var line = EffectManager.ApplySpecificEffectAt ( "Boss_08_chuansongdianlu", ( startPosition + Owner.transform.position ) / 2f );
        // line.transform.SetEulerAngles ( null, null, MathUtils.DirectionToAngle ( ( Owner.transform.position - startPosition ).normalized ) );
        // line.transform.SetScale ( 1f / LINE_LENGTH * Vector2.Distance ( startPosition, Owner.transform.position ) );
        //
        // // 特效
        // EffectManager.ApplySpecificEffectAt ( "Boss_08_yuandian", Owner.transform.position );
    }