Esempio n. 1
0
    public static MovementForce AddMovementForce(Movable target, Vector3 force, float duration = 0, bool impactsAnimation = false, bool autoStart = true, bool destroyOnEnd = true, MoveCompiler.Movable_OnMoveFactorEndCallback callback = null)
    {
        if (callback == null)
        {
            callback = delegate() { };
        }

        MovementForce movementForce = target.gameObject.AddComponent <MovementForce>();

        movementForce.force            = force;
        movementForce.impactsAnimation = impactsAnimation;

        if (duration > 0)
        {
            movementForce.hasDuration = true;
            movementForce.duration    = duration;
        }

        movementForce.callback = delegate()
        {
            callback();

            if (destroyOnEnd)
            {
                Destroy(movementForce);
            }
        };

        if (autoStart)
        {
            movementForce.StartMovementForce();
        }

        return(movementForce);
    }
 // Use this for initialization
 new void Start()
 {
     base.Start();
     afterMoveCallback = delegate() { };
 }
    public void AddMovement(Vector2 moveDirection, MovementType movementType, float duration = 0, MoveCompiler.Movable_OnMoveFactorEndCallback callback = null)
    {
        bool  impactsAnimation = movementType == MovementType.NORMAL;
        float moveSpeed;

        switch (movementType)
        {
        case MovementType.NORMAL:
            moveSpeed = moveSpeedInFight;
            break;

        case MovementType.DASH:
            moveSpeed = dashMoveSpeed;
            break;

        case MovementType.BLINK:
            // TODO do a real blink
            moveSpeed = blinkMoveSpeed;
            break;

        default:
            throw new System.Exception("Unhandled movementType " + movementType);
        }

        moveId = ennemyController.MoveCompiler.AddOrEditMoveFactor(localIdInFile, moveDirection * moveSpeed, moveId, impactsAnimation, false, duration > 0, duration, callback);
    }