コード例 #1
0
    void Boom_Enter()
    {
        // EffectManager.ApplyParticleEffectAt ( "pse_effect_boss08_xuecisuipian", transform.position );

        Object.Destroy(gameObject);

        var   hit = Physics2D.Raycast(transform.position, Vector2.down, float.MaxValue, LayerMask.GetMask("Platform", "OneWayPlatform", "Wall"));
        float rangeLeft = 0f, rangeRight = 0f;

        if (hit.collider != null)
        {
            rangeLeft  = transform.position.x - SkillRange * 0.5f;
            rangeRight = transform.position.x + SkillRange * 0.5f;
            AIUtils.ClampPlatformEdgePoint(hit.collider, ref rangeLeft, ref rangeRight);
        }
        else
        {
            Debug.LogError($"Action_Boss08_Atk4_Teleport没找到平台");
        }

        for (var i = 0; i < SkillCount; ++i)
        {
            var obj = Object.Instantiate(Resources.Load <GameObject> ("Prefabs/Object/Boss08_Atk04_Arrow"), transform.position, Quaternion.identity);

            var arrow = obj.GetComponent <Boss08_Atk04_EndArrow> ();
            arrow.velocity                    = MathUtils.AngleToDirection(Random.Range(-180f, 0f));
            arrow.targetPosition              = new Vector3(Random.Range(rangeLeft, rangeRight), hit.collider.bounds.max.y);
            arrow.DamageSource                = DamageSource;
            arrow.FlyTrackWaitTime            = FlyTrackWaitTime;
            arrow.FlyTrackWaitTimeRandomRange = FlyTrackWaitTimeRandomRange;
            arrow.target = target;
        }
    }
コード例 #2
0
    public override void OnEnter()
    {
        eventHandler.OnCustomAnimationEvent += OnCustomEvent;
        controller.ClearVelocity();
        controller.ActiveGravity = false;

        target = Owner.GetComponent <NodeCanvas.Framework.Blackboard> ().GetValue <Transform> ("Target");

        currentCount = 0;

        var hit = Physics2D.Raycast(target.position, Vector2.down, float.MaxValue, LayerMask.GetMask("Platform", "OneWayPlatform", "Wall"));

        if (hit.collider != null)
        {
            heightY    = hit.collider.bounds.max.y + height;
            rangeLeft  = target.position.x - range * 0.5f;
            rangeRight = target.position.x + range * 0.5f;
            AIUtils.ClampPlatformEdgePoint(hit.collider, ref rangeLeft, ref rangeRight);
        }
        else
        {
            Debug.LogError($"Action_Boss08_Atk3_Teleport没找到平台");
        }

        // 状态起始先传送一下
        Owner.transform.SetPosition(Random.Range(rangeLeft, rangeRight), heightY);
    }